/* ============================================================
   KinuPamokos — Mandarin for Engineers
   Light paper theme with vermillion, indigo, jade accents
   ============================================================ */

/* -- Reset & Base -- */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #faf8f3;
    --bg-alt: #f3efe6;
    --text: #2c2c2c;
    --text-muted: #6b6b6b;
    --vermillion: #c23b22;
    --indigo: #2f4858;
    --jade: #00a86b;
    --jade-light: #e8f8f0;
    --border: #ddd5c8;
    --shadow: rgba(44, 44, 44, 0.08);
    --radius: 8px;
    --radius-sm: 4px;
    --max-width: 1200px;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-heading: Georgia, "Times New Roman", serif;
    --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
}

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

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

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.25;
    color: var(--indigo);
}

h1 { font-size: 2.25rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.75rem; margin-bottom: 0.6rem; }
h3 { font-size: 1.35rem; margin-bottom: 0.5rem; }
h4 { font-size: 1.1rem;  margin-bottom: 0.4rem; }

p { margin-bottom: 1rem; }

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

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

img { max-width: 100%; }

/* -- Layout -- */

.layout {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* -- Navigation -- */

nav {
    background: var(--indigo);
    color: #fff;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow);
}

nav .nav-brand {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    margin-right: 2rem;
    padding: 0.85rem 0;
    white-space: nowrap;
}

nav .nav-links {
    display: flex;
    list-style: none;
    gap: 0;
}

nav .nav-links a {
    display: block;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
    font-weight: 500;
    transition: color 0.2s, border-bottom-color 0.2s;
    border-bottom: 3px solid transparent;
}

nav .nav-links a:hover,
nav .nav-links a.active {
    color: #fff;
    border-bottom-color: var(--vermillion);
    text-decoration: none;
}

nav .nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0.5rem;
}

/* -- Footer -- */

footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

/* -- Buttons -- */

.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
    line-height: 1.4;
}

.btn:hover {
    border-color: var(--indigo);
    color: var(--indigo);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #a83220;
    border-color: #a83220;
    color: #fff;
}

.btn-jade {
    background: var(--jade);
    color: #fff;
    border-color: var(--jade);
}

.btn-jade:hover {
    background: #008f5b;
    border-color: #008f5b;
    color: #fff;
}

.btn:disabled,
.btn.completed {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
}

/* -- Post-it note shadow (shared by cards, exercise boxes, content panels) -- */

.paper-shadow {
    box-shadow:
        0 1px 3px rgba(44, 44, 44, 0.06),
        0 4px 8px rgba(44, 44, 44, 0.04),
        0 12px 24px rgba(44, 44, 44, 0.06),
        inset 0 -2px 0 rgba(221, 213, 200, 0.3);
}

/* -- Cards -- */

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow:
        0 1px 3px rgba(44, 44, 44, 0.06),
        0 4px 8px rgba(44, 44, 44, 0.04),
        0 12px 24px rgba(44, 44, 44, 0.06),
        inset 0 -2px 0 rgba(221, 213, 200, 0.3);
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow:
        0 2px 4px rgba(44, 44, 44, 0.08),
        0 8px 16px rgba(44, 44, 44, 0.06),
        0 16px 32px rgba(44, 44, 44, 0.08);
}

/* -- Module Cards -- */

