/* =========================================================================
   AI Lesson Plan Generator — Design System v3.3
   Modern SaaS aesthetic: indigo→purple brand, Inter type, soft tinted shadows
   ========================================================================= */

:root {
    /* Brand */
    --alpg-brand-1: #6366f1;          /* indigo-500 */
    --alpg-brand-2: #8b5cf6;          /* violet-500 */
    --alpg-brand-deep: #4f46e5;       /* indigo-600 (hover) */
    --alpg-brand-bg: #eef2ff;         /* indigo-50 */
    --alpg-brand-soft: #ede9fe;       /* violet-100 */

    /* Surface */
    --alpg-bg: #f8fafc;               /* slate-50 page wash */
    --alpg-surface: #ffffff;
    --alpg-surface-2: #f1f5f9;        /* slate-100 inset */

    /* Text */
    --alpg-ink: #0f172a;              /* slate-900 */
    --alpg-ink-2: #334155;            /* slate-700 */
    --alpg-muted: #64748b;            /* slate-500 */
    --alpg-faint: #94a3b8;            /* slate-400 */

    /* Borders */
    --alpg-border: #e2e8f0;           /* slate-200 */
    --alpg-border-strong: #cbd5e1;    /* slate-300 */

    /* Status */
    --alpg-success: #10b981;
    --alpg-success-bg: #ecfdf5;
    --alpg-warn: #f59e0b;
    --alpg-warn-bg: #fffbeb;
    --alpg-danger: #ef4444;
    --alpg-danger-bg: #fef2f2;

    /* Shadows — tinted with the brand for warmth */
    --alpg-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --alpg-shadow-md: 0 1px 3px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(99, 102, 241, 0.07);
    --alpg-shadow-lg: 0 4px 16px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(99, 102, 241, 0.10);
    --alpg-shadow-glow: 0 0 0 4px rgba(99, 102, 241, 0.12);

    /* Radius */
    --alpg-r-sm: 8px;
    --alpg-r: 12px;
    --alpg-r-lg: 16px;
    --alpg-r-pill: 999px;

    /* Type */
    --alpg-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* =========================================================================
   App shell
   ========================================================================= */

.alpg-app {
    font-family: var(--alpg-font);
    color: var(--alpg-ink);
    max-width: 920px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.alpg-app *,
.alpg-app *::before,
.alpg-app *::after { box-sizing: border-box; }

/* =========================================================================
   Hero (generator page)
   ========================================================================= */

.alpg-hero {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 1rem 0;
}

/* Solid dark navy pill, uppercase, no icon — matches ClassroomAI brand */
.alpg-hero-badge {
    display: inline-block;
    padding: 0.65rem 1.6rem;
    background: var(--alpg-ink);
    color: #fff;
    border-radius: var(--alpg-r-pill);
    font-family: var(--alpg-font);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 1.75rem;
}

/* Display serif headline, solid color (no gradient) */
.alpg-hero-title {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-size: clamp(2.2rem, 5.5vw, 3.4rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.015em;
    margin: 0 0 1.1rem;
    color: var(--alpg-ink);
    /* Override any prior gradient-text styles */
    background: none;
    -webkit-text-fill-color: var(--alpg-ink);
}

.alpg-hero-sub {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--alpg-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* =========================================================================
   Card
   ========================================================================= */

.alpg-card {
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-lg);
    box-shadow: var(--alpg-shadow-md);
    padding: 2rem;
}

.alpg-card-form { padding: 2.25rem; }

@media (max-width: 600px) {
    .alpg-app { margin: 1.25rem auto; padding: 0 0.85rem; }
    .alpg-card,
    .alpg-card-form { padding: 1.25rem; }
}

/* =========================================================================
   Form
   ========================================================================= */

.alpg-form { display: flex; flex-direction: column; gap: 1.25rem; }

.alpg-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.alpg-field { display: flex; flex-direction: column; gap: 0.4rem; }
.alpg-field-full { grid-column: 1 / -1; }

.alpg-field label {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--alpg-ink-2);
    letter-spacing: 0;
}

.alpg-req { color: var(--alpg-brand-1); margin-left: 1px; }

.alpg-input,
.alpg-form select,
.alpg-form textarea,
.alpg-form input[type="text"],
.alpg-form input[type="number"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--alpg-surface);
    color: var(--alpg-ink);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-sm);
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
}

.alpg-input::placeholder { color: var(--alpg-faint); }

.alpg-input:focus,
.alpg-form select:focus,
.alpg-form textarea:focus {
    outline: none;
    border-color: var(--alpg-brand-1);
    box-shadow: var(--alpg-shadow-glow);
}

/* Native select arrow */
.alpg-form select.alpg-input {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.25rem;
    /* Guarantee the line box clears descenders/tall glyphs on every browser. */
    min-height: 2.9rem;
    height: auto;
}

.alpg-form textarea { resize: vertical; min-height: 64px; }

@media (max-width: 600px) {
    .alpg-form-grid { grid-template-columns: 1fr; }
}

/* =========================================================================
   Advanced disclosure
   ========================================================================= */

.alpg-advanced {
    border: 1px dashed var(--alpg-border-strong);
    border-radius: var(--alpg-r-sm);
    background: var(--alpg-surface-2);
}

