/* ============================================================
   Personal Truth Base — main.css
   
   STRUCTURE:
   1.  CSS Custom Properties (easy theming — edit these only)
   2.  Reset / base
   3.  Layout (nav, main, footer)
   4.  Typography
   5.  Buttons
   6.  Forms
   7.  Cards (source, knowledge, section)
   8.  Badges (domain, status, confidence)
   9.  Flash messages
   10. Dashboard / stats
   11. Tables
   12. Utilities
   13. Dark theme override
   ============================================================ */


/* ── 1. CSS CUSTOM PROPERTIES ─────────────────────────────────
   To change the look: edit only this block.
   ─────────────────────────────────────────────────────────── */
:root {
    /* Brand */
    --color-brand:           #2A7DBF;
    --color-brand-hover:     #1F6299;
    --color-brand-light:     #E6F1FB;

    /* Surfaces */
    --color-bg:              #F7F7F5;
    --color-surface:         #FFFFFF;
    --color-surface-raised:  #FFFFFF;
    --color-border:          #E2E0DA;
    --color-border-subtle:   #EDEBE5;

    /* Text */
    --color-text-primary:    #1C1C1A;
    --color-text-secondary:  #5A5955;
    --color-text-muted:      #9A9790;
    --color-text-inverse:    #FFFFFF;

    /* Semantic */
    --color-success:         #1D9E75;
    --color-success-bg:      #E1F5EE;
    --color-warning:         #EF9F27;
    --color-warning-bg:      #FAEEDA;
    --color-danger:          #E24B4A;
    --color-danger-bg:       #FCEAEA;
    --color-info:            #378ADD;
    --color-info-bg:         #E6F1FB;

    /* Domain accent colours */
    --color-domain-bible:       #1D9E75;
    --color-domain-bible-bg:    #E1F5EE;
    --color-domain-science:     #378ADD;
    --color-domain-science-bg:  #E6F1FB;
    --color-domain-history:     #D5821C;
    --color-domain-history-bg:  #FAEEDA;
    --color-domain-philosophy:  #6D57D2;
    --color-domain-philosophy-bg:#EEEDFE;
    --color-domain-language:    #C83C64;
    --color-domain-language-bg: #FBEAF0;
    --color-domain-literature:  #3C96BE;
    --color-domain-literature-bg:#E0F4FB;
    --color-domain-other:       #888;
    --color-domain-other-bg:    #F0F0EE;

    /* Confidence colours */
    --color-conf-very-high: #1D9E75;
    --color-conf-high:      #378ADD;
    --color-conf-medium:    #EF9F27;
    --color-conf-low:       #E24B4A;
    --color-conf-speculative:#9B64CC;
    --color-conf-disproven: #888;

    /* Spacing */
    --space-1:  4px;
    --space-2:  8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Typography */
    --font-sans:  'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    --font-mono:  'Cascadia Code', 'Fira Code', Consolas, monospace;
    --font-size-xs:   11px;
    --font-size-sm:   13px;
    --font-size-base: 15px;
    --font-size-lg:   17px;
    --font-size-xl:   20px;
    --font-size-2xl:  26px;
    --line-height:    1.6;

    /* Radii */
    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
    --shadow-md:  0 2px 8px rgba(0,0,0,.10);
    --shadow-lg:  0 4px 20px rgba(0,0,0,.12);

    /* Nav */
    --nav-height:     56px;
    --nav-bg:         #FFFFFF;
    --nav-border:     var(--color-border);
    --nav-width-side: 220px;

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
}


/* ── 2. RESET / BASE ──────────────────────────────────────────*/
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--color-text-primary);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-brand); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--color-brand-hover); }

img { max-width: 100%; display: block; }
ul { list-style: none; }


