@font-face {
    font-family: 'WenQuanYi Micro Hei';
    src: url('/public/fonts/wqy-microhei.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* V4 Design — Mobile-first, clean, premium feel */

:root {
    --bg: #f4f4f5;
    --card-bg: #fff;
    --fg: #18181b;
    --muted: #71717a;
    --border: #e4e4e7;
    --border-light: #f0f0f2;
    --accent: #3f3f46;
    --shadow-soft: 0 1px 2px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.04), 0 4px 8px rgba(0,0,0,0.04);
    --shadow-card: 0 4px 6px -1px rgba(0,0,0,0.05), 0 10px 20px -5px rgba(0,0,0,0.08), 0 25px 50px -12px rgba(0,0,0,0.06);
    --shadow-elevated: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-cn: "WenQuanYi Micro Hei", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-pinyin: system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    height: 100dvh;
    overflow: hidden;
}

/* ============ APP SHELL ============ */

.app {
    display: flex;
    height: 100dvh;
}

/* ============ SIDEBAR (desktop only by default, slide-in on mobile) ============ */

.days-sidebar {
    display: none;
    width: 272px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(12px);
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--fg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-char {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-cn);
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar-subtitle {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-weight: 500;
}

.presence-indicator {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
}

.presence-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.presence-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}

.presence-flags {
    font-size: 11px;
    line-height: 1.4;
    word-break: break-all;
}

[x-cloak] {
    display: none !important;
}

.sidebar-progress {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-progress-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

.sidebar-progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg);
}

.sidebar-progress-bar {
    width: 100%;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.sidebar-progress-fill {
    height: 100%;
    background: var(--fg);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Month selector (inside sidebar) */
.month-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.month-arrow {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--muted);
    transition: all 0.15s ease;
}

.month-arrow:hover {
    background: var(--border);
    color: var(--fg);
}

.month-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.month-label {
    text-align: center;
}

.month-name {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
}

.month-level {
    font-size: 0.7rem;
    color: var(--muted);
    font-family: var(--font-mono);
}

.days-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.days-list::-webkit-scrollbar { width: 4px; }
.days-list::-webkit-scrollbar-track { background: transparent; }
.days-list::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 4px; }

.day-item {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--muted);
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: inherit;
}

.day-item:hover {
    background: #e4e4e7;
    color: var(--fg);
}

.day-item.active {
    background: var(--fg);
    color: #fff;
}

.day-item.today .day-date {
    font-weight: 700;
}

.day-date {
    font-size: 0.85rem;
    font-family: var(--font-mono);
}

.day-count {
    font-size: 0.75rem;
    opacity: 0.6;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.day-actions {
    display: none;
    gap: 0.3rem;
}

.day-item.active .day-actions {
    display: flex;
}

.day-review-btn,
.day-drill-btn {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid rgba(255,255,255,0.4);
    cursor: pointer;
    background: transparent;
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.day-review-btn:hover,
.day-drill-btn:hover {
    background: #fff;
    color: #000;
}

/* Sidebar handle (mobile close) */
.sidebar-handle {
    display: none;
}

/* ============ SIDEBAR OVERLAY (mobile) ============ */

.sidebar-overlay {
    display: none;
}

/* ============ MAIN AREA ============ */

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ============ DAY WHEEL ============ */

.day-wheel-container {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border-light);
    background: rgba(255,255,255,0.5);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}

.day-wheel-arrow {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.day-wheel-arrow:hover {
    background: var(--border);
    color: var(--fg);
}

.day-wheel {
    flex: 1;
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding: 0.25rem 0;
}

.day-wheel::-webkit-scrollbar { display: none; }

.day-wheel-pill {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    scroll-snap-align: center;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-mono);
}

.day-wheel-pill:hover {
    background: var(--border);
    color: var(--fg);
}

.day-wheel-pill.active {
    background: var(--fg);
    color: #fff;
    font-weight: 700;
}

.day-wheel-pill.today {
    box-shadow: inset 0 0 0 2px var(--fg);
}

.day-wheel-pill.today:not(.active) {
    color: var(--fg);
    font-weight: 600;
}

/* ============ PROGRESS HEADER ============ */

.progress-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

.progress-header-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.progress-ring {
    width: 32px;
    height: 32px;
    transform: rotate(-90deg);
}

.progress-ring-circle {
    transition: stroke-dashoffset 0.4s ease;
}

.progress-header-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg);
    font-family: var(--font-mono);
}