.alpg-advanced > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--alpg-ink-2);
    font-size: 0.92rem;
    user-select: none;
}
.alpg-advanced > summary::-webkit-details-marker { display: none; }
.alpg-advanced > summary::after {
    content: '+';
    margin-left: auto;
    font-size: 1.25rem;
    color: var(--alpg-muted);
    transition: transform 0.15s;
}
.alpg-advanced[open] > summary::after { content: '−'; }
.alpg-advanced > summary:hover { color: var(--alpg-brand-deep); }

.alpg-advanced-hint {
    color: var(--alpg-muted);
    font-weight: 400;
    font-size: 0.82rem;
    margin-left: 0.25rem;
}

.alpg-advanced-body {
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--alpg-border);
    padding-top: 1rem;
}

/* =========================================================================
   Quota strip
   ========================================================================= */

.alpg-quota {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 0.95rem;
    background: var(--alpg-brand-bg);
    border: 1px solid #c7d2fe;
    border-radius: var(--alpg-r-sm);
    color: var(--alpg-brand-deep);
    font-size: 0.88rem;
    font-weight: 500;
}

.alpg-quota strong { font-weight: 700; }

/* =========================================================================
   Buttons
   ========================================================================= */

.alpg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--alpg-r-sm);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.08s, box-shadow 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.alpg-btn:active { transform: translateY(1px); }
.alpg-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.alpg-btn svg { flex-shrink: 0; }

/* Primary — gradient with glow on hover */
.alpg-btn-primary {
    background: linear-gradient(135deg, var(--alpg-brand-1) 0%, var(--alpg-brand-2) 100%);
    color: #fff;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.4), 0 4px 16px rgba(139, 92, 246, 0.25);
}
.alpg-btn-primary:hover {
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.4), 0 8px 24px rgba(139, 92, 246, 0.4);
    filter: brightness(1.05);
}

/* Secondary — solid muted (used by streaming actions) */
.alpg-btn-secondary {
    background: var(--alpg-surface-2);
    color: var(--alpg-ink-2);
    border-color: var(--alpg-border);
}
.alpg-btn-secondary:hover {
    background: var(--alpg-brand-bg);
    color: var(--alpg-brand-deep);
    border-color: #c7d2fe;
}

/* Soft — subtle pill, used in toolbars */
.alpg-btn-soft {
    background: var(--alpg-surface);
    color: var(--alpg-ink-2);
    border-color: var(--alpg-border);
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
}
.alpg-btn-soft:hover {
    background: var(--alpg-brand-bg);
    color: var(--alpg-brand-deep);
    border-color: #c7d2fe;
}

/* Ghost — no fill */
.alpg-btn-ghost {
    background: transparent;
    color: var(--alpg-muted);
    border-color: transparent;
}
.alpg-btn-ghost:hover {
    background: var(--alpg-surface-2);
    color: var(--alpg-brand-deep);
}

/* Small util button (legacy hook for JS-generated lesson cards) */
.alpg-btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-sm);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--alpg-ink-2);
    background: var(--alpg-surface);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: all 0.15s;
}
.alpg-btn-small:hover {
    background: var(--alpg-brand-bg);
    color: var(--alpg-brand-deep);
    border-color: #c7d2fe;
}
.alpg-btn-small.alpg-danger {
    color: var(--alpg-danger);
    border-color: #fecaca;
}
.alpg-btn-small.alpg-danger:hover {
    background: var(--alpg-danger);
    color: #fff;
    border-color: var(--alpg-danger);
}

/* Link-style button (kept for JS-rendered fallbacks) */
.alpg-btn-link {
    background: transparent;
    color: var(--alpg-brand-deep);
    border: none;
    text-decoration: underline;
    padding: 0.5rem 0;
    cursor: pointer;
    font-weight: 500;
}
.alpg-btn-link:hover { color: var(--alpg-brand-1); }

.alpg-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

/* =========================================================================
   Notices
   ========================================================================= */

.alpg-notice {
    padding: 1rem 1.15rem;
    border-radius: var(--alpg-r-sm);
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: 0.92rem;
}
.alpg-notice-warning {
    background: var(--alpg-warn-bg);
    border-color: #fde68a;
    color: #92400e;
}
.alpg-notice-error {
    background: var(--alpg-danger-bg);
    border-color: #fecaca;
    color: #991b1b;
}
.alpg-notice-info {
    background: var(--alpg-brand-bg);
    border-color: #c7d2fe;
    color: var(--alpg-brand-deep);
}

/* =========================================================================
   Streaming result panel
   ========================================================================= */

.alpg-streaming-wrapper {
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r);
    padding: 1.5rem 1.75rem 1.75rem;
    margin-top: 1.5rem;
    box-shadow: var(--alpg-shadow-md);
}

.alpg-streaming-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--alpg-border);
    padding-bottom: 0.85rem;
    margin-bottom: 1.15rem;
}

.alpg-streaming-header h2 {
    margin: 0;
    color: var(--alpg-ink);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.alpg-streaming-indicator { display: inline-flex; align-items: center; }

.alpg-pulse-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--alpg-brand-1);
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6);
    animation: alpg-pulse 1.4s infinite;
}

@keyframes alpg-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6); transform: scale(1); }
    70%  { box-shadow: 0 0 0 14px rgba(99, 102, 241, 0); transform: scale(1.08); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); transform: scale(1); }
}

.alpg-stream-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--alpg-border);
}

