/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f3f0;
    --surface: #ffffff;
    --surface-alt: #faf9f7;
    --border: #e2dfd9;
    --text: #2c2825;
    --text-muted: #7a7268;
    --accent: #4a6741;
    --accent-light: #e8f0e6;
    --accent-dark: #3a5234;
    --tag-bg: #eee9e2;
    --tag-text: #6b6057;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius: 8px;
    --radius-lg: 12px;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Georgia', 'Times New Roman', serif;
    --dna-bg: #f8f6f3;
    --dna-border: #ebe7e1;
    --fav-color: #d4a017;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Layout ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem 6rem;
}

/* ===== Header ===== */
.site-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    text-align: left;
    padding: 2.5rem 0 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.site-header-text {
    flex: 1;
    min-width: 0;
}

/* ===== Logo Mark ===== */
.qm-logo {
    width: 116px;
    height: 116px;
    display: block;
    flex-shrink: 0;
}

.qm-ring {
    fill: none;
    stroke: var(--border);
    stroke-width: 1.5;
}

.qm-ticks line {
    stroke: var(--border);
    stroke-width: 1.5;
    stroke-linecap: round;
}

.qm-orbit {
    transform-origin: 60px 60px;
    animation: qm-orbit-spin 48s linear infinite;
}

.qm-orbit-path {
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 1;
    stroke-dasharray: 1.5 7.5;
    opacity: 0.45;
}

.qm-node { fill: var(--accent); }
.qm-node-b { fill: var(--fav-color); }
.qm-node-c { fill: var(--text-muted); }

.qm-mark {
    fill: none;
    stroke: var(--accent);
    stroke-width: 7;
    stroke-linecap: round;
}

.qm-dot { fill: var(--accent); }

@keyframes qm-orbit-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .qm-orbit { animation: none; }
}

.site-header h1 {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.site-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin: 0;
}

/* ===== Site Navigation ===== */
.site-nav {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-start;
    gap: 1.5rem;
}

.nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    padding: 0.3rem 0;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.nav-link:hover {
    border-bottom-color: var(--accent);
}

.nav-link i,
.btn i,
.btn-sm i {
    margin-right: 0.25em;
}

.fav-badge {
    font-size: 0.65rem;
    background: var(--fav-color);
    color: #fff;
    border-radius: 999px;
    padding: 0.1rem 0.4rem;
    margin-left: 0.25rem;
    font-weight: 600;
    vertical-align: super;
}

.fav-badge:empty {
    display: none;
}

/* ===== Generator Tabs ===== */
.gen-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
}

.gen-tab {
    appearance: none;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.gen-tab:hover {
    color: var(--text);
}

.gen-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ===== Controls ===== */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.seed-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.seed-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.seed-group input {
    width: 130px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    text-align: center;
}

.seed-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-alt);
}

/* ===== Generator Sections ===== */
.generator-section {
    margin-bottom: 2.5rem;
}

.generator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.15s ease;
    user-select: none;
}

.generator-header:hover {
    box-shadow: var(--shadow-sm);
}

.generator-header.open {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom-color: transparent;
}

.generator-title {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.generator-title h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 400;
}

.generator-title .badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--tag-bg);
    color: var(--tag-text);
}

.generator-chevron {
    font-size: 0.85rem;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.generator-header.open .generator-chevron {
    transform: rotate(180deg);
}

.generator-body {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
}

.generator-description {
    padding: 1rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

/* ===== Repeat Likelihood Stat ===== */
.repeat-stat {
    padding: 0.4rem 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

.repeat-stat:empty {
    display: none;
}

.repeat-stat i {
    margin-right: 0.2em;
}

.repeat-stat .repeat-detail {
    opacity: 0.65;
}

.repeat-low {
    color: var(--accent);
    font-weight: 600;
}

.repeat-med {
    color: #b8860b;
    font-weight: 600;
}

.repeat-high {
    color: #c04040;
    font-weight: 600;
}

/* ===== Repeat Question Highlight ===== */
.question-item.repeat,
.chain-step.repeat {
    background: var(--repeat-bg, #f5f0e8);
    border-radius: 6px;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding-left: 1.75rem;
    padding-right: 0.5rem;
}

.question-item.repeat::after,
.chain-step.repeat::after {
    content: 'seen before';
    position: absolute;
    right: 0.75rem;
    top: 0.45rem;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--repeat-label, #b8a070);
    opacity: 0.7;
    font-weight: 600;
    pointer-events: none;
}

/* ===== Category Cards ===== */
.category-group {
    padding: 1.25rem;
}

.category-group + .category-group {
    border-top: 1px solid var(--border);
}

.category-name {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.question-list {
    list-style: none;
}

.question-item {
    padding: 0.6rem 0;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text);
    position: relative;
    padding-left: 1.25rem;
}

.question-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
}

.question-item + .question-item {
    border-top: 1px solid #f0eeeb;
}

.question-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.question-text {
    flex: 1;
}

/* ===== Question Actions (DNA + Fav buttons) ===== */
.question-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.question-item:hover .question-actions,
.chain-step:hover .question-actions {
    opacity: 1;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.15s ease;
    padding: 0;
}

.btn-icon:hover {
    background: var(--tag-bg);
    color: var(--text);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-icon i {
    font-size: 14px;
}

.btn-fav.active {
    color: var(--fav-color);
}

.btn-fav.active svg {
    fill: var(--fav-color);
}

.btn-fav.active i.fa-star {
    font-weight: 900; /* switches fa-solid to fa-solid */
}

/* ===== DNA Panel ===== */
.dna-panel {
    display: none;
    margin-top: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: var(--dna-bg);
    border: 1px solid var(--dna-border);
    border-radius: var(--radius);
    font-size: 0.75rem;
    line-height: 1.6;
}

.dna-panel.visible {
    display: block;
}

.dna-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}

.dna-section:last-child {
    margin-bottom: 0;
}

.dna-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-size: 0.65rem;
    margin-right: 0.25rem;
}

.dna-tag {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: var(--surface);
    border: 1px solid var(--dna-border);
    color: var(--tag-text);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.7rem;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.taxonomy-tag {
    background: var(--accent-light);
    border-color: #c8dcc4;
    color: var(--accent-dark);
}

/* ===== Socratic Chain ===== */
.socratic-chain {
    padding: 0;
    list-style: none;
    position: relative;
}

.socratic-chain::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 1.1rem;
    bottom: 0.5rem;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent-light), var(--border));
}