.module-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow:
        0 1px 3px rgba(44, 44, 44, 0.06),
        0 4px 8px rgba(44, 44, 44, 0.04),
        0 12px 24px rgba(44, 44, 44, 0.06),
        inset 0 -2px 0 rgba(221, 213, 200, 0.3);
    transition: box-shadow 0.2s, transform 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.module-card:hover {
    box-shadow:
        0 2px 4px rgba(44, 44, 44, 0.08),
        0 8px 16px rgba(44, 44, 44, 0.06),
        0 20px 40px rgba(44, 44, 44, 0.1);
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

.module-card .module-number {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--vermillion);
    background: rgba(194, 59, 34, 0.08);
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.module-card h3 {
    margin-bottom: 0.25rem;
}

.module-card .module-subtitle {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.module-card .module-desc {
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

/* -- Badge -- */

.badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    background: var(--bg-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-jade {
    background: var(--jade-light);
    color: var(--jade);
    border-color: rgba(0, 168, 107, 0.25);
}

.badge-vermillion {
    background: rgba(194, 59, 34, 0.08);
    color: var(--vermillion);
    border-color: rgba(194, 59, 34, 0.2);
}

.badge-indigo {
    background: rgba(47, 72, 88, 0.08);
    color: var(--indigo);
    border-color: rgba(47, 72, 88, 0.2);
}

/* -- Progress Bar -- */

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-alt);
    border-radius: 100px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--jade), #3ec98a);
    border-radius: 100px;
    transition: width 0.4s ease;
}

/* -- Lesson Content -- */

.lesson-content {
    font-size: 1.02rem;
    line-height: 1.75;
}

.lesson-content h2 {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.lesson-content h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.lesson-content h3 {
    margin-top: 1.5rem;
}

.lesson-content ul,
.lesson-content ol {
    margin: 0.75rem 0 1rem 1.5rem;
}

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

/* -- Exercise Box -- */

.exercise-box {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--vermillion);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow:
        0 1px 3px rgba(44, 44, 44, 0.06),
        0 4px 8px rgba(44, 44, 44, 0.04),
        0 12px 24px rgba(44, 44, 44, 0.06),
        inset 0 -2px 0 rgba(221, 213, 200, 0.3);
}

.exercise-box .exercise-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--vermillion);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}

.exercise-box .exercise-prompt {
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.exercise-box input[type="text"],
.exercise-box textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-family: var(--font-mono);
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: border-color 0.2s;
}

.exercise-box input:focus,
.exercise-box textarea:focus {
    outline: none;
    border-color: var(--jade);
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.12);
}

.exercise-box .exercise-feedback {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
}

.exercise-box .exercise-feedback.correct {
    background: var(--jade-light);
    color: #006b44;
}

.exercise-box .exercise-feedback.incorrect {
    background: rgba(194, 59, 34, 0.08);
    color: var(--vermillion);
}

/* -- Vocab Table -- */

.vocab-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
}

.vocab-table thead th {
    text-align: left;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border);
}

.vocab-table tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.vocab-table tbody tr:hover {
    background: var(--bg-alt);
}

.vocab-table .vocab-hanzi {
    font-size: 1.2rem;
    font-weight: 600;
}

.vocab-table .vocab-pinyin {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    color: var(--text-muted);
}

/* -- Vocab Toolbar -- */

.vocab-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.vocab-search {
    flex: 1;
    min-width: 200px;
}

.vocab-search .input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.2s;
}

.vocab-search .input:focus {
    outline: none;
    border-color: var(--jade);
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.12);
}

.vocab-level-tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.btn-tab {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text);
}

.btn-tab:hover:not(:disabled) {
    border-color: var(--indigo);
}

.btn-tab.active {
    background: var(--indigo);
    color: #fff;
    border-color: var(--indigo);
}

.btn-tab:disabled {
    opacity: 0.4;
    cursor: default;
}

/* -- Vocab Tag Filter -- */

.vocab-tag-filter {
    width: 100%;
    margin-bottom: 1rem;
}

.vocab-filter-label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    display: block;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.badge-tag-filter {
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.badge-tag-filter:hover {
    border-color: var(--jade);
    background: var(--jade-light);
    color: var(--jade);
}

.badge-tag-filter.active {
    background: var(--jade);
    color: #fff;
    border-color: var(--jade);
}

.badge-tag-filter:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.badge-hsk {
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 1.6rem;
    text-align: center;
}

/* -- Vocab Detail Row -- */

.vocab-row {
    cursor: pointer;
    transition: background 0.1s;
}

.vocab-row.expanded {
    background: var(--bg-alt);
}

.vocab-detail-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--border);
}

.vocab-detail {
    padding: 0.75rem 1rem 1rem;
    background: var(--bg-alt);
    border-left: 3px solid var(--jade);
}

.vocab-detail .label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.vocab-detail .vocab-example .hanzi {
    font-size: 1.1em;
}

.vocab-detail .vocab-radical-btn {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text);
}