/* ── 3. LAYOUT ────────────────────────────────────────────────*/
.site-nav {
    position: sticky; top: 0; z-index: 100;
    height: var(--nav-height);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    display: flex; align-items: center;
    padding: 0 var(--space-5);
    gap: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.nav-brand { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.brand-link { display: flex; align-items: center; gap: var(--space-2); color: inherit; font-weight: 600; font-size: var(--font-size-lg); text-decoration: none; }
.brand-icon { color: var(--color-brand); font-size: 18px; }

.nav-links { display: flex; gap: var(--space-2); flex: 1; list-style: none; margin: 0; padding: 0; }
.nav-link {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
    text-decoration: none;
}
.nav-link:hover  { background: var(--color-bg); color: var(--color-text-primary); text-decoration: none; }
.nav-link.active { background: var(--color-brand-light); color: var(--color-brand); }

.nav-user { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.user-name { font-size: var(--font-size-sm); color: var(--color-text-secondary); }

.site-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-5);
    min-height: calc(100vh - var(--nav-height) - 60px);
}

.site-footer {
    text-align: center;
    padding: var(--space-4);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border-subtle);
}

/* Page header row */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
    gap: var(--space-3);
}
.page-title { font-size: var(--font-size-2xl); font-weight: 600; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }


/* ── 4. TYPOGRAPHY ────────────────────────────────────────────*/
h1 { font-size: var(--font-size-2xl); font-weight: 600; }
h2 { font-size: var(--font-size-xl);  font-weight: 600; }
h3 { font-size: var(--font-size-lg);  font-weight: 500; }
h4 { font-size: var(--font-size-base);font-weight: 500; }

.text-muted    { color: var(--color-text-muted); }
.text-sm       { font-size: var(--font-size-sm); }
.text-xs       { font-size: var(--font-size-xs); }
.text-serif    { font-family: var(--font-serif); }

.scripture-text {
    font-family: var(--font-serif);
    font-size: var(--font-size-base);
    line-height: 1.8;
    color: var(--color-text-primary);
}


/* ── 5. BUTTONS ───────────────────────────────────────────────*/
.btn {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), box-shadow var(--transition-fast),
                transform var(--transition-fast), border-color var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

.btn-primary  { background: var(--color-brand);   color: var(--color-text-inverse); border-color: var(--color-brand); }
.btn-primary:hover { background: var(--color-brand-hover); text-decoration: none; color: var(--color-text-inverse); }

.btn-success  { background: var(--color-success); color: var(--color-text-inverse); }
.btn-success:hover { opacity: .88; text-decoration: none; color: var(--color-text-inverse); }

.btn-danger   { background: var(--color-danger);  color: var(--color-text-inverse); }
.btn-danger:hover { opacity: .88; text-decoration: none; color: var(--color-text-inverse); }

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-bg); text-decoration: none; }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--font-size-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--font-size-base); }

.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }


/* ── 6. FORMS ────────────────────────────────────────────────*/
.form-group { margin-bottom: var(--space-4); }
.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-1);
}
.form-control {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-family: var(--font-sans);
    background: var(--color-surface);
    color: var(--color-text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(42,125,191,.15);
}
.form-control::placeholder { color: var(--color-text-muted); }
textarea.form-control { min-height: 90px; resize: vertical; }
select.form-control { cursor: pointer; }

.form-row { display: flex; gap: var(--space-4); }
.form-row .form-group { flex: 1; }

.form-actions {
    display: flex; gap: var(--space-3); justify-content: flex-end;
    margin-top: var(--space-5); padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-subtle);
}

/* Login page */
.login-wrap {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: var(--color-bg);
}
.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-7);
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: var(--space-6); }
.login-brand .brand-icon { font-size: 36px; color: var(--color-brand); margin-bottom: var(--space-2); }


/* ── 7. CARDS ────────────────────────────────────────────────*/
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border-subtle);
    display: flex; align-items: center; gap: var(--space-3);
}
.card-body  { padding: var(--space-4); }
.card-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border-subtle);
    background: var(--color-bg);
}

