/*
 * EnGo Editorial UI System
 * Rebuilt from a blank visual layer. This is the only source of UI styling.
 */

:root {
    --color-primary: #292524;
    --color-primary-active: #0c0a09;
    --color-canvas: #f5f5f5;
    --color-canvas-soft: #fafafa;
    --color-canvas-deep: #0c0a09;
    --color-surface-card: #ffffff;
    --color-surface-strong: #f0efed;
    --color-surface-dark: #0c0a09;
    --color-surface-dark-elevated: #1c1917;
    --color-hairline: #e7e5e4;
    --color-hairline-soft: #f0efed;
    --color-hairline-strong: #d6d3d1;
    --color-ink: #0c0a09;
    --color-body: #4e4e4e;
    --color-body-strong: #292524;
    --color-muted: #777169;
    --color-muted-soft: #a8a29e;
    --color-on-primary: #ffffff;
    --color-on-dark: #ffffff;
    --color-on-dark-soft: #a8a29e;
    --color-gradient-mint: #a7e5d3;
    --color-gradient-peach: #f4c5a8;
    --color-gradient-lavender: #c8b8e0;
    --color-gradient-sky: #a8c8e8;
    --color-gradient-rose: #e8b8c4;
    --color-success: #16a34a;
    --color-error: #dc2626;
    --color-warning: #a16207;

    --font-display: "EB Garamond", "Noto Serif SC", "Songti SC", "Times New Roman", serif;
    --font-body: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;
    --space-section: 96px;

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-xxl: 24px;
    --radius-pill: 9999px;

    --shadow-soft: 0 4px 16px rgba(0, 0, 0, .04);
    --content-width: 1200px;
    --header-height: 64px;

    /* compatibility aliases used by functional JavaScript */
    --accent: var(--color-primary);
    --accent-color: var(--color-primary);
    --primary-color: var(--color-primary);
    --danger: var(--color-error);
    --danger-color: var(--color-error);
    --success: var(--color-success);
    --text-main: var(--color-ink);
    --text-sub: var(--color-muted);
    --text-muted: var(--color-muted-soft);
    --page-bg: var(--color-canvas);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--color-canvas); color-scheme: light; scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--color-canvas);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: .16px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body::before,
body::after {
    content: "";
    position: fixed;
    z-index: -2;
    width: min(48vw, 680px);
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(86px);
    opacity: .34;
    pointer-events: none;
}
body::before {
    top: -24vw;
    right: -10vw;
    background: radial-gradient(circle, var(--color-gradient-lavender) 0 28%, transparent 70%);
}
body::after {
    left: -18vw;
    bottom: -28vw;
    background: radial-gradient(circle, var(--color-gradient-mint) 0 28%, transparent 70%);
}

::selection { background: var(--color-gradient-peach); color: var(--color-ink); }
img, svg { max-width: 100%; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; }
button, [role="button"] { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--color-ink);
    outline-offset: 3px;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--color-ink);
    font-family: var(--font-display);
    font-weight: 300;
    text-wrap: balance;
}
h1 { font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1.05; letter-spacing: -.03em; }
h2 { font-size: clamp(1.8rem, 3vw, 2.25rem); line-height: 1.17; letter-spacing: -.01em; }
h3 { font-size: 1.5rem; line-height: 1.2; }
p { color: var(--color-body); }
small, .meta, .subtitle, .sub-title, .sub, .card-desc, .form-desc { color: var(--color-muted); }

/* ---------- Global navigation ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 2000;
    height: var(--header-height);
    border-bottom: 1px solid var(--color-hairline);
    background: var(--color-canvas);
}
.site-header__inner {
    width: min(calc(100% - 40px), var(--content-width));
    height: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-8);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--color-ink);
    text-decoration: none;
}
.brand__mark {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 34px;
    height: 34px;
    padding: 0 6px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--color-ink);
    color: var(--color-on-dark);
    font-family: var(--font-display);
    font-size: 14px;
    line-height: 1;
}
.brand__mark span:last-child { opacity: .58; transform: translateX(-2px); }
.brand__wordmark { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.desktop-nav { display: flex; align-items: center; justify-content: center; gap: 2px; }
.desktop-nav__link {
    position: relative;
    padding: 10px 14px;
    border-radius: var(--radius-pill);
    color: var(--color-body);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
}
.desktop-nav__link:hover,
.desktop-nav__link.is-active { color: var(--color-ink); }
.desktop-nav__link.is-active::after {
    content: "";
    position: absolute;
    right: 14px;
    bottom: 5px;
    left: 14px;
    height: 1px;
    background: var(--color-ink);
}
.site-header__actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--color-hairline-strong);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}
.nav-toggle span { display: block; width: 16px; height: 1px; margin: 5px auto; background: var(--color-ink); transition: transform .2s ease; }
.nav-open .nav-toggle span:first-child { transform: translateY(3px) rotate(45deg); }
.nav-open .nav-toggle span:last-child { transform: translateY(-3px) rotate(-45deg); }
.mobile-menu { display: none; }

/* ---------- Buttons ----------
 * Every native button is normalized here so browser-default rectangles can never
 * leak into a page again. Page-specific components only override layout/size.
 */
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.button,
.btn,
.btn-add,
.btn-manage,
.btn-act,
.btn-sm,
.btn-submit,
.btn-sso,
.btn-post,
.btn-toggle,
.btn-finish,
.btn-logout,
.primary,
.secondary,
.back,
.p-btn,
.text-btn,
.fm-btn,
.m-btn,
.search-btn,
.sm-btn,
.tiny-add,
.category-edit,
.category-toggle,
.tree-collapse-all,
.close-btn,
.nav-btn-text,
.btn-link,
.expand-others-btn,
.ext-link,
.pager a,
.pagination button {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 10px 18px;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transition:
        background-color .15s ease,
        border-color .15s ease,
        color .15s ease,
        opacity .15s ease,
        transform .15s ease,
        box-shadow .15s ease;
}
:where(button, input[type="button"], input[type="submit"], input[type="reset"]):hover:not(:disabled),
.button:hover,
.btn:hover,
.secondary:hover,
.back:hover,
.p-btn:hover,
.text-btn:hover,
.fm-btn:hover,
.m-sec:hover,
.btn-toggle:hover,
.btn-link:hover,
.expand-others-btn:hover,
.ext-link:hover,
.pager a:hover,
.pagination button:hover,
.btn-manage:hover,
.nav-btn-text:hover {
    border-color: var(--color-hairline-strong);
    background: var(--color-surface-strong);
    color: var(--color-ink);
}
:where(button, input[type="button"], input[type="submit"], input[type="reset"]):active:not(:disabled),
.button:active,
.btn:active {
    transform: translateY(1px);
}
:where(button, input[type="button"], input[type="submit"], input[type="reset"]):disabled,
.button[aria-disabled="true"] {
    opacity: .46;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary actions */
.button--primary,
.btn-add,
.btn-submit,
.btn-post,
.btn-finish,
.primary,
.save,
.m-primary,
.search-btn,
.sm-btn,
.btn-green,
.btn-positive,
.btn-solid-green,
.btn-solid-blue {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: var(--color-on-primary);
}
.button--primary:hover,
.btn-add:hover,
.btn-submit:hover,
.btn-post:hover,
.btn-finish:hover,
.primary:hover,
.save:hover,
.m-primary:hover,
.search-btn:hover,
.sm-btn:hover,
.btn-green:hover,
.btn-positive:hover,
.btn-solid-green:hover,
.btn-solid-blue:hover {
    border-color: var(--color-primary-active);
    background: var(--color-primary-active);
    color: var(--color-on-primary);
}

/* Quiet / secondary actions */
.button--outline,
.secondary,
.cancel,
.back,
.p-btn,
.text-btn,
.fm-btn,
.m-sec,
.btn-toggle,
.btn-link,
.expand-others-btn,
.ext-link,
.pager a,
.pagination button,
.btn-manage,
.nav-btn-text,
.btn-act,
.btn-sm,
.btn-sso,
.btn-text-undo {
    border-color: var(--color-hairline-strong);
    background: transparent;
    color: var(--color-ink);
}

/* Compact icon/text actions */
.button--text,
.close-btn,
.tiny-add,
.category-edit,
.category-toggle,
.tree-collapse-all {
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border-color: transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--color-body);
}
.button--text:hover,
.close-btn:hover,
.tiny-add:hover,
.category-edit:hover,
.category-toggle:hover,
.tree-collapse-all:hover {
    border-color: transparent;
    background: var(--color-surface-strong);
    color: var(--color-ink);
}