/* ============ REVIEW NAV ============ */

.review-nav {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-light);
}

.review-exit-btn {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--fg);
    cursor: pointer;
    background: var(--fg);
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    font-family: inherit;
    transition: all 0.15s ease;
}

.review-exit-btn:hover {
    background: #fff;
    color: var(--fg);
}

.review-progress {
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* ============ CARD AREA ============ */

.card-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    min-height: 0;
    gap: 0.5rem;
}

.flashcard-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.flashcard {
    width: 100%;
    aspect-ratio: 4 / 5;
    max-height: 55vh;
    max-width: min(100%, calc(55vh * 4 / 5));
    perspective: 1200px;
    cursor: pointer;
    position: relative;
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-xl);
    background: var(--card-bg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.flashcard-front {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    transform: rotateY(0deg);
    pointer-events: auto;
}

.flashcard-back {
    transform: rotateY(180deg);
    pointer-events: none;
    padding: 0;
}

.flashcard.flipped .flashcard-front {
    transform: rotateY(-180deg);
    pointer-events: none;
}

.flashcard.flipped .flashcard-back {
    transform: rotateY(0deg);
    pointer-events: auto;
}

/* Front decorations */
.card-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--border);
    border-style: solid;
    border-width: 0;
}

.card-corner-tl { top: 16px; left: 16px; border-left-width: 2px; border-top-width: 2px; border-top-left-radius: 4px; }
.card-corner-tr { top: 16px; right: 16px; border-right-width: 2px; border-top-width: 2px; border-top-right-radius: 4px; }
.card-corner-bl { bottom: 16px; left: 16px; border-left-width: 2px; border-bottom-width: 2px; border-bottom-left-radius: 4px; }
.card-corner-br { bottom: 16px; right: 16px; border-right-width: 2px; border-bottom-width: 2px; border-bottom-right-radius: 4px; }

.card-front-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: #c4c4c8;
    font-weight: 500;
    margin-bottom: 1rem;
}

.card-front-hint {
    font-size: 10px;
    color: #c4c4c8;
    font-weight: 500;
    letter-spacing: 0.15em;
    margin-top: 1.5rem;
}

/* Front example overlay */
.front-example {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    margin-top: 0.5rem;
    animation: fadeSlideUp 0.2s ease;
}

.front-example-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0 1rem;
    width: 100%;
}

.front-example-body .sentence-zh {
    font-size: 1rem;
    white-space: nowrap;
}

.front-example-nav {
    font-size: 9px;
    color: #c4c4c8;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.5rem;
    letter-spacing: 0.05em;
}

.front-example-nav:hover {
    color: var(--fg);
}

.example-slide-up {
    animation: slideUp 150ms cubic-bezier(0.25, 0.1, 0.25, 1) both;
}
.example-slide-down {
    animation: slideDown 150ms cubic-bezier(0.25, 0.1, 0.25, 1) both;
}