.vocab-detail .vocab-radical-btn:hover {
    border-color: var(--indigo);
    background: rgba(47, 72, 88, 0.06);
}

.vocab-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    text-align: right;
}

/* -- Radical Panel -- */

.radical-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 340px;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(44, 44, 44, 0.1),
                -1px 0 4px rgba(44, 44, 44, 0.05);
    z-index: 100;
    overflow-y: auto;
    padding: 1.5rem;
    transition: transform 0.25s ease;
}

.radical-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.radical-panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.radical-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
}

.radical-panel-close:hover {
    color: var(--text);
}

.radical-info {
    text-align: center;
    margin-bottom: 1rem;
}

.radical-char {
    font-size: 2.8rem;
    font-weight: 600;
    color: var(--indigo);
    display: block;
    margin-bottom: 0.25rem;
}

.radical-meta {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.radical-meta .pinyin {
    font-family: var(--font-mono);
}

.radical-mnemonic {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0.75rem 0 1rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-alt);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.radical-neighbors-label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.radical-neighbors {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.radical-neighbor,
.radical-neighbors .hanzi {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    color: var(--text);
    text-decoration: none;
}

.radical-neighbor:hover,
.radical-neighbors .hanzi:hover {
    background: var(--bg-alt);
    border-color: var(--indigo);
    color: var(--indigo);
}

.radical-neighbor.in-vocab {
    border-color: var(--jade);
    background: var(--jade-light);
    color: var(--jade);
}

/* -- Hanzi & Pinyin inline -- */

.hanzi {
    font-size: 1.35em;
    font-weight: 600;
    color: var(--indigo);
}

.pinyin {
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--text-muted);
}

.hanzi-block {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 0 0.3rem;
    text-align: center;
}

.hanzi-block .pinyin {
    font-size: 0.72rem;
    margin-bottom: 0.1rem;
}

.hanzi-block .hanzi {
    font-size: 1.6rem;
}

.hanzi-block .meaning {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* -- Hanzi Tooltip (hover on desktop, tap on mobile) -- */

.hanzi[data-meaning] {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--indigo);
    transition: background 0.15s;
}

.hanzi[data-meaning]:hover,
.hanzi[data-meaning].tooltip-active {
    background: rgba(47, 72, 88, 0.06);
    border-radius: var(--radius-sm);
}

.hanzi-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--indigo);
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.hanzi-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--indigo);
}

.hanzi-tooltip .tooltip-pinyin {
    font-family: var(--font-mono);
    opacity: 0.8;
    margin-right: 0.3rem;
}

.hanzi[data-meaning]:hover .hanzi-tooltip,
.hanzi[data-meaning].tooltip-active .hanzi-tooltip {
    opacity: 1;
}

/* -- Grammar Highlights -- */

.grammar-highlight {
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.grammar-highlight.noun {
    color: var(--indigo);
    background: rgba(47, 72, 88, 0.08);
}

.grammar-highlight.verb {
    color: var(--jade);
    background: rgba(0, 168, 107, 0.08);
}

.grammar-highlight.particle {
    color: var(--vermillion);
    background: rgba(194, 59, 34, 0.08);
}

/* -- Code Block — post-it note on the paper -- */

.code-block {
    background: #fef9e0;
    color: #3a3a3a;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    padding: 1.25rem 1.5rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1.75rem 0;
    border: 1px solid #e8ddb3;
    box-shadow:
        3px 4px 10px rgba(44, 44, 44, 0.1),
        1px 2px 3px rgba(44, 44, 44, 0.06),
        inset 0 -3px 0 rgba(180, 155, 90, 0.12);
    position: relative;
}

.code-block pre {
    margin: 0;
    font-family: inherit;
    color: inherit;
    background: none;
    white-space: pre;
}

.code-block .comment {
    color: #8a7a4a;
    font-style: italic;
}

.code-block .keyword {
    color: var(--vermillion);
    font-weight: 600;
}

.code-block .string {
    color: var(--jade);
}

.code-block .type {
    color: var(--indigo);
    font-weight: 600;
}

/* -- Tip -- */

.tip {
    background: var(--jade-light);
    border-left: 4px solid var(--jade);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.tip strong,
.tip .tip-label {
    color: var(--jade);
    font-weight: 700;
}

/* -- Comparison Table -- */

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.95rem;
}

.comparison-table th {
    background: var(--indigo);
    color: #fff;
    font-weight: 600;
    padding: 0.65rem 0.75rem;
    text-align: left;
}

.comparison-table th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.comparison-table th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.comparison-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.comparison-table tbody tr:nth-child(even) {
    background: var(--bg-alt);
}

.comparison-table tbody tr:hover {
    background: rgba(47, 72, 88, 0.04);
}

/* -- Reveal Card (Progressive Flashcard) -- */

.flashcard-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
}