/* Destructive actions */
.btn-red,
.delete,
.btn-negative,
.btn-logout {
    border-color: color-mix(in srgb, var(--color-error) 30%, var(--color-hairline));
    background: transparent;
    color: var(--color-error);
}
.btn-red:hover,
.delete:hover,
.btn-negative:hover,
.btn-logout:hover {
    border-color: color-mix(in srgb, var(--color-error) 42%, var(--color-hairline));
    background: color-mix(in srgb, var(--color-error) 7%, transparent);
    color: var(--color-error);
}

.btn-text-undo { color: var(--color-body); }
.nav-toggle { padding: 0; border-radius: 50%; }
.is-pending { opacity: .65; pointer-events: none; }

/* ---------- Form controls ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea,
.search-input,
.search-inp,
.search-inp,
.sm-input,
.review-input,
.note-textarea,
.input-area,
.prompt-box {
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 12px 16px;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface-card);
    color: var(--color-ink);
    box-shadow: none;
    outline: 0;
}
textarea { min-height: 132px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--color-muted-soft); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
select:focus,
textarea:focus { border-color: var(--color-ink); box-shadow: 0 0 0 1px var(--color-ink); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-ink); }
input[type="file"] { padding: 10px; }
input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 8px 14px;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-ink);
    font-weight: 500;
    cursor: pointer;
}
label, .form-label, .field > label { color: var(--color-body-strong); font-size: 14px; font-weight: 500; }
.form-group, .field { display: grid; gap: 8px; margin-bottom: var(--space-5); }
.check-row, .label-row { display: flex; align-items: flex-start; gap: 10px; color: var(--color-body); }
.check-row input, .label-row input { margin-top: 4px; }

/* ---------- General page shell ---------- */
.page > .container,
.page-shell,
.page > main.page-shell {
    width: min(calc(100% - 40px), var(--content-width));
    margin-inline: auto;
    padding-top: var(--space-12);
    padding-bottom: var(--space-section);
}
.header,
.app-header,
.page-head,
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-8);
    margin-bottom: var(--space-12);
}
.page-title,
.user-info h1,
.page-head h1 { font-family: var(--font-display); font-size: clamp(2.5rem, 5vw, 4rem); font-weight: 300; line-height: 1.05; letter-spacing: -.03em; }
.user-info p, .title-block p, .page-head .sub { margin: 10px 0 0; max-width: 660px; color: var(--color-muted); }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); }
.eyebrow,
.algo-badge,
.badge,
.tag,
.preview-badge,
.status-badge,
.time-badge,
.restore-tag {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-strong);
    color: var(--color-body-strong);
    flex: 0 0 auto;
    max-width: 100%;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    hyphens: none;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}
.card,
.settings-card,
.info-card,
.search-card,
.stat-card,
.book-card,
.article-card,
.group-card,
.item-card,
.review-section,
.search-modal,
.modal,
.pane,
.auth-card {
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-xl);
    background: var(--color-surface-card);
    box-shadow: none;
}
.card:hover,
.stat-card:hover,
.book-card:hover,
.article-card:hover,
.group-card:hover,
.item-card:hover { border-color: var(--color-hairline-strong); box-shadow: var(--shadow-soft); }
.card { padding: var(--space-6); }
.notice,
.tip,
.error-msg,
.success-msg {
    padding: 12px 14px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg);
    background: var(--color-canvas-soft);
    color: var(--color-body);
    line-height: 1.6;
}
.error-msg { border-color: color-mix(in srgb, var(--color-error) 30%, var(--color-hairline)); color: var(--color-error); }
.success-msg { border-color: color-mix(in srgb, var(--color-success) 28%, var(--color-hairline)); color: var(--color-success); }
.empty,
.empty-state { grid-column: 1 / -1; padding: var(--space-12); border: 1px dashed var(--color-hairline-strong); border-radius: var(--radius-xl); color: var(--color-muted); text-align: center; }
.or { display: flex; align-items: center; gap: 12px; margin: var(--space-5) 0; color: var(--color-muted-soft); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--color-hairline); }
.pager, .pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); margin-top: var(--space-8); color: var(--color-muted); }

/* ---------- Footer ---------- */
.site-footer { width: min(calc(100% - 40px), var(--content-width)); margin: 0 auto; padding: var(--space-16) 0 var(--space-12); border-top: 1px solid var(--color-hairline); }
.site-footer__inner { display: grid; grid-template-columns: 1fr auto; gap: var(--space-8); align-items: end; }
.site-footer__brand { font-family: var(--font-display); font-size: 28px; text-decoration: none; }
.site-footer p { margin: 8px 0 0; font-size: 14px; }
.site-footer__links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 18px; }
.site-footer__links a { color: var(--color-body); font-size: 14px; text-decoration: none; }
.site-footer__links a:hover { color: var(--color-ink); }
.mobile-footer { display: none; }

/* ---------- Dashboard ---------- */
.page-index .app-header {
  width: min(calc(100% - 40px), var(--content-width));
  margin: 0 auto var(--space-12);
  padding: var(--space-16) 0 0;
}
.page-index .container {
  max-width: var(--content-width);
  padding-top: 0;
}
.search-card { position: relative; padding: var(--space-6); margin-bottom: var(--space-5); overflow: hidden; }
.search-card::after {
    content: "";
    position: absolute;
    z-index: 0;
    width: 260px;
    height: 260px;
    right: -90px;
    bottom: -140px;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--color-gradient-sky) 64%, transparent) 0, transparent 68%);
    pointer-events: none;
}
.search-card > * { position: relative; z-index: 1; }
.search-input-group { display: grid; grid-template-columns: 1fr auto; gap: var(--space-3); }
.search-results { display: grid; gap: var(--space-3); margin-top: var(--space-4); }
.result-section-title { padding-top: var(--space-3); border-top: 1px solid var(--color-hairline); color: var(--color-muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.result-item { padding: 14px 0; border-bottom: 1px solid var(--color-hairline-soft); }
.result-item:last-child { border-bottom: 0; }
.result-word { display: flex; align-items: baseline; gap: 8px; color: var(--color-ink); font-size: 18px; font-weight: 500; }
.result-def, .result-note { margin-top: 6px; color: var(--color-body); }
.external-links { display: flex; gap: 8px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin: var(--space-6) 0 var(--space-12); }
.stat-card { min-height: 210px; padding: var(--space-6); display: flex; flex-direction: column; justify-content: space-between; color: var(--color-ink); text-decoration: none; overflow: hidden; }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, white 70%, transparent); font-size: 20px; }
.stat-num { font-family: var(--font-display); font-size: clamp(3rem, 6vw, 4.8rem); font-weight: 300; line-height: .9; letter-spacing: -.05em; }
.stat-label { margin-top: 10px; color: var(--color-body); font-size: 14px; font-weight: 500; }
.stat-detail { margin-top: 6px; color: var(--color-muted); font-size: 12px; line-height: 1.45; letter-spacing: .02em; }
.section-title { margin: var(--space-12) 0 var(--space-4); font-family: var(--font-display); font-size: 32px; font-weight: 300; }
.menu-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.menu-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-4); min-height: 88px; padding: var(--space-5); border: 1px solid var(--color-hairline); border-radius: var(--radius-xl); background: var(--color-surface-card); color: var(--color-ink); text-decoration: none; }
.menu-item:hover { border-color: var(--color-hairline-strong); box-shadow: var(--shadow-soft); }
.menu-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--color-surface-strong); font-size: 20px; }
.menu-text { font-weight: 500; }
.menu-arrow { color: var(--color-muted-soft); font-size: 22px; }