.chain-step {
    padding: 0.5rem 0 0.5rem 2rem;
    position: relative;
}

.chain-step::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 0.85rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--surface);
    z-index: 1;
}

.chain-step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.chain-stage {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 0.15rem;
}

.chain-question {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
}

/* ===== Stats Footer ===== */
.stats {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.stats span {
    font-weight: 600;
    color: var(--text);
}

/* ===== Notices ===== */
.notice {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.notice a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.notice-warning {
    background: #fef3e2;
    border: 1px solid #f0d6a8;
    color: #7a5c1f;
}

.notice-empty {
    background: #fce8e8;
    border: 1px solid #e8b4b4;
    color: #7a1f1f;
}

/* ===== FAB ===== */
.generate-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.1);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    z-index: 1000;
}

.generate-fab:hover {
    background: var(--accent-dark);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.12);
    transform: scale(1.05);
}

.generate-fab:active {
    transform: scale(0.95);
}

.generate-fab-icon {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.fab-loading .generate-fab-icon {
    animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ===== Content Transitions ===== */
#questions-container {
    transition: opacity 0.15s ease;
}

#questions-container.fade-out {
    opacity: 0;
}

#questions-container.fade-in {
    animation: fade-in 0.3s ease forwards;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Collapsed State ===== */
.generator-body.collapsed {
    display: none;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    background: var(--text);
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 1001;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Solver Panel ===== */
.solver-panel {
    margin-bottom: 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
}

.solver-toggle {
    padding: 1rem 1.25rem;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.solver-toggle::-webkit-details-marker {
    display: none;
}

.solver-toggle::before {
    content: '+';
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.solver-panel[open] .solver-toggle::before {
    content: '-';
}

.solver-body {
    padding: 0 1.25rem 1.25rem;
}

.solver-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.solver-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.solver-field label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.solver-field select,
.solver-field input[type="number"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-body);
}

.solver-field select:focus,
.solver-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.solver-checkboxes {
    flex: 1;
    min-width: 200px;
}

.solver-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
}

.solver-checks label {
    font-size: 0.8rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.solver-checks input[type="checkbox"] {
    accent-color: var(--accent);
}

.solver-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.solver-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.solver-results {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.solver-results:empty {
    display: none;
}

.solver-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.solver-meta {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

/* ===== Favorites Panel ===== */
.favorites-panel {
    margin-bottom: 2.5rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.favorites-panel h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 400;
    margin-bottom: 1rem;
}

.favorites-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.favorites-list {
    min-height: 2rem;
}

.favorites-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.favorite-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0eeeb;
}

.favorite-item:last-child {
    border-bottom: none;
}

.favorite-text {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.5;
}

.favorite-gen {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--tag-bg);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    white-space: nowrap;
}

.btn-fav-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.btn-fav-remove:hover {
    background: #fce8e8;
    color: #7a1f1f;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .container {
        padding: 1rem 1rem 5rem;
    }

    .site-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 2rem 0 1.5rem;
    }

    .site-header p {
        margin: 0 auto;
    }

    .site-header h1 {
        font-size: 1.75rem;
    }

    .site-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }

    .qm-logo {
        width: 88px;
        height: 88px;
    }

    .controls {
        flex-direction: column;
    }

    .generator-title h2 {
        font-size: 1.15rem;
    }

    .generate-fab {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 50px;
        height: 50px;
    }

    .generate-fab-icon {
        font-size: 1.1rem;
    }

    .solver-row {
        flex-direction: column;
    }

    .question-actions {
        opacity: 1;
    }

    .dna-tag {
        max-width: 200px;
    }

    .search-bar {
        flex-direction: column;
    }

    .capacity-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Dim Theme ===== */