.flashcard-wrapper {
    width: 100%;
    max-width: 420px;
}

.reveal-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    text-align: center;
    cursor: pointer;
    box-shadow: 2px 3px 8px rgba(44, 44, 44, 0.06),
                0 1px 2px rgba(44, 44, 44, 0.04),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
    transition: box-shadow 0.2s;
    outline: none;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.reveal-card:hover {
    box-shadow: 3px 5px 14px rgba(44, 44, 44, 0.1),
                0 1px 3px rgba(44, 44, 44, 0.06),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
}

.reveal-card:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.25);
}

.card-hanzi {
    font-size: 3rem;
    font-weight: 700;
    color: var(--indigo);
    line-height: 1.2;
}

.card-pinyin {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--text-muted);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.card-pinyin.revealed {
    opacity: 1;
    max-height: 3rem;
}

.card-meaning {
    font-size: 1.1rem;
    color: var(--text);
    font-weight: 500;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.card-meaning.revealed {
    opacity: 1;
    max-height: 3rem;
}

.card-example {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.4s ease;
    width: 100%;
}

.card-example.revealed {
    opacity: 1;
    max-height: 10rem;
}

.card-example-zh {
    font-size: 1.05rem;
    color: var(--indigo);
    font-weight: 500;
}

.card-example-pinyin {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.card-example-en {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.card-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

/* Rating buttons */

.flashcard-ratings {
    display: flex;
    gap: 1rem;
    margin-top: 1.25rem;
    justify-content: center;
}

.rating-btn {
    padding: 0.7rem 1.8rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 140px;
}

.rating-sooner {
    border-color: var(--vermillion);
    color: var(--vermillion);
    background: rgba(194, 59, 34, 0.06);
}

.rating-sooner:hover {
    background: var(--vermillion);
    color: #fff;
}

.rating-later {
    border-color: var(--jade);
    color: var(--jade);
    background: rgba(0, 168, 107, 0.06);
}

.rating-later:hover {
    background: var(--jade);
    color: #fff;
}

.rating-btn.selected {
    color: #fff;
}

.rating-sooner.selected {
    background: var(--vermillion);
}

.rating-later.selected {
    background: var(--jade);
}

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

/* Flashcard progress and completion */

.flashcard-progress {
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

.flashcard-done {
    text-align: center;
    font-size: 1.3rem;
    color: var(--jade);
    font-weight: 600;
    padding: 3rem 1rem;
}

/* -- Stats Grid -- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow:
        0 1px 3px rgba(44, 44, 44, 0.06),
        0 4px 8px rgba(44, 44, 44, 0.04),
        0 12px 24px rgba(44, 44, 44, 0.06),
        inset 0 -2px 0 rgba(221, 213, 200, 0.3);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--indigo);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* -- States -- */

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 0;
    font-style: italic;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 0;
}

.error-state {
    text-align: center;
    color: var(--vermillion);
    padding: 2rem 0;
}

/* -- Hero Section (Home) -- */

.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    color: var(--indigo);
    margin-bottom: 0.5rem;
}

.hero .tagline {
    font-size: 1.15rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 1.5rem;
}

.hero .pitch {
    max-width: 600px;
    margin: 0 auto 2rem;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text);
}

/* -- Analogy Table (Home) -- */

.analogy-table {
    max-width: 640px;
    margin: 2rem auto;
}

/* -- Page Header -- */

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
}

/* -- 404 -- */

.error-page {
    text-align: center;
    padding: 5rem 0;
}