/* ---------- Library ---------- */
.page-library .container { max-width: var(--content-width); }
.search-box { display: flex; align-items: center; gap: 8px; min-width: min(360px, 100%); }
.search-icon { color: var(--color-muted-soft); }
.library-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--space-8); align-items: start; }
.category-panel { position: sticky; top: calc(var(--header-height) + 24px); border-top: 1px solid var(--color-hairline-strong); }
.category-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 4px 14px; }
.category-head strong { font-family: var(--font-display); font-size: 22px; font-weight: 300; }
.category-head-actions { display: inline-flex; align-items: center; gap: 2px; }
.category-list { display: grid; gap: 2px; }
.category-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 38px;
    align-items: center;
    min-width: 0;
    padding-left: calc(var(--depth, 0) * 16px);
    border-radius: var(--radius-lg);
}
.category-row[hidden] { display: none !important; }
.category-row[data-depth="1"] { --depth: 1; }
.category-row[data-depth="2"] { --depth: 2; }
.category-row[data-depth="3"] { --depth: 3; }
.category-row[data-depth="4"] { --depth: 4; }
.category-row[data-depth="5"] { --depth: 5; }
.category-row[data-depth="6"] { --depth: 6; }
.category-row[data-depth="7"] { --depth: 7; }
.category-row.active { background: var(--color-surface-strong); }
.category-toggle,
.category-toggle-spacer {
    width: 30px;
    height: 38px;
    min-width: 30px;
}
.category-toggle { position: relative; }
.category-toggle::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translate(-1px, -1px) rotate(-45deg);
    transition: transform .16s ease;
}
.category-toggle[aria-expanded="true"]::before {
    transform: translateY(-2px) rotate(45deg);
}
.category-link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 8px;
    color: var(--color-body);
    text-decoration: none;
}
.category-row.active .category-link { color: var(--color-ink); font-weight: 500; }
.category-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-count { color: var(--color-muted-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
.category-edit { font-size: 20px; line-height: 1; letter-spacing: 1px; }
.tree-divider { height: 1px; margin: 8px 0; background: var(--color-hairline); }
.category-note { margin-top: 14px; color: var(--color-muted); font-size: 13px; line-height: 1.55; }
.content-area { min-width: 0; }
.filter-title { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--color-hairline); color: var(--color-muted); font-size: 14px; }
.category-learning-batch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: -2px 0 18px;
    padding: 16px 18px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-xl);
    background: var(--color-surface-card);
}
.category-learning-batch__copy { display: grid; gap: 4px; min-width: 0; }
.category-learning-batch__copy strong { color: var(--color-ink); font-size: 15px; font-weight: 500; }
.category-learning-batch__copy span { color: var(--color-muted); font-size: 12px; line-height: 1.5; }
.category-learning-batch__status { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex: 0 0 auto; }
.category-learning-batch__status > span { color: var(--color-body); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.category-learning-batch__actions { display: inline-flex; align-items: center; gap: 8px; }
.category-learning-batch__actions .btn-sm { min-height: 36px; padding: 8px 14px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.book-card { min-width: 0; min-height: 290px; padding: var(--space-5); display: flex; flex-direction: column; }
.book-link { flex: 1; color: inherit; text-decoration: none; }
.tag-row { min-height: 26px; }
.tag-pub, .st-published { color: var(--color-success); }
.tag-pending, .st-pending { color: var(--color-warning); }
.tag-priv, .st-private { color: var(--color-muted); }
.book-title { margin-top: 20px; font-family: var(--font-display); font-size: 26px; font-weight: 300; line-height: 1.1; }
.book-desc { min-height: 48px; margin-top: 10px; color: var(--color-body); font-size: 14px; line-height: 1.55; }
.word-count { margin-top: 20px; font-family: var(--font-display); font-size: 48px; font-weight: 300; line-height: 1; }
.book-author { margin-top: 6px; color: var(--color-muted); font-size: 12px; }
.organize-row, .toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--color-hairline-soft); }
.organize-row label, .toggle-label { color: var(--color-muted); font-size: 12px; }
.category-select { width: min(160px, 56%); min-height: 36px; padding: 8px 10px; font-size: 13px; }
.category-readonly { max-width: 62%; color: var(--color-body-strong); font-size: 13px; line-height: 1.35; text-align: right; overflow-wrap: anywhere; }
.page-admin-books .actions .category-select { width: min(220px, 100%); min-width: 150px; }
.switch { position: relative; display: inline-flex; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.slider { position: absolute; inset: 0; border: 1px solid var(--color-hairline-strong); border-radius: var(--radius-pill); background: var(--color-surface-strong); transition: .2s ease; }
.slider::before { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--color-surface-card); box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: .2s ease; }
.switch input:checked + .slider { background: var(--color-ink); border-color: var(--color-ink); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.import-card { align-items: center; justify-content: center; border-style: dashed; background: transparent; color: var(--color-body); text-decoration: none; }
.plus { font-family: var(--font-display); font-size: 52px; font-weight: 300; }
.modal-backdrop, .modal-overlay, .search-modal-overlay { position: fixed; inset: 0; z-index: 4000; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(12,10,9,.48); }
.modal-backdrop.open, .modal-overlay.open, .search-modal-overlay.open { display: grid; }
.modal { width: min(100%, 520px); padding: var(--space-8); }
.modal h2, .modal h3 { margin-bottom: 8px; }
.modal p { margin: 0 0 20px; }
.modal > label { display: block; margin: 16px 0 8px; }
.modal-actions, .modal-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.modal-actions > button,
.modal-btns > button { min-width: 88px; }
.modal-actions .delete { order: -1; margin-right: auto; }
#deleteCategoryButton { display: none; }
.toast { position: fixed; z-index: 6000; left: 50%; bottom: 28px; transform: translate(-50%, 24px); padding: 10px 16px; border-radius: var(--radius-pill); background: var(--color-surface-dark); color: var(--color-on-dark); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Article library ---------- */
.page-article-library .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.article-card { min-height: 250px; padding: var(--space-6); display: flex; flex-direction: column; cursor: pointer; }
.art-top { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 12px; }
.art-title { flex: 1 1 auto; min-width: 0; max-width: none; font-family: var(--font-display); font-size: 28px; font-weight: 300; line-height: 1.15; overflow-wrap: anywhere; }
.art-top > .badge { margin-top: 2px; }
.art-preview { flex: 1; margin-top: 26px; color: var(--color-body); line-height: 1.7; }
.art-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--color-hairline); color: var(--color-muted); font-size: 12px; }
.art-footer .btn-sm { min-height: 32px; padding: 7px 12px; }

/* ---------- Memory groups ---------- */
.page-memory-groups .page-title { margin-bottom: 32px; }
.search-bar { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 24px; }
#groupsList { display: grid; gap: 14px; }
.group-card { padding: 22px 24px; }
.word-pair { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-icon { color: var(--color-muted-soft); }
.group-card .definition { margin-top: 8px; color: var(--color-body); }

/* ---------- Upload management & moderation ---------- */
.page-admin-books .list,
.page-admin-content #batchForm { display: grid; gap: 12px; }
.item-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; padding: 20px 22px; }
.item-title { font-family: var(--font-display); font-size: 24px; font-weight: 300; }
.item-meta, .card-meta { margin-top: 6px; color: var(--color-muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.page-admin-content .tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--color-hairline); border-radius: var(--radius-pill); background: var(--color-surface-card); }
.page-admin-content .tab { display: inline-flex; min-height: 36px; align-items: center; padding: 8px 16px; border-radius: var(--radius-pill); color: var(--color-body); text-decoration: none; }
.page-admin-content .tab.active { background: var(--color-ink); color: var(--color-on-dark); }
.admin-filter { display: grid; grid-template-columns: 1fr 180px auto; gap: 10px; margin-bottom: 22px; }
.page-admin-content .card { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 18px 20px; }
.card-checkbox { margin-top: 5px; }
.card-content { margin-top: 8px; color: var(--color-body); }
.batch-bar { position: sticky; bottom: 18px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding: 12px 16px; border: 1px solid var(--color-hairline-strong); border-radius: var(--radius-pill); background: var(--color-surface-card); box-shadow: var(--shadow-soft); }

/* ---------- Import pages ---------- */
.page-admin-upload .page-shell,
.page-admin-article-upload .page-shell { padding-top: var(--space-16); }
.page-admin-upload .page-head,
.page-admin-article-upload .page-head { display: block; max-width: 840px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr); gap: var(--space-5); align-items: start; }
.layout > .card { padding: var(--space-8); }
.layout > aside.card { position: sticky; top: calc(var(--header-height) + 24px); }
.prompt-box { min-height: 480px; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; background: var(--color-canvas-soft); }
.prompt-actions { display: flex; gap: 10px; margin-top: 12px; }
.status { min-height: 22px; margin-top: 8px; color: var(--color-success); font-size: 13px; }
.page-admin-upload textarea#import_text,
.page-admin-article-upload textarea#import_text { min-height: 330px; font-family: var(--font-mono); font-size: 13px; }

