:root {
  color-scheme: dark;
  --page: #10120f;
  --surface: #1a1d18;
  --surface-soft: #20241d;
  --ink: #f3f1e8;
  --muted: #9ca091;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #d8f273;
  --accent-ink: #18200b;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background: radial-gradient(circle at 15% 0%, rgba(111, 137, 72, 0.14), transparent 30%), var(--page);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}
.app-shell { position: relative; width: min(1080px, 100%); min-height: 100dvh; margin: auto; padding: 18px 18px 110px; }
.topbar { height: 48px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; color: var(--ink); background: none; font-size: 14px; font-weight: 650; letter-spacing: .02em; cursor: pointer; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid rgba(216,242,115,.45); border-radius: 9px; color: var(--accent); font: 16px Georgia, serif; }
.streak-pill { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.streak-pill span:first-child { color: var(--accent); }
.view, .study-view { display: none; }
.view.is-active, .study-view.is-active { display: block; }

.home-view { width: min(680px, 100%); margin: auto; }
.home-intro { padding: 42px 2px 30px; }
.date-label, .section-label { margin: 0 0 10px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.home-intro h1, .page-heading h1 { margin: 0; font: 400 clamp(36px, 10vw, 58px)/1.08 Georgia, "Times New Roman", serif; letter-spacing: -.035em; }
.home-intro > p:last-child, .page-heading p { margin: 14px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

.daily-card { padding: 24px; border: 1px solid rgba(216,242,115,.18); border-radius: 26px; background: linear-gradient(145deg, rgba(43,50,34,.92), rgba(25,28,23,.94)); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.daily-card-head, .section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.daily-card h2, .home-section h2, .settings-card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.time-estimate, .section-head span { color: var(--muted); font-size: 12px; }
.task-counts { display: flex; align-items: center; gap: 26px; margin: 30px 0 26px; }
.task-counts div { display: flex; flex-direction: column; gap: 4px; }
.task-counts strong { font: 400 42px/1 Georgia, serif; }
.task-counts span { color: var(--muted); font-size: 12px; }
.task-counts i { width: 1px; height: 38px; background: var(--line); }
.start-button { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 17px; color: var(--accent-ink); background: var(--accent); font-weight: 700; cursor: pointer; }
.start-button svg { width: 18px; }
.start-button:disabled { color: var(--muted); background: rgba(255,255,255,.07); cursor: default; }

.home-section { margin-top: 32px; padding: 0 2px; }
.home-progress { height: 6px; margin-top: 18px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.home-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.section-note { margin: 12px 0 0; color: #73786c; font-size: 12px; line-height: 1.6; }
.memory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.memory-grid div { min-width: 0; padding: 18px 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.025); }
.memory-grid strong, .memory-grid span { display: block; }
.memory-grid strong { font: 400 25px Georgia, serif; }
.memory-grid span { margin-top: 7px; color: var(--muted); font-size: 11px; }

.page-heading { padding: 42px 2px 28px; }
.book-view, .profile-view { width: min(720px, 100%); margin: auto; }
.search-box { height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.035); }
.search-box svg { width: 19px; color: var(--muted); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--ink); background: none; }
.search-box input::placeholder { color: #6f7369; }
.word-list { margin-top: 16px; border-top: 1px solid var(--line); }
.word-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 2px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: none; text-align: left; cursor: pointer; }
.word-row > span { min-width: 0; }
.word-row strong, .word-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-row strong { font: 400 20px Georgia, serif; }
.word-row small { max-width: 55vw; margin-top: 5px; color: var(--muted); font-size: 11px; }
.word-status { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.05); font-size: 10px; font-style: normal; }
.word-status.review { color: #e8dba1; background: rgba(232,219,161,.09); }
.word-status.mastered { color: var(--accent); background: rgba(216,242,115,.09); }

.settings-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.03); }
.settings-card p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.settings-card select { min-width: 88px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.profile-stats div { padding: 20px 14px; border: 1px solid var(--line); border-radius: 18px; }
.profile-stats span, .profile-stats strong { display: block; }
.profile-stats span { color: var(--muted); font-size: 11px; }
.profile-stats strong { margin-top: 10px; font: 400 28px Georgia, serif; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); width: min(360px, calc(100% - 28px)); height: 66px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px; transform: translateX(-50%); border: 1px solid rgba(255,255,255,.1); border-radius: 22px; background: rgba(25,28,23,.92); box-shadow: 0 16px 45px rgba(0,0,0,.4); backdrop-filter: blur(18px); }
.bottom-nav[hidden] { display: none; }
.bottom-nav button { display: grid; place-items: center; border: 0; border-radius: 16px; color: #777b70; background: none; font-size: 12px; cursor: pointer; }
.bottom-nav button.is-active { color: var(--accent); background: rgba(216,242,115,.08); }

.study-view { padding-bottom: 20px; }
.study-header { height: 48px; display: grid; grid-template-columns: 40px 1fr 42px; align-items: center; gap: 12px; }
.back-button, .sound-button { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: rgba(255,255,255,.04); cursor: pointer; }
.back-button { width: 38px; height: 38px; }
.back-button svg, .sound-button svg { width: 19px; }
.study-header > span { color: var(--muted); font-size: 11px; text-align: right; }
.study-progress { height: 3px; overflow: hidden; border-radius: 9px; background: var(--line); }
.study-progress span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .3s ease; }
.study-layout { display: grid; gap: 22px; padding-top: 18px; }
.video-stage { position: relative; width: min(100%, 480px); aspect-ratio: 3 / 4; justify-self: center; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: #090a09; box-shadow: 0 28px 70px rgba(0,0,0,.35); isolation: isolate; }
.video-frame, .native-video { width: 100%; height: 100%; }
.native-video { display: block; border: 0; background: #090a09; object-fit: contain; object-position: center; animation: video-in .18s ease-out; }
@keyframes video-in { from { opacity: .35; } to { opacity: 1; } }
.video-error { width: 100%; height: 100%; display: grid; place-items: center; padding: 24px; color: var(--accent); background: var(--surface); text-align: center; text-decoration: none; font-size: 12px; }
.video-dots { position: absolute; z-index: 3; right: 14px; bottom: 16px; display: flex; gap: 7px; }
.video-dot { width: 6px; height: 6px; padding: 0; border: 0; border-radius: 9px; background: rgba(255,255,255,.35); transition: .18s ease; }
.video-dot.is-active { width: 18px; background: var(--accent); }
.empty-video { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 9px; padding: 28px 22px; overflow: hidden; background: radial-gradient(circle at 50% 30%, rgba(216,242,115,.18), transparent 28%), linear-gradient(145deg,#303a29,#171a16 65%); }
.empty-letter { position: absolute; inset: 0; display: grid; place-items: center; font: 200 180px Georgia,serif; color: rgba(255,255,255,.055); }
.empty-video strong, .empty-video p { position: relative; }
.empty-video strong { font-size: 15px; }
.empty-video p { margin: 0; color: var(--muted); font-size: 12px; }
.word-panel { width: min(620px, 100%); justify-self: center; display: flex; flex-direction: column; justify-content: flex-start; min-height: 0; }
.word-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.word-heading h1 { margin: 0; overflow-wrap: anywhere; font: 400 clamp(45px, 13vw, 80px)/.98 Georgia,serif; letter-spacing: -.045em; }
.sound-button { flex: 0 0 auto; width: 42px; height: 42px; }
.phonetic { min-height: 21px; margin: 14px 0 0; color: var(--accent); font: 16px Georgia,serif; }
.answer-panel { max-height: 0; min-height: 0; margin: 0; padding: 0; overflow: hidden; border-top: 1px solid transparent; filter: blur(9px); opacity: 0; user-select: none; transition: .2s ease; }
.answer-panel.is-revealed { max-height: 240px; margin-top: 16px; padding-top: 16px; border-top-color: rgba(216,242,115,.35); filter: none; opacity: 1; user-select: auto; }
.translation { margin: 0; color: #d4d5cd; font-size: 16px; line-height: 1.7; }
.recall-actions { margin-top: 18px; }
.reveal-button { width: 100%; min-height: 54px; border: 1px solid var(--accent); border-radius: 16px; color: var(--accent-ink); background: var(--accent); font-weight: 700; cursor: pointer; }
.rating-actions { display: none; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.rating-actions.is-visible { display: grid; }
.rating-actions button { min-width: 0; min-height: 60px; padding: 8px 3px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: rgba(255,255,255,.035); cursor: pointer; }
.rating-actions strong, .rating-actions span { display: block; }
.rating-actions strong { font-size: 12px; }
.rating-actions span { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 96px; max-width: calc(100% - 32px); padding: 10px 14px; transform: translate(-50%,16px); border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: rgba(25,28,23,.96); box-shadow: 0 12px 30px rgba(0,0,0,.3); font-size: 12px; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (min-width: 820px) {
  .app-shell { padding: 24px 34px 70px; }
  .bottom-nav { top: 22px; right: 34px; bottom: auto; left: auto; width: 260px; height: 48px; transform: none; border-radius: 16px; }
  .home-intro, .page-heading { padding-top: 80px; }
  .study-layout { grid-template-columns: minmax(320px,.8fr) minmax(390px,1fr); align-items: center; min-height: calc(100dvh - 92px); gap: clamp(50px,8vw,110px); padding: 20px clamp(20px,4vw,56px); }
  .video-stage { width: min(100%, 480px); aspect-ratio: 3 / 4; }
  .word-panel { min-height: 0; padding: 28px 0; }
  .rating-actions { gap: 10px; }
  .rating-actions button { min-height: 70px; }
}

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