.error-page h1 {
    font-size: 4rem;
    color: var(--vermillion);
    margin-bottom: 0.5rem;
}

.error-page p {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* -- Reading Page -- */

.reading-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.reading-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: 2px 3px 8px rgba(44, 44, 44, 0.06),
                0 1px 2px rgba(44, 44, 44, 0.04),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
    transition: box-shadow 0.15s, transform 0.15s;
    display: block;
}

.reading-card:hover {
    box-shadow: 3px 5px 14px rgba(44, 44, 44, 0.1),
                0 1px 3px rgba(44, 44, 44, 0.06),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
    transform: translateY(-1px);
}

.reading-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.reading-card-title-zh {
    font-size: 1.2rem;
    color: var(--indigo);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.reading-card-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.reading-card-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Text reader layout */

.reading-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
    margin-top: 1.5rem;
}

.reading-main {
    min-width: 0;
}

.reading-segment {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 1px 2px 4px rgba(44, 44, 44, 0.04);
}

.reading-segment-hanzi {
    font-size: 1.4rem;
    line-height: 2;
    color: var(--text);
    font-weight: 500;
}

.reading-segment-pinyin {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    display: none;
}

.reading-segment-meaning {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: none;
}

.reading-segment.show-pinyin .reading-segment-pinyin {
    display: block;
}

.reading-segment.show-meaning .reading-segment-meaning {
    display: block;
}

.reading-sidebar {
    position: sticky;
    top: 1rem;
    align-self: start;
}

.reading-sidebar h3 {
    font-size: 0.88rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.reading-vocab-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

.reading-vocab-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.reading-vocab-item .hanzi {
    font-size: 1.1em;
}

.reading-phrase {
    padding: 0.75rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.reading-phrase-hanzi {
    font-size: 1.05rem;
    color: var(--indigo);
    font-weight: 500;
}

.reading-phrase-meaning {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.reading-phrase-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.15rem;
}

.reading-add-btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: #fff;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}

.reading-add-btn:hover {
    border-color: var(--jade);
    color: var(--jade);
    background: var(--jade-light);
}

.reading-add-btn.added {
    background: var(--jade-light);
    color: var(--jade);
    border-color: var(--jade);
    cursor: default;
}

.reading-toggle-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* -- Articles Page -- */

.article-section {
    margin: 2rem 0 2.5rem;
}

.article-section-header {
    font-size: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-weight: 700;
    margin-bottom: 0.2rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.article-section-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0.35rem 0 1rem;
}

.article-section-empty {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem 0;
}

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

.article-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: 2px 3px 8px rgba(44, 44, 44, 0.06),
                0 1px 2px rgba(44, 44, 44, 0.04),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
    transition: box-shadow 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.article-card:hover {
    box-shadow: 3px 5px 14px rgba(44, 44, 44, 0.1),
                0 1px 3px rgba(44, 44, 44, 0.06),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
    transform: translateY(-1px);
    text-decoration: none;
}

.article-card-title {
    font-size: 1.1rem;
    color: var(--indigo);
    margin: 0;
}

.article-card-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin: 0;
    flex: 1;
}

.article-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-top: 0.25rem;
}