/* ---------- Settings ---------- */
.page-settings .container { max-width: 840px; }
.settings-card { padding: var(--space-8); }
.settings-card + .settings-card { margin-top: 16px; }
.settings-card h2 { margin-bottom: 22px; }
.form-group { padding: 16px 0; border-bottom: 1px solid var(--color-hairline-soft); }
.form-group:last-child { border-bottom: 0; }
.switch-container { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
input[type="range"] { width: 100%; accent-color: var(--color-ink); }

/* ---------- Book preview ---------- */
.page-book-preview .container { max-width: 1020px; }
.back-link { display: inline-flex; margin-bottom: 24px; color: var(--color-body); text-decoration: none; }
.info-card { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 30px; align-items: end; padding: var(--space-8); overflow: hidden; }
.info-card::after { content: ""; position: absolute; right: -80px; top: -100px; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle, var(--color-gradient-peach), transparent 68%); opacity: .48; }
.info-card > * { position: relative; z-index: 1; }
.info-card .book-title { margin-top: 0; font-size: clamp(2.5rem, 5vw, 4rem); }
.big-num { font-family: var(--font-display); font-size: 72px; font-weight: 300; line-height: .8; }
.review-section { margin-top: 20px; overflow: hidden; }
.review-header { display: flex; justify-content: space-between; gap: 16px; padding: 18px 22px; cursor: pointer; }
.review-body { padding: 0 22px 22px; }
.review-input-group { display: grid; gap: 10px; }
.review-item { padding: 16px 0; border-top: 1px solid var(--color-hairline); }
.review-meta { color: var(--color-muted); font-size: 12px; }
.review-status-tag,
.meta-status {
    display: inline-flex;
    width: max-content;
    max-width: 100%;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-strong);
    color: var(--color-body-strong);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    vertical-align: middle;
}
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 32px 0 12px; }
.data-table { width: 100%; border-collapse: collapse; border: 1px solid var(--color-hairline); border-radius: var(--radius-xl); overflow: hidden; background: var(--color-surface-card); }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid var(--color-hairline-soft); text-align: left; vertical-align: top; }
.data-table th { color: var(--color-muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.hl { font-weight: 600; }

/* ---------- Summary ---------- */
.page-study-summary .container { max-width: 760px; padding-top: var(--space-16); }
.page-study-summary .header { display: block; text-align: center; }
.page-study-summary .page-title { font-size: clamp(3rem, 8vw, 5rem); }
.page-study-summary .list { display: grid; gap: 10px; }
.page-study-summary .item { padding: 18px 20px; border: 1px solid var(--color-hairline); border-radius: var(--radius-xl); background: var(--color-surface-card); }
.item-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-study-summary .word { font-family: var(--font-display); font-size: 24px; }
.page-study-summary .definition { margin-top: 10px; color: var(--color-body); }
.btn-finish { width: 100%; margin-top: 28px; }

/* ---------- Authentication ---------- */
.page-login,
.page-register { display: grid; min-height: 100vh; place-items: center; padding: 40px 20px; overflow: hidden; }
.page-login::before,
.page-register::before { top: -220px; right: -120px; opacity: .58; }
.page-login::after,
.page-register::after { left: -180px; bottom: -220px; background: radial-gradient(circle, var(--color-gradient-peach) 0 28%, transparent 70%); opacity: .46; }
.auth-card { position: relative; width: min(100%, 480px); padding: 48px; overflow: hidden; }
.auth-card::before { content: ""; position: absolute; top: -100px; right: -120px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, var(--color-gradient-sky), transparent 68%); opacity: .4; }
.auth-card > * { position: relative; z-index: 1; }
.auth-card .logo { width: 42px; height: 42px; margin-bottom: 34px; }
.auth-card h1 { font-size: 48px; }
.auth-card .sub-title { margin: 10px 0 30px; }
.auth-card form { display: grid; gap: 4px; }
.auth-card .btn-submit { width: 100%; margin-top: 8px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--color-muted-soft); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--color-hairline); }
.sso-actions { display: grid; }
.btn-sso { background: transparent; border-color: var(--color-hairline-strong); color: var(--color-ink); }
.auth-card .footer { margin-top: 26px; color: var(--color-muted); text-align: center; }
.auth-card .footer a { color: var(--color-ink); font-weight: 500; }

/* ---------- Word study ---------- */
.page-study { min-height: 100vh; overflow-x: hidden; }
.page-study::before { background: radial-gradient(circle, var(--color-gradient-sky) 0 28%, transparent 70%); }
.page-study .progress-bar-container { position: fixed; inset: 0 0 auto; z-index: 3000; height: 3px; background: var(--color-hairline); }
.page-study .progress-bar { width: 0; height: 100%; background: var(--color-ink); transition: width .25s ease; }
.page-study .navbar,
.page-study-article .navbar { width: min(calc(100% - 40px), var(--content-width)); min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--color-hairline); }
.page-study .navbar > div { display: flex; align-items: center; gap: 15px; }
.close-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 22px; }
.page-study .stage { width: min(calc(100% - 40px), 760px); margin: 0 auto; padding: 42px 0 64px; }
.mode-switcher { display: flex; width: fit-content; max-width: 100%; margin: 0 auto 24px; padding: 4px; border: 1px solid var(--color-hairline); border-radius: var(--radius-pill); background: var(--color-surface-card); }
.mode-opt { padding: 9px 15px; border-radius: var(--radius-pill); color: var(--color-muted); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.mode-opt.active { background: var(--color-ink); color: var(--color-on-dark); }
#planTip { display: none; max-width: 520px; margin: 0 auto 16px; padding: 8px 12px; border: 1px solid var(--color-hairline); border-radius: var(--radius-pill); background: var(--color-surface-card); color: var(--color-warning); font-size: 13px; text-align: center; }
.card-container { position: relative; min-height: 480px; perspective: 1600px; cursor: pointer; }
.card-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 46px; border: 1px solid var(--color-hairline); border-radius: var(--radius-xxl); background: var(--color-surface-card); backface-visibility: hidden; transform-style: preserve-3d; transition: transform .48s cubic-bezier(.2,.8,.2,1); }
.card-face.front::after { content: ""; position: absolute; z-index: -1; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--color-gradient-lavender) 62%, transparent), transparent 68%); }
.card-face.back { transform: rotateY(180deg); overflow-y: auto; justify-content: flex-start; }
.card-container.flipped .front { transform: rotateY(-180deg); }
.card-container.flipped .back { transform: rotateY(0); }
#t-main { font-family: var(--font-display); font-size: clamp(3rem, 10vw, 6rem); font-weight: 300; text-align: center; }
.hint { margin-top: 16px; color: var(--color-muted); }
.btn-master {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    appearance: none;
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    gap: 7px;
    padding: 7px 13px 7px 8px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--color-surface-card) 88%, transparent);
    color: var(--color-muted);
    box-shadow: 0 1px 0 rgba(12, 10, 9, .03);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: border-color .16s ease, background-color .16s ease, color .16s ease, transform .16s ease;
}
.btn-master__icon {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    background: var(--color-surface-strong);
    color: var(--color-body-strong);
    font-size: 12px;
    transition: background-color .16s ease, color .16s ease;
}
.btn-master:hover {
    border-color: var(--color-hairline-strong);
    background: var(--color-surface-card);
    color: var(--color-ink);
    transform: translateY(-1px);
}
.btn-master:hover .btn-master__icon { background: var(--color-ink); color: var(--color-on-dark); }
.btn-master:active { transform: none; }
.word-sm { font-family: var(--font-display); font-size: 42px; }
.phonetic { margin-top: 4px; color: var(--color-muted); font-family: var(--font-mono); }
.def { margin-top: 24px; font-size: 20px; line-height: 1.6; text-align: center; }
.ex { margin-top: 18px; color: var(--color-body); font-style: italic; text-align: center; }
.note-toggle { margin-top: 28px; color: var(--color-body); cursor: pointer; }
.note-area { display: none; width: 100%; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--color-hairline); }
.note-area.open { display: block; }
.note-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.status-saved { color: var(--color-success); font-size: 12px; opacity: 0; }
.status-saved.show { opacity: 1; }
.other-notes-list { display: grid; gap: 8px; margin-top: 12px; }
.controls { margin-top: 20px; }
.btn-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#group-confirm, #group-force { display: none; }
#group-force { grid-template-columns: 1fr; }
.controls .btn { min-height: 52px; }
.search-modal-overlay { display: none; }
.search-modal-overlay.open { display: grid; }
.search-modal { width: min(100%, 680px); max-height: min(80vh, 720px); padding: 24px; overflow: hidden; }
.sm-header { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.sm-body { max-height: 58vh; overflow-y: auto; margin-top: 16px; }

/* ---------- Article study ---------- */
.page-study-article {
    display: grid;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: 72px minmax(0, 1fr);
    overflow: hidden;
}
.page-study-article::before { background: radial-gradient(circle, var(--color-gradient-rose) 0 28%, transparent 70%); }
.page-study-article .navbar {
    width: min(calc(100% - 40px), var(--content-width));
    min-height: 0;
    height: 72px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--color-hairline);
}
.nav-title { min-width: 0; overflow: hidden; font-family: var(--font-display); font-size: 24px; white-space: nowrap; text-overflow: ellipsis; }
.nav-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.page-study-article .article-workspace {
    width: min(calc(100% - 40px), var(--content-width));
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    padding: 20px 0;
    display: grid;
    grid-template-columns: minmax(0, 1.16fr) minmax(340px, .84fr);
    gap: 16px;
    overflow: hidden;
}
.article-pane {
    height: 100%;
    min-height: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.mode-tabs {
    display: flex;
    flex: none;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-pill);
    background: var(--color-canvas-soft);
}
.mode-tabs .tab {
    appearance: none;
    flex: 1;
    min-width: 0;
    min-height: 40px;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-muted);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.mode-tabs .tab:hover { color: var(--color-ink); }