/* Source card */
.source-card { margin-bottom: var(--space-3); }
.source-card-header {
    cursor: pointer;
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-4);
    transition: background var(--transition-fast);
}
.source-card-header:hover { background: var(--color-bg); }

.source-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.source-meta { flex: 1; min-width: 0; }
.source-title { font-weight: 600; font-size: var(--font-size-base); }
.source-sub   { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 2px; }

.source-chevron {
    font-size: 18px; color: var(--color-text-muted);
    transition: transform var(--transition-base);
    flex-shrink: 0;
}
.source-card.open .source-chevron { transform: rotate(180deg); }

/* Sections list inside source card */
.sections-list { border-top: 1px solid var(--color-border-subtle); }
.section-row {
    padding: var(--space-3) var(--space-4) var(--space-3) 64px;
    border-bottom: 1px solid var(--color-border-subtle);
    transition: background var(--transition-fast);
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}
.section-row:last-child { border-bottom: none; }
.section-row:hover { background: var(--color-bg); }
.section-row.active { background: var(--color-brand-light); }
.section-link:hover .section-name { color: var(--color-brand); }
.section-name { font-weight: 500; font-size: var(--font-size-sm); }
.section-note {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: 3px; line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.section-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.section-add-row {
    padding: var(--space-2) var(--space-4) var(--space-2) 64px;
    background: var(--color-bg);
}

/* Knowledge card */
.knowledge-card { margin-bottom: var(--space-3); }
.knowledge-title { font-weight: 600; font-size: var(--font-size-base); }
.knowledge-summary { font-size: var(--font-size-sm); color: var(--color-text-secondary); margin-top: var(--space-2); line-height: 1.7; }
.knowledge-source { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: var(--space-2); font-style: italic; }
.knowledge-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }
.knowledge-date { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-left: auto; }


/* ── 8. BADGES ────────────────────────────────────────────────*/
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* Domain badges */
.badge-bible       { background: var(--color-domain-bible-bg);       color: var(--color-domain-bible);       }
.badge-science     { background: var(--color-domain-science-bg);     color: var(--color-domain-science);     }
.badge-history     { background: var(--color-domain-history-bg);     color: var(--color-domain-history);     }
.badge-philosophy  { background: var(--color-domain-philosophy-bg);  color: var(--color-domain-philosophy);  }
.badge-language    { background: var(--color-domain-language-bg);    color: var(--color-domain-language);    }
.badge-literature  { background: var(--color-domain-literature-bg);  color: var(--color-domain-literature);  }
.badge-other       { background: var(--color-domain-other-bg);       color: var(--color-domain-other);       }

