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

:root {
    --accent: #3b5bdb;
    --accent-dark: #364fc7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f2f2ed;
    color: #1a1a1a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent);
}

/* ── Nav ── */
nav {
    background: #1a1a1a;
    color: #fff;
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.nav-logo {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    letter-spacing: 0.05em;
    color: #fff;
    text-decoration: none;
}

.mode-toggle {
    display: flex;
    gap: 2px;
    background: #333;
    border-radius: 7px;
    padding: 3px;
}

.mode-toggle a {
    color: #999;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 5px;
    transition: background 0.12s, color 0.12s;
}

.mode-toggle a.active {
    background: #555;
    color: #fff;
}

.nav-links a {
    color: #999;
    text-decoration: none;
    margin-left: 24px;
    font-size: 14px;
    transition: color 0.12s;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
}

.nav-email {
    color: #555;
    font-size: 13px;
    margin-left: 24px;
}

/* ── Main ── */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

/* ── Review page wrapper & panels ── */
.review-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 700px;
    width: 100%;
}

.review-panels {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.review-panel {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e8e8e4;
    font-size: 14px;
}

.review-panel > summary {
    padding: 10px 14px;
    cursor: pointer;
    color: #666;
    user-select: none;
    list-style: none;
}

.review-panel > summary::-webkit-details-marker { display: none; }

.review-panel[open] > summary {
    border-bottom: 1px solid #f0f0ec;
}

.review-panel-content {
    padding: 12px 14px;
}

.active-col-names {
    color: #999;
    font-weight: 400;
    margin-left: 4px;
}

/* ── Start screen hero ── */
.start-hero {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.07);
    padding: 40px 32px 36px;
    text-align: center;
}

.start-heading {
    font-size: 26px;
    margin-bottom: 26px;
}

.start-stats {
    display: flex;
    justify-content: center;
    gap: 56px;
    margin-bottom: 30px;
}

.start-stat-num {
    display: block;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
}

.start-stat-label {
    font-size: 13px;
    color: #888;
}

.start-hero .btn-start {
    max-width: 340px;
    margin: 0 auto;
}

/* Start hero: all caught up */
.start-done-icon {
    font-size: 40px;
    line-height: 1;
    color: #2ea05a;
    margin-bottom: 14px;
}

.start-done-note {
    color: #666;
    font-size: 15px;
}

.start-done-streak {
    color: #666;
    font-size: 14px;
    margin-top: 8px;
}

.start-hero .btn-boost {
    margin-top: 22px;
}

/* ── State messages (no_words / all_done) ── */
.state-message {
    text-align: center;
    max-width: 400px;
}

.state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.state-message h2 {
    font-size: 26px;
    margin-bottom: 10px;
}

.state-message p {
    color: #666;
    font-size: 15px;
    line-height: 1.6;
}

.state-message-btn {
    display: inline-block;
    width: auto;
    margin-top: 24px;
    padding: 11px 28px;
}

.state-message code {
    background: #e8e8e4;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
}

/* ── Review card ── */
.card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.07);
    padding: 40px 44px;
    max-width: 700px;
    width: 100%;
}

/* Active review screen: fixed-height card so the action buttons never move
   when the answer is revealed. The question stays at the top, the answer
   fills the middle, and the actions are pinned to the bottom edge. */
.review-main {
    align-items: flex-start;
    padding-bottom: 0;
}

.review-main .card {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 84px);   /* nav 52px + main top padding 32px */
    min-height: calc(100dvh - 84px);
    padding-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.review-main .card form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

@media (min-width: 641px) {
    .review-main .sentence-area {
        margin-top: 7vh;
    }

    .review-main .listening-area {
        margin-top: 3vh;
    }
}

/* Pinned action bar: same spot before and after reveal, and stays on
   screen when the answer content grows past the viewport */
.review-main .actions {
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 14px 0 20px;
    border-top: 1px solid #f0f0ec;
}

