/* ==========================================================================
   Word Power Made Easy — Modern Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */

:root {
    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-controls: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6a6a6a;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e2e2e5;
    --shadow: rgba(0, 0, 0, 0.08);
    --code-bg: #f0f0f3;
    --highlight: #fef3c7;
    --card-bg: #ffffff;
    --card-hover: #f0f4ff;

    /* Typography */
    --font-size-base: 18px;
    --font-family: 'Times New Roman', Georgia, serif;
    --line-height: 1.7;
    --content-max-width: 740px;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4rem;

    /* Transitions */
    --transition-speed: 0.3s;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-controls: #1a1a2e;
    --text-primary: #f5f5f5;
    --text-secondary: #d0d0d0;
    --text-muted: #a8a8a8;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --border: #2d2d44;
    --shadow: rgba(0, 0, 0, 0.3);
    --code-bg: #2d2d44;
    --highlight: #4a3f2a;
    --card-bg: #16213e;
    --card-hover: #1e2d4a;
}

/* --------------------------------------------------------------------------
   2. Font Family System
   -------------------------------------------------------------------------- */

[data-font="times"]    { --font-family: 'Times New Roman', Georgia, serif; }
[data-font="roboto"]   { --font-family: 'Roboto', sans-serif; }
[data-font="opensans"] { --font-family: 'Open Sans', sans-serif; }
[data-font="inter"]    { --font-family: 'Inter', sans-serif; }
[data-font="source"]   { --font-family: 'Source Sans Pro', sans-serif; }
[data-font="system"]   { --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }

/* --------------------------------------------------------------------------
   3. Width Toggle
   -------------------------------------------------------------------------- */

[data-width="narrow"] { --content-max-width: 740px; }
[data-width="wide"]   { --content-max-width: 95%; }

/* --------------------------------------------------------------------------
   4. Global Reset & Base Styles
   -------------------------------------------------------------------------- */

*, *::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-family);
    font-size: 1rem;
    line-height: var(--line-height);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color var(--transition-speed) ease,
                color var(--transition-speed) ease;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

img {
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   5. Controls Bar
   -------------------------------------------------------------------------- */

.controls-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-controls);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px var(--shadow);
    padding: var(--space-sm) var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    transition: background-color var(--transition-speed) ease,
                border-color var(--transition-speed) ease;
}

.site-title {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.site-title:hover {
    color: var(--accent);
    text-decoration: none;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4em;
    height: 2.4em;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    line-height: 1;
}

.control-btn:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn svg {
    width: 1.1em;
    height: 1.1em;
}

/* --------------------------------------------------------------------------
   5b. Settings Panel
   -------------------------------------------------------------------------- */

.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
    opacity: 1;
    transition: opacity var(--transition-speed) ease;
}

.settings-overlay[hidden] {
    display: block;
    opacity: 0;
    pointer-events: none;
}

.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px var(--shadow);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform var(--transition-speed) ease,
                background-color var(--transition-speed) ease;
    overflow-y: auto;
}

.settings-panel[hidden] {
    display: flex;
    transform: translateX(100%);
    pointer-events: none;
}