.article-read-time {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.article-nav {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.article-content {
    max-width: 960px;
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--vermillion);
}

.breadcrumb-sep {
    color: var(--border);
}

.badge-module {
    background: var(--indigo);
    color: #fff;
    border-color: var(--indigo);
}

.badge-tag {
    background: var(--bg-alt);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* Radical family block inside articles */

.radical-family {
    margin: 2rem 0 2.5rem;
    padding: 1.25rem 1.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 2px 3px 8px rgba(44, 44, 44, 0.05),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
}

.radical-family-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.radical-family-header .radical-char {
    font-size: 2.4rem;
    margin: 0;
    display: inline-block;
}

.radical-family-header h2 {
    margin: 0;
    font-size: 1.4rem;
}

.radical-family-header .pinyin {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Phrasebook article components */

.phrasebook-sig {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    background: var(--bg-alt);
    border-left: 3px solid var(--indigo);
    padding: 0.65rem 0.9rem;
    margin: 0.6rem 0;
    border-radius: 0 6px 6px 0;
    line-height: 1.7;
}

.phrasebook-sig .sig-name {
    color: var(--indigo);
    font-weight: 600;
}

.phrasebook-sig .sig-arrow {
    color: var(--text-muted);
    margin: 0 0.35rem;
}

.slot {
    display: inline-block;
    padding: 0 0.3rem;
    background: rgba(201, 74, 55, 0.08);
    border: 1px dashed var(--vermillion);
    border-radius: 4px;
    color: var(--vermillion);
    font-family: var(--font-mono);
    font-size: 0.88em;
    font-style: italic;
}

.phrasebook-dialog {
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 2px 3px 7px rgba(44, 44, 44, 0.04),
                inset 0 -2px 0 rgba(44, 44, 44, 0.03);
}

.phrasebook-dialog .dialog-title {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.7rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed var(--border);
}

.phrasebook-dialog .turn {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    gap: 0.5rem;
    margin: 0.55rem 0;
    align-items: baseline;
}

.phrasebook-dialog .speaker {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: right;
    padding-top: 0.15rem;
}

.phrasebook-dialog .speaker.a { color: var(--indigo); }
.phrasebook-dialog .speaker.b { color: var(--jade); }

.phrasebook-dialog .line-zh {
    font-size: 1.05rem;
    line-height: 1.55;
}

.phrasebook-dialog .line-py {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.phrasebook-dialog .line-gloss {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.1rem;
}

@media (max-width: 520px) {
    .phrasebook-dialog .turn {
        grid-template-columns: 1.8rem 1fr;
    }
}

/* ============================================================
   Buttons — secondary + link
   ============================================================ */

.btn-secondary {
    background: #fff;
    color: var(--indigo);
    border-color: var(--indigo);
}

.btn-secondary:hover {
    background: var(--indigo);
    color: #fff;
    border-color: var(--indigo);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s;
}

.btn-link:hover { color: var(--vermillion); }
.btn-link:disabled {
    opacity: 0.4;
    cursor: default;
    text-decoration: none;
}

/* ============================================================
   Practice index — deck list
   ============================================================ */

.practice-summary {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.1rem 1.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 1.5rem 0 2rem;
    box-shadow:
        0 1px 3px rgba(44, 44, 44, 0.06),
        0 4px 8px rgba(44, 44, 44, 0.04),
        inset 0 -2px 0 rgba(221, 213, 200, 0.3);
    flex-wrap: wrap;
}

.practice-summary-stat {
    display: flex;
    flex-direction: column;
    min-width: 80px;
}

.practice-summary-value {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--indigo);
    line-height: 1;
}

.practice-summary-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.25rem;
}

.practice-summary-action {
    margin-left: auto;
}

.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.deck-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem 1.4rem;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 1px 3px rgba(44, 44, 44, 0.06),
        0 4px 8px rgba(44, 44, 44, 0.04),
        0 12px 24px rgba(44, 44, 44, 0.06),
        inset 0 -2px 0 rgba(221, 213, 200, 0.3);
    transition: box-shadow 0.2s;
}

.deck-card:hover {
    box-shadow:
        0 2px 4px rgba(44, 44, 44, 0.08),
        0 8px 16px rgba(44, 44, 44, 0.06),
        0 20px 40px rgba(44, 44, 44, 0.1);
}

.deck-card-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.deck-tag {
    color: var(--vermillion);
    background: rgba(194, 59, 34, 0.08);
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.deck-source {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
}

.deck-card-title {
    margin: 0 0 0.3rem;
    font-size: 1.15rem;
}

.deck-card-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 0.85rem;
}

.deck-card-stats {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    margin: 0.4rem 0 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.deck-stat strong { color: var(--text); font-weight: 700; }
.deck-stat-added strong { color: var(--indigo); }
.deck-stat-due   strong { color: var(--vermillion); }

.deck-card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: auto;
}

.deck-status-caughtup {
    color: var(--jade);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.4rem 0;
}

/* ============================================================
   Review page additions — undo button, tag pill
   ============================================================ */

.review-stats-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 1rem 0 1.5rem;
    box-shadow: inset 0 -2px 0 rgba(221, 213, 200, 0.3);
}

