:root {
  --ink: #142236;
  --navy: #183153;
  --navy-2: #23466f;
  --blue: #326cbe;
  --sky: #e9f2ff;
  --paper: #f5f7fb;
  --surface: #ffffff;
  --line: #dce3ed;
  --muted: #64748b;
  --amber: #b86512;
  --amber-bg: #fff2dc;
  --red: #b74242;
  --red-bg: #fff0ef;
  --green: #24805c;
  --green-bg: #e9f8f1;
  --shadow: 0 12px 34px rgba(20, 34, 54, 0.09);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --keyboard-offset: 0px;
  --visual-viewport-height: 100dvh;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100%; color: var(--ink); background: radial-gradient(circle at 8% 0, #e5efff 0, transparent 28rem), var(--paper); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(50, 108, 190, .32); outline-offset: 2px; }

.app-shell { min-height: 100vh; min-height: 100dvh; max-width: 1120px; margin: 0 auto; padding: 0 28px calc(88px + var(--safe-bottom)); }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; }
.brand-button { border: 0; background: transparent; display: flex; align-items: center; gap: 11px; padding: 5px; text-align: left; }
.brand-button strong { display: block; letter-spacing: -.02em; font-size: 1.05rem; }
.brand-button small { display: block; color: var(--muted); margin-top: 2px; font-size: .75rem; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--navy); color: white; font-size: 1.3rem; box-shadow: 0 5px 14px rgba(24,49,83,.23); }
.offline-badge { padding: 5px 10px; background: var(--amber-bg); color: var(--amber); border-radius: 99px; font-size: .8rem; font-weight: 650; }