.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.settings-panel-title {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2em;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-close-btn svg {
    width: 1.2em;
    height: 1.2em;
}

.settings-panel-body {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.settings-label {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Segmented toggle (theme, width) */
.settings-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.settings-toggle-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-toggle-btn + .settings-toggle-btn {
    border-left: 1px solid var(--border);
}

.settings-toggle-btn.active {
    background: var(--accent);
    color: #ffffff;
}

.settings-toggle-btn:hover:not(.active) {
    background: var(--card-hover);
}

/* Font size stepper */
.settings-font-size {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.settings-stepper-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4em;
    height: 2.4em;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-stepper-btn:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.settings-font-size-value {
    min-width: 3.5em;
    text-align: center;
    font-weight: 600;
    font-size: 0.95em;
    color: var(--text-primary);
}

/* Font family list */
.settings-font-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.settings-font-option {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9em;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-font-option:hover {
    background: var(--card-hover);
    border-color: var(--accent);
}

.settings-font-option.active {
    background: var(--card-hover);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   6. Index Page — Book Header
   -------------------------------------------------------------------------- */

.book-header {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.book-header h1 {
    font-size: 2.4em;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.book-header .subtitle {
    font-size: 1.1em;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--space-xs);
}

.book-header .author {
    font-size: 1em;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   6b. Index Page — Progress Summary
   -------------------------------------------------------------------------- */

.progress-summary {
    max-width: var(--content-max-width);
    margin: 0 auto var(--space-xl);
    padding: 0 var(--space-md);
}

.progress-summary-inner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.progress-bar-track {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    width: 0%;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   7. Index Page — Table of Contents
   -------------------------------------------------------------------------- */

.index-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 var(--space-md) var(--space-2xl);
}

.toc-section {
    margin-bottom: var(--space-xl);
}

.toc-section h2 {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--accent);
    margin-bottom: var(--space-md);
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.toc-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.toc-item:hover {
    background-color: var(--card-hover);
    border-color: var(--border);
    text-decoration: none;
    color: var(--text-primary);
}

.toc-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2em;
    font-weight: 700;
    font-size: 0.85em;
    color: var(--accent);
    background: var(--card-hover);
    border-radius: 50%;
    flex-shrink: 0;
}

.toc-title {
    font-size: 1em;
    flex: 1;
}

.toc-description {
    font-size: 0.85em;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Content type badges */
.toc-badge {
    font-size: 0.65em;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex-shrink: 0;
}

.toc-badge-vocab {
    color: var(--accent);
    background: var(--card-hover);
    border: 1px solid var(--accent);
}

.toc-badge-test {
    color: #d97706;
    background: var(--highlight);
    border: 1px solid #d97706;
}

.toc-badge-intro {
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.toc-badge-grammar {
    color: #7c3aed;
    background: #f3e8ff;
    border: 1px solid #7c3aed;
}

[data-theme="dark"] .toc-badge-grammar {
    color: #a78bfa;
    background: #2e1065;
    border-color: #a78bfa;
}

[data-theme="dark"] .toc-badge-test {
    color: #fbbf24;
    background: #4a3f2a;
    border-color: #fbbf24;
}

.toc-badge-start {
    color: #fff;
    background: var(--accent);
    border: 1px solid var(--accent);
    font-weight: 700;
}
.toc-badge-start:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Progress checkbox */
.toc-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6em;
    height: 1.6em;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    padding: 0;
    margin-left: auto;
}

.toc-progress:hover {
    border-color: var(--accent);
    background: var(--card-hover);
}

.toc-progress.completed {
    background: var(--accent);
    border-color: var(--accent);
}

.toc-progress.completed::after {
    content: '';
    display: block;
    width: 0.5em;
    height: 0.3em;
    border-left: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: rotate(-45deg) translateY(-1px);
}

/* Coming soon state */
.toc-item.coming-soon {
    opacity: 0.5;
    cursor: default;
}

.toc-item.coming-soon:hover {
    background-color: transparent;
    border-color: transparent;
}

.toc-item.coming-soon .toc-number {
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.coming-soon-badge {
    font-size: 0.7em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Intermission items (inline with chapters) */
.toc-item-intermission {
    margin-left: 1.5rem;
    font-size: 0.92em;
    border-left: 3px solid #a78bfa;
    background: rgba(243, 232, 255, 0.3);
}

.toc-item-intermission .toc-number {
    background: #f3e8ff;
    color: #7c3aed;
    font-size: 0.75em;
}

[data-theme="dark"] .toc-item-intermission {
    border-left-color: #7c3aed;
    background: rgba(46, 16, 101, 0.25);
}

[data-theme="dark"] .toc-item-intermission .toc-number {
    background: #2e1065;
    color: #a78bfa;
}

/* --------------------------------------------------------------------------
   8. Chapter Page — Navigation Strip
   -------------------------------------------------------------------------- */

.chapter-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9em;
}

.chapter-nav a {
    color: var(--accent);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.chapter-nav a:hover {
    background-color: var(--card-hover);
    text-decoration: none;
}

.nav-prev::before { content: "\2190 "; }
.nav-next::after { content: " \2192"; }

.nav-toc {
    font-weight: 600;
}

/* Placeholder when prev/next doesn't exist */
.chapter-nav .nav-placeholder {
    visibility: hidden;
}

/* --------------------------------------------------------------------------
   8b. Chapter Tabs
   -------------------------------------------------------------------------- */

.chapter-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-xs) var(--space-md);
    border-bottom: 1px solid var(--border);
}

.chapter-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    user-select: none;
    white-space: nowrap;
    border-radius: 0;
    line-height: 1;
    margin-bottom: -1px;
}

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

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

.chapter-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Tab panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* --------------------------------------------------------------------------
   9. Chapter Page — Content
   -------------------------------------------------------------------------- */

.chapter-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md) var(--space-2xl);
    transition: max-width var(--transition-speed) ease;
}

.chapter-header {
    margin-bottom: var(--space-xl);
    text-align: center;
}

.chapter-header .chapter-number {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-xs);
}

.chapter-header h1 {
    font-size: 2em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.chapter-header .sessions-info {
    font-size: 0.9em;
    color: var(--text-muted);
    font-style: italic;
}

/* Headings within chapter content */
.chapter-content h2 {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border);
}

.chapter-content h3 {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.chapter-content h4 {
    font-size: 1.05em;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: var(--space-md);
    margin-bottom: var(--space-sm);
}

/* Paragraphs */
.chapter-content p {
    margin-bottom: 1em;
    text-align: justify;
    hyphens: auto;
}

/* Lists */
.chapter-content ol,
.chapter-content ul {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.chapter-content li {
    margin-bottom: 0.4em;
}

/* Dividers */
.chapter-content hr {
    border: none;
    height: 2px;
    background: var(--border);
    margin: var(--space-xl) 0;
}

/* Blockquotes */
.chapter-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: var(--space-md);
    margin: var(--space-md) 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Emphasis within content */
.chapter-content em {
    font-style: italic;
}

.chapter-content strong {
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   10. Vocabulary & Etymology Styles
   -------------------------------------------------------------------------- */

.vocab-word {
    font-weight: 700;
    color: var(--accent);
}

.pronunciation {
    font-family: 'Times New Roman', Georgia, serif;
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9em;
}

.definition {
    color: var(--text-secondary);
}

.word-list {
    list-style: decimal;
    padding-left: 1.5em;
    margin-bottom: var(--space-lg);
}

.word-list li {
    margin-bottom: var(--space-sm);
    padding: var(--space-xs) 0;
}

.etymology-block {
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.etymology-block h4 {
    margin-top: 0;
    color: var(--accent);
}

/* --------------------------------------------------------------------------
   10b. Word List Mode
   -------------------------------------------------------------------------- */

.wordlist-intro {
    text-align: center;
    margin-bottom: var(--space-xl);
    color: var(--text-secondary);
}

.wordlist-intro p {
    text-align: center;
}

.wordlist-count {
    margin-top: var(--space-sm);
    font-size: 0.9em;
    color: var(--text-muted);
}

.wordlist-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.wordlist-card {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    transition: background-color var(--transition-speed) ease;
}

.wordlist-term {
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 var(--space-xs);
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    flex-wrap: wrap;
    border-bottom: none;
}

.wordlist-definition {
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
    text-align: left;
}

.wordlist-forms {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: baseline;
    margin-bottom: var(--space-xs);
    font-size: 0.9em;
}

.wordlist-form-label,
.wordlist-root-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wordlist-form {
    display: inline-block;
    padding: 2px 8px;
    background: var(--card-bg);
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.wordlist-root {
    font-size: 0.9em;
    color: var(--text-muted);
    font-style: italic;
}

/* --------------------------------------------------------------------------
   10c. Practice Mode Placeholder
   -------------------------------------------------------------------------- */

.practice-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 40vh;
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
}

.practice-icon {
    width: 3em;
    height: 3em;
    margin-bottom: var(--space-lg);
    color: var(--text-muted);
}

.practice-placeholder h2 {
    border-bottom: none;
    margin-top: 0;
    margin-bottom: var(--space-sm);
}

.practice-placeholder p {
    color: var(--text-secondary);
    max-width: 500px;
    text-align: center;
}

.practice-switch-link {
    background: none;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.practice-switch-link:hover {
    color: var(--accent-hover);
}

/* --------------------------------------------------------------------------
   11. Exercise Styles
   -------------------------------------------------------------------------- */

.exercise-section {
    margin: var(--space-lg) 0;
}

.exercise-list {
    list-style: decimal;
    padding-left: 1.5em;
}

.exercise-list li {
    margin-bottom: var(--space-sm);
    padding: var(--space-xs) 0;
}

.exercise-word {
    font-weight: 700;
}

.exercise-options {
    color: var(--text-secondary);
    margin-left: var(--space-md);
}

/* Answer key using <details> */
.answer-key {
    margin-top: var(--space-md);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.answer-key summary {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    cursor: pointer;
    font-weight: 600;
    user-select: none;
    transition: background-color 0.2s ease;
}

.answer-key summary:hover {
    background: var(--card-hover);
}

.answer-key > :not(summary) {
    padding: var(--space-md);
}

/* --------------------------------------------------------------------------
   11b. Quiz & Practice Styles
   -------------------------------------------------------------------------- */

.quiz-options-list {
    list-style-type: lower-alpha;
    padding-left: 2em;
    margin-top: var(--space-xs);
}

.quiz-options-list li {
    margin-bottom: 0.25em;
    padding: 0.15em 0;
}

.quiz-questions-list > li {
    margin-bottom: var(--space-md);
}

/* Scoring tables */
.scoring-table {
    border-collapse: collapse;
    margin: var(--space-md) auto;
    min-width: 280px;
}

.scoring-table th,
.scoring-table td {
    border: 1px solid var(--border);
    padding: var(--space-xs) var(--space-md);
    text-align: center;
}

.scoring-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.scoring-table td {
    background: var(--bg-primary);
}

/* Verbal speed / responsiveness tables */
.verbal-speed-table,
.verbal-responsiveness-table {
    border-collapse: collapse;
    width: 100%;
    margin: var(--space-md) 0;
}

.verbal-speed-table th,
.verbal-speed-table td,
.verbal-responsiveness-table th,
.verbal-responsiveness-table td {
    border: 1px solid var(--border);
    padding: var(--space-xs) var(--space-sm);
    text-align: left;
}

.verbal-speed-table th,
.verbal-responsiveness-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

/* Interactive quiz styles (Practice panel) */
.quiz-score {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: var(--space-sm) var(--space-md);
    font-weight: 600;
    font-size: 1.1em;
    text-align: center;
    margin-bottom: var(--space-lg);
    position: sticky;
    top: 3.5em;
    z-index: 5;
}

.practice-quiz-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    transition: border-color 0.2s ease;
}

.practice-quiz-item.answered {
    opacity: 0.85;
}

.quiz-question {
    margin-bottom: var(--space-sm);
    font-size: 1em;
}

.quiz-question em {
    color: var(--accent);
    font-weight: 600;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
}

.quiz-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6em 1em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95em;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.quiz-option:hover:not(:disabled) {
    background: var(--card-hover);
    border-color: var(--accent);
}

.quiz-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.quiz-option:disabled {
    cursor: default;
    opacity: 0.7;
}

.quiz-option.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
    opacity: 1;
    font-weight: 600;
}

.quiz-option.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
    opacity: 1;
}

[data-theme="dark"] .quiz-option.correct {
    background: #1a3a2a;
    border-color: #28a745;
    color: #a3d9b1;
}

[data-theme="dark"] .quiz-option.incorrect {
    background: #3a1a1a;
    border-color: #dc3545;
    color: #f5a5a5;
}

.quiz-feedback {
    margin-top: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9em;
}

.quiz-feedback.correct {
    color: #155724;
    background: #d4edda;
}

.quiz-feedback.incorrect {
    color: #721c24;
    background: #f8d7da;
}

[data-theme="dark"] .quiz-feedback.correct {
    color: #a3d9b1;
    background: #1a3a2a;
}

[data-theme="dark"] .quiz-feedback.incorrect {
    color: #f5a5a5;
    background: #3a1a1a;
}

/* --------------------------------------------------------------------------
   12. Coming Soon Page
   -------------------------------------------------------------------------- */

.coming-soon-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
}

.coming-soon-icon {
    width: 4em;
    height: 4em;
    margin-bottom: var(--space-lg);
    color: var(--text-muted);
}

.coming-soon-content h1 {
    font-size: 2em;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.coming-soon-content p {
    font-size: 1.1em;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    max-width: 500px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-lg);
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1em;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn:hover {
    background: var(--accent-hover);
    color: #ffffff;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

/* --------------------------------------------------------------------------
   13. Notification Toast
   -------------------------------------------------------------------------- */

.notification-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
}

.notification-toast.visible {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   14. Page Footer
   -------------------------------------------------------------------------- */

.page-footer {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    text-align: center;
    font-size: 0.85em;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   15. Responsive Design
   -------------------------------------------------------------------------- */

/* Mobile (base) */
@media (max-width: 639px) {
    :root {
        --font-size-base: 16px;
    }

    .controls-bar {
        padding: var(--space-xs) var(--space-sm);
        gap: var(--space-xs);
    }

    .control-btn {
        width: 2.6em;
        height: 2.6em;
        font-size: 0.8em;
    }

    .book-header {
        padding: var(--space-xl) var(--space-sm);
    }

    .book-header h1 {
        font-size: 1.8em;
    }

    .chapter-content {
        padding: var(--space-md) var(--space-sm) var(--space-xl);
    }

    .chapter-header h1 {
        font-size: 1.6em;
    }

    .chapter-nav {
        font-size: 0.8em;
        padding: var(--space-xs) var(--space-sm);
    }

    .toc-item {
        padding: var(--space-sm);
        gap: var(--space-sm);
    }

    /* Chapter tabs mobile */
    .chapter-tabs {
        padding: var(--space-xs) var(--space-sm);
        gap: 0;
    }

    .chapter-tab {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.8em;
        flex: 1;
    }

    /* Word list mobile */
    .wordlist-card {
        padding: var(--space-sm) var(--space-md);
    }

    .wordlist-term {
        flex-direction: column;
        gap: var(--space-xs);
    }

    /* Settings panel mobile */
    .settings-panel {
        width: 100vw;
        max-width: 100vw;
    }

    /* Progress summary mobile */
    .progress-summary-inner {
        flex-direction: column;
        gap: var(--space-sm);
        padding: var(--space-md);
    }

    .progress-bar-track {
        width: 100%;
    }
}

/* Tablet */
@media (min-width: 640px) and (max-width: 1023px) {
    .chapter-content {
        padding: var(--space-lg) var(--space-lg) var(--space-2xl);
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .controls-bar {
        padding: var(--space-sm) var(--space-lg);
    }

    .index-content {
        padding: 0 var(--space-lg) var(--space-2xl);
    }
}

/* --------------------------------------------------------------------------
   16. Print Styles
   -------------------------------------------------------------------------- */

@media print {
    .controls-bar,
    .chapter-nav,
    .chapter-tabs,
    .notification-toast,
    .settings-panel,
    .settings-overlay,
    .toc-progress,
    .progress-summary {
        display: none !important;
    }

    body {
        color: #000000;
        background: #ffffff;
        font-size: 12pt;
    }

    .chapter-content {
        max-width: 100%;
        padding: 0;
    }

    a {
        color: #000000;
        text-decoration: underline;
    }

    .answer-key {
        border: 1px solid #cccccc;
    }

    .answer-key[open] > summary {
        background: #eeeeee;
    }

    /* Only show active tab panel */
    .tab-panel:not(.active) {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   17. Practice Mode — Reveal & Key Points
   -------------------------------------------------------------------------- */

/* Reveal / insight blocks */
.practice-reveal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-lg) 0;
}

.practice-reveal > p:first-child {
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.reveal-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.reveal-btn:hover {
    background: var(--accent-hover);
}
.reveal-btn[hidden] {
    display: none;
}

.reveal-answer {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.reveal-answer p {
    margin-bottom: var(--space-sm);
}

.reveal-answer p:last-child {
    margin-bottom: 0;
}

/* Key points / summary boxes */
.practice-key-points {
    margin: var(--space-lg) 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.practice-key-points summary {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    cursor: pointer;
    font-weight: 700;
    font-size: 1em;
    user-select: none;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.practice-key-points summary:hover {
    background: var(--card-hover);
}

.practice-key-points ul {
    padding: var(--space-md) var(--space-md) var(--space-md) var(--space-lg);
    list-style: disc;
}

.practice-key-points li {
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
}

/* =============================================
   18. Match-the-Following Exercises
   ============================================= */

.practice-match {
    margin: var(--space-lg) 0;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.match-instruction {
    font-size: 0.9em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.match-score {
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

.match-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.match-left,
.match-right {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.match-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5em 0.75em;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.match-item:hover:not(:disabled):not(.matched) {
    border-color: var(--accent);
    background: var(--card-hover);
}

.match-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.match-item.selected {
    border-color: var(--accent);
    background: var(--card-hover);
    box-shadow: 0 0 0 1px var(--accent);
}

.match-item.matched {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
    cursor: default;
    opacity: 0.85;
}

.match-item.wrong {
    animation: match-shake 0.4s ease;
    border-color: #dc3545;
}

[data-theme="dark"] .match-item.matched {
    background: #1a3a2a;
    border-color: #28a745;
    color: #a3d9b1;
}

@keyframes match-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.match-item:disabled {
    cursor: default;
}

@media (max-width: 600px) {
    .match-columns {
        grid-template-columns: 1fr;
    }
    .match-left {
        border-bottom: 2px solid var(--border);
        padding-bottom: var(--space-sm);
    }
}

/* =============================================
   19. Fill-in-the-Blank Exercises
   ============================================= */

.practice-fill-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    transition: border-color 0.2s ease;
}

.practice-fill-item.answered {
    opacity: 0.85;
}

.fill-clue {
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.fill-input-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.fill-hint {
    font-weight: 700;
    color: var(--accent);
    font-size: 1.1em;
    min-width: 1.5em;
}

.fill-input {
    flex: 1;
    padding: 0.4em 0.6em;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text-primary);
}

.fill-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.fill-check-btn {
    padding: 0.4em 0.8em;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-family: inherit;
    transition: background-color 0.15s ease;
}

.fill-check-btn:hover {
    filter: brightness(1.1);
}

.fill-check-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.fill-feedback {
    margin-top: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.9em;
}

.fill-feedback.correct {
    color: #155724;
    background: #d4edda;
}

.fill-feedback.incorrect {
    color: #721c24;
    background: #f8d7da;
}

[data-theme="dark"] .fill-feedback.correct {
    color: #a3d9b1;
    background: #1a3a2a;
}

[data-theme="dark"] .fill-feedback.incorrect {
    color: #f5a5a5;
    background: #3a1a1a;
}

.practice-key-points li:last-child {
    margin-bottom: 0;
}

/* Section dividers in practice mode */
.practice-section-heading {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text-primary);
    margin: var(--space-xl) 0 var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--accent);
}

/* --------------------------------------------------------------------------
   18. Accessibility
   -------------------------------------------------------------------------- */

/* Focus outlines for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Skip to content link (screen readers) */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent);
    color: #ffffff;
    border-radius: 0 0 6px 6px;
    z-index: 200;
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* Screen reader only */
.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;
}