.mode-tabs .tab.active { background: var(--color-ink); color: var(--color-on-dark); box-shadow: 0 1px 2px rgba(12, 10, 9, .12); }
.article-panel-stack {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}
.reader-surface {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg);
    background: var(--color-surface-card);
}
.reader-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 24px 28px 20px;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
}
.ref-content {
    min-height: 100%;
    padding: 0;
    color: var(--color-ink);
    font-family: var(--font-display);
    font-size: clamp(20px, 1.55vw, 24px);
    font-weight: 300;
    line-height: 1.86;
    white-space: pre-wrap;
    transform-origin: center;
}
.ref-content.blur-mode {
    filter: blur(12px);
    opacity: .16;
    transform: scale(1.008);
    user-select: none;
    transition: filter .2s ease, opacity .2s ease, transform .2s ease;
}
.reader-scroll:hover .ref-content.blur-mode,
.ref-content.blur-mode:focus-visible,
.phrase-stage:hover .ref-content.blur-mode {
    filter: blur(0);
    opacity: 1;
    transform: none;
    user-select: text;
}
.reader-toolbar {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px 11px 16px;
    border-top: 1px solid var(--color-hairline);
    background: var(--color-canvas-soft);
}
.reader-toolbar__hint {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    color: var(--color-muted);
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.reader-toolbar__dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--color-gradient-rose); }
.reader-toolbar__actions { display: flex; flex: none; align-items: center; gap: 6px; }
.reader-control { min-height: 34px; padding: 8px 12px; font-size: 12px; }
.trans-box {
    display: none;
    flex: none;
    max-height: min(32vh, 300px);
    margin-top: 12px;
    padding: 17px 18px;
    overflow: auto;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg);
    background: var(--color-canvas-soft);
    color: var(--color-body);
    line-height: 1.8;
    overscroll-behavior: contain;
}
.trans-box.show { display: block; }
#phrase-wrapper { display: none; }
.phrase-nav { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.phrase-index { color: var(--color-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.phrase-stage {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 28px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg);
    background: var(--color-canvas-soft);
    overscroll-behavior: contain;
}
#phrase-target { min-height: auto; margin: 0 0 20px; font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.2; text-align: center; }
#phrase-trans { color: var(--color-body); font-size: 18px; text-align: center; }
.practice-panel { flex: 1; min-height: 0; }
#right-recite { display: flex; flex-direction: column; }
.dictation-head {
    display: flex;
    flex: none;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 0 2px 12px;
}
.dictation-head > div:first-child { display: grid; gap: 2px; }
.dictation-head strong { color: var(--color-body-strong); font-size: 14px; font-weight: 500; }
.dictation-kicker { color: var(--color-muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.score-number { color: var(--color-ink); font-family: var(--font-display); font-size: 32px; font-variant-numeric: tabular-nums; line-height: 1; }
.score-number small { margin-left: 2px; color: var(--color-muted); font-family: var(--font-body); font-size: 12px; }
.input-area {
    flex: 1;
    min-height: 0;
    resize: none;
    overflow: auto;
    padding: 20px;
    border-radius: var(--radius-lg);
    font-family: var(--font-display);
    font-size: clamp(18px, 1.3vw, 21px);
    line-height: 1.82;
    overscroll-behavior: contain;
}
.score-box { display: grid; flex: none; grid-template-columns: 1fr auto; align-items: center; gap: 12px; margin-top: 12px; }
.score-bar { height: 5px; overflow: hidden; border-radius: var(--radius-pill); background: var(--color-surface-strong); }
.score-fill { width: 0; height: 100%; background: var(--color-ink); transition: width .2s ease; }
.score-caption { color: var(--color-muted); font-size: 11px; letter-spacing: .04em; }
.score-text { display: none; }
.tool-list {
    display: none;
    flex-direction: column;
    gap: 26px;
    overflow: auto;
    padding: 2px 4px 8px 2px;
    overscroll-behavior: contain;
}
.tool-section { display: grid; gap: 8px; }
.tool-section + .tool-section { padding-top: 22px; border-top: 1px solid var(--color-hairline); }
.tool-section__head { display: grid; gap: 2px; padding-bottom: 4px; }
.tool-section__head strong { font-size: 14px; font-weight: 500; }
.tool-section__head span { color: var(--color-muted); font-size: 12px; }
.note-item, .scheme-item, .other-note-item { padding: 14px 0; border-bottom: 1px solid var(--color-hairline); }
.note-quote { margin-top: 6px; color: var(--color-body); }
.reader-scroll,
.trans-box,
.input-area,
.tool-list,
.phrase-stage { scrollbar-width: thin; scrollbar-color: var(--color-hairline-strong) transparent; }
.reader-scroll::-webkit-scrollbar,
.trans-box::-webkit-scrollbar,
.input-area::-webkit-scrollbar,
.tool-list::-webkit-scrollbar,
.phrase-stage::-webkit-scrollbar { width: 8px; height: 8px; }
.reader-scroll::-webkit-scrollbar-thumb,
.trans-box::-webkit-scrollbar-thumb,
.input-area::-webkit-scrollbar-thumb,
.tool-list::-webkit-scrollbar-thumb,
.phrase-stage::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: var(--radius-pill); background: var(--color-hairline-strong); background-clip: padding-box; }
#float-menu { position: fixed; z-index: 5000; display: none; align-items: center; gap: 2px; padding: 6px; border-radius: var(--radius-pill); background: var(--color-surface-dark); color: var(--color-on-dark); box-shadow: 0 8px 28px rgba(0,0,0,.2); }
#float-menu .fm-btn { min-height: 34px; border: 0; color: var(--color-on-dark); }
#color-picker { position: absolute; top: calc(100% + 8px); left: 0; display: none; gap: 7px; padding: 9px; border: 1px solid var(--color-hairline); border-radius: var(--radius-pill); background: var(--color-surface-card); }
.cp-dot { width: 24px; height: 24px; border: 1px solid rgba(12,10,9,.12); border-radius: 50%; cursor: pointer; }
.cp-dot:nth-child(1) { background: #fff176; }
.cp-dot:nth-child(2) { background: #ffcdd2; }
.cp-dot:nth-child(3) { background: #c8e6c9; }
.cp-dot:nth-child(4) { background: #bbdefb; }
.cp-dot:nth-child(5) { display: grid; place-items: center; background: white; color: var(--color-error); font-size: 12px; }
#note-modal, #scheme-modal, #guide-modal { display: none; }
#note-modal.open, #scheme-modal.open, #guide-modal.open { display: grid; }
.guide-list { display: grid; gap: 12px; }
.guide-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--color-surface-strong); }
.guide-content { flex: 1; }
.guide-title { font-weight: 500; }
.guide-list > li { display: flex; gap: 12px; list-style: none; }
.page-study-article .modal-overlay { overflow: auto; overscroll-behavior: contain; }
.page-study-article .modal { max-height: calc(100dvh - 32px); overflow: auto; }

/* ---------- AJAX & calm motion ---------- */
#ajax-progress-bar { position: fixed; left: 0; top: 0; z-index: 2147483647; width: 0; height: 2px; background: var(--color-ink); opacity: 0; pointer-events: none; transition: width .22s ease, opacity .18s ease; }
html.ajax-busy { cursor: progress; }
.calm-reveal { opacity: 0; transform: translateY(8px); }
.calm-reveal.is-visible { opacity: 1; transform: none; transition: opacity .45s ease, transform .45s ease; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .desktop-nav { gap: 0; }
    .desktop-nav__link { padding-inline: 9px; }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid, .page-article-library .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-study-article .article-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1.08fr) minmax(0, .92fr);
    }
    .layout { grid-template-columns: 1fr; }
    .layout > aside.card { position: static; }
}

@media (max-width: 767px) {
  .page-index .app-header {
    width: min(calc(100% - 28px), var(--content-width));
    margin-bottom: var(--space-8);
    padding-top: var(--space-12);
  }

    :root { --header-height: 60px; }
    body::before, body::after { width: 560px; filter: blur(100px); opacity: .26; }
    .site-header__inner { width: min(calc(100% - 28px), var(--content-width)); grid-template-columns: 1fr auto; }
    .desktop-nav, .header-import { display: none; }
    .nav-toggle { display: block; }
    .mobile-menu {
        position: fixed;
        inset: var(--header-height) 0 auto;
        z-index: 1999;
        display: grid;
        grid-template-rows: 1fr auto;
        height: calc(100dvh - var(--header-height));
        padding: 22px 20px max(22px, env(safe-area-inset-bottom));
        background: var(--color-canvas);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity .18s ease, transform .18s ease, visibility .18s;
    }
    .nav-open { overflow: hidden; }
    .nav-open .mobile-menu { opacity: 1; visibility: visible; transform: none; }
    .mobile-menu__nav { display: grid; align-content: start; }
    .mobile-menu__link { display: flex; justify-content: space-between; gap: 16px; padding: 17px 2px; border-bottom: 1px solid var(--color-hairline); font-family: var(--font-display); font-size: 30px; font-weight: 300; text-decoration: none; }
    .mobile-menu__link.is-active { color: var(--color-muted); }
    .mobile-menu__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .page > .container, .page-shell, .page > main.page-shell { width: min(calc(100% - 28px), var(--content-width)); padding-top: 34px; }
    .header, .app-header, .page-head { align-items: flex-start; flex-direction: column; margin-bottom: 34px; }
    .header-actions { width: 100%; justify-content: flex-start; }
    .library-layout { grid-template-columns: 1fr; }
    .category-panel { position: static; }
    .category-list {
        max-height: min(42dvh, 360px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 0 2px 8px;
        scrollbar-gutter: stable;
    }
    .category-row { padding-left: calc(var(--depth, 0) * 14px); }
    .category-note { display: none; }
    .category-learning-batch { align-items: stretch; flex-direction: column; gap: 12px; padding: 14px; }
    .category-learning-batch__status { justify-content: space-between; gap: 10px; }
    .category-learning-batch__actions { flex: 1; justify-content: flex-end; }
    .menu-list { grid-template-columns: 1fr; }
    .site-footer__inner { grid-template-columns: 1fr; }
    .site-footer__links { justify-content: flex-start; }
    .page-study .navbar, .page-study-article .navbar { width: calc(100% - 28px); }
    .page-study .stage { width: calc(100% - 28px); padding-top: 28px; }
    .page-study-article { grid-template-rows: 60px minmax(0, 1fr); }
    .page-study-article .navbar { height: 60px; }
    .page-study-article .article-workspace {
        width: calc(100% - 16px);
        padding: 8px 0;
        gap: 8px;
        grid-template-rows: minmax(0, 1.06fr) minmax(0, .94fr);
    }
    .article-pane { padding: 12px; border-radius: var(--radius-lg); }
    .mode-tabs { margin-bottom: 9px; }
    .mode-tabs .tab { min-height: 36px; padding: 7px 9px; }
    .reader-scroll { padding: 16px 17px 14px; }
    .reader-toolbar { align-items: flex-start; flex-direction: column; gap: 7px; padding: 9px 10px; }
    .reader-toolbar__hint { width: 100%; }
    .reader-toolbar__actions { width: 100%; }
    .reader-control { flex: 1; }
    .dictation-head { margin-bottom: 8px; }
    .input-area { padding: 15px; }
}

@media (max-width: 639px) {
    .category-learning-batch__status { align-items: stretch; flex-direction: column; }
    .category-learning-batch__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .category-learning-batch__actions .btn-sm { width: 100%; }
    h1, .page-title, .user-info h1, .page-head h1 { font-size: 2.35rem; }
    h2 { font-size: 1.7rem; }
    .page > .container, .page-shell, .page > main.page-shell { padding-bottom: 64px; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { min-height: 170px; padding: 18px; }
    .stat-num { font-size: 3.1rem; }
    .search-input-group, .search-bar, .admin-filter { grid-template-columns: 1fr; }
    .search-input-group .search-btn, .search-bar button, .admin-filter button { width: 100%; }
    .grid, .page-article-library .grid { grid-template-columns: 1fr; }
    .book-card { min-height: 250px; }
    .layout > .card { padding: 22px; }
    .prompt-box { min-height: 360px; }
    .auth-card { padding: 34px 24px; }
    .auth-card h1 { font-size: 40px; }
    .info-card { grid-template-columns: 1fr; }
    .info-card > :last-child { text-align: left; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .data-table { display: block; overflow-x: auto; white-space: nowrap; }
    .item-card { grid-template-columns: 1fr; }
    .actions { justify-content: flex-start; }
    .batch-bar { align-items: stretch; flex-direction: column; border-radius: var(--radius-xl); }
    .batch-bar > div { display: grid; grid-template-columns: repeat(3, 1fr); }
    .page-study .card-container { min-height: 450px; }
    .card-face { padding: 34px 22px; }
    .mode-switcher { width: 100%; overflow-x: auto; }
    .mode-opt { flex: 1; text-align: center; }
    .btn-group { grid-template-columns: 1fr; }
    .page-study-article .article-workspace { width: calc(100% - 12px); padding: 6px 0; }
    .nav-title { max-width: 48vw; font-size: 20px; }
    .nav-btn-text span { display: none; }
    .nav-btn-text { min-height: 36px; padding: 8px 11px; font-size: 12px; }
    .ref-content { font-size: 19px; }
    .input-area { min-height: 320px; }
    .site-footer { width: calc(100% - 28px); padding-top: 48px; }
}

@media (max-height: 760px) and (min-width: 1101px) {
    .page-study-article .article-workspace { padding: 12px 0; }
    .article-pane { padding: 16px; }
    .mode-tabs { margin-bottom: 10px; }
    .reader-scroll { padding-block: 17px; }
}

@media (max-width: 900px) and (orientation: landscape) {
    .page-study-article .article-workspace {
        grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr);
        grid-template-rows: 1fr;
    }
    .reader-toolbar__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
    .calm-reveal { opacity: 1; transform: none; }
}

/* Compact labels are atomic UI units: never split Chinese or English status text. */
:where(
    .eyebrow,
    .algo-badge,
    .badge,
    .tag,
    .preview-badge,
    .status-badge,
    .time-badge,
    .restore-tag,
    .note-status,
    .listen-label,
    .score-caption,
    .category-count,
    .review-status-tag,
    .meta-status,
    .page-admin-content .tab,
    .mode-tabs .tab,
    .filter-title > span:last-child,
    .pager > span
) {
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
    hyphens: none;
}

/* Keep status chips visible while allowing adjacent titles to take the remaining width. */
:where(.badge, .tag, .status-badge, .time-badge, .preview-badge, .restore-tag) {
    flex-shrink: 0;
}

.page-admin-books .item-info > div:first-child {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}
.page-admin-books .item-title { min-width: 0; overflow-wrap: anywhere; }

/* Functional state variants */
.status-badge--new { color: var(--color-body-strong); background: color-mix(in srgb, var(--color-gradient-mint) 36%, var(--color-surface-strong)); }
.status-badge--review { color: var(--color-body-strong); background: color-mix(in srgb, var(--color-gradient-peach) 36%, var(--color-surface-strong)); }
.note-status--published { color: var(--color-success); }
.note-status--pending { color: var(--color-warning); }
.note-status--private { color: var(--color-muted); }
.score-fill.score-low { background: var(--color-error); }
.score-fill.score-mid { background: var(--color-warning); }
.score-fill.score-high { background: var(--color-success); }

.header-logout { margin: 0; }
.stat-card { position: relative; background: var(--color-surface-card) !important; }
.stat-card::after {
    content: "";
    position: absolute;
    z-index: 0;
    right: -88px;
    bottom: -115px;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    opacity: .48;
    pointer-events: none;
}
.stat-card:nth-child(1)::after { background: radial-gradient(circle, var(--color-gradient-rose), transparent 67%); }
.stat-card:nth-child(2)::after { background: radial-gradient(circle, var(--color-gradient-mint), transparent 67%); }
.stat-card:nth-child(3)::after { background: radial-gradient(circle, var(--color-gradient-peach), transparent 67%); }
.stat-card:nth-child(4)::after { background: radial-gradient(circle, var(--color-gradient-lavender), transparent 67%); }
.stat-card > * { position: relative; z-index: 1; }
.stat-icon { color: var(--color-muted); font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; }
.menu-icon { color: var(--color-body); font-family: var(--font-display); font-size: 18px; }
.audio-btn {
    appearance: none;
    display: inline-grid;
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--color-hairline);
    border-radius: 50%;
    background: var(--color-surface-card);
    color: var(--color-body);
    vertical-align: middle;
    cursor: pointer;
}
.audio-btn::before {
    content: "";
    width: 15px;
    height: 15px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4Z' fill='black'/%3E%3Cpath d='M16 8.2a5.2 5.2 0 0 1 0 7.6M18.7 5.8a8.5 8.5 0 0 1 0 12.4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4Z' fill='black'/%3E%3Cpath d='M16 8.2a5.2 5.2 0 0 1 0 7.6M18.7 5.8a8.5 8.5 0 0 1 0 12.4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.audio-btn:hover {
    border-color: var(--color-ink);
    background: var(--color-ink);
    color: var(--color-on-dark);
}
.audio-btn:focus-visible { outline: 2px solid var(--color-ink); outline-offset: 2px; }
@media (max-width: 767px) { .header-logout { display: none; } }

/* Editorial refinements for semantic markup */
.page-index a.search-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    color: inherit;
    text-decoration: none;
}
.page-index a.search-card > div:first-child > div:first-child {
    margin-bottom: 7px;
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.page-index a.search-card > div:first-child > div:nth-child(2) {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 300;
    line-height: 1.15;
}
.page-index a.search-card > div:first-child > div:nth-child(3) {
    margin-top: 8px;
    color: var(--color-muted);
    font-size: 13px;
}
.page-index a.search-card > div:last-child { font-family: var(--font-display); font-size: 34px; }
hr { height: 1px; margin: 28px 0; border: 0; background: var(--color-hairline); }
.audio-preview { margin-bottom: 16px; }
.cp-dot:nth-child(1) { background: var(--color-gradient-peach); }
.cp-dot:nth-child(2) { background: var(--color-gradient-rose); }
.cp-dot:nth-child(3) { background: var(--color-gradient-mint); }
.cp-dot:nth-child(4) { background: var(--color-gradient-sky); }
@media (max-width: 639px) {
    .page-index a.search-card > div:first-child > div:nth-child(2) { font-size: 22px; }
}

.batch-bar > div { display: flex; flex-wrap: wrap; gap: 10px; }
.batch-bar label { display: flex; align-items: center; gap: 7px; color: var(--color-body); font-size: 14px; }
.btn-logout { margin-top: 20px; border-color: color-mix(in srgb, var(--color-error) 28%, var(--color-hairline)); background: transparent; color: var(--color-error); }
.btn-logout:hover { background: color-mix(in srgb, var(--color-error) 7%, transparent); }
.word-box { min-width: 0; flex: 1 1 260px; }
.word-text { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 26px; font-weight: 300; }
.word-def { margin-top: 8px; color: var(--color-body); }
#note-quote-preview { max-height: 82px; overflow: auto; margin: 14px 0; padding: 12px 14px; border-left: 2px solid var(--color-hairline-strong); background: var(--color-canvas-soft); color: var(--color-muted); font-size: 13px; font-style: italic; }
.del-btn { display: inline-flex; min-height: 30px; align-items: center; justify-content: center; padding: 6px 10px; border: 1px solid var(--color-hairline); border-radius: var(--radius-pill); color: var(--color-error); font-size: 12px; cursor: pointer; }

/* ==========================================================
 * Word study fixed workspace + shared search icon system
 * ========================================================== */

/* Search controls use one vector icon at a stable visual size. */
.search-control,
.search-box {
    position: relative;
    min-width: 0;
}
.search-control {
    display: flex;
    width: 100%;
    align-items: center;
}
.search-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    background: currentColor;
    color: var(--color-muted);
    font-size: 0;
    line-height: 0;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='6.5' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m16 16 4.25 4.25' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='6.5' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m16 16 4.25 4.25' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.search-control > .search-icon,
.search-box > .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    z-index: 1;
    transform: translateY(-50%);
    pointer-events: none;
}
.search-control > input,
.search-box > input.search-input,
.search-form-inline .search-inp {
    padding-left: 46px;
}
.search-form-inline {
    width: min(100%, 340px);
}
.search-input-group > .search-control,
.search-bar > .search-control,
.admin-filter > .search-control,
.sm-header > .search-control {
    min-width: 0;
}

/* Word study is a true application workspace, not a scrolling document. */
body.page-study {
    display: grid;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: 100dvh;
    grid-template-rows: 72px minmax(0, 1fr);
    overflow: hidden;
    overscroll-behavior: none;
}
.page-study .navbar {
    width: min(calc(100% - 40px), var(--content-width));
    height: 72px;
    min-height: 0;
    margin: 0 auto;
    flex: none;
}
.page-study #progress-text {
    color: var(--color-body-strong);
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: .02em;
}
.page-study .study-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.study-search-trigger {
    appearance: none;
    display: grid;
    width: 40px;
    height: 40px;
    min-height: 40px;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--color-body);
    cursor: pointer;
}
.study-search-trigger .search-icon {
    width: 21px;
    height: 21px;
    flex-basis: 21px;
    color: currentColor;
}
.study-search-trigger:hover {
    border-color: var(--color-hairline);
    background: var(--color-surface-card);
    color: var(--color-ink);
}
.page-study .stage {
    display: grid;
    width: min(calc(100% - 40px), 810px);
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    padding: clamp(10px, 2vh, 22px) 0 max(clamp(10px, 2vh, 20px), env(safe-area-inset-bottom));
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: clamp(8px, 1.35vh, 16px);
    overflow: hidden;
}
.page-study .mode-switcher {
    margin: 0 auto;
    flex: none;
}
.page-study #planTip {
    width: min(100%, 560px);
    margin: 0 auto;
}
.page-study .card-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.page-study .card-face {
    min-height: 0;
    padding: clamp(22px, 4vh, 42px);
    overflow: hidden;
}
.page-study .card-face.back {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.page-study .card-face.front::after {
    width: min(54vh, 420px);
    height: min(54vh, 420px);
}
.page-study .controls {
    width: 100%;
    margin: 0;
    flex: none;
}
.page-study .controls {
    position: relative;
}
.review-sync-status {
    position: absolute;
    z-index: 8;
    left: 50%;
    bottom: calc(100% + 9px);
    width: min(100%, 620px);
    min-height: 38px;
    transform: translateX(-50%);
    padding: 9px 16px;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--color-surface-card) 94%, transparent);
    color: var(--color-body-strong);
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
    box-shadow: 0 4px 16px rgba(12, 10, 9, .05);
    backdrop-filter: blur(10px);
}
.review-sync-status[hidden] { display: none; }
.review-sync-status--warning {
    border-color: color-mix(in srgb, var(--color-gradient-peach) 72%, var(--color-hairline));
    background: color-mix(in srgb, var(--color-gradient-peach) 18%, var(--color-surface-card));
}
.page-study .controls.is-saving .btn {
    cursor: wait;
}
.page-study .controls .btn:disabled {
    opacity: .58;
    pointer-events: none;
}
.page-study .btn-group,
.page-study #group-init,
.page-study #group-confirm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.page-study .controls .btn {
    min-height: clamp(46px, 5.6vh, 52px);
}
.page-study .study-prompt {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100%;
    max-width: 680px;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-ink);
    font-family: var(--font-display);
    font-size: clamp(3.3rem, 8.2vw, 6rem);
    font-weight: 300;
    line-height: .98;
    letter-spacing: -.045em;
    text-align: center;
    text-wrap: balance;
}
.page-study .study-prompt.zh-mode {
    max-width: 620px;
    font-family: var(--font-body);
    font-size: clamp(1.55rem, 3.6vw, 2.45rem);
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: .02em;
}
.page-study .hint {
    position: relative;
    z-index: 1;
    margin-top: clamp(12px, 2vh, 20px);
    font-size: 14px;
}