.alpg-remaining-pill {
    background: var(--alpg-brand-bg);
    color: var(--alpg-brand-deep);
    border: 1px solid #c7d2fe;
    padding: 0.4rem 0.8rem;
    border-radius: var(--alpg-r-pill);
    font-size: 0.82rem;
    font-weight: 600;
    margin-left: auto;
}

/* =========================================================================
   Lesson display (rendered Markdown)
   ========================================================================= */

.alpg-lesson-display {
    color: var(--alpg-ink-2);
    font-size: 1rem;
}

.alpg-lesson-display h1 {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--alpg-ink);
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.alpg-lesson-display h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--alpg-ink);
    margin: 1.75rem 0 0.85rem;
    padding-bottom: 0.45rem;
    border-bottom: 2px solid var(--alpg-border);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.alpg-lesson-display h3 {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--alpg-brand-deep);
    background: linear-gradient(135deg, var(--alpg-brand-bg) 0%, var(--alpg-brand-soft) 100%);
    padding: 0.55rem 0.9rem;
    border-radius: var(--alpg-r-sm);
    border-left: 3px solid var(--alpg-brand-1);
    margin: 1.25rem 0 0.65rem;
}

.alpg-lesson-display p {
    line-height: 1.7;
    margin: 0.65rem 0;
    color: var(--alpg-ink-2);
}

.alpg-lesson-display ul,
.alpg-lesson-display ol {
    margin: 0.6rem 0 0.85rem 1.5rem;
    line-height: 1.7;
}

.alpg-lesson-display li { margin-bottom: 0.35rem; }

.alpg-lesson-display strong { color: var(--alpg-ink); font-weight: 700; }

.alpg-lesson-display em { color: var(--alpg-ink-2); }

.alpg-lesson-display blockquote {
    border-left: 3px solid var(--alpg-brand-1);
    background: var(--alpg-brand-bg);
    margin: 0.85rem 0;
    padding: 0.6rem 1rem;
    color: var(--alpg-brand-deep);
    border-radius: var(--alpg-r-sm);
}
.alpg-lesson-display blockquote p { margin: 0.25rem 0; color: inherit; }

.alpg-lesson-display hr {
    border: 0;
    border-top: 1px solid var(--alpg-border);
    margin: 1.5rem 0;
}

/* Tables */
.alpg-md-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1rem 0;
    font-size: 0.92rem;
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-sm);
    overflow: hidden;
}

.alpg-md-table th,
.alpg-md-table td {
    padding: 0.6rem 0.9rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--alpg-border);
}

.alpg-md-table tbody tr:last-child td { border-bottom: none; }

.alpg-md-table th {
    background: var(--alpg-surface-2);
    font-weight: 700;
    color: var(--alpg-ink);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.alpg-md-table tr:nth-child(even) td { background: var(--alpg-surface-2); }

/* =========================================================================
   Library
   ========================================================================= */

.alpg-library { width: 100%; }

.alpg-library-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--alpg-border);
}

.alpg-section-title {
    margin: 0 0 0.25rem;
    color: var(--alpg-ink);
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.alpg-library-subtitle {
    color: var(--alpg-muted);
    margin: 0;
    font-size: 0.95rem;
}

.alpg-library-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.alpg-lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1.25rem;
}

.alpg-lesson-card {
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r);
    padding: 1.25rem;
    box-shadow: var(--alpg-shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.alpg-lesson-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--alpg-shadow-md);
    border-color: #c7d2fe;
}

.alpg-lesson-card h3 {
    margin: 0 0 0.5rem;
    color: var(--alpg-ink);
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.005em;
}

.alpg-lesson-meta {
    color: var(--alpg-muted);
    font-size: 0.83rem;
    margin: 0 0 1rem;
}

.alpg-lesson-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    flex-wrap: wrap;
}

.alpg-lesson-actions .alpg-btn-small { flex: 1; text-align: center; }

/* Type badge */
.alpg-type-badge {
    display: inline-block;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 0.18rem 0.55rem;
    border-radius: var(--alpg-r-pill);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 0.55rem;
    vertical-align: middle;
}
.alpg-type-badge-lesson    { background: #dbeafe; color: #1e40af; }
.alpg-type-badge-worksheet { background: #ede9fe; color: #6d28d9; }
.alpg-type-badge-answerkey { background: #d1fae5; color: #047857; }

/* Empty state */
.alpg-empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    background: var(--alpg-surface);
    border: 2px dashed var(--alpg-border-strong);
    border-radius: var(--alpg-r-lg);
    color: var(--alpg-muted);
}
.alpg-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: var(--alpg-brand-bg);
    color: var(--alpg-brand-deep);
    border-radius: 50%;
    margin-bottom: 1rem;
}
.alpg-empty-state h3 {
    margin: 0 0 0.4rem;
    color: var(--alpg-ink);
    font-weight: 700;
    font-size: 1.15rem;
}
.alpg-empty-state p { margin: 0; font-size: 0.95rem; }

/* =========================================================================
   Library viewer
   ========================================================================= */

.alpg-library-viewer {
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-lg);
    padding: 1.5rem 2rem 2rem;
    box-shadow: var(--alpg-shadow-md);
}

.alpg-library-viewer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--alpg-border);
}

.alpg-library-viewer-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* =========================================================================
   Worksheet + answer-key sub-panels
   ========================================================================= */