.review-stat {
    display: flex;
    flex-direction: column;
}

.review-stat-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--indigo);
    line-height: 1;
}

.review-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.25rem;
}

.review-undo-btn {
    margin-left: 0.4rem;
}

.review-toggles {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.2;
}

.toggle-pill:hover {
    border-color: var(--indigo);
    color: var(--indigo);
}

.toggle-pill.toggle-active {
    background: var(--indigo);
    border-color: var(--indigo);
    color: #fff;
}

.toggle-pill .toggle-icon {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.toggle-pill .toggle-icon .icon {
    width: 0.95rem;
    height: 0.95rem;
}

/* Eye / eye-slash swap: default shows eye; .toggle-active shows eye-slash */
.toggle-pill .icon-eye-slash { display: none; }
.toggle-pill.toggle-active .icon-eye       { display: none; }
.toggle-pill.toggle-active .icon-eye-slash { display: inline-block; }

.toggle-pill .toggle-label {
    font-weight: 600;
}

.toggle-pill .toggle-state {
    opacity: 0.85;
}

/* ============================================================
   Sentence-focus card + translation peek
   ============================================================ */

.flashcard-wrapper.focus-sentence .reveal-card {
    text-align: left;
    padding: 2.25rem 2rem;
}

.card-sentence {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    color: var(--indigo);
    line-height: 1.45;
    font-weight: 600;
    text-align: center;
}

.card-sentence-pinyin {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--text-muted);
    text-align: center;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.card-sentence-pinyin.revealed {
    opacity: 1;
    max-height: 4rem;
}

.card-sentence-en {
    font-size: 1rem;
    color: var(--text);
    text-align: center;
    margin-top: 0.4rem;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.4s ease;
}

.card-sentence-en.revealed {
    opacity: 1;
    max-height: 8rem;
}

.card-context {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem 0.85rem;
    font-size: 0.92rem;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.4s ease;
}

.card-context.revealed {
    opacity: 1;
    max-height: 6rem;
}

.card-context-front  { color: var(--indigo);     font-weight: 700; }
.card-context-pinyin { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.85rem; }
.card-context-back   { color: var(--text); }

/* Translation peek button (used in both word + sentence focus) */

.peek-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.85rem;
    background: rgba(47, 72, 88, 0.06);
    border: 1px dashed var(--border);
    border-radius: 100px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s;
}

.peek-btn:hover {
    border-color: var(--indigo);
    color: var(--indigo);
    background: rgba(47, 72, 88, 0.1);
}

.peek-btn .peek-icon {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.peek-btn .peek-icon .icon {
    width: 0.95rem;
    height: 0.95rem;
}

/* ============================================================
   Quick-Easy button — visible at reveal states 0/1, hidden at 2.
   ============================================================ */

.quick-easy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.85rem auto 0;
    padding: 0.4rem 0.95rem;
    background: #fff;
    border: 1px dashed var(--border);
    border-radius: 100px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    align-self: center;
    transition: all 0.15s;
}

.quick-easy-btn:hover {
    border-style: solid;
    border-color: var(--jade);
    color: var(--jade);
    background: rgba(0, 168, 107, 0.06);
}

.quick-easy-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.quick-easy-btn .qe-label {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.quick-easy-btn .qe-arrow {
    font-size: 1rem;
    line-height: 1;
}

.quick-easy-btn .qe-key {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.05rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(44, 44, 44, 0.04);
    color: var(--text-muted);
    line-height: 1.2;
}

/* Center the button under the card; the wrapper is a column flex container by default,
   but reveal-card centering doesn't naturally extend to a sibling — use margin auto. */
.flashcard-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.card-example-en.peek-hidden,
.card-sentence-en.peek-hidden {
    /* Override the text styling when it's just a peek button */
    color: inherit;
    font-style: normal;
}

.review-tag-pill {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--vermillion);
    background: rgba(194, 59, 34, 0.08);
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-sm);
}

/* ============================================================
   Flashcard ratings — 4-grade SM-2 (Again / Hard / Good / Easy)
   Overrides the older 2-button styles.
   ============================================================ */

