:root {
  --paper: oklch(96.5% 0.018 145);
  --paper-deep: oklch(91.5% 0.035 145);
  --ink: oklch(27% 0.04 150);
  --muted: oklch(45% 0.035 150);
  --line: oklch(82% 0.04 145);
  --card: oklch(99% 0.008 145);
  --accent: oklch(56% 0.12 155);
  --accent-dark: oklch(39% 0.1 155);
  --accent-soft: oklch(92% 0.045 155);
  --green: oklch(50% 0.11 150);
  --green-soft: oklch(93% 0.04 150);
  --yellow: oklch(67% 0.13 78);
  --yellow-soft: oklch(94% 0.05 82);
  --red: oklch(56% 0.16 30);
  --red-soft: oklch(94% 0.04 30);
  --blue: oklch(53% 0.1 225);
  --blue-soft: oklch(93% 0.04 225);
  --overlay: oklch(24% 0.025 150 / 58%);
  --shadow: 0 12px 32px oklch(28% 0.03 150 / 10%), 0 2px 4px oklch(28% 0.03 150 / 7%);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, article:focus-visible, label:focus-within {
  outline: 3px solid oklch(67% 0.11 155 / 45%);
  outline-offset: 3px;
}

.app-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 24px; }

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; font-weight: 800; font-size: 20px; cursor: pointer; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--accent-dark); color: var(--card); border-radius: 9px 9px 9px 2px; font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.streak { color: var(--muted); font-size: 13px; }
.account-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 800; }
.logout-button { color: var(--muted); font-size: 12px; }
.icon-button, .secondary-button, .text-button, .close-button { border: 0; cursor: pointer; }
.icon-button { width: 40px; height: 40px; border-radius: 50%; background: transparent; font-weight: 800; }
.icon-button.is-muted { opacity: 0.38; }
.secondary-button { padding: 10px 16px; border-radius: 10px; color: var(--card); background: var(--accent-dark); font-weight: 700; }
.secondary-button:hover { background: var(--accent); }