:root.dim {
    --bg: #2a2825;
    --surface: #33302c;
    --surface-alt: #2e2b27;
    --border: #4a4540;
    --text: #c8c2b8;
    --text-muted: #8a8378;
    --accent: #7a9d6f;
    --accent-light: #3a4a35;
    --accent-dark: #8fb382;
    --tag-bg: #3a3730;
    --tag-text: #9a9488;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --dna-bg: #2e2b27;
    --dna-border: #3e3a35;
    --fav-color: #d4a017;
    --repeat-bg: #35322a;
    --repeat-label: #8a7d60;
}

:root.dim .notice-warning {
    background: #3a3425;
    border-color: #5a4d35;
    color: #c8a860;
}

:root.dim .notice-empty {
    background: #3a2525;
    border-color: #5a3535;
    color: #c87070;
}

:root.dim .question-item + .question-item {
    border-top-color: #3e3a35;
}

:root.dim .favorite-item {
    border-bottom-color: #3e3a35;
}

:root.dim .taxonomy-tag {
    background: #3a4a35;
    border-color: #4a5a45;
    color: var(--accent-dark);
}

:root.dim .btn-fav-remove:hover {
    background: #3a2525;
    color: #c87070;
}

/* ===== Dark Theme ===== */
:root.dark {
    --bg: #1a1a1e;
    --surface: #242428;
    --surface-alt: #1e1e22;
    --border: #3a3a40;
    --text: #d4d4d8;
    --text-muted: #8a8a92;
    --accent: #6ea85f;
    --accent-light: #2a3a25;
    --accent-dark: #8fc882;
    --tag-bg: #2a2a30;
    --tag-text: #9a9aa0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --dna-bg: #1e1e22;
    --dna-border: #2e2e35;
    --fav-color: #e0b030;
    --repeat-bg: #28272a;
    --repeat-label: #7a7460;
}

:root.dark .notice-warning {
    background: #2e2a1a;
    border-color: #4a4025;
    color: #d4b060;
}

:root.dark .notice-empty {
    background: #2e1a1a;
    border-color: #4a2525;
    color: #d47070;
}

:root.dark .question-item + .question-item {
    border-top-color: #2e2e35;
}

:root.dark .favorite-item {
    border-bottom-color: #2e2e35;
}

:root.dark .taxonomy-tag {
    background: #2a3a25;
    border-color: #3a4a35;
    color: var(--accent-dark);
}

:root.dark .btn-fav-remove:hover {
    background: #2e1a1a;
    color: #d47070;
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    vertical-align: middle;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
}

.theme-toggle i {
    font-size: 14px;
}

/* ===== Search Bar ===== */
.search-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.search-bar input {
    width: 100%;
    max-width: 500px;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.search-wrapper svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
    display: none;
}

/* ===== Loading Skeleton ===== */
.skeleton-section {
    margin-bottom: 2.5rem;
}

.skeleton-header {
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.skeleton-body {
    margin-top: -1px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--surface);
    padding: 1.25rem;
}

.skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: var(--tag-bg);
    margin-bottom: 0.75rem;
    position: relative;
    overflow: hidden;
}

.skeleton-line:nth-child(1) { width: 85%; }
.skeleton-line:nth-child(2) { width: 72%; }
.skeleton-line:nth-child(3) { width: 90%; }
.skeleton-line:nth-child(4) { width: 65%; }

.skeleton-header::after,
.skeleton-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.08) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}

:root.dim .skeleton-header::after,
:root.dim .skeleton-line::after,
:root.dark .skeleton-header::after,
:root.dark .skeleton-line::after {
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
}

@keyframes shimmer {
    0%   { left: -100%; }
    100% { left: 100%; }
}

/* ===== Staggered Entrance Animation ===== */
.question-item.animate-in,
.chain-step.animate-in {
    animation: slideUp 0.3s ease forwards;
    opacity: 0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Capacity Stats ===== */
.capacity-row {
    text-align: center;
    margin-top: 0.75rem;
}

.capacity-total {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.capacity-total strong {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.95rem;
}

.capacity-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    font-family: var(--font-body);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    transition: color 0.15s ease;
    opacity: 0.7;
}

.capacity-toggle:hover {
    color: var(--text);
    opacity: 1;
}

.capacity-details {
    display: none;
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: left;
}

.capacity-details.visible {
    display: block;
}

.capacity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.capacity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background: var(--surface-alt);
}

.capacity-item-name {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.capacity-item-value {
    color: var(--text);
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.7rem;
}

/* ===== Keyboard Shortcuts Hint ===== */
.keyboard-hints {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.keyboard-hints-top {
    margin-top: 0;
    margin-bottom: 1rem;
}

.kbd-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 0.3rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ===== Export Button Group ===== */
.export-group {
    display: inline-flex;
    position: relative;
}

.export-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 100;
    min-width: 160px;
    overflow: hidden;
}

.export-dropdown.visible {
    display: block;
}

.export-dropdown a {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.1s ease;
}

.export-dropdown a:hover {
    background: var(--surface-alt);
}