.view { display: none; }
.view.active { display: block; opacity: 1; transform: none; }
.view-enter-forward { animation: view-in-forward 190ms cubic-bezier(.22,.72,.32,1); }
.view-enter-back { animation: view-in-back 190ms cubic-bezier(.22,.72,.32,1); }
.view-enter-up { animation: view-in-up 190ms cubic-bezier(.22,.72,.32,1); }
.view-enter-fade { animation: view-in-fade 160ms ease-out; }
@keyframes view-in-forward { from { opacity: 0; transform: translateX(12px); } }
@keyframes view-in-back { from { opacity: 0; transform: translateX(-12px); } }
@keyframes view-in-up { from { opacity: 0; transform: translateY(10px); } }
@keyframes view-in-fade { from { opacity: 0; } }
.home-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 22px; }
.today-card, .task-panel, .study-card, .stage-section, .privacy-note { background: rgba(255,255,255,.94); border: 1px solid rgba(220,227,237,.9); border-radius: 25px; box-shadow: var(--shadow); }
.today-card { min-height: 370px; padding: 34px; background: linear-gradient(145deg, rgba(255,255,255,.99), rgba(244,248,255,.97)); position: relative; overflow: hidden; }
.today-card::after { content: ""; position: absolute; width: 180px; height: 180px; border: 36px solid rgba(50,108,190,.06); border-radius: 50%; right: -65px; top: -65px; pointer-events: none; }
.eyebrow { color: var(--blue); font-size: .72rem; font-weight: 780; letter-spacing: .15em; margin-bottom: 10px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-weight: 650; letter-spacing: -.035em; }
.today-card h1 { max-width: 470px; font-size: clamp(2rem, 4.2vw, 3.25rem); line-height: 1.12; margin-bottom: 16px; }
.muted { color: var(--muted); line-height: 1.6; }
.progress-track { width: 100%; height: 8px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #62a2ef); transition: width .35s ease; }
.today-numbers { display: flex; justify-content: space-between; color: var(--muted); font-size: .86rem; margin: 9px 0 24px; }
.today-numbers strong { color: var(--ink); font-size: 1rem; }
.primary-button { border: 0; border-radius: 13px; background: var(--navy); color: white; padding: 12px 18px; font-weight: 700; min-height: 46px; box-shadow: 0 5px 14px rgba(24,49,83,.19); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; background: #99a7b8; box-shadow: none; }
.primary-button.large { width: 100%; font-size: 1rem; }

.task-panel { padding: 26px; }
.section-heading, .page-heading, .dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.section-heading h2, .page-heading h1, .dialog-heading h2 { margin: 0; }
.section-heading h2 { font-size: 1.35rem; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: white; font-size: 1.3rem; }
.task-list { margin-top: 18px; display: grid; gap: 9px; }
.task-row { display: flex; align-items: center; gap: 13px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.task-badge { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; font-weight: 760; }
.task-badge.review { background: var(--sky); color: var(--blue); }
.task-badge.hard { background: var(--red-bg); color: var(--red); }
.task-badge.word { background: var(--green-bg); color: var(--green); }
.task-badge.phrase { background: var(--amber-bg); color: var(--amber); }
.task-row > span:nth-child(2) { min-width: 0; flex: 1; }
.task-row strong, .task-row small { display: block; }
.task-row small { color: var(--muted); margin-top: 2px; }
.task-row b { font-size: 1.25rem; }
.empty-task { color: var(--muted); text-align: center; padding: 42px 10px; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.action-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 17px 19px; border-radius: 18px; background: rgba(255,255,255,.86); border: 1px solid var(--line); text-align: left; }
.action-card strong, .action-card small { display: block; }
.action-card small { color: var(--muted); margin-top: 4px; }
.action-icon { width: 43px; height: 43px; border-radius: 13px; display: grid; place-items: center; font-weight: 800; }
.action-icon.blue { background: var(--sky); color: var(--blue); }
.action-icon.amber { background: var(--amber-bg); color: var(--amber); }

.study-header { max-width: 720px; margin: 3px auto 14px; display: flex; align-items: center; gap: 14px; }
.study-back-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.text-button { border: 0; background: transparent; color: var(--blue); padding: 10px 2px; font-weight: 650; }
.undo-review-button { min-height: 44px; color: var(--muted); font-size: .78rem; white-space: nowrap; }
.study-progress-wrap { flex: 1; }
.study-meta { display: flex; justify-content: space-between; font-size: .76rem; font-weight: 450; color: var(--muted); margin-bottom: 7px; }
.study-session-mode { position: relative; flex: 0 0 auto; }
.study-session-mode::after { content: "⌄"; position: absolute; right: 10px; top: 50%; transform: translateY(-55%); color: var(--muted); font-size: .75rem; pointer-events: none; }
.study-session-mode select { appearance: none; -webkit-appearance: none; min-height: 44px; max-width: 128px; border: 1px solid var(--line); border-radius: 11px; padding: 0 27px 0 11px; background: rgba(255,255,255,.9); color: var(--ink); font: inherit; font-size: .8rem; font-weight: 550; }
.study-session-mode select:focus-visible { outline: 2px solid rgba(45,105,184,.28); outline-offset: 2px; }
.progress-track.slim { height: 5px; }
.study-card { max-width: 720px; min-height: 500px; margin: 0 auto; padding: 26px clamp(24px, 6vw, 54px) 30px; border-radius: 22px; box-shadow: 0 8px 28px rgba(20,34,54,.07); }
.study-card.card-leave-next { animation: card-out-next 80ms ease-in forwards; pointer-events: none; }
.study-card.card-enter-next { animation: card-in-next 170ms cubic-bezier(.22,.72,.32,1); }
.study-card.card-leave-previous { animation: card-out-previous 80ms ease-in forwards; pointer-events: none; }
.study-card.card-enter-previous { animation: card-in-previous 170ms cubic-bezier(.22,.72,.32,1); }
@keyframes card-out-next { to { opacity: 0; transform: translateX(-9px); } }
@keyframes card-in-next { from { opacity: 0; transform: translateX(12px); } }
@keyframes card-out-previous { to { opacity: 0; transform: translateX(9px); } }
@keyframes card-in-previous { from { opacity: 0; transform: translateX(-12px); } }
.card-topline { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.pill { background: var(--sky); color: var(--blue); border-radius: 99px; padding: 4px 9px; font-size: .74rem; font-weight: 550; }
.stage-label { color: var(--muted); font-size: .76rem; font-weight: 450; }
.source-label { font-weight: 400; }
.prompt-area { min-height: 150px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; text-align: center; padding-top: 24px; }
.prompt-area h2 { margin: 0; font-size: clamp(2.15rem, 6.5vw, 3.7rem); font-weight: 700; line-height: 1.12; letter-spacing: -.035em; overflow-wrap: anywhere; }
.phonetic { margin: -2px 0 0; color: var(--muted); font-size: 1rem; font-weight: 400; line-height: 1.35; }
.phrase-hint { width: 100%; margin: 0 0 -18px; color: var(--muted); font-size: .86rem; }
.speak-button { border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 500; padding: 7px 10px; }
.speak-button:active { background: var(--paper); }
.recall-wait { text-align: center; color: var(--muted); font-size: .9rem; height: 30px; }
.reveal-button { display: block; width: min(310px, 100%); margin: 4px auto 0; }
.answer-rule { height: 1px; background: var(--line); margin: 25px 0 20px; }
.answer-panel { max-width: 560px; margin: 0 auto; text-align: left; }
.answer-panel h3 { font-size: 1.28rem; font-weight: 600; line-height: 1.55; margin: 5px 0 0; }
.input-check { max-width: 560px; margin: 12px auto 0; display: grid; gap: 9px; text-align: left; scroll-margin: 18px; }
.input-check[hidden] { display: none; }
.input-check label, .answer-row > small { color: var(--muted); font-size: .76rem; font-weight: 500; letter-spacing: .01em; }
.input-check textarea { width: 100%; min-height: 86px; resize: vertical; border: 1px solid #cfd9e6; border-radius: 13px; padding: 12px 13px; color: var(--ink); background: #fbfcfe; font: inherit; font-size: 1rem; line-height: 1.5; box-shadow: 0 1px 2px rgba(20,34,54,.025); }
.input-check textarea::placeholder { color: #96a2b1; }
.input-check-button { width: 100%; min-height: 44px; padding: 9px 16px; border-radius: 12px; font-weight: 600; box-shadow: none; }
.answer-row { padding: 0 0 15px; }
.answer-row + .answer-row { padding-top: 15px; border-top: 1px solid var(--line); }
.user-answer { margin: 0; background: transparent; }
.user-answer p { margin: 5px 0 0; color: #45556b; line-height: 1.5; }
.standard-answer { text-align: left; }
.answer-pos { margin: 7px 0 0; color: var(--muted); font-size: .84rem; font-weight: 500; }
.reading { color: var(--muted); margin: 5px 0 0; font-size: .86rem; }
.example-block { padding-bottom: 4px; }
.example { color: #28384d; font-size: 1.16rem; font-weight: 450; line-height: 1.55; margin: 7px 0 0; overflow-wrap: anywhere; }
.example-zh { color: #536276; font-size: 1.1rem; font-weight: 400; line-height: 1.55; margin: 7px 0 0; }
.note { background: var(--amber-bg); color: #75430f; padding: 9px 12px; border-radius: 10px; display: inline-block; font-size: .9rem; }
.feedback-prompt { color: var(--muted); font-size: .8rem; margin: 22px 0 10px; }
.feedback-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.feedback-button { border: 1px solid var(--line); background: white; min-height: 64px; border-radius: 12px; padding: 9px; font-weight: 500; }
.feedback-button strong, .feedback-button small { display: block; }
.feedback-button small { color: var(--muted); margin-top: 3px; font-size: .72rem; }
.feedback-button.instant { border-color: #bde5d2; }
.feedback-button.fuzzy { border-color: #f0d3a2; }
.feedback-button.wrong { border-color: #efc1bf; }
.feedback-button.again { border-color: #dda9a6; background: #fffafa; }
.keyboard-tip { max-width: 760px; text-align: center; margin: 13px auto 0; color: var(--muted); font-size: .75rem; }

.page-heading { margin: 8px 0 22px; }
.page-heading h1 { font-size: 2.3rem; }
.library-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.search-box { flex: 1; display: flex; align-items: center; gap: 8px; background: white; border: 1px solid var(--line); border-radius: 13px; padding: 0 13px; min-height: 47px; }
.search-box input { width: 100%; border: 0; outline: none; font-size: 1rem; }
.library-toolbar select { border: 1px solid var(--line); border-radius: 13px; background: white; padding: 0 14px; min-width: 110px; }
.library-list { display: grid; gap: 8px; }
.library-item { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(170px, 1.4fr) auto; gap: 18px; align-items: center; background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 15px; padding: 15px 18px; }
.library-item strong { font-size: 1.08rem; }
.entry-number { display: inline-block; min-width: 3.2em; color: var(--muted); font: 650 .78rem -apple-system, BlinkMacSystemFont, sans-serif; }
.library-item p { margin: 0; color: #46576b; }
.library-meta { text-align: right; color: var(--muted); font-size: .78rem; }
.hard-dot { color: var(--red); font-weight: 750; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 20px 16px; }
.stat-card strong { display: block; font-size: 2rem; }
.stat-card span { color: var(--muted); font-size: .85rem; }
.stage-section { margin-top: 16px; padding: 24px; }
.stage-section h2 { font-size: 1.2rem; }
.stage-chart { display: grid; gap: 13px; }
.stage-row { display: grid; grid-template-columns: 42px 1fr 35px; gap: 10px; align-items: center; font-size: .84rem; }
.stage-bar { height: 12px; background: #e7ebf1; border-radius: 99px; overflow: hidden; }
.stage-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-2), #6aa6eb); border-radius: inherit; }

.settings-list { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: white; }
.daily-settings { margin-bottom: 16px; padding: 20px 21px; border: 1px solid var(--line); border-radius: 20px; background: white; }
.daily-settings h2 { margin: 0 0 15px; font-size: 1.1rem; }
.daily-setting-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.daily-setting-grid label { display: grid; gap: 7px; color: var(--muted); font-size: .84rem; }
.daily-setting-grid input { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font: inherit; color: var(--ink); background: var(--paper); }
.setting-toggle { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.setting-toggle.compact-toggle { margin-top: 14px; }
.setting-toggle strong, .setting-toggle small { display: block; }
.setting-toggle small { color: var(--muted); margin-top: 3px; }
.daily-settings > p { margin: 12px 0 0; font-size: .8rem; }
.learning-mode-field select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 13px; padding: 0 12px; background: var(--paper); color: var(--ink); }
.settings-row { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 20px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; padding: 18px 21px; }
.settings-row:last-child { border-bottom: 0; }
.settings-row strong, .settings-row small { display: block; }
.settings-row small { color: var(--muted); margin-top: 5px; }
.settings-row.danger strong { color: var(--red); }
.privacy-note { margin-top: 16px; padding: 20px 22px; box-shadow: none; }
.privacy-note p { color: var(--muted); line-height: 1.55; margin: 7px 0 0; }

dialog { width: min(540px, calc(100% - 28px)); border: 0; border-radius: 22px; padding: 0; box-shadow: 0 24px 70px rgba(20,34,54,.28); }
dialog::backdrop { background: rgba(20,34,54,.42); backdrop-filter: blur(3px); }
dialog[open] .dialog-card { animation: dialog-in 170ms cubic-bezier(.22,.72,.32,1); }
@keyframes dialog-in { from { opacity: 0; transform: scale(.985) translateY(4px); } }
.dialog-card { padding: 25px; }
.dialog-card p { color: var(--muted); line-height: 1.55; }
.file-drop { min-height: 130px; display: grid; place-content: center; text-align: center; border: 2px dashed #b8c7d9; border-radius: 16px; background: var(--paper); }
.file-drop small { color: var(--muted); margin-top: 6px; }
.import-result { margin-top: 12px; color: var(--green); min-height: 20px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translate(-50%, 12px); background: var(--ink); color: white; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: calc(12px + var(--safe-bottom)); transform: translateX(-50%); width: min(560px, calc(100% - 28px)); height: 64px; background: rgba(255,255,255,.92); border: 1px solid rgba(207,216,228,.95); border-radius: 20px; box-shadow: 0 12px 35px rgba(20,34,54,.16); backdrop-filter: blur(18px); display: grid; grid-template-columns: repeat(4,1fr); padding: 6px; }
.nav-button { border: 0; background: transparent; border-radius: 14px; display: grid; place-items: center; align-content: center; gap: 1px; color: var(--muted); }
.nav-button > span { font-size: 1.2rem; line-height: 1; }
.nav-button small { font-size: .72rem; }
.nav-button.active { background: var(--navy); color: white; }

@media (max-width: 800px) {
  .app-shell { padding-left: 18px; padding-right: 18px; }
  .home-grid { grid-template-columns: 1fr; }
  .today-card { min-height: 330px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card:first-child { grid-column: span 2; }
}

@media (max-width: 560px) {
  .app-shell { padding-left: 13px; padding-right: 13px; }
  .topbar { height: 68px; }
  .today-card, .task-panel, .study-card { border-radius: 21px; }
  .today-card { padding: 25px 22px; min-height: 310px; }
  .today-card h1 { font-size: 2.3rem; }
  .task-panel { padding: 20px 16px; }
  .quick-actions { grid-template-columns: 1fr; }
  .study-header { margin-bottom: 10px; }
  .study-header { gap: 9px; }
  .study-back-actions { gap: 6px; }
  .undo-review-button { font-size: 0; width: 44px; padding: 0; }
  .undo-review-button::before { content: "↶"; font-size: 1.05rem; }
  .study-session-mode select { min-height: 44px; max-width: 112px; padding-left: 9px; font-size: .76rem; }
  .study-card { padding: 20px 17px calc(22px + var(--safe-bottom)); min-height: 0; border-radius: 18px; }
  .prompt-area { min-height: 132px; padding-top: 15px; }
  .prompt-area h2 { font-size: clamp(2rem, 10vw, 3rem); }
  .input-check { margin-top: 8px; }
  .input-check textarea { min-height: 78px; }
  .feedback-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .feedback-button { min-height: 68px; padding: 7px 3px; }
  .keyboard-tip { display: none; }
  .library-item { grid-template-columns: 1fr auto; gap: 7px 12px; }
  .library-item p { grid-column: 1 / -1; grid-row: 2; }
  .library-meta { grid-column: 2; grid-row: 1; }
  .daily-setting-grid { grid-template-columns: 1fr; }
  .page-heading h1 { font-size: 2rem; }
}

body.keyboard-open .app-shell { padding-bottom: calc(18px + var(--keyboard-offset)); }
body.keyboard-open .bottom-nav { display: none; }
body.keyboard-open #view-study { min-height: var(--visual-viewport-height); }
body.keyboard-open .study-header { margin-top: 3px; }
body.keyboard-open .study-session-mode { visibility: hidden; width: 0; }

@media (orientation: landscape) and (max-height: 600px) {
  body.keyboard-open .study-card { min-height: 0; }
  body.keyboard-open .prompt-area { min-height: 112px; padding-top: 10px; }
  body.keyboard-open .input-check { margin-top: 4px; }
}

@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top, 0); height: calc(78px + env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .view-enter-forward, .view-enter-back, .view-enter-up, .view-enter-fade,
  .study-card.card-leave-next, .study-card.card-enter-next, .study-card.card-leave-previous, .study-card.card-enter-previous,
  dialog[open] .dialog-card { transform: none !important; }
}

/* MyVocab V2: account, books and sync surfaces */
.account-area { display: flex; align-items: center; gap: 8px; }
.sync-chip, .account-chip { border: 1px solid var(--line); background: rgba(255,255,255,.9); min-height: 42px; border-radius: 13px; display: flex; align-items: center; gap: 8px; padding: 6px 11px; }
.sync-chip { color: var(--muted); font-size: .78rem; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-bg); }
.sync-chip.offline .sync-dot { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-bg); }
.sync-chip.pending .sync-dot { background: var(--blue); box-shadow: 0 0 0 4px var(--sky); animation: pulse 1.2s infinite; }
.sync-chip.error .sync-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-bg); }
@keyframes pulse { 50% { opacity: .35; } }
.account-chip > span { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; background: var(--navy); color: white; font-weight: 750; }
.account-chip small { max-width: 115px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.auth-view.active { display: grid; place-items: center; min-height: calc(100dvh - 165px); }
.login-card { width: min(520px, 100%); text-align: center; padding: clamp(28px, 6vw, 48px); background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.login-brand { position: relative; width: max-content; margin: 0 auto 24px; }
.brand-mark.large { width: 60px; height: 60px; border-radius: 19px; font-size: 2rem; }
.cloud-mark { position: absolute; right: -18px; bottom: -8px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--sky); border: 3px solid white; font-size: .8rem; }
.login-card h1 { font-size: clamp(2rem, 6vw, 2.7rem); line-height: 1.08; margin-bottom: 8px; }
.login-card > p { color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 10px; text-align: left; margin-top: 26px; }
.login-form label, .dialog-card > label, .form-fields label { font-size: .86rem; font-weight: 680; color: #46576b; }
.login-form input, .dialog-card input:not([type="checkbox"]), .dialog-card select, .dialog-card textarea { width: 100%; min-height: 49px; margin-top: 7px; border: 1px solid var(--line); border-radius: 13px; padding: 0 13px; background: white; font-size: 1rem; color: var(--ink); }
.login-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.login-actions .large { width: 100%; min-height: 49px; }
.login-secondary { display: flex; justify-content: space-between; gap: 16px; margin-top: 3px; }
.login-secondary .text-button { font-size: .84rem; }
.dialog-card textarea { padding-top: 12px; padding-bottom: 12px; resize: vertical; }
.form-message { min-height: 22px; margin-top: 10px; color: var(--green); line-height: 1.45; }
.form-message.error { color: var(--red); }
.login-note { font-size: .8rem; margin: 8px 0 0; }
.setup-notice { margin-top: 20px; padding: 15px; text-align: left; border: 1px solid #f0d3a2; border-radius: 14px; background: var(--amber-bg); color: #75430f; }
.setup-notice p { margin: 6px 0 0; line-height: 1.5; }

.books-home { margin-top: 24px; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.book-grid.compact { margin-top: 14px; }
.book-card { min-height: 205px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.93); padding: 20px; text-align: left; box-shadow: 0 8px 24px rgba(20,34,54,.055); display: flex; flex-direction: column; }
.book-card:hover { border-color: #b9cae0; }
.book-cover { width: 46px; height: 54px; border-radius: 7px 12px 12px 7px; display: grid; place-items: center; margin-bottom: 17px; background: linear-gradient(145deg, var(--navy-2), var(--blue)); color: white; font-size: 1.2rem; box-shadow: 4px 5px 0 #dbe6f5; }
.book-card.phrasebook .book-cover { background: linear-gradient(145deg, #976216, #d09133); box-shadow: 4px 5px 0 #f3dfbd; }
.book-card.custom .book-cover { background: linear-gradient(145deg, #28705a, #3a9d7b); box-shadow: 4px 5px 0 #d2eddf; }
.book-card strong { display: block; font-size: 1.03rem; line-height: 1.35; }
.book-card footer { margin-top: auto; display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; }
.book-card footer b { color: var(--ink); }
.empty-books { grid-column: 1 / -1; padding: 44px 20px; border: 1px dashed #bdc9d8; border-radius: 20px; text-align: center; color: var(--muted); background: rgba(255,255,255,.6); }
.empty-books > strong { display: block; color: var(--ink); font-size: 1.05rem; }
.empty-book-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.book-detail-heading { display: flex; justify-content: space-between; align-items: center; margin: 5px 0 32px; }
.book-detail-actions { display: flex; align-items: center; gap: 9px; }
.book-menu { position: relative; }
.book-menu summary { list-style: none; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--muted); cursor: pointer; letter-spacing: .08em; }
.book-menu summary::-webkit-details-marker { display: none; }
.book-menu-popover { position: absolute; z-index: 12; top: calc(100% + 7px); right: 0; min-width: 150px; padding: 6px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: 0 12px 30px rgba(20,34,54,.14); }
.book-menu-popover button { width: 100%; min-height: 42px; border: 0; border-radius: 9px; padding: 8px 11px; background: transparent; text-align: left; font-weight: 550; }
.book-menu-popover button:active { background: var(--paper); }
.book-menu-popover .danger-menu-item { color: var(--red); }
#book-title { font-size: clamp(2.2rem, 6vw, 3.6rem); margin-bottom: 20px; }
.book-notes { max-width: 720px; margin-top: -8px; }
.metric-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.metric { padding: 15px 12px; border: 1px solid var(--line); background: white; border-radius: 15px; }
.metric strong, .metric small { display: block; }
.metric strong { font-size: 1.55rem; }
.metric small { color: var(--muted); margin-top: 3px; }
.entry-heading { margin: 30px 0 13px; }
.secondary-button { min-height: 42px; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 9px 14px; font-weight: 680; }
.source-label { color: var(--muted); font-size: .76rem; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 10px; }

.account-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; margin-bottom: 16px; padding: 19px 21px; border: 1px solid var(--line); border-radius: 20px; background: white; }
.account-avatar { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--navy); color: white; font-weight: 780; font-size: 1.2rem; }
.account-panel strong, .account-panel small { display: block; }
.account-panel small { color: var(--muted); margin-top: 4px; }
.pending-detail { font-weight: 680; color: var(--blue) !important; }
.dialog-card { display: grid; gap: 15px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.danger-button { min-height: 44px; border: 0; border-radius: 12px; padding: 9px 14px; background: var(--red); color: white; font-weight: 680; }
.form-fields { display: grid; gap: 15px; }
.check-row { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; }
.check-row strong, .check-row small { display: block; }
.check-row small { color: var(--muted); margin-top: 3px; font-weight: 400; }
.import-preview, .migration-preview { padding: 13px; border-radius: 13px; background: var(--sky); color: var(--navy); line-height: 1.5; }
.bottom-nav.five { width: min(620px, calc(100% - 28px)); grid-template-columns: repeat(5, 1fr); }

@media (max-width: 800px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .library-toolbar { flex-wrap: wrap; }
  .search-box { flex-basis: 100%; }
}

@media (max-width: 560px) {
  .book-grid { grid-template-columns: 1fr; }
  .book-card { min-height: 175px; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .sync-chip span:last-child, .account-chip small { display: none; }
  .account-panel { grid-template-columns: auto 1fr; }
  .account-panel .secondary-button { grid-column: 1 / -1; }
  .bottom-nav { height: 62px; }
}