/* Status badges */
.badge-todo        { background: #F1EFE8; color: #5F5E5A; }
.badge-in_progress { background: var(--color-warning-bg); color: #7A4F00; }
.badge-done        { background: var(--color-info-bg);    color: #134E8C; }
.badge-mastered    { background: var(--color-success-bg); color: #0C5E46; }

/* Confidence dots (pure CSS) */
.conf-dots { display: inline-flex; gap: 4px; align-items: center; }
.conf-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--color-border);
}
.conf-dots[data-level="very_high"] .conf-dot:nth-child(-n+5) { background: var(--color-conf-very-high); }
.conf-dots[data-level="high"]      .conf-dot:nth-child(-n+4) { background: var(--color-conf-high);      }
.conf-dots[data-level="medium"]    .conf-dot:nth-child(-n+3) { background: var(--color-conf-medium);    }
.conf-dots[data-level="low"]       .conf-dot:nth-child(-n+2) { background: var(--color-conf-low);       }
.conf-dots[data-level="speculative"].conf-dot:nth-child(-n+1){ background: var(--color-conf-speculative);}
.conf-dots[data-level="disproven"] .conf-dot                 { background: var(--color-border);         }


/* ── 9. FLASH MESSAGES ────────────────────────────────────────*/
.flash {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-sm);
    border-left: 4px solid;
}
.flash-success { background: var(--color-success-bg); border-color: var(--color-success); color: #0C5E46; }
.flash-error   { background: var(--color-danger-bg);  border-color: var(--color-danger);  color: #7A1010; }
.flash-info    { background: var(--color-info-bg);    border-color: var(--color-info);    color: #134E8C; }
.flash-warning { background: var(--color-warning-bg); border-color: var(--color-warning); color: #7A4F00; }
.flash-close   { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; padding: 0 var(--space-1); line-height: 1; }


/* ── 10. DASHBOARD / STATS ────────────────────────────────────*/
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    box-shadow: var(--shadow-sm);
}
.stat-number { font-size: var(--font-size-2xl); font-weight: 700; color: var(--color-brand); }
.stat-label  { font-size: var(--font-size-sm); color: var(--color-text-muted); margin-top: 2px; }


/* ── 11. TABLES ───────────────────────────────────────────────*/
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
th, td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--color-border-subtle); }
th { font-weight: 600; color: var(--color-text-secondary); font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-bg); }


/* ── 12. UTILITIES ────────────────────────────────────────────*/
.hidden   { display: none !important; }
.sr-only  { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.w-full { width: 100%; }

.loading-spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: var(--space-7) var(--space-5);
    color: var(--color-text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: var(--space-3); }
.empty-state p    { font-size: var(--font-size-sm); margin-top: var(--space-2); }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: var(--space-4);
}
.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    width: 100%; max-width: 520px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-subtle);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600;
}
.modal-body   { padding: var(--space-5); }
.modal-close  { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--color-text-muted); line-height: 1; }


/* ── 13. DARK THEME ───────────────────────────────────────────
   Add class="theme-dark" to <body> or use prefers-color-scheme
   ─────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .theme-default {
        --color-bg:              #111110;
        --color-surface:         #1A1A18;
        --color-surface-raised:  #222220;
        --color-border:          #2E2E2C;
        --color-border-subtle:   #252523;
        --color-text-primary:    #EDECEA;
        --color-text-secondary:  #A8A6A0;
        --color-text-muted:      #6A6864;
        --nav-bg:                #1A1A18;
        --nav-border:            #2E2E2C;
    }
}

body.theme-dark {
    --color-bg:              #111110;
    --color-surface:         #1A1A18;
    --color-surface-raised:  #222220;
    --color-border:          #2E2E2C;
    --color-border-subtle:   #252523;
    --color-text-primary:    #EDECEA;
    --color-text-secondary:  #A8A6A0;
    --color-text-muted:      #6A6864;
    --nav-bg:                #1A1A18;
    --nav-border:            #2E2E2C;
}

/* ── Category cards ───────────────────────────────────────────────────────*/
.category-card {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    cursor: pointer;
}
.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

/* ── Item accordion (content.php) ─────────────────────────────────────────*/
.item-card { transition: box-shadow var(--transition-fast); }
.item-header:hover { background: var(--color-bg) !important; }
.item-card.open .item-header { background: var(--color-brand-light); }
.item-card.open .item-header .item-chevron { transform: rotate(180deg); }

/* ── Three-level accordion ────────────────────────────────────────────────*/
.ac-source-hdr:hover  { background: var(--color-bg) !important; }
.ac-section-hdr:hover { background: var(--color-surface) !important; }
.ac-item-hdr:hover    { background: var(--color-bg) !important; }

.ac-source.open  .ac-source-hdr  { background: var(--color-brand-light); }
.ac-section.open .ac-section-hdr { background: var(--color-brand-light); }
.ac-item.open    .ac-item-hdr    { background: var(--color-brand-light); }

.ac-source.open  .ac-source-hdr  .ac-chevron,
.ac-section.open .ac-section-hdr .ac-chevron,
.ac-item.open    .ac-item-hdr    .ac-chevron {
    transform: rotate(180deg);
}

/* ── My Notes accordion ───────────────────────────────────────────────────*/
/* My Notes uses the same ac-indent-* classes as the knowledge accordion */
.mn-source-hdr:hover,
.mn-version-hdr:hover,
.mn-section-hdr:hover,
.mn-item-hdr:hover    { background: var(--color-bg) !important; }