.study-header { min-height: 132px; display: flex; align-items: end; justify-content: space-between; gap: 28px; padding: 28px 0 22px; }
.status-banner { margin-top: 18px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--accent-soft); color: var(--accent-dark); font-size: 13px; line-height: 1.5; }
.eyebrow { margin: 0 0 6px; color: var(--accent-dark); font: 800 11px/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: 0.14em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 47px); line-height: 1.08; letter-spacing: -0.04em; }
.session-meta { display: grid; grid-template-columns: repeat(3, auto); gap: 22px; padding-bottom: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.session-meta strong { display: block; color: var(--ink); font-size: 21px; line-height: 1.1; }
.study-tools { display: grid; justify-items: end; gap: 10px; }
.volume-picker { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.volume-picker select { min-width: 154px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); padding: 9px 34px 9px 12px; font: inherit; cursor: pointer; }
.volume-picker select:focus-visible { outline: 3px solid color-mix(in oklch, var(--accent) 28%, transparent); outline-offset: 2px; }
.library-summary { color: var(--muted); font-size: 12px; }
.data-credit { padding: 20px 0 28px; color: var(--muted); font-size: 11px; text-align: center; }
.data-credit a { color: inherit; text-underline-offset: 3px; }
.data-credit a:hover { color: var(--ink); }

.study-layout { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 34px; align-items: stretch; }
.progress-panel { padding-top: 22px; display: flex; flex-direction: column; align-items: center; }
.progress-ring { width: 118px; aspect-ratio: 1; padding: 8px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) 0deg, var(--paper-deep) 0deg); }
.progress-ring::before { content: ""; position: absolute; width: 94px; aspect-ratio: 1; border-radius: 50%; background: var(--paper); }
.progress-ring > div { position: relative; z-index: 1; text-align: center; }
.progress-ring strong { display: block; font-size: 24px; }
.progress-ring span { color: var(--muted); font-size: 11px; }
.progress-copy { width: 100%; margin-top: 20px; padding: 15px 0; display: grid; gap: 8px; text-align: center; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.streak-card { width: 100%; margin-top: 15px; padding: 13px 11px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); text-align: center; }
.streak-card > div { display: flex; justify-content: center; align-items: baseline; gap: 3px; }.streak-card > div strong { font-size: 24px; }.streak-card > div span { color: var(--muted); font-size: 11px; }
.streak-card p { margin: 4px 0 9px; color: var(--muted); font-size: 10px; line-height: 1.45; }.streak-card p b { color: var(--ink); }
.makeup-count { display: inline-block; padding: 5px 8px; border-radius: 7px; background: var(--paper-deep); font-size: 10px; }
.legend { width: 100%; display: grid; gap: 10px; margin-top: 18px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot-new { background: var(--accent); }.dot-learning { background: var(--yellow); }.dot-review { background: var(--green); }

.card-stage { min-width: 0; display: grid; grid-template-columns: 88px minmax(0, 760px) 88px; justify-content: center; align-items: stretch; }
.nav-zone { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; cursor: pointer; font-size: 11px; transition: color 160ms ease, transform 160ms ease; }
.nav-zone span:first-child { font-size: 24px; }
.nav-zone:hover { color: var(--accent-dark); transform: translateX(-3px); }
.nav-zone-right:hover { transform: translateX(3px); }

.flashcard { position: relative; min-height: 560px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: box-shadow 220ms ease; }
.flashcard.is-flipped { box-shadow: 0 16px 38px oklch(28% 0.03 150 / 14%), 0 2px 4px oklch(28% 0.03 150 / 7%); }
.card-face { position: absolute; inset: 0; padding: 28px; display: flex; flex-direction: column; transition: opacity 190ms ease, transform 240ms cubic-bezier(.2,.75,.25,1); }
.card-front { opacity: 1; transform: translateY(0) scale(1); }
.card-back { opacity: 0; transform: translateY(10px) scale(.99); pointer-events: none; cursor: default; }
.flashcard.is-flipped .card-front { opacity: 0; transform: translateY(-8px) scale(.99); pointer-events: none; }
.flashcard.is-flipped .card-back { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.card-status { align-self: flex-start; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 11px; }
.front-content { flex: 1; display: grid; place-content: center; justify-items: center; padding-bottom: 12px; text-align: center; }
.word { margin-bottom: 10px; font-size: clamp(46px, 8vw, 86px); font-weight: 800; line-height: 1; letter-spacing: -0.055em; overflow-wrap: anywhere; }
.phonetic { margin-bottom: 26px; color: var(--muted); font: 500 clamp(17px, 2vw, 22px)/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.pronounce-button { border: 1px solid var(--line); background: transparent; border-radius: 11px; padding: 10px 15px; display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-size: 13px; font-weight: 700; }
.pronounce-button:hover { border-color: var(--accent); color: var(--accent-dark); }
.flip-hint { margin-bottom: 0; color: var(--muted); text-align: center; font-size: 11px; }
kbd { padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--card); font: 600 10px/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace; }

.card-back { padding-bottom: 22px; }
.card-back .card-status { position: absolute; z-index: 2; top: 20px; left: 20px; color: var(--card); border-color: oklch(96% 0.01 145 / 55%); background: oklch(28% 0.03 150 / 58%); backdrop-filter: blur(8px); }
.image-frame { position: relative; height: 205px; flex: 0 0 auto; margin: -28px -28px 19px; overflow: hidden; background: var(--paper-deep); }
.image-frame::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 -32px 40px oklch(25% 0.02 150 / 7%); pointer-events: none; }
.image-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-placeholder { position: absolute; inset: 0; z-index: 1; display: none; place-content: center; justify-items: center; gap: 10px; color: var(--muted); background: var(--paper-deep); }
.image-placeholder.is-visible { display: grid; }
.image-placeholder button { border: 0; background: transparent; color: var(--accent-dark); text-decoration: underline; cursor: pointer; }
.answer-copy { flex: 1; display: grid; grid-template-columns: .8fr 1.2fr; gap: 30px; min-height: 0; }
.answer-word { margin-bottom: 5px; font-size: 19px; font-weight: 800; }
.definition { margin-bottom: 0; font-size: clamp(19px, 2.4vw, 27px); line-height: 1.35; font-weight: 750; }
.example-block { padding: 14px 16px; border-radius: 10px; background: var(--accent-soft); align-self: start; }
.example { margin-bottom: 8px; font-size: 16px; line-height: 1.55; font-weight: 650; }
.translation { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.rating-wrap { padding-top: 18px; border-top: 1px solid var(--line); }
.rating-wrap > p { margin-bottom: 10px; color: var(--muted); text-align: center; font-size: 11px; }
.rating-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.rating { min-height: 55px; border: 1px solid var(--line); border-radius: 11px; background: transparent; display: grid; place-content: center; gap: 2px; cursor: pointer; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.rating:hover { transform: translateY(-2px); }
.rating span { font-weight: 800; font-size: 13px; }.rating small { color: var(--muted); font-size: 10px; }
.rating-again:hover { border-color: var(--red); background: var(--red-soft); }.rating-hard:hover { border-color: var(--yellow); background: var(--yellow-soft); }.rating-good:hover { border-color: var(--green); background: var(--green-soft); }.rating-easy:hover { border-color: var(--blue); background: var(--blue-soft); }

.shortcut-bar { margin: 18px auto 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; color: var(--muted); font-size: 10px; }
.shortcut-bar span { display: inline-flex; align-items: center; gap: 5px; }

.import-dialog { width: min(620px, calc(100% - 28px)); max-height: min(760px, calc(100dvh - 28px)); padding: 0; border: 0; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.import-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
.dialog-shell { padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.dialog-head h2 { margin-bottom: 0; font-size: 28px; letter-spacing: -0.03em; }
.close-button { width: 36px; height: 36px; border-radius: 50%; background: var(--paper); font-size: 24px; line-height: 1; }
.dialog-intro { color: var(--muted); font-size: 14px; line-height: 1.6; }
.drop-zone { min-height: 170px; border: 1px dashed var(--muted); border-radius: 14px; display: grid; place-content: center; justify-items: center; gap: 7px; padding: 24px; text-align: center; cursor: pointer; background: var(--paper); }
.drop-zone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone span { color: var(--muted); font-size: 12px; }
.format-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.format-grid div { padding: 14px; border: 1px solid var(--line); border-radius: 11px; display: grid; gap: 5px; }
.format-grid strong { font-size: 12px; }.format-grid span { color: var(--muted); font: 500 10px/1.5 ui-monospace, "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
.dialog-feedback { min-height: 22px; margin-top: 12px; color: var(--green); font-size: 13px; }
.dialog-feedback.is-error { color: var(--red); }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.text-button { padding: 8px 0; background: transparent; color: var(--accent-dark); font-weight: 700; }
.primary-button { width: 100%; border: 0; border-radius: 11px; padding: 13px 16px; color: var(--card); background: var(--accent-dark); font-weight: 800; cursor: pointer; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.auth-dialog { width: min(430px, calc(100% - 28px)); padding: 0; border: 0; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.auth-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(7px); }
.auth-shell { display: grid; gap: 17px; padding: 30px; }
.auth-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; }
.auth-shell h2 { margin-bottom: 7px; font-size: 29px; letter-spacing: -.035em; }
.auth-intro, .auth-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.field-label { display: grid; gap: 7px; font-size: 12px; font-weight: 800; }
.field-label input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--paper); outline: 0; }
.field-label input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px oklch(67% 0.11 155 / 24%); }
.auth-feedback { min-height: 18px; color: var(--red); font-size: 12px; }
.auth-switch { justify-self: center; padding: 2px; }
.auth-note { text-align: center; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 28px; translate: -50% 20px; padding: 11px 16px; border-radius: 9px; color: var(--card); background: var(--accent-dark); opacity: 0; pointer-events: none; transition: opacity 180ms ease, translate 180ms ease; font-size: 12px; box-shadow: 0 8px 20px oklch(25% 0.03 150 / 18%); }
.toast.is-visible { opacity: 1; translate: -50% 0; }

@media (max-width: 860px) {
  .app-shell { width: min(100% - 24px, 760px); }
  .study-header { align-items: start; flex-direction: column; gap: 18px; }
  .study-tools { width: 100%; justify-items: stretch; }
  .volume-picker { justify-content: space-between; }
  .study-layout { grid-template-columns: 1fr; gap: 16px; }
  .progress-panel { order: 2; padding: 0; flex-direction: row; justify-content: center; gap: 20px; }
  .progress-ring { width: 82px; flex: 0 0 auto; }.progress-ring::before { width: 64px; }.progress-ring strong { font-size: 17px; }.progress-ring span { font-size: 9px; }
  .progress-copy { width: auto; min-width: 140px; margin: 0; }.streak-card { width: 150px; margin: 0; }.legend { display: none; }
  .card-stage { grid-template-columns: 54px minmax(0, 1fr) 54px; }
}

@media (max-width: 620px) {
  .app-shell { width: 100%; padding: 0 12px 18px; }
  .topbar { height: 64px; }.brand { font-size: 17px; }.brand-mark { width: 32px; height: 32px; }
  .streak, .icon-button, .logout-button { display: none; }.secondary-button { padding: 9px 12px; font-size: 12px; }.account-name { max-width: 72px; }
  .study-header { min-height: 0; padding: 24px 4px 16px; }.session-meta { width: 100%; justify-content: space-between; gap: 12px; }.session-meta strong { font-size: 18px; }
  .volume-picker select { min-width: 142px; }
  .card-stage { display: grid; grid-template-columns: 1fr; }
  .nav-zone { position: absolute; z-index: 5; top: 230px; width: 44px; height: 98px; color: var(--card); background: oklch(31% 0.04 150 / 48%); backdrop-filter: blur(6px); }
  .nav-zone span:last-child { display: none; }.nav-zone-left { left: 12px; border-radius: 0 12px 12px 0; }.nav-zone-right { right: 12px; border-radius: 12px 0 0 12px; }
  .flashcard { min-height: 590px; }.card-face { padding: 20px; }.word { font-size: clamp(40px, 15vw, 64px); }
  .image-frame { height: 210px; margin: -20px -20px 17px; }
  .answer-copy { grid-template-columns: 1fr; gap: 13px; }.definition { font-size: 21px; }.example-block { padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--paper-deep); }
  .rating-grid { gap: 5px; }.rating { min-height: 58px; }.rating span { font-size: 11px; }.rating small { font-size: 9px; }
  .progress-panel { padding: 2px 8px; justify-content: space-between; flex-wrap: wrap; }.streak-card { order: 3; width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; text-align: left; }.streak-card p { margin: 0; text-align: center; }.legend { display: none; }
  .shortcut-bar { display: none; }
  .format-grid { grid-template-columns: 1fr; }
  .dialog-shell { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