.flashcard-ratings {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
    margin-top: 1.25rem;
    width: 100%;
}

.rating-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.18rem;
    padding: 0.6rem 0.4rem;
    min-width: 0;
    border: 2px solid;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.1;
}

.rating-btn .rating-key {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.6;
}

.rating-btn .rating-label {
    font-weight: 700;
    font-size: 0.95rem;
}

.rating-btn .rating-interval {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    opacity: 0.85;
}

.rating-again { border-color: var(--vermillion); color: var(--vermillion); background: rgba(194, 59, 34, 0.06); }
.rating-again:hover:not(:disabled) { background: var(--vermillion); color: #fff; }
.rating-again.selected { background: var(--vermillion); color: #fff; }

.rating-hard { border-color: #c98e3a; color: #c98e3a; background: rgba(201, 142, 58, 0.06); }
.rating-hard:hover:not(:disabled) { background: #c98e3a; color: #fff; }
.rating-hard.selected { background: #c98e3a; color: #fff; }

.rating-good { border-color: var(--jade); color: var(--jade); background: rgba(0, 168, 107, 0.06); }
.rating-good:hover:not(:disabled) { background: var(--jade); color: #fff; }
.rating-good.selected { background: var(--jade); color: #fff; }

.rating-easy { border-color: var(--indigo); color: var(--indigo); background: rgba(47, 72, 88, 0.06); }
.rating-easy:hover:not(:disabled) { background: var(--indigo); color: #fff; }
.rating-easy.selected { background: var(--indigo); color: #fff; }

/* ============================================================
   Responsive (< 768px)
   ============================================================ */

@media (max-width: 768px) {
    :root {
        --max-width: 100%;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.15rem; }

    .layout {
        padding: 1.25rem 1rem 3rem;
    }

    /* Mobile nav */
    nav {
        flex-wrap: wrap;
        padding: 0 1rem;
    }

    nav .nav-toggle {
        display: block;
    }

    nav .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        padding-bottom: 0.5rem;
    }

    nav .nav-links.open {
        display: flex;
    }

    nav .nav-links a {
        padding: 0.65rem 0;
        border-bottom: none;
        border-left: 3px solid transparent;
        padding-left: 0.75rem;
    }

    nav .nav-links a.active {
        border-left-color: var(--vermillion);
        border-bottom: none;
    }

    /* Cards */
    .module-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Reading layout */
    .reading-layout {
        grid-template-columns: 1fr;
    }

    .reading-sidebar {
        position: static;
    }

    /* Article layout */
    .article-grid {
        grid-template-columns: 1fr;
    }

    .radical-family {
        padding: 1rem 1.15rem;
    }

    .radical-family-header .radical-char {
        font-size: 2rem;
    }

    /* Flashcard */
    .reveal-card {
        padding: 2rem 1.5rem;
    }

    .card-hanzi {
        font-size: 2.5rem;
    }

    .flashcard-ratings {
        grid-template-columns: 1fr 1fr;
    }

    .rating-btn {
        min-width: auto;
        width: 100%;
        padding: 0.7rem 0.5rem;
    }

    .deck-grid {
        grid-template-columns: 1fr;
    }

    .review-stats-bar,
    .practice-summary {
        gap: 1rem;
        padding: 0.85rem 1.1rem;
    }

    .practice-summary-action {
        margin-left: 0;
        width: 100%;
        margin-top: 0.5rem;
    }

    /* Hero */
    .hero h1 {
        font-size: 1.85rem;
    }

    .hero .tagline {
        font-size: 1rem;
    }

    /* Tables */
    .comparison-table,
    .vocab-table {
        font-size: 0.88rem;
    }

    .comparison-table th,
    .comparison-table td,
    .vocab-table thead th,
    .vocab-table tbody td {
        padding: 0.5rem;
    }

    /* Code block */
    .code-block {
        font-size: 0.82rem;
        padding: 1rem;
    }

    /* Vocab toolbar */
    .vocab-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .vocab-search {
        width: 100%;
    }

    .vocab-level-tabs {
        justify-content: center;
    }

    /* Radical panel */
    .radical-panel {
        width: 100%;
        max-width: 100%;
    }
}