/* Remaining counter */
.remaining {
    font-size: 12px;
    color: #bbb;
    text-align: right;
    margin-bottom: 16px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.btn-undo {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    font-size: 1.2em;
    vertical-align: middle;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    margin-left: 8px;
    line-height: 1;
}

.btn-undo:hover {
    opacity: 1;
    transform: scale(1.1);
}

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

/* Debug mode */
.debug-bar {
    margin-bottom: 10px;
}

.debug-badge {
    display: inline-block;
    font-size: 11px;
    font-family: monospace;
    color: #8b5cf6;
    background: #f3eeff;
    border: 1px solid #d8b4fe;
    border-radius: 4px;
    padding: 2px 7px;
}

.debug-word-meta {
    margin-bottom: 10px;
}

/* Word header inside the answer box */
.word-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eae9e4;
}

.word-chinese {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

.word-pinyin {
    font-size: 15px;
    color: #888;
}

.word-pos {
    font-size: 11px;
    color: #aaa;
    background: #f0f0ec;
    padding: 2px 9px;
    border-radius: 10px;
    margin-left: auto;
}

/* Sentence */
.sentence-area {
    margin-bottom: 36px;
    text-align: center;
    padding: 8px 0;
}

.sentence {
    font-size: 34px;
    line-height: 1.7;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

.sentence mark {
    background: #ffe566;
    border-radius: 3px;
    padding: 0 3px;
    font-style: normal;
}

/* Listening play button */
.listening-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    margin-bottom: 32px;
    padding: 20px 0 18px;
}

.play-btn {
    position: relative;
    width: 148px;
    height: 148px;
    background: radial-gradient(circle at 50% 42%, #2c2c2c 0, #151515 66%);
    border: 1px solid #151515;
    cursor: pointer;
    color: #fff;
    padding: 0 0 0 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.14);
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.1s;
}

.play-btn:hover {
    background: radial-gradient(circle at 50% 42%, #3a3a3a 0, #1f1f1f 66%);
    border-color: #222;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
}

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

.play-btn.playing {
    background: radial-gradient(circle at 50% 42%, #38b469 0, #21854a 68%);
    border-color: #2ea05a;
    box-shadow: 0 18px 48px rgba(46, 160, 90, 0.28);
}

.play-btn svg {
    position: relative;
    z-index: 1;
    transition: opacity 0.16s, transform 0.16s;
}

.play-btn.playing svg {
    opacity: 0.22;
    transform: scale(0.86);
}

.audio-bars {
    position: absolute;
    left: 50%;
    top: 50%;
    display: flex;
    align-items: center;
    gap: 7px;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.16s;
}

.audio-bars span {
    width: 8px;
    height: 24px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    animation: audio-bar 0.72s ease-in-out infinite;
}

.audio-bars span:nth-child(2) {
    animation-delay: 0.12s;
}

.audio-bars span:nth-child(3) {
    animation-delay: 0.24s;
}

.play-btn.playing .audio-bars {
    opacity: 1;
}

@keyframes audio-bar {
    0%, 100% {
        transform: scaleY(0.42);
    }
    50% {
        transform: scaleY(1.3);
    }
}

@media (prefers-reduced-motion: reduce) {
    .audio-bars span {
        animation: none;
    }
}

/* Reveal area */
.reveal-area {
    border-top: 1px solid #eee;
    padding-top: 24px;
    margin-bottom: 32px;
}

.sentence-revealed {
    font-size: 22px;
    text-align: center;
    margin-bottom: 12px;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

.sentence-pinyin {
    font-size: 16px;
    color: #999;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.sentence-english {
    font-size: 16px;
    color: #555;
    font-style: italic;
    text-align: center;
    margin-bottom: 22px;
    line-height: 1.5;
}

.word-details {
    background: #f7f7f3;
    border-radius: 10px;
    padding: 18px 20px;
}

.word-def-en {
    font-size: 15px;
    color: #222;
    margin-bottom: 8px;
    font-weight: 500;
}

.word-def-zh {
    font-size: 14px;
    color: #555;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    line-height: 1.65;
}

.note {
    font-size: 13px;
    color: #888;
    margin-top: 10px;
    line-height: 1.55;
    padding-top: 10px;
    border-top: 1px solid #eae9e4;
}

.note-zh {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
}

/* Actions */
.actions {
    display: flex;
    justify-content: center;
}

.btn {
    display: inline-block;
    font-size: 16px;
    font-weight: 500;
    padding: 13px 32px;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    transition: filter 0.12s;
    background: #e8e8e4;
    color: #1a1a1a;
    text-decoration: none;
}

.btn:hover {
    filter: brightness(0.9);
}

.btn:active {
    filter: brightness(0.8);
}

.btn-reveal {
    background: #1a1a1a;
    color: #fff;
    width: 100%;
    max-width: 340px;
}

.btn-boost {
    margin-top: 12px;
    background: #444;
}

.rating-btns {
    display: flex;
    gap: 12px;
    width: 100%;
}

.btn-fail  { background: #e05252; color: #fff; flex: 1; }
.btn-kinda { background: #e8960a; color: #fff; flex: 1; }
.btn-pass  { background: #2ea05a; color: #fff; flex: 1; }

.rating-btns .btn {
    white-space: nowrap;
    padding-left: 8px;
    padding-right: 8px;
}

.btn kbd {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 5px;
    font-size: 0.7em;
    font-family: inherit;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 3px;
    opacity: 0.7;
    vertical-align: middle;
    pointer-events: none;
}
.btn-reveal kbd {
    border-color: rgba(0,0,0,0.2);
    opacity: 0.5;
}
.play-kbd {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-family: inherit;
    padding: 0 5px;
    color: rgba(255,255,255,0.75);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 3px;
    pointer-events: none;
}

/* Keyboard hints are meaningless on touch screens */
@media (hover: none), (pointer: coarse) {
    .btn kbd,
    .play-kbd {
        display: none;
    }
}

/* ── Page columns ──
   Two shared widths so headings don't jump when switching tabs:
   700px for content pages (matches the review card), 460px for forms. */
.settings-container {
    max-width: 460px;
    width: 100%;
}

.settings-container-wide {
    max-width: 700px;
    width: 100%;
}

/* Content pages start at the top of the viewport instead of floating
   vertically, so short pages line up with tall ones. */
.page-main {
    align-items: flex-start;
}

.settings-container-wide h2 {
    font-size: 22px;
    margin-bottom: 28px;
}

.hsk-level-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 15px;
}

.form-footer-link {
    margin-top: 16px;
}

.empty-hint {
    text-align: center;
    padding: 24px 0;
}

.settings-container h2 {
    font-size: 22px;
    margin-bottom: 28px;
}

.field {
    margin-bottom: 24px;
}

.field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #444;
    margin-bottom: 8px;
}

.field select,
.field input[type="number"],
.field input[type="text"],
.field input[type="email"],
.field textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    margin-bottom: 8px;
    font-family: inherit;
}

.field select,
.field input[type="number"] {
    cursor: pointer;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: #333;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.col-count {
    color: #aaa;
    font-size: 12px;
    margin-left: 4px;
}

.btn-panel-save {
    margin-top: 12px;
    background: #1a1a1a;
    color: #fff;
}

.btn-sm {
    font-size: 14px;
    padding: 7px 14px;
    border-radius: 7px;
}

.btn-start {
    background: #1a1a1a;
    color: #fff;
    display: block;
    text-align: center;
    text-decoration: none;
}

.btn-start:hover {
    filter: brightness(0.9);
}

.field-hint {
    font-size: 13px;
    color: #999;
    line-height: 1.55;
}

.settings-container .btn-reveal {
    max-width: none;
    width: auto;
    padding: 12px 28px;
    margin-bottom: 36px;
}

.stats {
    background: #f7f7f3;
    border-radius: 10px;
    padding: 20px 24px;
}

.stats h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #aaa;
    margin-bottom: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    color: #444;
    padding: 6px 0;
    border-bottom: 1px solid #eee;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-value {
    font-weight: 600;
    color: #1a1a1a;
}

/* ── Auth ── */
.auth-container {
    max-width: 460px;
    width: 100%;
}

.auth-container h2 {
    font-size: 22px;
    margin-bottom: 24px;
}

.auth-container .field input[type="email"],
.auth-container .field input[type="password"] {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    margin-bottom: 8px;
}

.auth-container .btn-reveal {
    width: 100%;
    max-width: none;
    margin-bottom: 20px;
}

.auth-error {
    background: #fdecea;
    color: #b91c1c;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 20px;
}

.auth-switch {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-top: 20px;
}

.auth-switch a {
    color: #1a1a1a;
    font-weight: 500;
}

.cross-refs {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.cross-ref {
    font-size: 13px;
    color: #888;
    margin: 4px 0 0;
}

.cross-ref strong {
    color: #555;
}

.lang-toggle {
    font-size: 13px;
    color: #888;
    text-decoration: none;
    padding: 2px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-left: 4px;
}

.lang-toggle:hover {
    color: #333;
    border-color: #aaa;
}

.welcome-banner {
    background: #eef6ee;
    border: 1px solid #b4d9b4;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.5;
    color: #1a3a1a;
}

/* ── Homepage ── */
.home-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 64px 24px 48px;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

.home-hero {
    text-align: center;
    margin-bottom: 64px;
}

.home-title {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.home-subtitle {
    font-size: 18px;
    color: #555;
    line-height: 1.7;
    max-width: 560px;
    margin: 0 auto 36px;
}

.home-actions {
    display: flex;
    align-items: center;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.home-actions .btn {
    width: auto;
    max-width: none;
    padding: 14px 36px;
    font-size: 16px;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
    color: #555;
    text-decoration: none;
    font-size: 15px;
}

.btn-link:hover {
    color: #1a1a1a;
}

.btn-nav-cta {
    background: #fff;
    color: #1a1a1a;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 7px;
    margin-left: 16px;
    transition: background 0.12s;
}

.btn-nav-cta:hover {
    background: #e8e8e4;
}

.home-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 28px;
    width: 100%;
}

.feature {
    background: #fff;
    border-radius: 12px;
    padding: 28px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.feature-icon {
    color: var(--accent);
    margin-bottom: 14px;
}

.feature-icon svg {
    display: block;
}

.feature h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.feature p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

/* ── Collection rows in settings ── */
.collection-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.col-progress-link {
    font-size: 12px;
    color: #888;
    text-decoration: none;
    flex-shrink: 0;
}

.col-progress-link:hover {
    color: #1a1a1a;
    text-decoration: underline;
}

/* ── Collection progress page ── */
.col-progress-main {
    align-items: flex-start;
    justify-content: flex-start;
}

.col-progress-container {
    max-width: 700px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 16px 48px;
}

.col-progress-header {
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.col-progress-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
}

.col-selector {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.col-selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.col-selector-group label {
    font-size: 14px;
    color: #666;
}

.progress-overview .col-progress-header {
    margin-bottom: 12px;
}

.progress-controls {
    display: flex;
    align-items: end;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px;
    border: 1px solid #eeeeea;
    border-radius: 8px;
    background: #fafaf8;
}

.progress-controls .col-selector-group {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
}

.progress-controls .col-selector-group:last-child {
    flex: 1 1 220px;
}

.progress-controls label {
    font-size: 12px;
    font-weight: 600;
    color: #777;
}

.col-selector select, .mode-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

.mode-selector-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-selector-wrap label {
    font-size: 13px;
    color: #888;
}

.mode-select {
    padding: 6px 10px;
    font-size: 13px;
    background: #f9f9f9;
    color: #666;
}

.mode-select:hover {
    border-color: #bbb;
    background: #fff;
}

.col-progress-back {
    display: inline-block;
    font-size: 13px;
    color: #888;
    text-decoration: none;
}

.col-progress-back:hover {
    color: #444;
}

.col-progress-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.col-progress-desc {
    margin-top: 6px;
    font-size: 14px;
    color: #666;
}

.col-progress-section {
    margin-bottom: 28px;
}

.col-progress-collection {
    padding-bottom: 32px;
    border-bottom: 1px solid #e8e8e4;
}

.col-progress-collection:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.col-progress-collection-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a1a;
}

.col-progress-bar-wrap {
    margin-bottom: 10px;
}

.col-progress-bar {
    display: flex;
    height: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: #e0e0e0;
}

.cpb-known   { background: #4caf50; }
.cpb-learning { background: #ff9800; }
.cpb-failed  { background: #e53935; }
.cpb-unseen  { background: #e0e0e0; }

.col-progress-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    align-items: center;
}

.cpl-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #555;
}

.cpl-item::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.cpl-known::before   { background: #4caf50; }
.cpl-learning::before { background: #ff9800; }
.cpl-failed::before  { background: #e53935; }
.cpl-unseen::before  { background: #d0d0d0; border: 1px solid #bbb; }

.cpl-total {
    margin-left: auto;
    color: #aaa;
    font-size: 13px;
}

.col-word-details {
    margin-top: 20px;
}

.btn-show-words {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    background: #e8e8e4;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.btn-show-words::-webkit-details-marker { display: none; }

.btn-show-words:hover {
    background: #ddd;
    color: #333;
}

.col-word-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.col-word-chip {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    font-size: 15px;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: default;
    user-select: none;
}

.col-chip-known    { background: #c8e6c9; color: #1b5e20; }
.col-chip-learning { background: #ffe0b2; color: #7f3e00; }
.col-chip-failed   { background: #ffcdd2; color: #7f0000; }
.col-chip-unseen   { background: #eeeeee; color: #777; }

/* ── Utility ── */
.hidden {
    display: none !important;
}

/* ── My Collections / Manage Collection ─────────────────────────────────── */

.mc-quota-bar {
    margin: 0 0 12px;
}
.mc-collection-settings {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.mc-quota-label {
    font-size: 13px;
    color: #555;
    display: block;
    margin-bottom: 6px;
}
.mc-quota-track {
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}
.mc-quota-fill {
    height: 100%;
    background: #2ea05a;
    border-radius: 4px;
    transition: width 0.3s;
}

.mc-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}
.mc-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.mc-card-header { flex: 1; }
.mc-card-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.mc-card-name {
    font-size: 17px;
    font-weight: 600;
}
.mc-card-desc {
    font-size: 14px;
    color: #555;
    margin: 4px 0;
}
.mc-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    flex-shrink: 0;
}

.mc-role-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.mc-role-owner  { background: #fff3cd; color: #856404; }
.mc-role-editor { background: #cce5ff; color: #004085; }
.mc-role-viewer { background: #e8e8e8; color: #555; }

.mc-mode-toggles {
    display: flex;
    gap: 14px;
    align-items: center;
}
.mc-mode-toggle {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 14px;
    color: #444;
    cursor: pointer;
    white-space: nowrap;
}
.mc-mode-toggle input {
    cursor: pointer;
}

/* ── Word list navigation (filter tabs + search) ─────────────────── */
.mc-word-nav {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.mc-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.mc-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 13px;
    color: #555;
    background: #f0f0ec;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.mc-filter-tab:hover { background: #e4e4e0; color: #222; }
.mc-filter-tab-active {
    background: #1a1a1a;
    color: #fff;
}
.mc-filter-tab-active:hover { background: #333; color: #fff; }
.mc-filter-count {
    font-size: 11px;
    opacity: 0.7;
}
.mc-word-search {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.mc-search-input {
    font-size: 13px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 130px;
}
.mc-search-clear { font-size: 13px; }

/* ── Page info + pagination ───────────────────────────────────────── */
.mc-page-info {
    margin-bottom: 8px;
}
.mc-pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #ececec;
}
.mc-page-btn { text-decoration: none; }
.mc-page-disabled {
    opacity: 0.35;
    pointer-events: none;
}
.mc-page-num {
    font-size: 13px;
    color: #666;
}

/* ── Add-words mode tabs ──────────────────────────────────────────── */
.mc-input-mode-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}
.mc-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 6px 14px;
    font-size: 14px;
    color: #777;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.mc-tab:hover { color: #333; }
.mc-tab-active {
    color: #1a1a1a;
    border-bottom-color: #1a1a1a;
    font-weight: 500;
}

/* ── Extract mode options ─────────────────────────────────────────── */
.mc-extract-options {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.mc-extract-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
}
.mc-extract-select {
    font-size: 13px;
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}

/* ── Extract review UI ────────────────────────────────────────────── */
.mc-extract-tier {
    margin-top: 14px;
}
.mc-extract-tier-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #ececec;
}
.mc-extract-tier-target .mc-extract-tier-header {
    color: #3366cc;
    border-bottom-color: #c5d4f0;
}
.mc-extract-candidate {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    font-size: 14px;
}
.mc-extract-candidate.mc-in-collection {
    opacity: 0.45;
    pointer-events: none;
}
.mc-extract-candidate input[type=checkbox] {
    cursor: pointer;
    flex-shrink: 0;
}
.mc-extract-char {
    font-size: 16px;
    min-width: 40px;
}
.mc-extract-key {
    color: #c8940a;
    font-size: 13px;
    flex-shrink: 0;
}
.mc-extract-hsk {
    font-size: 11px;
    color: #999;
    background: #f2f2f2;
    border-radius: 3px;
    padding: 1px 5px;
    flex-shrink: 0;
}
.mc-extract-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #ececec;
    flex-wrap: wrap;
}
.mc-extract-capped {
    font-size: 12px;
    color: #a07000;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    padding: 4px 8px;
    margin-top: 8px;
}

.mc-card-inactive {
    opacity: 0.6;
}
.mc-card-inactive:hover {
    opacity: 1;
}

.mc-create-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    margin-top: 16px;
}
.mc-create-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
}
.mc-card-subcollections {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}
.mc-card-subcollection {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 9px;
    border-radius: 6px;
    background: #f5f5f5;
    color: #333;
    font-size: 13px;
    text-decoration: none;
}
.mc-card-subcollection:hover { background: #eeeeee; }
.mc-subcollection-disabled { opacity: 0.55; }
.mc-create-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
}
.mc-create-form .btn {
    align-self: flex-start;
    padding: 10px 28px;
}
.mc-code-input {
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.mc-code-input::placeholder {
    text-transform: none;
    letter-spacing: normal;
}
.mc-error {
    color: #c0392b;
    font-size: 13px;
    margin-left: 8px;
}

/* manage_collection.html */
.mc-manage-header {
    margin-bottom: 20px;
}
.mc-manage-header h2 {
    font-size: 22px;
    margin: 6px 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.mc-section {
    border-top: 1px solid #e8e8e8;
    padding: 20px 0;
}
.mc-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
}
.mc-count {
    font-weight: 400;
    color: #888;
    font-size: 14px;
}

.mc-add-words {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mc-add-words label { font-size: 14px; }
.mc-subcol-select {
    width: 220px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}
.mc-add-words textarea {
    width: 100%;
    max-width: 420px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
}
.mc-add-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mc-word-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    max-height: 320px;
    overflow-y: auto;
}
.mc-word-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f9f9f9;
    font-size: 14px;
}
.mc-word-char {
    font-size: 17px;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    min-width: 40px;
}
.mc-word-pinyin { color: #666; min-width: 90px; }
.mc-word-location {
    color: #555;
    background: #eeeeee;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    white-space: nowrap;
}
.mc-word-card-count {
    color: #777;
    font-size: 12px;
    white-space: nowrap;
}
.mc-gen-badge { font-size: 13px; }
.mc-gen-error {
    color: #a33;
    font-size: 12px;
    flex: 1;
}
.mc-gen-complete .mc-gen-badge { color: #2ea05a; }
.mc-gen-pending .mc-gen-badge { color: #888; }
.mc-gen-failed  .mc-gen-badge { color: #c0392b; }
.mc-gen-failed  { background: #fff0f0; }

.mc-spinner {
    display: inline-block;
    animation: mc-spin 1s linear infinite;
}
@keyframes mc-spin { to { transform: rotate(360deg); } }

.mc-add-results {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
}
.mc-result-row { padding: 4px 8px; border-radius: 4px; }
.mc-result-ok      { color: #2ea05a; }
.mc-result-queued  { color: #888; }
.mc-result-invalid { color: #c0392b; background: #fff0f0; }

.mc-subcol-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.mc-subcol-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 14px;
}
.mc-subcol-name { font-weight: 500; flex: 1; }
.mc-subcol-count {
    color: #666;
    font-size: 12px;
}
.mc-subcol-on  { color: #2ea05a; font-size: 12px; }
.mc-subcol-off { color: #aaa;    font-size: 12px; }

.mc-inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.mc-inline-form input[type="text"] {
    flex: 1;
    max-width: 280px;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}

.mc-codes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.mc-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 13px;
    flex-wrap: wrap;
}
.mc-code-inactive { opacity: 0.55; }
.mc-code-text {
    font-size: 12px;
    color: #333;
    word-break: break-all;
    flex: 1;
}
.mc-code-meta { color: #888; font-size: 12px; }
.mc-gen-code-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.mc-gen-code-option {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mc-btn-share-viewer {
    border: 1px solid #ccc;
}
.mc-btn-share-viewer:hover { filter: brightness(0.93); }
.mc-btn-share-editor {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #f0d080;
}
.mc-btn-share-editor:hover { background: #ffe8a0; }

.mc-members-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mc-member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 14px;
}
.mc-member-email { flex: 1; }
.mc-role-select {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

.mc-btn-danger {
    background: #e05252;
    color: #fff;
}
.mc-btn-danger:hover { background: #c0392b; }

/* ── Hamburger (hidden on desktop) ── */
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}

/* ── Mobile layout ── */
@media (max-width: 640px) {
    nav {
        position: relative;
        padding: 0 16px;
    }

    .nav-hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 52px;
        left: 0;
        right: 0;
        background: #1a1a1a;
        flex-direction: column;
        padding: 4px 0 8px;
        z-index: 100;
        border-top: 1px solid #2a2a2a;
    }

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

    .nav-links a {
        margin-left: 0;
        padding: 12px 20px;
        font-size: 15px;
        border-bottom: 1px solid #222;
        color: #ccc;
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    .nav-links a.active {
        color: #fff;
    }

    .lang-toggle {
        border: none;
        border-radius: 0;
        margin-left: 0;
    }

    /* Mode toggle: tighter on narrow screens */
    .mode-toggle a {
        padding: 4px 9px;
    }

    /* Card */
    .card {
        padding: 24px 18px;
        border-radius: 10px;
    }

    .review-main .card {
        min-height: calc(100vh - 68px);   /* nav 52px + main top padding 16px */
        min-height: calc(100dvh - 68px);
    }

    .rating-btns {
        gap: 8px;
    }

    .rating-btns .btn {
        font-size: 15px;
    }

    .sentence {
        font-size: 28px;
    }

    .sentence-area {
        margin-bottom: 24px;
    }

    .listening-area {
        min-height: 190px;
        padding: 18px 0 12px;
    }

    .play-btn {
        width: 112px;
        height: 112px;
    }

    .play-btn svg {
        width: 60px;
        height: 60px;
    }

    /* Main area: less vertical breathing room */
    main {
        padding: 16px 12px;
        align-items: flex-start;
    }

    /* Start screen hero */
    .start-hero {
        padding: 28px 20px 24px;
    }

    .start-heading {
        font-size: 22px;
    }

    .start-stats {
        gap: 36px;
    }

    .start-stat-num {
        font-size: 28px;
    }

    /* Manage collection: word rows wrap instead of overflowing */
    .mc-word-row {
        flex-wrap: wrap;
        row-gap: 4px;
    }

    .mc-word-pinyin {
        min-width: 0;
        flex: 1;
    }

    .mc-word-row .mc-gen-error {
        display: none;
    }

    .mc-word-row.mc-gen-failed .mc-gen-error {
        display: block;
        flex: 1 1 100%;
        order: 10;
    }

    /* Manage collection: invite code rows keep the code on one line,
       meta drops to its own line */
    .mc-code-text {
        flex: 0 1 auto;
        word-break: normal;
    }

    .mc-code-row .mc-copy-btn {
        margin-left: auto;
    }

    .mc-code-meta {
        flex-basis: 100%;
        order: 5;
    }

    /* Home page */
    .home-main {
        padding: 36px 16px 32px;
    }

    .home-title {
        font-size: 28px;
    }

    .home-subtitle {
        font-size: 16px;
    }

    .home-hero {
        margin-bottom: 40px;
    }
}

/* Legal pages */
.policy-page h1 { font-size: 24px; margin-bottom: 4px; }
.policy-page h2 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
.policy-page p, .policy-page li { font-size: 14px; color: #444; line-height: 1.65; margin-bottom: 10px; }
.policy-page ul { padding-left: 20px; margin-bottom: 10px; }
.policy-page a { color: #2563eb; }

/* Home footer */
.home-footer { text-align: center; padding: 24px 16px 32px; display: flex; gap: 20px; justify-content: center; }
.home-footer a { font-size: 13px; color: #999; text-decoration: none; }
.home-footer a:hover { color: #555; }

/* Login legal notice */
.auth-legal { font-size: 12px; color: #999; margin-top: 12px; text-align: center; line-height: 1.5; }
.auth-legal a { color: #999; text-decoration: underline; }
.auth-legal a:hover { color: #555; }