/* Listening mode deliberately avoids inheriting the display-word typography. */
.listen-mode-panel {
    display: grid;
    width: min(100%, 590px);
    gap: clamp(16px, 2.3vh, 24px);
    justify-items: center;
    font-family: var(--font-body);
    letter-spacing: .16px;
}
.audio-preview {
    appearance: none;
    display: inline-flex;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-hairline-strong);
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-surface-card) 90%, transparent);
    color: var(--color-body-strong);
    font-family: var(--font-body);
    font-size: 0;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
}
.audio-preview:hover {
    border-color: var(--color-ink);
    background: var(--color-ink);
    color: var(--color-on-dark);
}
.audio-preview__icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4Z' fill='black'/%3E%3Cpath d='M16 8.2a5.2 5.2 0 0 1 0 7.6M18.7 5.8a8.5 8.5 0 0 1 0 12.4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4Z' fill='black'/%3E%3Cpath d='M16 8.2a5.2 5.2 0 0 1 0 7.6M18.7 5.8a8.5 8.5 0 0 1 0 12.4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.listen-input-wrap {
    display: grid;
    width: 100%;
    gap: 9px;
    text-align: left;
}
.listen-label {
    color: var(--color-muted);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.page-study .input-listen {
    width: 100%;
    min-height: clamp(58px, 7.5vh, 72px);
    padding: 12px 20px;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--color-surface-card) 94%, transparent);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: clamp(1.55rem, 3.6vw, 2.15rem);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: .025em;
    text-align: center;
    caret-color: var(--color-ink);
}
.page-study .input-listen::placeholder {
    color: var(--color-muted-soft);
    font-size: .78em;
    letter-spacing: .01em;
}
.page-study .input-listen:focus {
    border-color: var(--color-ink);
    box-shadow: 0 0 0 1px var(--color-ink);
}
.page-study .input-listen.correct {
    border-color: var(--color-success);
    box-shadow: 0 0 0 1px var(--color-success);
}
.page-study .input-listen.wrong {
    border-color: var(--color-error);
    box-shadow: 0 0 0 1px var(--color-error);
}