.alpg-worksheet-output {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--alpg-brand-soft);
}
.alpg-worksheet-output .alpg-streaming-wrapper {
    border-color: var(--alpg-brand-soft);
    background: linear-gradient(180deg, #faf8ff 0%, #ffffff 100%);
}
.alpg-worksheet-output .alpg-streaming-header h2 { color: #6d28d9; }
.alpg-worksheet-output .alpg-streaming-header { border-bottom-color: #c4b5fd; }

.alpg-answerkey-output {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px dashed #a7f3d0;
}
.alpg-answerkey-output .alpg-streaming-wrapper {
    border-color: #a7f3d0;
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
}
.alpg-answerkey-output .alpg-streaming-header h2 { color: #047857; }
.alpg-answerkey-output .alpg-streaming-header { border-bottom-color: #6ee7b7; }

/* =========================================================================
   Inline editor
   ========================================================================= */

.alpg-editor {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.alpg-editor-title {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-sm);
    color: var(--alpg-ink);
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.alpg-editor-title:focus {
    outline: none;
    border-color: var(--alpg-brand-1);
    box-shadow: var(--alpg-shadow-glow);
}

.alpg-editor-textarea {
    width: 100%;
    min-height: 480px;
    padding: 1rem;
    font-family: ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
    font-size: 0.93rem;
    line-height: 1.6;
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-sm);
    resize: vertical;
    color: var(--alpg-ink-2);
    background: var(--alpg-surface-2);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.alpg-editor-textarea:focus {
    outline: none;
    border-color: var(--alpg-brand-1);
    box-shadow: var(--alpg-shadow-glow);
    background: var(--alpg-surface);
}

.alpg-editor-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.alpg-editor-hint {
    color: var(--alpg-muted);
    font-size: 0.83rem;
}

/* =========================================================================
   Per-section regenerate
   ========================================================================= */

.alpg-regen-btn {
    margin-left: auto;
    padding: 0.25rem 0.7rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--alpg-brand-deep);
    background: var(--alpg-brand-bg);
    border: 1px solid #c7d2fe;
    border-radius: var(--alpg-r-pill);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.alpg-regen-btn:hover {
    background: var(--alpg-brand-1);
    color: #fff;
    border-color: var(--alpg-brand-1);
}

.alpg-regen-preview {
    background: var(--alpg-warn-bg);
    border: 1px dashed var(--alpg-warn);
    padding: 1rem;
    border-radius: var(--alpg-r-sm);
    margin: 0.75rem 0;
}

.alpg-regen-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #92400e;
    font-weight: 600;
    margin: 0.5rem 0;
}

/* =========================================================================
   Print
   ========================================================================= */

@media print {
    body { background: #fff; }
    .alpg-app { margin: 0; padding: 0; max-width: 100%; }
    .alpg-card,
    .alpg-card-form,
    .alpg-library-viewer,
    .alpg-streaming-wrapper {
        box-shadow: none;
        border: none;
        padding: 0;
    }
    .alpg-form,
    .alpg-hero,
    .alpg-library-header,
    .alpg-library-viewer-toolbar,
    .alpg-stream-actions,
    .alpg-streaming-indicator,
    .alpg-regen-btn,
    .alpg-editor-actions,
    .alpg-editor-title,
    .alpg-notice,
    .alpg-quota,
    button {
        display: none !important;
    }
    .alpg-lesson-display h2,
    .alpg-lesson-display h3 { break-after: avoid; }
    .alpg-md-table { break-inside: avoid; }
}

/* =========================================================================
   Misc admin-side leftovers (kept for backwards compat)
   ========================================================================= */

.alpg-spinner { display: inline-block; margin-left: 15px; vertical-align: middle; }
.alpg-spinner .spinner { float: none; margin: 0; }

/* =========================================================================
   Standards autocomplete combobox
   ========================================================================= */
.alpg-combobox { position: relative; }
.alpg-combobox-menu {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
    background: #fff; border: 1px solid #d1d5db; border-radius: 8px;
    box-shadow: 0 12px 28px -8px rgba(15,23,42,0.18);
    max-height: 320px; overflow-y: auto; margin-top: 4px;
}
.alpg-combobox-item {
    padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
    display: flex; flex-direction: column; gap: 2px;
}
.alpg-combobox-item:last-child { border-bottom: 0; }
.alpg-combobox-item:hover,
.alpg-combobox-item.is-active { background: #eef2ff; }
.alpg-combobox-item .code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px; font-weight: 600; color: #1f3864;
}
.alpg-combobox-item .desc { font-size: 13px; color: #1f2937; line-height: 1.35; }
.alpg-combobox-item .meta { font-size: 11px; color: #6b7280; }
.alpg-combobox-empty { padding: 12px; color: #6b7280; font-size: 13px; text-align: center; }
.alpg-hint { display: block; color: #6b7280; font-size: 12px; margin-top: 4px; }
.alpg-hint-inline { color: #9ca3af; font-weight: 400; font-size: 12px; margin-left: 4px; }

/* =========================================================================
   Inline Personalize mode (WYSIWYG-style edit on the rendered lesson)
   ========================================================================= */
.alpg-personalize-toolbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    background: #ffffff; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 8px 10px; margin: 0 0 14px;
    box-shadow: 0 2px 6px -2px rgba(15,23,42,0.08);
}
.alpg-personalize-toolbar .group { display: inline-flex; gap: 4px; padding-right: 6px; border-right: 1px solid #e5e7eb; }
.alpg-personalize-toolbar .group:last-of-type { border-right: 0; }
.alpg-personalize-toolbar button {
    background: #f9fafb; border: 1px solid #e5e7eb; color: #1f2937;
    border-radius: 6px; padding: 5px 9px; cursor: pointer;
    font-size: 13px; font-weight: 500; line-height: 1.2;
}
.alpg-personalize-toolbar button:hover { background: #eef2ff; border-color: #c7d2fe; }
.alpg-personalize-toolbar .spacer { flex: 1; }
.alpg-personalize-toolbar .alpg-saving { color: #6b7280; font-size: 12px; margin-right: 6px; }

.alpg-personalize-host { position: relative; }
.alpg-personalize-host[data-editing="1"] .alpg-lesson-display {
    border: 1px dashed #c7d2fe; border-radius: 10px; padding: 14px 16px; background: #fdfdff;
}
.alpg-personalize-host[data-editing="1"] .alpg-lesson-display:focus-within {
    border-color: #6366f1; background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.alpg-personalize-host[data-editing="1"] .alpg-lesson-display [contenteditable]:hover {
    outline: 1px dashed #c7d2fe; outline-offset: 4px; border-radius: 4px;
}
.alpg-personalize-host[data-editing="1"] .alpg-lesson-display [contenteditable]:focus {
    outline: 2px solid #6366f1; outline-offset: 4px; border-radius: 4px;
}

.alpg-section-controls {
    display: inline-flex; gap: 4px; margin-left: 10px; vertical-align: middle;
    opacity: 0; transition: opacity .15s;
}
.alpg-personalize-host[data-editing="1"] h2:hover .alpg-section-controls,
.alpg-personalize-host[data-editing="1"] .alpg-section-controls:focus-within { opacity: 1; }
.alpg-section-controls button {
    background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
    border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 11px; font-weight: 600;
}
.alpg-section-controls button.alpg-section-add { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alpg-section-controls button:hover { filter: brightness(0.97); }

.alpg-personalize-savebar {
    position: sticky; bottom: 12px; z-index: 41;
    display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px;
    background: linear-gradient(to top, #ffffff 70%, rgba(255,255,255,0));
    padding: 10px 0;
}
.alpg-personalize-savebar .status { margin-right: auto; align-self: center; color: #6b7280; font-size: 13px; }
.alpg-personalize-host .alpg-regen-btn { opacity: 0.55; }

/* Toolbar accessibility toggles */
.alpg-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: #1f2937; padding: 4px 8px;
    background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
    cursor: pointer; user-select: none;
}
.alpg-toggle input { margin: 0; }
.alpg-toggle:hover { background: #eef2ff; border-color: #c7d2fe; }

/* =========================================================================
   Features showcase (shown above the generator form)
   ========================================================================= */
.alpg-features {
    margin: 0 0 28px;
}
.alpg-features-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 26px;
    font-weight: 700;
    color: #111827;
    text-align: center;
    margin: 0 0 22px;
    letter-spacing: -0.01em;
}
.alpg-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin: 0 0 24px;
}
.alpg-feature {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px 18px 16px;
    transition: transform .12s, box-shadow .12s, border-color .12s;
}
.alpg-feature:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -12px rgba(15,23,42,0.12);
    border-color: #c7d2fe;
}
.alpg-feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: #4338ca;
    margin: 0 0 12px;
}
.alpg-feature h3 {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 6px;
    line-height: 1.25;
}
.alpg-feature p {
    font-size: 13.5px;
    color: #4b5563;
    line-height: 1.5;
    margin: 0;
}

/* How-it-works strip */
.alpg-howitworks {
    list-style: none;
    margin: 0;
    padding: 18px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    background: linear-gradient(135deg, #fafafa 0%, #f5f3ff 100%);
    border: 1px solid #ede9fe;
    border-radius: 14px;
}
.alpg-howitworks li {
    display: grid;
    grid-template-columns: 36px 1fr;
    grid-template-areas: "num label" "num desc";
    column-gap: 12px;
    row-gap: 2px;
    align-items: start;
}
.alpg-howitworks .num {
    grid-area: num;
    align-self: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #4338ca;
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.alpg-howitworks .label {
    grid-area: label;
    font-weight: 700;
    color: #111827;
    font-size: 14px;
}
.alpg-howitworks .desc {
    grid-area: desc;
    color: #4b5563;
    font-size: 12.5px;
    line-height: 1.45;
}

@media (max-width: 600px) {
    .alpg-features-title { font-size: 22px; }
    .alpg-feature h3 { font-size: 14.5px; }
}

/* Hide the features section once a lesson is on screen so the teacher
   isn't scrolling past marketing every time. */
.alpg-app:has(#alpg-result .alpg-streaming-wrapper) .alpg-features { display: none; }

/* Timeline integrity callout — appears above "Lesson Timeline" heading */
.alpg-timeline-callout {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 10px;
    margin: 16px 0 8px;
    font-size: 13.5px; line-height: 1.45;
}
.alpg-timeline-callout.is-ok {
    background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534;
}
.alpg-timeline-callout.is-warn {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
}
.alpg-timeline-callout .ico {
    flex: 0 0 auto; font-weight: 700; font-size: 16px;
}
.alpg-timeline-callout .msg { flex: 1; }
.alpg-timeline-callout strong { color: inherit; }
.alpg-timeline-callout .alpg-timeline-fix {
    margin-left: 10px;
    background: #f59e0b; color: #ffffff; border: 0;
    padding: 4px 10px; border-radius: 6px;
    font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.alpg-timeline-callout .alpg-timeline-fix:hover { background: #d97706; }
.alpg-timeline-callout .alpg-timeline-fix[disabled] { opacity: 0.65; cursor: wait; }

/* Don't print the callout — teachers don't need to see this on paper */
@media print { .alpg-timeline-callout { display: none !important; } }

/* =========================================================================
   Source upload (PDF / image) block in the generator form
   ========================================================================= */
.alpg-source-upload {
    border: 1.5px dashed #c7d2fe;
    background: linear-gradient(135deg, #fafafa 0%, #f5f3ff 100%);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 16px 0;
}
.alpg-source-head {
    display: flex; align-items: flex-start; gap: 10px;
    margin-bottom: 10px;
    color: #4338ca;
}
.alpg-source-head label { display: flex; flex-direction: column; line-height: 1.35; cursor: pointer; }
.alpg-source-head strong { color: #111827; font-size: 14px; }
.alpg-source-sub { color: #4b5563; font-size: 13px; margin-top: 2px; font-weight: 400; }
.alpg-source-upload input[type="file"] {
    display: block; width: 100%;
    padding: 10px 12px; margin: 0 0 6px;
    background: #ffffff;
    border: 1px solid #e5e7eb; border-radius: 8px;
    font-size: 13px; color: #1f2937;
    cursor: pointer;
}
.alpg-source-upload input[type="file"]::-webkit-file-upload-button {
    background: #4338ca; color: #ffffff;
    border: 0; padding: 6px 12px; border-radius: 6px;
    font-weight: 600; font-size: 12.5px; cursor: pointer;
    margin-right: 10px;
}
.alpg-source-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: #6b7280; font-size: 12px; }
.alpg-source-privacy { color: #6b7280; font-style: italic; }
.alpg-source-list {
    margin-top: 10px; padding: 8px 12px;
    background: #ffffff; border: 1px solid #e5e7eb; border-radius: 8px;
    font-size: 12.5px; color: #1f2937;
}
.alpg-source-list .item { display: flex; justify-content: space-between; padding: 4px 0; }
.alpg-source-list .name { font-weight: 500; }
.alpg-source-list .size { color: #6b7280; font-variant-numeric: tabular-nums; }
.alpg-source-list .item.invalid .name { color: #b91c1c; }

/* =========================================================================
   Phase B — Drag-drop, thumbnails, redaction modal
   ========================================================================= */
.alpg-dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px;
    padding: 22px 16px;
    background: #ffffff;
    border: 2px dashed #c7d2fe;
    border-radius: 10px;
    color: #4338ca;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .12s;
}
.alpg-dropzone:hover, .alpg-dropzone:focus { outline: none; background: #f5f3ff; border-color: #818cf8; }
.alpg-dropzone.is-dragging { background: #eef2ff; border-color: #4f46e5; transform: scale(1.005); }
.alpg-dropzone-icon { color: #4338ca; flex: 0 0 auto; }
.alpg-dropzone-text { text-align: center; line-height: 1.35; }
.alpg-dropzone-text strong { display: block; color: #111827; font-size: 14px; }
.alpg-dropzone-text span { color: #6b7280; font-size: 12.5px; }
.alpg-dropzone input[type="file"] {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}

.alpg-source-list {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}
.alpg-source-file {
    position: relative;
    display: flex; flex-direction: column;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
    min-height: 120px;
}
.alpg-source-file.is-invalid { border-color: #fecaca; background: #fef2f2; }
.alpg-source-file .thumb {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    background: #f3f4f6;
    min-height: 90px;
    overflow: hidden;
}
.alpg-source-file .thumb img {
    max-width: 100%; max-height: 90px;
    object-fit: contain;
    display: block;
}
.alpg-source-file .thumb .pdf-icon {
    width: 40px; height: 50px;
    background: #ef4444;
    color: #ffffff;
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.alpg-source-file .meta {
    padding: 6px 8px;
    font-size: 11.5px;
    line-height: 1.3;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}
.alpg-source-file .meta .name {
    display: block;
    color: #111827; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.alpg-source-file .meta .size { color: #6b7280; font-size: 11px; }
.alpg-source-file.is-invalid .meta .size { color: #b91c1c; }
.alpg-source-file .actions {
    display: flex; gap: 4px;
    padding: 4px 6px;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
}
.alpg-source-file .actions button {
    flex: 1;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px; color: #1f2937;
    cursor: pointer;
}
.alpg-source-file .actions button:hover { background: #eef2ff; border-color: #c7d2fe; }
.alpg-source-file .actions .remove { color: #b91c1c; }
.alpg-source-file .actions .remove:hover { background: #fef2f2; border-color: #fecaca; }
.alpg-source-file.is-redacted::before {
    content: "REDACTED";
    position: absolute; top: 6px; right: 6px; z-index: 2;
    background: #111827; color: #ffffff;
    padding: 2px 6px; border-radius: 3px;
    font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
}

/* Redaction modal */
.alpg-redact-modal {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
/* CRITICAL: the line above overrides the HTML `hidden` attribute. This rule
 * restores the standard browser behavior so the modal actually stays hidden
 * until openRedactModal() sets hidden=false. Without this !important, the
 * modal pops open on every page load with no way to close it. */
.alpg-redact-modal[hidden] { display: none !important; }
.alpg-redact-backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
}
.alpg-redact-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    width: min(92vw, 760px);
    max-height: 92vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px -12px rgba(0,0,0,0.4);
}
.alpg-redact-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
}
.alpg-redact-head h3 { margin: 0; font-size: 16px; color: #111827; }
.alpg-redact-x {
    background: transparent; border: 0;
    width: 32px; height: 32px;
    font-size: 22px; line-height: 1;
    color: #6b7280; cursor: pointer;
    border-radius: 6px;
}
.alpg-redact-x:hover { background: #f3f4f6; color: #111827; }
.alpg-redact-hint {
    margin: 0; padding: 12px 18px;
    background: #fffbeb; color: #92400e;
    font-size: 13px; border-bottom: 1px solid #fde68a;
}
.alpg-redact-canvas-wrap {
    flex: 1;
    overflow: auto;
    background: #1f2937;
    padding: 16px;
    display: flex; align-items: center; justify-content: center;
    min-height: 200px;
}
#alpg-redact-canvas {
    max-width: 100%; max-height: 70vh;
    cursor: crosshair;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
.alpg-redact-actions {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}
.alpg-redact-spacer { flex: 1; }

/* IEP accommodation checkbox grid (lesson form, advanced options) */
.alpg-iep-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem 1rem;
    margin-top: 0.35rem;
}
.alpg-iep-grid .alpg-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    color: var(--alpg-ink-2);
    cursor: pointer;
}
@media (max-width: 600px) {
    .alpg-iep-grid { grid-template-columns: 1fr; }
}

/* Monospace fenced block (diagrams / aligned text preserved verbatim) */
.alpg-pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--alpg-surface-2);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-sm);
    padding: 0.7rem 0.9rem;
    margin: 0.8rem 0;
    line-height: 1.4;
}
.alpg-lesson-content { overflow-wrap: break-word; }

/* =========================================================================
   Personalize: hero button + modal
   ========================================================================= */
.alpg-hero-actions {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.alpg-hero-actions-hint { color: var(--alpg-muted); font-size: 0.85rem; }

body.alpg-modal-open { overflow: hidden; }

.alpg-modal { display: none; }
.alpg-modal:not([hidden]) {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 100000;
    align-items: flex-start;
    justify-content: center;
    padding: 4vh 1rem;
    overflow-y: auto;
}
.alpg-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}
.alpg-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 760px;
    background: var(--alpg-surface);
    border-radius: var(--alpg-r-lg);
    box-shadow: var(--alpg-shadow-lg);
    padding: 1.5rem 1.75rem 1.25rem;
    margin: auto;
}
.alpg-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
.alpg-modal-head h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--alpg-ink);
}
.alpg-modal-x {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--alpg-muted);
    cursor: pointer;
    padding: 0 0.25rem;
}
.alpg-modal-x:hover { color: var(--alpg-ink); }
.alpg-modal-sub { color: var(--alpg-muted); font-size: 0.92rem; margin: 0 0 1rem; }
.alpg-modal-section {
    margin: 1.4rem 0 0.6rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--alpg-border);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--alpg-ink);
}
.alpg-modal-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0.5rem; }
.alpg-modal-section-hint { font-weight: 400; color: var(--alpg-muted); font-size: 0.82rem; margin-left: 0.35rem; }
.alpg-prefs-logo { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.alpg-prefs-logo img {
    max-height: 56px;
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r-sm);
    padding: 4px;
    background: #fff;
}
.alpg-modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--alpg-border);
}
.alpg-prefs-msg { margin-right: auto; font-size: 0.88rem; }
.alpg-prefs-msg-ok  { color: var(--alpg-success); font-weight: 600; }
.alpg-prefs-msg-err { color: var(--alpg-danger);  font-weight: 600; }

/* Derived artifacts (rubric, quiz) */
.alpg-artifact-output { margin-top: 1.25rem; }
.alpg-type-badge-rubric { background: #fee2e2; color: #b91c1c; }
.alpg-type-badge-quiz   { background: #e0e7ff; color: #4338ca; }

/* Leveled reading / parent note / translation badges + translate picker */
.alpg-type-badge-passage     { background: #dcfce7; color: #15803d; }
.alpg-type-badge-parent      { background: #fef9c3; color: #a16207; }
.alpg-type-badge-translation { background: #cffafe; color: #0e7490; }

.alpg-translate-picker {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r);
    box-shadow: var(--alpg-shadow-sm);
    padding: 0.9rem 1.1rem;
    margin-top: 1.25rem;
}
.alpg-translate-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--alpg-ink-2);
    white-space: nowrap;
}
.alpg-translate-lang { max-width: 280px; flex: 1 1 200px; }

/* Leveled-reading source panel */
.alpg-source-panel {
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r);
    box-shadow: var(--alpg-shadow-sm);
    padding: 1rem 1.1rem;
    margin-top: 1.25rem;
}
.alpg-source-panel-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--alpg-ink-2);
    margin-bottom: 0.5rem;
}
.alpg-passage-source { width: 100%; }

/* Quiz options panel */
.alpg-quiz-opts {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.25rem;
    margin: 0.25rem 0 0.75rem;
}
.alpg-quiz-opt { display: flex; flex-direction: column; gap: 0.3rem; }
.alpg-quiz-opt-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--alpg-ink-2);
}
.alpg-quiz-opt input { max-width: 9rem; }
.alpg-quiz-types-wrap { margin: 0.25rem 0 0.5rem; }
.alpg-quiz-types {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.1rem;
    margin-top: 0.4rem;
}
.alpg-quiz-type {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.92rem;
    color: var(--alpg-ink-2);
    cursor: pointer;
}

/* =========================================================================
   Freemium: trial bar, Pro locks, login gate, quota
   ========================================================================= */
.alpg-trialbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-radius: var(--alpg-r);
    box-shadow: var(--alpg-shadow-sm);
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
}
.alpg-trialbar-text { font-weight: 600; color: var(--alpg-ink-2); }
.alpg-trialbar-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.alpg-btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }

/* Pro-locked upload block */
.alpg-pro-locked { position: relative; opacity: 0.7; cursor: pointer; }
.alpg-pro-locked .alpg-dropzone,
.alpg-pro-locked .alpg-source-meta { pointer-events: none; }
.alpg-pro-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #fff;
    background: var(--alpg-brand-1, #4f46e5);
    border-radius: 0.3rem;
    vertical-align: middle;
}

/* Login gate (shown in the result area when a guest hits Generate) */
.alpg-notice-info {
    background: var(--alpg-surface);
    border: 1px solid var(--alpg-border);
    border-left: 3px solid var(--alpg-brand-1, #4f46e5);
}
.alpg-login-gate-actions { display: flex; gap: 0.5rem; margin-top: 0.7rem; flex-wrap: wrap; }

/* Quota meter empty/exhausted state */
.alpg-quota-empty { color: #b91c1c; }
.alpg-quota-empty a { color: #b91c1c; font-weight: 600; }

/* Grouped completion actions: primary row + a labelled "create" row */
.alpg-actions-primary,
.alpg-actions-create {
    flex: 1 0 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.alpg-actions-create {
    margin-top: 0.6rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--alpg-border);
}
.alpg-actions-label {
    width: 100%;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--alpg-muted);
    margin-bottom: 0.1rem;
}

.alpg-translate-hint { flex-basis: 100%; color: var(--alpg-muted); font-size: 0.78rem; }

.alpg-type-badge-slides { background: #ffedd5; color: #c2410c; }

/* Collapse / close controls on generated output blocks */
.alpg-streaming-header { display: flex; align-items: center; gap: 0.5rem; }
.alpg-output-controls { margin-left: auto; display: inline-flex; gap: 0.15rem; }
.alpg-output-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--alpg-muted);
    font-size: 1.15rem;
    line-height: 1;
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s, transform 0.12s;
}
.alpg-output-btn:hover { background: var(--alpg-surface-2); color: var(--alpg-ink); }
.alpg-streaming-wrapper.alpg-collapsed > :not(.alpg-streaming-header) { display: none; }
.alpg-streaming-wrapper.alpg-collapsed .alpg-streaming-header { margin-bottom: 0; }
.alpg-streaming-wrapper.alpg-collapsed [data-output-collapse] { transform: rotate(-90deg); }

/* =========================================================================
   Compact hero + single "what you get" offer card (v3.4)
   ========================================================================= */
.alpg-hero-compact { margin-bottom: 1.25rem; padding: 0.5rem 0 0; }
.alpg-hero-compact .alpg-hero-badge {
    padding: 0.38rem 1rem;
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    margin-bottom: 0.85rem;
}
.alpg-hero-compact .alpg-hero-title {
    font-size: clamp(1.6rem, 3.4vw, 2.2rem);
    margin-bottom: 0.55rem;
}
.alpg-hero-compact .alpg-hero-sub { font-size: 0.98rem; }

.alpg-offer-card { padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.alpg-offer-list {
    list-style: none;
    margin: 0 0 1.1rem;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.75rem;
}
.alpg-offer-list li {
    position: relative;
    padding-left: 1.6rem;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--alpg-ink-2);
}
.alpg-offer-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--alpg-success);
    font-weight: 800;
}
@media (max-width: 600px) { .alpg-offer-list { grid-template-columns: 1fr; } }

.alpg-personalize-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-align: left;
    height: auto;
    padding: 0.55rem 1.1rem;
}
.alpg-personalize-btn-text { display: flex; flex-direction: column; line-height: 1.2; }
.alpg-personalize-btn-main { font-weight: 700; }
.alpg-personalize-btn-sub { font-size: 0.76rem; font-weight: 400; color: var(--alpg-muted); }

/* =========================================================================
   Tier 3 polish — library toolbar grouping + mobile
   ========================================================================= */
/* Stack the viewer actions into labelled groups instead of one long row. */
.alpg-library-viewer-actions {
    flex: 1 1 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
}
.alpg-vt-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding-top: 0.55rem;
    border-top: 1px dashed var(--alpg-border);
}
.alpg-vt-group:first-of-type { padding-top: 0; border-top: none; }
.alpg-vt-label {
    width: 100%;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--alpg-muted);
    margin-bottom: 0.1rem;
}

/* Wide tables (rubrics, leveled-reading grids) scroll on small screens
   instead of overflowing the viewport. */
@media (max-width: 600px) {
    .alpg-lesson-display { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
