:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #697386;
  --line: #e4e8ee;
  --surface: #ffffff;
  --bg: #f4f6f8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warm: #f59e0b;
  --danger: #dc5252;
  --good: #168768;
  --shadow: 0 12px 36px rgba(21, 33, 61, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }
.auth-shell { min-height: 100vh; max-width: 480px; margin: auto; padding: 9vh 22px 32px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand strong { display: block; font-size: 25px; }
.auth-brand small { color: var(--muted); display: block; margin-top: 4px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; color: white; background: var(--ink); border-radius: 8px; font: 700 24px Georgia, serif; }
.brand-mark.small { width: 34px; height: 34px; font-size: 18px; }
.auth-panel { margin-top: 64px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); padding: 4px; background: #eef1f4; border-radius: 7px; margin-bottom: 24px; }
.segmented button { border: 0; padding: 10px; background: transparent; color: var(--muted); border-radius: 5px; }
.segmented button.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(20,33,61,.08); font-weight: 650; }
label { display: block; color: #44506a; font-size: 13px; font-weight: 650; margin: 15px 0; }
input { width: 100%; margin-top: 7px; padding: 13px 14px; border: 1px solid #d7dce3; border-radius: 6px; outline: none; background: white; color: var(--ink); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.primary { border: 0; border-radius: 6px; color: white; background: var(--accent); padding: 13px 16px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary:hover { background: var(--accent-dark); }
.wide { width: 100%; margin-top: 12px; }
.avatar-field em { font-style: normal; font-weight: 400; color: var(--muted); }
.avatar-picker { display: flex; align-items: center; gap: 12px; margin-top: 9px; }
.avatar-field input { display: none; }
.file-button { padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }
.avatar { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: #d7e9e5; color: var(--accent-dark); font-weight: 750; overflow: hidden; }
.avatar-lg { width: 58px; height: 58px; font-size: 20px; }
.avatar-btn { border: 0; padding: 0; }
.app-shell { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; z-index: 10; top: 0; height: 64px; padding: 0 max(18px, calc((100vw - 920px)/2)); display: flex; align-items: center; justify-content: space-between; background: rgba(244,246,248,.94); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(228,232,238,.8); }
.brand-inline { display: flex; align-items: center; gap: 10px; }
.view { display: none; max-width: 920px; margin: auto; padding: 24px 18px 44px; animation: enter .28s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 12px; font-weight: 750; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(26px, 7vw, 38px); line-height: 1.18; }
h2 { margin: 0; font-size: 19px; }
p { line-height: 1.6; }
.muted { color: var(--muted); }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 22px; }
.daily-alert { width: 100%; margin: 0 0 22px; padding: 16px 18px; border: 0; border-radius: 8px; background: var(--ink); color: white; display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left; box-shadow: var(--shadow); }
.daily-alert span, .daily-alert small, .daily-alert strong { display: block; }
.daily-alert small { margin-bottom: 4px; color: #fbbf24; font-size: 11px; font-weight: 750; }
.daily-alert strong { font-size: 15px; line-height: 1.4; }
.daily-alert b { flex: 0 0 auto; color: #fbbf24; font-size: 13px; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.progress { height: 4px; background: #dfe4e9; margin: 18px 0 28px; }
.progress span { display: block; height: 100%; background: var(--warm); }
.word-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.word-card { min-width: 0; padding: 19px 4px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) 40px; grid-template-rows: auto 32px; gap: 8px; }
.word-card > div { grid-row: 1 / span 2; }
.word-card:nth-child(odd) { padding-right: 18px; border-right: 1px solid var(--line); }
.word-card:nth-child(even) { padding-left: 18px; }
.word-number { color: #9aa3b0; font-size: 11px; font-variant-numeric: tabular-nums; }
.word-title { margin: 5px 0 2px; font: 700 23px Georgia, "Times New Roman", serif; overflow-wrap: anywhere; }
.ipa { color: var(--accent); font-size: 13px; overflow-wrap: anywhere; }
.meaning { margin: 8px 0 0; color: #4b566d; font-size: 14px; line-height: 1.55; }
.sound { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); display: grid; place-items: center; }
.mark-word { min-width: 40px; min-height: 28px; padding: 4px 6px; border: 1px solid #d4dbe3; border-radius: 5px; background: white; color: var(--muted); font-size: 11px; line-height: 1; white-space: nowrap; }
.mark-word.active { border-color: #f1c55a; background: #fff8df; color: #8a6613; }
.word-card > .mark-word { grid-column: 2; grid-row: 2; align-self: end; }
.action-bar { display: flex; gap: 10px; margin: 24px 0 2px; }
.action-bar > * { flex: 1; }
.secondary { border: 1px solid #ccd3dc; background: white; color: var(--ink); padding: 12px 14px; border-radius: 6px; font-weight: 650; }
.notice { padding: 14px 16px; margin: 18px 0; border-left: 3px solid var(--warm); background: #fff9eb; color: #755c1d; font-size: 14px; }
.date-panel, .ranking-panel, .profile-panel, .test-panel { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.date-input { display: flex; gap: 10px; align-items: flex-end; }
.date-input label { flex: 1; margin: 0; }
.date-input button { flex: 0 0 auto; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 28px; }
.quick { min-height: 104px; text-align: left; padding: 15px; border: 1px solid var(--line); background: white; border-radius: 8px; }
.quick strong, .quick span { display: block; }
.quick span { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.makeup-panel { margin: 18px 0 28px; padding: 0 20px; background: #fffaf0; border: 1px solid #f1dfb3; border-radius: 8px; }
.makeup-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 18px 0; cursor: pointer; }
.makeup-heading::-webkit-details-marker { display: none; }
.makeup-heading::after { content: '+'; margin-left: auto; color: var(--muted); font-size: 22px; line-height: 1; }
.makeup-panel[open] .makeup-heading::after { content: '−'; }
.makeup-heading .eyebrow { margin-bottom: 5px; }
.makeup-list { display: grid; }
.makeup-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid #f1dfb3; }
.makeup-row strong, .makeup-row span { display: block; }
.makeup-row span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.rank-tabs { margin: 18px 0; }
.rank-list { display: grid; }
.rank-row { display: grid; grid-template-columns: 28px 42px 1fr auto; gap: 10px; align-items: center; min-height: 64px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-no { color: var(--muted); font-weight: 700; }
.rank-value { font-weight: 750; color: var(--accent-dark); }
.empty { padding: 40px 8px; text-align: center; color: var(--muted); }
.profile-head { display: flex; align-items: center; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.profile-head h2 { margin-bottom: 3px; }
.username-editor { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.username-editor label { margin: 0; }
.username-editor button { min-height: 45px; }
.profile-actions { display: grid; gap: 10px; margin-top: 20px; }
.profile-actions input { display: none; }
.history-heading { margin: 30px 0 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.history-heading .eyebrow { margin-bottom: 5px; }
.history-stats { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--ink); color: white; border-radius: 8px; overflow: hidden; }
.history-stats div { min-width: 0; padding: 17px 14px; border-right: 1px solid rgba(255,255,255,.13); }
.history-stats div:last-child { border-right: 0; }
.history-stats strong, .history-stats span { display: block; }
.history-stats strong { font: 700 25px Georgia, serif; overflow-wrap: anywhere; }
.history-stats span { margin-top: 4px; color: #cbd5e1; font-size: 11px; }
.history-panel { margin-top: 12px; padding: 4px 20px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.history-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-row strong, .history-row span { display: block; }
.history-row strong { font-size: 14px; }
.history-row span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.history-row b { color: var(--accent-dark); font: 700 22px Georgia, serif; }
.unfamiliar-heading { margin-top: 34px; }
.unfamiliar-panel { padding: 4px 20px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.unfamiliar-toolbar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.unfamiliar-toolbar .muted { font-size: 12px; }
.unfamiliar-toolbar button:disabled { cursor: not-allowed; opacity: .45; }
.unfamiliar-row { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.unfamiliar-row:last-child { border-bottom: 0; }
.unfamiliar-row strong, .unfamiliar-row span { display: block; }
.unfamiliar-row strong { font: 700 18px Georgia, serif; }
.unfamiliar-row span { max-width: 62vw; margin-top: 4px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger { color: var(--danger); }
.test-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.back { width: 38px; height: 38px; border: 1px solid var(--line); background: white; border-radius: 50%; }
.question { padding: 18px 0; border-bottom: 1px solid var(--line); }
.question-title { display: flex; align-items: baseline; gap: 10px; }
.question-title strong { font: 700 21px Georgia, serif; }
.question-title .test-marker { margin-left: auto; }
.pos { color: var(--accent); font-weight: 750; font-size: 13px; }
.question input { margin-top: 10px; }
.question.correct input { border-color: var(--good); background: #f0fbf7; }
.question.wrong input { border-color: var(--danger); background: #fff5f5; }
.answer-line { font-size: 13px; margin-top: 8px; color: var(--muted); }
.answer-line b { color: var(--ink); }
.score-box { margin: 18px 0; padding: 20px; text-align: center; background: var(--ink); color: white; border-radius: 8px; }
.score-box strong { font: 700 42px Georgia, serif; }
.bottom-nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(66px + env(safe-area-inset-bottom)); padding: 5px max(8px, calc((100vw - 700px)/2)) env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.bottom-nav button { border: 0; background: transparent; color: #7c8595; font-size: 11px; display: grid; place-content: center; gap: 2px; }
.bottom-nav button.active { color: var(--accent-dark); font-weight: 750; }
.nav-icon { font-size: 21px; line-height: 1; }
.toast { position: fixed; z-index: 50; left: 50%; top: 18px; transform: translate(-50%,-80px); width: max-content; max-width: calc(100vw - 36px); padding: 11px 16px; background: var(--ink); color: white; border-radius: 6px; box-shadow: var(--shadow); transition: transform .25s; font-size: 13px; }
.toast.show { transform: translate(-50%,0); }
@media (max-width: 620px) {
  .word-grid { grid-template-columns: 1fr; }
  .word-card:nth-child(odd), .word-card:nth-child(even) { padding-left: 0; padding-right: 0; border-right: 0; }
  .view { padding-top: 20px; }
  .auth-panel { padding: 20px; }
  .daily-alert { align-items: flex-start; }
  .daily-alert b { max-width: 72px; text-align: right; line-height: 1.4; }
  .history-stats { grid-template-columns: repeat(2, 1fr); }
  .history-stats div:nth-child(even) { border-right: 0; }
  .history-stats div:nth-child(-n+4) { border-bottom: 1px solid rgba(255,255,255,.13); }
  .history-stats div:last-child { grid-column: 1 / -1; text-align: center; }
  .username-editor { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .view { animation: none; } * { scroll-behavior: auto !important; } }