@keyframes slideUp {
    0% { opacity: 0.3; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    0% { opacity: 0.3; transform: translateY(-6px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Back example (discreet, drill-style) */
.back-example {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.4rem 0 0.4rem 0.6rem;
    border-left: 2px solid var(--border-light);
    margin-top: 0.3rem;
}

.back-example .sentence-zh {
    font-family: var(--font-cn);
    font-size: 0.9rem;
    color: var(--muted);
}

.back-example .sentence-en {
    font-size: 0.7rem;
    color: #bbb;
}

.character-svg {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.character-svg svg {
    width: 100%;
    max-width: 280px;
    height: auto;
}

/* Back accent line */
.card-back-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--border-light), var(--border), var(--border-light));
}

/* ============ CARD GRID (back side) ============ */

.card-grid {
    display: grid;
    grid-template-rows: auto 1fr auto;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

.card-row-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    align-items: stretch;
    min-height: 0;
}

.card-header-left {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card-header-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card-header-left .label,
.card-header-right .label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
    margin-bottom: 0.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stroke-count {
    font-style: italic;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 11px;
}

.card-char {
    font-family: var(--font-cn);
    font-size: 2rem;
    flex-shrink: 0;
}

.pinyin {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
    font-family: var(--font-pinyin);
}

.definition {
    font-size: 0.8rem;
    line-height: 1.3;
    color: var(--muted);
    word-break: break-word;
    overflow-wrap: break-word;
}

.words-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(3, auto);
    gap: 0.2rem 0.5rem;
    font-family: var(--font-cn);
    font-size: 1rem;
    flex: 1;
    min-height: 0;
}

.word-item {
    display: flex;
    flex-direction: column;
    padding: 0.15rem 0.25rem;
    border-radius: 4px;
    min-height: 0;
}

.word-top {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.word-pinyin {
    font-size: 0.75rem;
    color: var(--muted);
    margin-left: 0.2rem;
    font-family: var(--font-pinyin);
}

.word-def {
    font-size: 0.6rem;
    color: var(--muted);
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
}

.card-row-radicals {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-light);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.decomposition-list {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.decomp-row {
    display: flex;
    align-items: center;
    padding: 0.15rem 0;
}

.decomp-arrow {
    font-size: 1rem;
    color: var(--muted);
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
    user-select: none;
}

.decomp-arrow:hover {
    color: var(--fg);
}

.decomp-node.open > .decomp-row > .decomp-arrow {
    transform: rotate(90deg);
}

.decomp-children {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.decomp-children > * {
    overflow: hidden;
    min-height: 0;
}

.decomp-node.open > .decomp-children {
    grid-template-rows: 1fr;
}

.decomp-arrow-spacer {
    width: 1rem;
    display: inline-block;
    flex-shrink: 0;
}

.radical-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.decomp-box { padding: 0 0.3rem; }

.decomp-char {
    font-family: var(--font-cn);
    font-size: 1rem;
    padding: 0 0.3rem;
    border-right: 1px solid var(--border);
}

.decomp-pinyin {
    font-size: 0.8rem;
    color: var(--fg);
    padding: 0 0.3rem;
    border-right: 1px solid var(--border);
}

.decomp-def {
    font-size: 0.75rem;
    color: var(--muted);
    padding: 0 0.3rem;
}

.card-row-examples {
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.card-row-examples ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-row-examples li {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding: 0.25rem 0;
    gap: 0.4rem;
}

.card-row-examples li:last-child { border-bottom: none; }

.sentence-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sentence-play-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--fg);
    font-size: 10px;
    cursor: pointer;
    line-height: 24px;
    text-align: center;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.sentence-play-btn:hover {
    background: var(--fg);
    color: #fff;
    border-color: var(--fg);
}

.sentence-play-btn.playing {
    background: var(--fg);
    color: #fff;
    border-color: var(--fg);
}

.sentence-play-btn.loading {
    cursor: wait;
    color: transparent;
    position: relative;
}

.sentence-play-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid var(--border);
    border-top-color: var(--fg);
    border-radius: 50%;
    animation: spin 0.5s linear infinite;
}

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

.sentence-zh {
    font-family: var(--font-cn);
    font-size: 1.1rem;
}

.sentence-en {
    font-size: 0.825rem;
    color: var(--muted);
    word-break: break-word;
    overflow-wrap: break-word;
}

.char-link {
    cursor: pointer;
    text-decoration-line: none;
}

.char-link:hover {
    text-decoration-line: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    text-decoration-color: var(--fg);
}

/* ============ CHARACTER INFO POPUP ============ */

.char-popup {
    position: fixed;
    z-index: 200;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevated);
    padding: 0.75rem;
    min-width: 200px;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.char-popup-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.char-popup-char {
    font-family: var(--font-cn);
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.char-popup-pinyin {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
    font-family: var(--font-pinyin);
}

.char-popup-pill {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--fg);
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    line-height: 1.3;
    white-space: nowrap;
}

.char-popup-pill.hsk1 { background: #22c55e; }
.char-popup-pill.hsk2 { background: #3b82f6; }

.char-popup-day {
    font-size: 0.7rem;
    color: var(--muted);
    font-family: var(--font-mono);
}

.char-popup-def {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

.char-popup-words {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    border-top: 1px solid var(--border-light);
    padding-top: 0.4rem;
}

.char-popup-word {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    font-size: 0.8rem;
}

.char-popup-word-zh {
    font-family: var(--font-cn);
    font-weight: 600;
}

.char-popup-word-pinyin {
    font-size: 0.7rem;
    color: var(--muted);
    font-family: var(--font-pinyin);
}

.char-popup-word-def {
    font-size: 0.7rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.char-popup-goto {
    margin-top: 0.2rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--fg);
    background: var(--fg);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.char-popup-goto:hover {
    background: #fff;
    color: var(--fg);
}

.label {
    font-weight: 700;
    margin-right: 0.4rem;
}

/* ============ CARD NAV (prev/next) ============ */

.card-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.card-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.15s ease;
    box-shadow: var(--shadow-soft);
}

.card-nav-btn:hover {
    background: var(--border);
    color: var(--fg);
}

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

.card-nav-label {
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: color 0.15s ease;
}

.card-nav-label:hover { color: var(--fg); }

.card-nav-divider {
    color: var(--border);
    font-size: 14px;
}

/* ============ CHARACTER NAV (bottom grid) ============ */

.character-nav {
    padding: 0.75rem;
    border-top: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
    flex-shrink: 0;
    background: transparent;
}

.character-tab {
    font-family: var(--font-cn);
    font-size: 1.5rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: pointer;
    background: var(--card-bg);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-soft);
}

.character-tab:hover {
    border-color: #ccc;
    color: var(--fg);
    transform: translateY(-2px);
}

.character-tab.active {
    background: var(--fg);
    color: #fff;
    border-color: var(--fg);
    transform: translateY(-8px);
    box-shadow: var(--shadow-elevated);
}

.character-tab:active {
    transform: scale(0.96);
}

/* ============ CONTROL CENTER ============ */

.control-center {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    flex-shrink: 0;
}

.control-btn {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    height: 44px;
    position: relative;
}

.control-btn:hover {
    border-color: #ccc;
    color: var(--fg);
}

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

.control-btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.control-btn.active {
    background: var(--fg);
    color: #fff;
    border-color: var(--fg);
    box-shadow: var(--shadow-elevated);
    pointer-events: none;
}

.control-btn.audio-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.control-btn.audio-loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--fg);
    border-radius: 50%;
    animation: spin 0.5s linear infinite;
    margin-left: 0.4rem;
    flex-shrink: 0;
}

.control-icon-bg {
    position: absolute;
    left: -14px;
    bottom: -14px;
    width: 80px;
    height: 80px;
    opacity: 0.07;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.control-btn:hover .control-icon-bg {
    opacity: 0.14;
}

.control-btn.active .control-icon-bg {
    opacity: 0.15;
    color: #fff;
}

.control-label {
    flex: 1;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

kbd.control-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    background: var(--fg);
    color: #fff;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.control-btn.active kbd.control-key {
    background: #fff;
    color: var(--fg);
}

/* ============ REVIEW MODE ============ */

.review-front {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 2rem;
}

.review-prompt {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
}

.review-hint {
    font-size: 0.8rem;
    color: var(--muted);
}

.review-reveal {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 1rem 0;
    gap: 0.4rem;
}

.review-reveal-char {
    display: flex;
    align-items: center;
    justify-content: center;
}

.review-reveal-char svg {
    width: 100px;
    height: 100px;
}

.review-reveal .pinyin { font-size: 1.6rem; margin-bottom: 0; }
.review-reveal .definition { font-size: 0.9rem; margin-bottom: 0.4rem; white-space: normal; }
.review-reveal .sentences { width: 100%; text-align: left; }
.review-reveal .sentences .label { font-size: 0.8rem; font-weight: 700; margin-bottom: 0.2rem; }
.review-reveal .sentences ul { list-style: none; padding: 0; margin: 0; }
.review-reveal .sentences li {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.4rem;
}
.review-reveal .sentences li:last-child { border-bottom: none; }

/* ============ DRILL MODE (TEXTBOOK VIEW) ============ */

.drill-pattern-label {
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

.drill-type-badge {
    font-family: var(--font-ui);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid var(--fg);
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
}

.drill-page {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem 5rem;
    overflow-y: auto;
}

.drill-tap-zone {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fg);
    color: var(--bg);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    z-index: 20;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.drill-tap-zone:active {
    opacity: 0.8;
}

.drill-section {
    margin-bottom: 2rem;
}

.drill-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 2px solid var(--fg);
    margin-bottom: 0.5rem;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
}

.drill-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 700;
}

.drill-transform-tag {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--muted);
    font-style: italic;
}

.drill-reveal-toggle {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: none;
    border: 1px solid var(--fg);
    color: var(--fg);
    padding: 0.2rem 0.6rem;
    cursor: pointer;
}
.drill-reveal-toggle:hover { background: var(--fg); color: var(--bg); }

.drill-pattern-group {
    margin-bottom: 0.5rem;
}

.drill-pattern-heading {
    font-family: var(--font-cn);
    font-size: 1rem;
    font-weight: 700;
    color: var(--muted);
    padding: 0.6rem 0 0.3rem;
    border-bottom: 1px dashed var(--border-light);
    margin-bottom: 0.25rem;
    letter-spacing: 0.05em;
    position: sticky;
    top: 42px;
    background: var(--bg);
    z-index: 4;
}

.drill-phase-label {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    flex: 1;
    text-align: center;
}

.drill-cue-prompt {
    align-items: flex-start;
    justify-content: center;
}

.drill-cue {
    font-family: var(--font-cn);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.drill-cue-pinyin {
    font-size: 0.85rem;
    color: var(--muted);
}

.drill-cue-def {
    font-size: 0.8rem;
    color: var(--muted);
    max-width: 200px;
}

.drill-row {
    border-bottom: 1px solid var(--border-light);
}
.drill-row:last-child { border-bottom: none; }

.drill-row.drill-active {
    background: rgba(0, 0, 0, 0.04);
    border-left: 3px solid var(--fg);
    padding-left: 0.5rem;
}

.drill-row-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 0.75rem 0;
    align-items: start;
}

.drill-row-prompt {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.drill-row-answer {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    cursor: pointer;
    transition: filter 0.2s ease;
    padding: 0.5rem;
    border-radius: 4px;
}
.drill-row-answer:hover { background: rgba(0,0,0,0.02); }

.drill-blurred {
    filter: blur(6px);
    user-select: none;
    -webkit-user-select: none;
}

.drill-sentence-zh {
    font-family: var(--font-cn);
    font-size: 1.4rem;
    font-weight: 700;
}

.drill-front-en {
    font-size: 0.85rem;
    color: var(--muted);
}

.drill-transform-label,
.drill-response-label,
.drill-step-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.drill-sentence-en {
    font-size: 0.9rem;
    color: var(--muted);
}

.drill-sub-label {
    font-size: 0.75rem;
    color: var(--muted);
}

.drill-highlight {
    border-bottom: 2px solid var(--fg);
    font-weight: 700;
}

.drill-play-btn {
    position: static;
    flex-shrink: 0;
}

.drill-sentence-line {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}

.drill-annotated {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.drill-char-anno {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
}

.drill-char-anno.drill-highlight .drill-char-hanzi {
    border-bottom: 2px solid var(--fg);
    font-weight: 700;
}

.drill-char-anno.drill-review-highlight .drill-char-hanzi {
    border-bottom: 2px dashed var(--muted);
}

.drill-char-hanzi {
    font-family: var(--font-cn);
    font-size: 1.3rem;
}

.drill-char-pinyin {
    font-size: 0.65rem;
    color: var(--muted);
    font-family: var(--font-pinyin);
}

/* Expansion: indent chained steps */
.drill-expansion-row {
    grid-template-columns: 1fr 1fr;
}

/* Mobile: stack prompt/answer vertically */
@media (max-width: 600px) {
    .drill-row-inner {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .drill-row-answer {
        padding-left: 1rem;
        border-left: 2px solid var(--border-light);
    }
    .drill-sentence-zh { font-size: 1.2rem; }
    .drill-char-hanzi { font-size: 1.1rem; }
}

/* ============ ANIMATIONS ============ */

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .flashcard-front, .flashcard-back { transition: none; }
    .character-tab, .day-wheel-pill { transition: none; }
}

/* ============ DESKTOP (1024px+) ============ */

@media (min-width: 1024px) {
    .days-sidebar {
        display: flex;
    }

    .flashcard {
        max-height: 60vh;
        max-width: min(480px, 60vh * 4 / 5);
    }

    .character-nav {
        grid-template-columns: repeat(10, 1fr);
        max-width: 600px;
        margin: 0 auto;
        width: 100%;
        padding: 0.75rem 1rem;
    }

    .character-tab {
        font-size: 1.6rem;
    }

    .card-area {
        padding: 1rem 2rem;
    }

    kbd.control-key {
        display: inline-flex;
    }

    .progress-header-text {
        font-size: 13px;
    }

    .day-wheel-pill {
        width: 44px;
        height: 44px;
        font-size: 13px;
    }

    /* Hide day wheel on desktop (sidebar is visible) */
    .day-wheel-container {
        display: none;
    }
}

/* ============ TABLET (768px - 1023px) ============ */

@media (min-width: 768px) and (max-width: 1023px) {
    .character-nav {
        grid-template-columns: repeat(10, 1fr);
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }

    .flashcard {
        max-height: 55vh;
        max-width: min(400px, calc(55vh * 4 / 5));
    }
}

/* ============ MOBILE (< 1024px) ============ */

@media (max-width: 1023px) {
    .days-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(12px);
        display: flex;
    }

    .days-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.open {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-handle {
        display: block;
        padding: 0.5rem;
        text-align: right;
        cursor: pointer;
        font-size: 1.2rem;
        color: var(--muted);
    }

    .sidebar-handle::after {
        content: '\2715';
    }

    kbd.control-key { display: none; }
}

/* ============ MOBILE CARD BACK (< 768px) ============ */

@media (max-width: 767px) {
    .day-wheel-pill { width: 60px; height: 40px; font-size: 13px; }
    .day-wheel { gap: 0.5rem; }
    .card-char { font-size: 1.75rem; }
    .pinyin { font-size: 0.9rem; }
    .definition { font-size: 0.75rem; }
    .sentence-zh { font-size: 1rem; }
    .sentence-en { font-size: 0.75rem; }
    .words-list { font-size: 0.9rem; }
    .word-pinyin { font-size: 0.65rem; }
    .word-def { font-size: 0.55rem; }
    .decomp-char { font-size: 0.9rem; }
    .decomp-pinyin { font-size: 0.7rem; }
    .decomp-def { font-size: 0.65rem; }
    .card-row-header { padding: 0.5rem 0.75rem; gap: 0.5rem; }
    .card-row-radicals { padding: 0.4rem 0.75rem; }
    .card-row-examples { padding: 0.4rem 0.75rem; }
    .card-row-examples li { padding: 0.15rem 0; gap: 0.3rem; }
    .sentence-play-btn { width: 22px; height: 22px; font-size: 9px; line-height: 22px; }
    .flashcard { aspect-ratio: 4 / 5; max-height: calc(100dvh - 220px); max-width: min(100%, calc((100dvh - 220px) * 4 / 5)); }
    .flashcard-container { max-width: 100%; flex: 1; min-height: 0; }
    .card-area { padding: 0.5rem 0.75rem; gap: 0.25rem; justify-content: flex-start; overflow-y: auto; }
    .card-nav-btn { width: 48px; height: 48px; }
    .card-nav-label { font-size: 14px; }
    .character-nav { width: 100%; padding: 0.75rem 0.5rem; }
}

/* ============ SMALL MOBILE (< 400px) ============ */

@media (max-width: 399px) {
    .character-tab {
        font-size: 1rem;
    }

    .day-wheel-pill {
        width: 52px;
        height: 36px;
        font-size: 12px;
    }

    .flashcard {
        max-height: calc(100dvh - 200px);
        max-width: min(100%, calc((100dvh - 200px) * 4 / 5));
        aspect-ratio: 4 / 5;
    }

    .card-char { font-size: 1.5rem; }
    .pinyin { font-size: 0.85rem; }
    .definition { font-size: 0.7rem; }
    .sentence-zh { font-size: 0.9rem; }
    .sentence-en { font-size: 0.7rem; }
    .words-list { font-size: 0.85rem; gap: 0.15rem 0.3rem; }
    .word-pinyin { font-size: 0.6rem; }
    .word-def { font-size: 0.5rem; }
    .decomp-char { font-size: 0.85rem; }
    .decomp-pinyin { font-size: 0.65rem; }
    .decomp-def { font-size: 0.6rem; }
    .card-row-header { padding: 0.4rem 0.6rem; gap: 0.4rem; }
    .card-row-radicals { padding: 0.3rem 0.6rem; }
    .card-row-examples { padding: 0.3rem 0.6rem; }
    .card-row-examples li { padding: 0.1rem 0; }
    .card-header-left .label,
    .card-header-right .label { font-size: 9px; margin-bottom: 0.1rem; }
    .radical-subtitle { font-size: 0.7rem; margin-bottom: 0.2rem; }
}

/* ============ LANDSCAPE MOBILE ============ */

@media (max-height: 500px) and (orientation: landscape) {
    .flashcard {
        max-height: 40vh;
        aspect-ratio: 5/4;
        max-width: min(100%, calc(40vh * 5 / 4));
    }

    .card-area {
        padding: 0.25rem 0.5rem;
        gap: 0.25rem;
        overflow-y: auto;
    }

    .day-wheel-container {
        padding: 0.25rem 0.25rem;
    }

    .progress-header {
        padding: 0.25rem 0.5rem;
    }

    .character-nav {
        grid-template-columns: repeat(10, 1fr);
        padding: 0.25rem 0.5rem;
        gap: 0.25rem;
    }

    .character-tab {
        padding: 0.3rem;
        font-size: 1.2rem;
    }

    .control-center {
        display: none;
    }

    .card-char { font-size: 1.5rem; }
    .pinyin { font-size: 0.85rem; }
    .sentence-zh { font-size: 0.9rem; }
    .sentence-en { font-size: 0.7rem; }
    .card-row-header { padding: 0.3rem 0.5rem; }
    .card-row-radicals { padding: 0.25rem 0.5rem; }
    .card-row-examples { padding: 0.25rem 0.5rem; }
}

/* Mobile: hide key labels */
@media (max-width: 767px) {
    kbd.control-key { display: none; }
}

/* ============ SHORT VIEWPORT (< 700px height, portrait) ============ */

@media (max-height: 700px) and (orientation: portrait) {
    .card-char { font-size: 1.5rem; }
    .pinyin { font-size: 0.85rem; }
    .sentence-zh { font-size: 0.9rem; }
    .sentence-en { font-size: 0.7rem; }
    .card-row-header { padding: 0.4rem 0.6rem; }
    .card-row-radicals { padding: 0.3rem 0.6rem; }
    .card-row-examples { padding: 0.3rem 0.6rem; }
    .card-row-examples li { padding: 0.1rem 0; }
    .words-list { font-size: 0.85rem; }
}