@media (max-width: 767px) {
    body.page-study {
        grid-template-rows: 60px minmax(0, 1fr);
    }
    .page-study .navbar {
        width: calc(100% - 28px);
        height: 60px;
    }
    .page-study .stage {
        width: calc(100% - 28px);
        padding: 8px 0 max(10px, env(safe-area-inset-bottom));
        gap: 8px;
    }
    .page-study .mode-switcher {
        width: 100%;
        margin: 0;
        overflow: visible;
    }
    .page-study .mode-opt {
        flex: 1 1 0;
        padding: 8px 7px;
        text-align: center;
    }
    .page-study .card-container {
        min-height: 0;
    }
    .page-study .card-face {
        padding: 22px 18px;
        border-radius: var(--radius-xl);
    }
    .page-study .btn-group,
    .page-study #group-init,
    .page-study #group-confirm {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .page-study .controls .btn {
        min-height: 46px;
        padding-inline: 14px;
    }
    .btn-master {
        top: 12px;
        right: 12px;
    }
    .page-study .study-prompt {
        font-size: clamp(2.7rem, 14vw, 4.7rem);
    }
    .listen-mode-panel {
        gap: 15px;
    }
    .page-study .input-listen {
        min-height: 58px;
        font-size: clamp(1.35rem, 7vw, 1.85rem);
    }
}