.mn-source.open  .mn-source-hdr,
.mn-version.open .mn-version-hdr,
.mn-section.open .mn-section-hdr,
.mn-item.open    .mn-item-hdr    { background: var(--color-brand-light); }

.mn-source.open  .mn-source-hdr  .mn-chevron,
.mn-version.open .mn-version-hdr .mn-chevron,
.mn-section.open .mn-section-hdr .mn-chevron,
.mn-item.open    .mn-item-hdr    .mn-chevron { transform: rotate(180deg); }

/* ── btn-success ──────────────────────────────────────────────────────────*/
.btn-success {
    background: var(--color-success, #1D9E75);
    color: #fff;
    border-color: var(--color-success, #1D9E75);
}
.btn-success:hover { opacity: .9; }

/* ── Source status badges ─────────────────────────────────────────────────*/
.badge-reviewing {
    background: #FAEEDA;
    color: #854F0B;
    border: 1px solid #EF9F27;
}

/* ══════════════════════════════════════════════════════════════════════════
   ACCORDION INDENTATION — controlled purely by CSS classes
   ══════════════════════════════════════════════════════════════════════════ */

.ac-indent-ver { padding-left: 66px !important; }
.ac-indent-sec { padding-left: 82px !important; }
.ac-indent-itm { padding-left: 98px !important; }

/* Hide hamburger on desktop */
.nav-toggle { display: none; }

/* ── Mobile (max 768px) ─────────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Indentation — tighter on mobile */
    .ac-indent-ver { padding-left: 28px !important; }
    .ac-indent-sec { padding-left: 38px !important; }
    .ac-indent-itm { padding-left: 38px !important; }

    /* Nav — collapses to hamburger */
    .site-nav {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 14px;
        gap: 0;
        align-items: center;
    }
    .nav-brand {
        flex: 1;
        min-width: 0;
    }
    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px; height: 38px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background: transparent;
        color: var(--color-text-secondary);
        font-size: 18px;
        cursor: pointer;
        flex-shrink: 0;
        margin-left: 8px;
    }
    /* Hidden by default — full width below brand row */
    .nav-links {
        display: none;
        flex-direction: column;
        flex-basis: 100%;
        width: 100%;
        gap: 2px;
        padding: 6px 0;
        border-top: 1px solid var(--color-border-subtle);
        margin-top: 8px;
        list-style: none;
    }
    .nav-links.open {
        display: flex !important;
        flex-direction: column !important;
    }
    .nav-links li { width: 100%; }
    .nav-links .nav-link {
        display: block;
        width: 100%;
        padding: 10px 12px;
        font-size: 15px;
    }
    .nav-user {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        flex-basis: 100%;
        width: 100%;
        gap: 8px;
        padding: 8px 0 4px;
        border-top: 1px solid var(--color-border-subtle);
        margin-top: 4px;
        margin-left: 0;
    }
    .nav-user.open {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Main content */
    .site-main  { padding: 16px 12px; }
    .page-title { font-size: var(--font-size-xl); }

    /* Modal slides up from bottom */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal {
        max-width: 100% !important;
        width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Forms stack vertically */
    .form-row { flex-direction: column; gap: 12px; }

    /* Bigger touch targets */
    .btn-sm { padding: 7px 10px; font-size: 12px; }

    /* Hide source domain icon to save space */
    .ac-source-icon { display: none; }

    /* TTS bar full width */
    #tts-stop-bar {
        bottom: 10px !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        transform: none !important;
    }
}

/* ── Small phones (max 480px) ───────────────────────────────────────────── */
@media (max-width: 480px) {
    .ac-indent-ver { padding-left: 14px !important; }
    .ac-indent-sec { padding-left: 22px !important; }
    .ac-indent-itm { padding-left: 22px !important; }
    .site-main { padding: 12px 8px; }
}