@media (max-height: 760px) {
    body.page-study {
        grid-template-rows: 60px minmax(0, 1fr);
    }
    .page-study .navbar {
        height: 60px;
    }
    .page-study .stage {
        padding-block: 7px;
        gap: 7px;
    }
    .page-study .mode-switcher {
        padding: 3px;
    }
    .page-study .mode-opt {
        padding-block: 7px;
    }
    .page-study #planTip {
        padding-block: 6px;
        font-size: 12px;
    }
    .page-study .card-face {
        padding-block: 18px;
    }
    .page-study .study-prompt {
        font-size: clamp(2.65rem, 9vh, 4.5rem);
    }
    .page-study .study-prompt.zh-mode {
        font-size: clamp(1.35rem, 4.6vh, 2rem);
    }
    .page-study .hint {
        margin-top: 9px;
        font-size: 12px;
    }
    .page-study .controls .btn {
        min-height: 44px;
    }
    .listen-mode-panel {
        gap: 12px;
    }
    .audio-preview {
        min-height: 38px;
        padding-block: 8px;
    }
    .page-study .input-listen {
        min-height: 52px;
        font-size: clamp(1.25rem, 4.5vh, 1.75rem);
    }
}

@media (max-height: 620px) {
    .page-study #planTip {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .page-study .card-face {
        padding: 14px 18px;
    }
    .btn-master {
        top: 9px;
        right: 9px;
        min-height: 32px;
        padding-block: 5px;
    }
    .btn-master__icon {
        width: 19px;
        height: 19px;
    }
    .page-study .study-prompt {
        font-size: clamp(2.35rem, 8vh, 3.7rem);
    }
    .page-study .controls .btn {
        min-height: 40px;
        padding-block: 8px;
    }
}

/* Keep icon clearance stronger than the generic form-control shorthand. */
.search-control > input,
.search-box > input.search-input,
.search-form-inline .search-inp {
    padding-left: 46px !important;
}


/* Runtime cache refresh utility */
.page-runtime-refresh .runtime-refresh-shell { max-width: 760px; padding-top: 72px; padding-bottom: 72px; }
.page-runtime-refresh .runtime-refresh-card { padding: 32px; }
.page-runtime-refresh .runtime-refresh-title { margin-top: 20px; }
.page-runtime-refresh .runtime-refresh-result { margin: 20px 0; }
.page-runtime-refresh .runtime-refresh-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.page-runtime-refresh .runtime-refresh-note { margin-top: 20px; color: var(--color-muted); }
@media (max-width: 640px) {
  .page-runtime-refresh .runtime-refresh-shell { padding-top: 32px; padding-bottom: 32px; }
  .page-runtime-refresh .runtime-refresh-card { padding: 22px; }
  .page-runtime-refresh .runtime-refresh-actions > * { width: 100%; }
}

/* Unified lookup status: partial provider failures should not collapse the whole result panel. */
.lookup-notice {
  margin: 0 0 var(--space-3);
  padding: 10px 14px;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-canvas-soft);
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1.5;
}
.lookup-notice--error {
  border-color: color-mix(in srgb, var(--color-error) 28%, var(--color-hairline));
  color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 5%, var(--color-surface-card));
}

/* --------------------------------------------------------------------------
   PWA install, update and connectivity surfaces
   -------------------------------------------------------------------------- */
.pwa-notice {
    position: fixed;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 2147483000;
    display: flex;
    align-items: center;
    gap: 20px;
    width: min(680px, calc(100vw - 32px));
    padding: 16px 18px 16px 20px;
    border: 1px solid var(--hairline, #e7e5e4);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 36px rgba(12, 10, 9, 0.12);
    opacity: 0;
    transform: translate(-50%, 18px);
    transition: opacity 180ms ease, transform 180ms ease;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.pwa-notice.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.pwa-notice__copy {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
    gap: 3px;
}

.pwa-notice__copy strong,
.pwa-notice__copy span {
    display: block;
}

.pwa-notice__copy strong {
    color: var(--ink, #0c0a09);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}

.pwa-notice__copy span {
    color: var(--muted, #777169);
    font-size: 13px;
    line-height: 1.45;
}

.pwa-notice__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.pwa-notice__primary,
.pwa-notice__secondary {
    min-width: 72px;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.pwa-notice__primary {
    border-color: var(--ink, #0c0a09);
    background: var(--ink, #0c0a09);
    color: #fff;
}

.pwa-notice__secondary {
    border-color: var(--hairline-strong, #d6d3d1);
    background: transparent;
    color: var(--body-strong, #292524);
}

.pwa-offline-indicator {
    position: fixed;
    left: 50%;
    top: max(12px, env(safe-area-inset-top));
    z-index: 2147483001;
    max-width: calc(100vw - 32px);
    padding: 8px 14px;
    border: 1px solid var(--hairline-strong, #d6d3d1);
    border-radius: 999px;
    background: #fff;
    color: var(--body-strong, #292524);
    box-shadow: 0 4px 16px rgba(12, 10, 9, 0.08);
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
    transform: translateX(-50%);
}

html.pwa-standalone body {
    overscroll-behavior-y: none;
}

@media (max-width: 640px) {
    .pwa-notice {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
        padding: 18px;
    }

    .pwa-notice__actions {
        justify-content: flex-end;
    }

    .pwa-notice__primary,
    .pwa-notice__secondary {
        min-height: 42px;
    }

    .pwa-offline-indicator {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-notice {
        transition: none;
    }
}
