:root {
  color-scheme: light;
  --bg: #F3F6F4;
  --surface: #FFFFFF;
  --surface2: #ECF1EE;
  --ink: #14221B;
  --dim: #57685E;
  --line: #D7E0D9;
  --teal: #0B6E5D;
  --teal-ink: #FFFFFF;
  --teal-soft: #DCF0E9;
  --amber: #C47100;
  --amber-soft: #FCEFD4;
  --red: #B3261E;
  --red-soft: #FCE4E1;
  --green: #1E7D32;
  --green-soft: #DFF1E2;
  --a1: #0E7C6B;
  --a2: #2563EB;
  --b1: #6F47C9;
  --b2: #C47100;
  --shadow: 0 1px 2px rgba(16, 36, 29, .06), 0 8px 24px -12px rgba(16, 36, 29, .16);
  --shadow-hero: 0 14px 28px rgba(9, 78, 70, .22), 0 2px 6px rgba(9, 78, 70, .12);
  --tabbar-h: 64px;
  /* Phase UI-Motion 1: Motion Design System (65% Apple + 35% Duolingo) */
  --motion-fast: 140ms;
  --motion-normal: 240ms;
  --motion-emph: 380ms;
  --ease-apple: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-duo: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --cta-grad: linear-gradient(180deg, #F5D474 0%, #E2B144 62%, #CA952B 100%);
  --cta-lip: #9E711A;
  --cta-ink: #2B2005;
  --streak-bg: linear-gradient(180deg, #EFF8F4 0%, #E7F4EE 100%);
  --streak-tile: #D8EDE4;
  --streak-dot-bg: rgba(15, 118, 110, .07);
  --nav-pill: #E4F4EE;
}

:root[data-theme="ocean"] {
  color-scheme: light;
  --bg: #EAF4FA;
  --surface: #FFFFFF;
  --surface2: #E1F0F8;
  --ink: #143449;
  --dim: #486477;
  --line: #C5DDEB;
  --teal: #126585;
  --teal-ink: #FFFFFF;
  --teal-soft: #D7EDF6;
  --a1: #126585;
  --shadow: 0 2px 4px rgba(20, 52, 73, .05), 0 12px 28px -16px rgba(20, 85, 125, .25);
  --shadow-hero: 0 14px 28px rgba(12, 74, 110, .24), 0 2px 6px rgba(12, 74, 110, .12);
  --streak-bg: linear-gradient(180deg, #EAF5FC 0%, #E0EFFA 100%);
  --streak-tile: #D0E8F8;
  --streak-dot-bg: rgba(18, 101, 133, .08);
  --nav-pill: #DFF1FC;
}

:root[data-theme="cream"] {
  color-scheme: light;
  --bg: #F7F2E8;
  --surface: #FFFCF5;
  --surface2: #F2EBDD;
  --ink: #342B20;
  --dim: #6B5D49;
  --line: #DED3BF;
  --teal: #50623E;
  --teal-ink: #FFFFFF;
  --teal-soft: #E7EDDB;
  --a1: #50623E;
  --shadow: 0 2px 4px rgba(52, 43, 32, .04), 0 12px 28px -16px rgba(86, 65, 31, .2);
  --shadow-hero: 0 14px 28px rgba(79, 96, 58, .22), 0 2px 6px rgba(79, 96, 58, .12);
  --streak-bg: linear-gradient(180deg, #F3F7EF 0%, #EAF2E6 100%);
  --streak-tile: #DCEBD9;
  --streak-dot-bg: rgba(80, 98, 62, .08);
  --nav-pill: #E7EDDB;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0D120E;
  --surface: #161D17;
  --surface2: #1E2820;
  --ink: #E8F0EA;
  --dim: #9BAE9F;
  --line: #2B392E;
  --teal: #2FA88F;
  --teal-ink: #06231C;
  --teal-soft: #163A31;
  --amber: #E8A33D;
  --amber-soft: #3A2C12;
  --red: #F0907F;
  --red-soft: #3D1D18;
  --green: #7BC47F;
  --green-soft: #1D331F;
  --a1: #3EC6A7;
  --a2: #7FA8F5;
  --b1: #B79BF0;
  --b2: #E8A33D;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-hero: 0 16px 32px rgba(0, 0, 0, .44);
  --cta-grad: linear-gradient(180deg, #F3CE67 0%, #DBA737 62%, #BF8B22 100%);
  --cta-lip: #875E12;
  --cta-ink: #241904;
  --streak-bg: linear-gradient(180deg, #132522 0%, #101F1C 100%);
  --streak-tile: rgba(47, 168, 143, .16);
  --streak-dot-bg: rgba(255, 255, 255, .06);
  --nav-pill: rgba(47, 168, 143, .18);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #0D120E;
    --surface: #161D17;
    --surface2: #1E2820;
    --ink: #E8F0EA;
    --dim: #9BAE9F;
    --line: #2B392E;
    --teal: #2FA88F;
    --teal-ink: #06231C;
    --teal-soft: #163A31;
    --amber: #E8A33D;
    --amber-soft: #3A2C12;
    --red: #F0907F;
    --red-soft: #3D1D18;
    --green: #7BC47F;
    --green-soft: #1D331F;
    --a1: #3EC6A7;
    --a2: #7FA8F5;
    --b1: #B79BF0;
    --b2: #E8A33D;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-hero: 0 16px 32px rgba(0, 0, 0, .44);
    --cta-grad: linear-gradient(180deg, #F3CE67 0%, #DBA737 62%, #BF8B22 100%);
    --cta-lip: #875E12;
    --cta-ink: #241904;
    --streak-bg: linear-gradient(180deg, #132522 0%, #101F1C 100%);
    --streak-tile: rgba(47, 168, 143, .16);
    --streak-dot-bg: rgba(255, 255, 255, .06);
    --nav-pill: rgba(47, 168, 143, .18);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
input { font: inherit; }
[hidden] { display: none !important; }
.storage-banner { position: fixed; z-index: 300; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: 740px; max-height: 45vh; overflow-y: auto; margin: auto; padding: 16px; background: var(--surface); color: var(--ink); border: 2px solid var(--amber); border-radius: 14px; box-shadow: var(--shadow); }
.storage-banner p { margin: 10px 0; line-height: 1.5; }
.voice-controls { margin-top: 18px; }
.voice-controls label { display: block; margin: 14px 0 7px; font-weight: 700; }
.voice-controls select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; }
.voice-controls p { margin: 12px 0; }
.voice-controls details { margin-top: 16px; }
.voice-controls summary { font-weight: 700; cursor: pointer; }
.voice-sample { padding: 14px; border-radius: 12px; background: var(--surface2); line-height: 1.65; }
.study-speech-status { color: var(--dim); font-size: 12px; padding: 0 16px 8px; margin: 0; overflow-wrap: anywhere; }
.study-speech-status:empty { display: none; }
.speech-lab > label, .rating-fields label { display: block; font-weight: 650; margin: 12px 0 6px; }
.speech-lab select, .speech-lab textarea { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); }
.speech-lab p { margin: 10px 0; }
.speech-lab .ab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.ab-card { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface2); min-width: 0; }
.ab-card p { overflow-wrap: anywhere; }
.speech-lab .lab-check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.lab-check input { width: 20px; height: 20px; }
@media (max-width: 460px) { .speech-lab .ab-grid { grid-template-columns: 1fr; } }
.lesson-outcome { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.lesson-outcome p { margin: 10px 0 14px; }
.takeaway { margin-top: 20px; text-align: left; }
.takeaway summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.takeaway p { margin: 8px 0 12px; }
.takeaway textarea { display: block; width: 100%; min-height: 180px; padding: 12px; margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.6; resize: vertical; }

/* ---------- App Shell & Topbar ---------- */
.app-shell {
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  border-radius: 9px;
  flex: none;
  box-shadow: 0 2px 6px rgba(11, 110, 93, .22);
}
.brand-title { font-size: 16px; font-weight: 800; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--dim); font-weight: 600; }
.topbar-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.streak-pill {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
}
.streak-pill.done-today {
  background: var(--green-soft);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
}
.status-pill {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--teal-soft);
  color: var(--teal);
}

.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 12px;
}
.tab-view { display: none; }
.tab-view.active { display: block; }

/* Desktop 2-Column Bento Layout (>= 960px) */
.home-bento {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.home-bento-left,
.home-bento-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.home-bento-left > .panel,
.home-bento-right > .panel {
  margin-top: 0;
}
@media (min-width: 960px) {
  .app-main { padding: 22px 24px 20px; }
  .home-bento {
    display: grid;
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
  }
  .home-bento-left {
    position: sticky;
    top: 76px;
  }
  .levels-panel .level-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }
  .levels-panel .lesson-grid {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 11px;
  }
  #viewReview,
  #viewDict,
  #viewSettings,
  #viewArena {
    max-width: 860px;
    margin: 0 auto;
  }
}

/* ---------- Install Banner ---------- */
.install-banner {
  max-width: 728px;
  margin: 12px auto 0;
  background: var(--surface);
  border: 1px solid var(--teal);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}
@media (max-width: 760px) {
  .install-banner { margin: 12px 16px 0; }
}
.install-banner-text { min-width: 0; }
.install-banner-text strong { display: block; font-size: 14px; font-weight: 800; }
.install-banner-text span { display: block; font-size: 12.5px; color: var(--dim); margin-top: 2px; }
.install-banner-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-close {
  border: 0;
  background: var(--surface2);
  color: var(--dim);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Dashboard ---------- */
.dash {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #13857A 0%, #0D6E64 52%, #095850 100%);
  color: #fff;
  border-radius: 22px;
  padding: 19px 18px 18px;
  border: 1px solid rgba(255, 255, 255, .15);
  box-shadow: var(--shadow-hero);
}
.dash::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 12% 8%, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, 0) 50%),
              radial-gradient(circle at 92% 96%, rgba(134, 239, 205, .18) 0%, rgba(134, 239, 205, 0) 48%);
  pointer-events: none;
}
:root[data-theme="dark"] .dash {
  background: linear-gradient(145deg, #167C71 0%, #0F6259 52%, #0A4942 100%);
}
:root[data-theme="ocean"] .dash {
  background: linear-gradient(145deg, #0284C7 0%, #0369A1 52%, #0C4A6E 100%);
}
:root[data-theme="cream"] .dash {
  background: linear-gradient(145deg, #627648 0%, #50623E 52%, #3D4C2F 100%);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .dash {
    background: linear-gradient(145deg, #167C71 0%, #0F6259 52%, #0A4942 100%);
  }
}
.dash-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dash-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: .82;
}
.dash h1 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; line-height: 1.22; margin-top: 3px; }
.dash-ring {
  position: relative;
  width: 66px;
  height: 66px;
  flex: none;
  display: grid;
  place-items: center;
}
.dash-ring-svg {
  width: 66px;
  height: 66px;
  transform: rotate(-90deg);
  display: block;
}
.dash-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, .2);
  stroke-width: 5.4;
}
.dash-ring-arc {
  fill: none;
  stroke: #86EFCD;
  stroke-width: 5.4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(134, 239, 205, .45));
  transition: stroke-dashoffset var(--motion-emph) var(--ease-apple);
}
.dash-ring-val {
  position: absolute;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.dash-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.dash-stat-tile {
  background: rgba(255, 255, 255, .11);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  padding: 9px 10px;
  min-width: 0;
}
.dash-stats .num-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dash-stats .num { font-size: 20px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.dash-stats .stat-ic { font-size: 14px; line-height: 1; }
.dash-stats .lbl { font-size: 11px; opacity: .86; margin-top: 3px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar {
  position: relative;
  z-index: 1;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .22);
  overflow: hidden;
  margin-top: 14px;
}
.bar > div {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #F7DC84 0%, #EAB542 100%);
  transition: width var(--motion-emph) var(--ease-apple);
}
.btn-continue {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  width: 100%;
  background: var(--cta-grad);
  color: var(--cta-ink);
  border: 0;
  border-radius: 15px;
  padding: 13px 18px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -.01em;
  min-height: 50px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 4px 0 var(--cta-lip), 0 10px 18px rgba(6, 46, 41, .24);
  transition: transform var(--motion-fast) var(--ease-duo), filter var(--motion-fast) var(--ease-standard);
}
.btn-continue:hover { filter: brightness(1.03); }
.btn-continue:active { transform: translateY(2.5px) scale(0.986); }
.btn-continue:disabled { opacity: .5; cursor: default; transform: none; filter: none; }

/* ---------- Panels & Common UI ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.panel:first-child { margin-top: 0; }
.panel h2 { font-size: 17px; font-weight: 800; }
.panel .desc { color: var(--dim); font-size: 14.5px; margin-top: 6px; }
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.muted-sm { font-size: 13px; color: var(--dim); font-weight: 600; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  border-radius: 11px;
  padding: 11px 15px;
  font-weight: 700;
  font-size: 14.5px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 13.5px; border-radius: 9px; }
.btn.full { width: 100%; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--teal-ink); }
.btn.danger { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.file-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.file-msg { font-size: 14px; margin-top: 10px; color: var(--teal); min-height: 18px; font-weight: 600; }

/* ---------- Levels & Lessons ---------- */
.level-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 560px) {
  .level-tabs { grid-template-columns: repeat(2, 1fr); }
}
.ltab {
  text-align: left;
  border: 1.5px solid var(--line);
  border-bottom-width: 3.5px;
  background: var(--surface2);
  border-radius: 17px;
  padding: 13px 13px 12px;
  color: var(--ink);
  min-height: 58px;
  transition: transform var(--motion-fast) var(--ease-duo),
              border-color var(--motion-normal) var(--ease-apple),
              background-color var(--motion-normal) var(--ease-apple),
              box-shadow var(--motion-normal) var(--ease-apple);
}
.ltab:hover { transform: translateY(-1px); }
.ltab:active { transform: translateY(2px) scale(0.982); }
.ltab.on {
  border-color: var(--teal);
  background: var(--surface);
  box-shadow: 0 6px 14px rgba(10, 35, 30, .07);
}
.ltab[data-lv="A1"].on { border-color: var(--a1); background: color-mix(in srgb, var(--a1) 8%, var(--surface)); }
.ltab[data-lv="A2"].on { border-color: var(--a2); background: color-mix(in srgb, var(--a2) 8%, var(--surface)); }
.ltab[data-lv="B1"].on { border-color: var(--b1); background: color-mix(in srgb, var(--b1) 8%, var(--surface)); }
.ltab[data-lv="B2"].on { border-color: var(--b2); background: color-mix(in srgb, var(--b2) 8%, var(--surface)); }
.ltab .lv { font-size: 18px; font-weight: 900; display: block; letter-spacing: -.02em; }
.ltab .nm { font-size: 12px; color: var(--dim); font-weight: 600; margin-top: 1px; }
.ltab .ct { font-size: 12px; margin-top: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ltab .mini { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 5px; }
.ltab .mini > div { height: 100%; border-radius: 99px; transition: width var(--motion-emph) var(--ease-apple); }
.ltab[data-lv="A1"] .lv { color: var(--a1); }
.ltab[data-lv="A2"] .lv { color: var(--a2); }
.ltab[data-lv="B1"] .lv { color: var(--b1); }
.ltab[data-lv="B2"] .lv { color: var(--b2); }
.ltab[data-lv="A1"] .mini > div { background: var(--a1); }
.ltab[data-lv="A2"] .mini > div { background: var(--a2); }
.ltab[data-lv="B1"] .mini > div { background: var(--b1); }
.ltab[data-lv="B2"] .mini > div { background: var(--b2); }

.lesson-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.lesson-head h3 { font-size: 15px; font-weight: 800; }
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 9px;
  margin-top: 12px;
}
.lbtn {
  border: 1.5px solid var(--line);
  border-bottom-width: 3.5px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 15px;
  padding: 11px 6px;
  font-weight: 800;
  font-size: 14.5px;
  text-align: center;
  min-height: 56px;
  box-shadow: 0 2px 6px rgba(12, 34, 28, .04);
  transition: transform var(--motion-fast) var(--ease-duo),
              border-color var(--motion-fast) var(--ease-standard),
              background-color var(--motion-fast) var(--ease-standard),
              box-shadow var(--motion-fast) var(--ease-standard);
}
.lbtn:hover { transform: translateY(-1.5px); box-shadow: 0 5px 12px rgba(12, 34, 28, .08); }
.lbtn:active { transform: translateY(2px) scale(0.97); }
.lbtn small { display: block; font-size: 10.5px; font-weight: 700; color: var(--dim); margin-top: 2px; }
.lbtn.done {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}
.lbtn.next {
  border: 2px solid var(--amber);
  border-bottom-width: 4px;
  background: var(--amber-soft);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(196, 113, 0, .14);
}
.more-row { margin-top: 12px; text-align: center; }

/* ---------- Review Tab ---------- */
.review-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
@media (max-width: 440px) {
  .review-cards { grid-template-columns: 1fr; }
}
.review-box {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.review-num { font-size: 28px; font-weight: 900; color: var(--teal); line-height: 1; }
.review-num.amber { color: var(--amber); }
.review-lbl { font-size: 13.5px; font-weight: 700; color: var(--dim); margin-bottom: 4px; }

/* ---------- Dictionary & Word Rows ---------- */
.search-wrap { margin-top: 12px; }
.search-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface2);
  color: var(--ink);
  padding: 12px 15px;
  font-size: 16px;
  min-height: 48px;
  transition: border-color var(--motion-fast) var(--ease-standard),
              background-color var(--motion-fast) var(--ease-standard),
              box-shadow var(--motion-fast) var(--ease-standard);
}
.search-input:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent);
}

.filter-chips, .theme-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  border: 1.5px solid var(--line);
  border-bottom-width: 3px;
  background: var(--surface2);
  color: var(--dim);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 700;
  min-height: 36px;
  transition: transform var(--motion-fast) var(--ease-duo),
              background-color var(--motion-fast) var(--ease-standard),
              border-color var(--motion-fast) var(--ease-standard),
              color var(--motion-fast) var(--ease-standard);
}
.chip:active { transform: translateY(1.5px) scale(0.96); }
.chip.on {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--teal-ink);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--teal) 28%, transparent);
}

.wlist { margin-top: 12px; display: grid; gap: 9px; }
.wrow {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(12, 34, 28, .035);
  transition: transform var(--motion-fast) var(--ease-apple),
              border-color var(--motion-fast) var(--ease-standard);
}
.wrow:hover { border-color: color-mix(in srgb, var(--teal) 38%, var(--line)); }
.word-copy { min-width: 0; flex: 1; overflow-wrap: anywhere; }
@media (max-width: 440px) {
  .wrow { flex-wrap: wrap; }
  .word-copy { flex-basis: calc(100% - 56px); }
  .wrow > .icon-btn:first-of-type { margin-left: auto; }
}
.wrow .ww { font-weight: 800; }
.wrow .wi { color: var(--teal); font-size: 13px; font-weight: 600; }
.wrow .wm { color: var(--dim); font-size: 13.5px; margin-top: 2px; }
.wrow .lvtag {
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 7px;
  color: var(--dim);
  background: var(--surface2);
  flex: none;
}
.icon-btn {
  border: 1.5px solid var(--line);
  border-bottom-width: 2.5px;
  background: var(--surface2);
  color: var(--ink);
  border-radius: 11px;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform var(--motion-fast) var(--ease-duo),
              background-color var(--motion-fast) var(--ease-standard),
              border-color var(--motion-fast) var(--ease-standard);
}
.icon-btn:active { transform: translateY(1.5px) scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.marked { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.icon-btn.learned-on { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 800; }
.empty { color: var(--dim); font-size: 14px; padding: 14px 4px; text-align: center; }

/* ---------- Bottom Tab Bar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-indicator {
  position: absolute;
  top: 6px;
  left: 4px;
  width: calc(100% / 5 - 8px);
  height: calc(var(--tabbar-h) - 12px);
  border-radius: 14px;
  background: var(--nav-pill);
  pointer-events: none;
  z-index: 0;
  transform: translateX(0%);
  will-change: transform;
  transition: transform var(--motion-normal) var(--ease-apple);
}
.tabbtn {
  position: relative;
  min-width: 0;
  padding: 0 2px;
  z-index: 1;
  border: 0;
  background: transparent;
  color: var(--dim);
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 700;
  transition: color var(--motion-fast) var(--ease-standard);
}
.tabbtn svg {
  width: 22px;
  height: 22px;
  display: block;
  transition: transform var(--motion-normal) var(--ease-duo);
}
.tabbtn.on { color: var(--teal); }
.tabbtn > span:last-child {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
@media (max-width: 350px) {
  .tabbtn > span:last-child { font-size: 10px; }
}
.tabbtn.on > svg,
.tabbtn.on > .tab-icon-wrap {
  transform: translateY(-1px) scale(1.06);
}
.tab-icon-wrap {
  position: relative;
  display: inline-flex;
  transition: transform var(--motion-normal) var(--ease-duo);
}
.nav-badge {
  position: absolute;
  top: -5px;
  right: -10px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
}

/* ---------- Study Screen (Focused Full-Screen Mobile View) ---------- */
.study-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
.study-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 10px;
}
.study-header > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.study-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.study-header-top h2 {
  font-size: 16px;
  font-weight: 800;
  text-align: right;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-back {
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 14px;
  min-height: 40px;
  flex: none;
}
.study-header-sub { margin-top: 10px; }
.modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--surface2);
  border-radius: 11px;
  padding: 4px;
}
.modes button {
  border: 0;
  background: transparent;
  color: var(--dim);
  border-radius: 8px;
  padding: 8px 4px;
  font-weight: 700;
  font-size: 13px;
  min-height: 40px;
  white-space: nowrap;
}
.modes button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.prog-line {
  height: 7px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}
.prog-line > div { height: 100%; background: var(--teal); transition: width .3s ease; }
.prog-txt { font-size: 12.5px; color: var(--dim); margin-top: 5px; font-weight: 600; }

.study-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Settings Row & Study Toolbar ---------- */
.setting-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.setting-title { font-size: 14.5px; font-weight: 700; }
.toggle-btn {
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--dim);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 800;
  min-height: 36px;
  min-width: 68px;
}
.toggle-btn[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--teal-ink);
}

.card-tools {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.tool-pill {
  flex: 1;
  min-width: 130px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  min-height: 36px;
}
.tool-pill.on,
.tool-pill[aria-pressed="true"] {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}

/* ---------- 3D Flip & Swipe Flashcard ---------- */
.fc-stage {
  perspective: 1200px;
  -webkit-perspective: 1200px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
.fc-swipe-wrap {
  position: relative;
  will-change: transform;
}
.fc-swipe-wrap.snap-back {
  transition: transform .28s cubic-bezier(.22, .85, .32, 1);
}
.fc-swipe-wrap.fly-out {
  transition: transform .2s ease-in, opacity .2s ease-in;
}
.fc-swipe-wrap.card-enter {
  animation: fcEnter .22s ease-out;
}
@keyframes fcEnter {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.fc-swipe-badge {
  position: absolute;
  top: 16px;
  z-index: 10;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
  pointer-events: none;
  opacity: 0;
}
.fc-swipe-badge.know {
  left: 16px;
  background: var(--green-soft);
  border: 2px solid var(--green);
  color: var(--green);
}
.fc-swipe-badge.dunno {
  right: 16px;
  background: var(--amber-soft);
  border: 2px solid var(--amber);
  color: var(--amber);
}

.fc-card {
  display: grid;
  grid-template-columns: 1fr;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform .5s var(--ease-apple);
  cursor: pointer;
}
.fc-card.is-flipped {
  transform: rotateY(180deg);
}
.fc-face {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1.5px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 24px;
  background: var(--surface);
  padding: 22px 20px 24px;
  text-align: center;
  box-shadow: 0 12px 30px -10px rgba(12, 42, 34, .16), 0 2px 6px rgba(12, 42, 34, .06);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}
.fc-front {
  transform: rotateY(0deg);
  z-index: 2;
  pointer-events: auto;
}
.fc-back {
  transform: rotateY(180deg);
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
}
.fc-card.is-flipped .fc-front {
  z-index: 1;
  pointer-events: none;
}
.fc-card.is-flipped .fc-back {
  z-index: 2;
  pointer-events: auto;
}

.fc-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fc-side-tag {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--dim);
}
.fc-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.fc-main {
  margin: auto 0;
  padding: 6px 0;
}
.fc-word { font-size: clamp(32px, 8.5vw, 44px); font-weight: 900; line-height: 1.15; word-break: break-word; }
.fc-ipa { font-size: 17px; color: var(--teal); font-weight: 700; margin-top: 5px; }
.fc-pos {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 10px;
}
.fc-core { font-size: clamp(24px, 6.5vw, 30px); font-weight: 800; line-height: 1.25; }
.fc-full { color: var(--dim); font-size: 14px; margin-top: 4px; }
.fc-ex-box {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
}
.fc-ex { font-size: 15.5px; font-weight: 600; }
.fc-exvi { color: var(--dim); font-size: 13.5px; margin-top: 3px; }
.fc-tip {
  margin-top: 10px;
  text-align: left;
  background: var(--amber-soft);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 13.5px;
}
.fc-tip b { color: var(--amber); }

.fc-foot-hint {
  font-size: 12.5px;
  color: var(--dim);
  font-weight: 600;
}
.fc-audio-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.fc-letter-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.fc-letter-btn {
  min-width: 30px;
  min-height: 32px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}
.fc-letter-btn.speaking {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--teal-ink);
}
.fc-letter-gap {
  align-self: center;
  color: var(--dim);
  font-weight: 800;
  padding: 0 2px;
}
.fc-deck-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.fc-deck-nav {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 8px;
}
.fc-swipe-hint {
  text-align: center;
  font-size: 12.5px;
  color: var(--dim);
  margin-top: 10px;
  font-weight: 600;
}
.fc-summary {
  border: 1.5px solid color-mix(in srgb, var(--teal) 35%, var(--line));
  border-radius: 22px;
  background: var(--surface);
  padding: 26px 20px;
  text-align: center;
  box-shadow: 0 14px 32px -10px rgba(11, 110, 93, .2), var(--shadow);
  animation: fcEnter .36s var(--ease-duo);
}
.fc-summary .big-score { font-size: 34px; font-weight: 900; color: var(--teal); letter-spacing: -.02em; }
.fc-summary p { margin-top: 8px; color: var(--dim); font-size: 15px; }

.row-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.btn.big {
  padding: 13px 15px;
  font-size: 15px;
  min-height: 50px;
  border-radius: 14px;
  border-bottom-width: 3.5px;
  transition: transform var(--motion-fast) var(--ease-duo), filter var(--motion-fast) var(--ease-standard);
}
.btn.big:active { transform: translateY(2px) scale(0.98); }
.btn.know {
  background: var(--teal);
  border-color: color-mix(in srgb, var(--teal) 72%, #000);
  color: var(--teal-ink);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--teal) 26%, transparent);
}
.btn.dunno {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}
.btn.marked { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }

/* ---------- Quiz ---------- */
.quiz-q {
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  padding: 22px 18px;
  box-shadow: var(--shadow);
  animation: fcEnter .26s var(--ease-apple);
}
.quiz-q .qtype { font-size: 12px; font-weight: 800; color: var(--teal); text-transform: uppercase; letter-spacing: .05em; }
.quiz-q .qmain { font-size: 27px; font-weight: 900; letter-spacing: -.02em; margin-top: 6px; word-break: break-word; }
.quiz-q .qsub { color: var(--dim); margin-top: 2px; font-size: 14px; }
.opts { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  text-align: left;
  border: 1.5px solid var(--line);
  border-bottom-width: 3.5px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  min-height: 54px;
  transition: transform var(--motion-fast) var(--ease-duo),
              border-color var(--motion-fast) var(--ease-standard),
              background-color var(--motion-fast) var(--ease-standard);
}
.opt:not(:disabled):active { transform: translateY(2px) scale(0.985); }
.opt.right {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
  animation: icRightPop .32s var(--ease-duo);
}
.opt.wrong {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
  animation: tileShake .32s ease;
}
@keyframes icRightPop {
  0% { transform: scale(0.98); }
  45% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.opt:disabled { cursor: default; }
.quiz-foot {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.score-end { text-align: center; padding: 10px 0 4px; }
.score-end .big-score { font-size: 34px; font-weight: 900; }

/* ---------- Modal Sheet (Install Guide) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
}
.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  margin-bottom: env(safe-area-inset-bottom);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal-content { margin-top: 12px; display: grid; gap: 12px; }
.guide-block {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.guide-os { font-size: 14px; font-weight: 800; color: var(--teal); margin-bottom: 6px; }
.guide-block ol { margin: 0; padding-left: 20px; font-size: 14px; }
.guide-block li + li { margin-top: 4px; }

/* ---------- Streak & Daily Goal ---------- */
.streak-panel {
  padding: 16px;
  border-radius: 20px;
  background: var(--streak-bg);
}
.streak-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.streak-fire {
  display: flex;
  align-items: center;
  gap: 11px;
}
.fire-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--streak-tile);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex: none;
  transition: transform var(--motion-normal) var(--ease-duo), background-color var(--motion-normal) var(--ease-apple);
}
.fire-badge.active {
  background: linear-gradient(135deg, #FFE09E 0%, #FFC53D 100%);
  box-shadow: 0 3px 10px rgba(196, 113, 0, .2);
}
.streak-num { font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.goal-picker {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.daily-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
}
.daily-meta span { color: var(--dim); font-weight: 600; }
.daily-meta strong { color: var(--teal); font-weight: 800; font-variant-numeric: tabular-nums; }
.daily-bar {
  height: 7px;
  border-radius: 99px;
  background: var(--streak-dot-bg);
  overflow: hidden;
  margin-top: 7px;
}
.daily-bar > div {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--teal) 0%, #26A68D 100%);
  transition: width var(--motion-emph) var(--ease-apple);
}
.daily-bar > div.done {
  background: linear-gradient(90deg, var(--green) 0%, #34B34F 100%);
}
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 14px;
}
.wday {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.wday-lbl { font-size: 11px; font-weight: 700; color: var(--dim); }
.wday.is-today .wday-lbl { color: var(--teal); font-weight: 800; }
.wday-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--streak-dot-bg);
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--dim);
  transition: transform var(--motion-normal) var(--ease-duo),
              background-color var(--motion-normal) var(--ease-apple),
              border-color var(--motion-normal) var(--ease-apple);
}
.wday.is-today .wday-dot { border-color: var(--teal); border-width: 2px; }
.wday.has-some .wday-dot {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}
.wday.met-goal .wday-dot {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--teal-ink);
}

.goal-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(92vw, 400px);
  background: #14221B;
  color: #FFFFFF;
  border: 1px solid rgba(255, 197, 61, .55);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  animation: toastIn .25s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- SRS & Mini-games (Matching & Spelling) ---------- */
.srs-hero {
  border-color: color-mix(in srgb, var(--teal) 45%, var(--line));
}
.match-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.match-stat {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--dim);
}
.match-combo {
  font-size: 12.5px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--amber-soft);
  color: var(--amber);
}
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.match-col {
  display: grid;
  gap: 9px;
  align-content: start;
}
.mtile {
  width: 100%;
  min-height: 60px;
  padding: 11px 11px;
  border-radius: 15px;
  border: 1.5px solid var(--line);
  border-bottom-width: 3.5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  word-break: break-word;
  box-shadow: 0 3px 10px rgba(12, 34, 28, .05);
  transition: transform var(--motion-fast) var(--ease-duo),
              border-color var(--motion-fast) var(--ease-standard),
              background-color var(--motion-fast) var(--ease-standard),
              box-shadow var(--motion-fast) var(--ease-standard),
              opacity var(--motion-normal) var(--ease-apple);
}
.mtile:not(:disabled):active { transform: translateY(2px) scale(0.975); }
.mtile.en { font-weight: 800; font-size: 16px; }
.mtile.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  transform: translateY(-2px) scale(1.025);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--teal) 24%, transparent);
}
.mtile.matched {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
  opacity: .56;
  cursor: default;
  box-shadow: none;
  animation: icRightPop .3s var(--ease-duo);
}
.mtile.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
  animation: tileShake .32s ease;
}
@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.spell-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 20px 16px;
  box-shadow: var(--shadow);
}
.spell-meaning {
  font-size: 25px;
  font-weight: 800;
  margin-top: 6px;
  line-height: 1.25;
}
.spell-cloze {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--surface2);
  font-size: 14.5px;
  color: var(--ink);
}
.spell-slots {
  margin-top: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .16em;
  color: var(--teal);
  text-align: center;
  word-break: break-word;
}
.spell-form {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}
.spell-input {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--ink);
  padding: 13px 14px;
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  min-height: 52px;
}
.spell-input:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--surface);
}
.spell-input.right { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.spell-input.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.spell-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14.5px;
}
.spell-feedback.right { background: var(--green-soft); color: var(--green); }
.spell-feedback.wrong { background: var(--red-soft); color: var(--red); }

@media (prefers-reduced-motion: reduce) {
  .bar > div,
  .prog-line > div,
  .daily-bar > div,
  .dash-ring-arc,
  .btn-continue,
  .ltab,
  .ltab .mini > div,
  .lbtn,
  .tabbar-indicator,
  .tabbtn,
  .tabbtn svg,
  .tab-icon-wrap,
  .fire-badge,
  .wday-dot,
  .fc-card,
  .fc-swipe-wrap,
  .fc-summary,
  .quiz-q,
  .opt,
  .goal-toast,
  .mtile {
    transition: none !important;
    animation: none !important;
  }
}

.notebook { border-top: 4px solid var(--teal); }
.nb-head,.nb-title { display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap }
.nb-head h2 { margin:0 }
.nb-head .desc { margin:5px 0 }
#nbList { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,255px),1fr));gap:12px }
.nb-card { border:1px solid var(--line);border-radius:14px;padding:14px;min-width:0;overflow-wrap:anywhere;background:var(--surface) }
.nb-title strong {font-size:1.2rem}
.nb-tag {background:var(--amber-soft);color:var(--ink);border-radius:12px;padding:3px 9px;font-size:.78rem}
.nb-meaning,.nb-state {margin:8px 0;color:var(--dim)}
.nb-state {font-size:.85rem}
.nb-card summary,.nb-backup summary {cursor:pointer;color:var(--teal);padding:8px 0;font-weight:650}
.nb-backup {margin-top:12px;border-top:1px solid var(--line)}
.nb-backup .file-actions,.nb-card .file-actions {flex-wrap:wrap}

.recall-panel { background:linear-gradient(118deg,var(--surface) 50%,var(--teal-soft)); }
.recall-source {display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:12px 0;font-size:.9rem}
.recall-source select {font:inherit;color:var(--ink);background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:7px}
.recall-modes {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,140px),1fr));gap:8px}
.recall-modes button {text-align:left;padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--surface);color:var(--ink);cursor:pointer}
.recall-modes strong,.recall-modes span {display:block}
.recall-modes strong {font-size:1rem;color:var(--teal)}
.recall-modes span {color:var(--dim);font-size:.85rem;margin-top:3px}
.recall-modes button:hover,.recall-modes button:focus-visible {border-color:var(--teal)}
.spell-form {scroll-margin-bottom:20px}

@media(max-width:480px) {
  .recall-modes {grid-template-columns:1fr}
  .recall-modes button {display:flex;align-items:baseline;justify-content:space-between;gap:8px}
}
#nbStatus {margin:10px 0}
.nb-errors {padding-left:1.25rem;color:var(--dim);font-size:.88rem}

.path-tasks {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%, 220px),1fr));gap:8px;margin:12px 0}
.path-task.btn {display:grid;gap:4px;white-space:normal;text-align:left;align-content:start;padding:12px;color:var(--ink)}
.path-task span {font-weight:400;font-size:.87rem;line-height:1.4}
#englishDialog {box-sizing:border-box;width:min(94vw,640px);max-height:88vh;max-height:88dvh;overflow:auto;overscroll-behavior:contain;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:16px;padding:clamp(14px,3vw,28px)}
#englishDialog::backdrop {background:rgba(19,36,32,.52)}
.english-tools {display:flex;justify-content:flex-end}
#englishBody h2 {margin:.4em 0 .6em}
.english-text,.english-task {border-top:1px solid var(--line);padding:12px 0}
.english-text summary {cursor:pointer;font-weight:650}
.english-text p,.english-task p,.english-entry span {line-height:1.55}
.english-word {font:inherit;color:inherit;background:transparent;border:0;border-bottom:1px dashed currentColor;padding:0;cursor:pointer}
.english-gloss,.english-options,.english-task form,.english-entry.btn {display:grid;gap:8px}
.english-gloss:empty {display:none}
.english-entry.btn {width:100%;margin:.45em 0;white-space:normal;text-align:left;justify-content:start;padding:12px}
.english-entry span {font-size:.88rem;font-weight:400}
.english-options .btn {white-space:normal;text-align:left}
.english-task h3 {margin:.4em 0 .8em}
.english-task input {width:100%;box-sizing:border-box;padding:10px;border:1px solid var(--line);border-radius:8px;font:inherit;font-size:16px;background:var(--surface);color:var(--ink)}
.english-hint,.english-feedback,.english-example {border-inline-start:3px solid var(--line);padding-inline-start:10px}
#englishNotice:empty {display:none}
#englishBody [aria-pressed=true] {outline:2px solid currentColor}
.practice-dialog {box-sizing:border-box;width:min(94vw,650px);max-height:90vh;max-height:90dvh;overflow:auto;overscroll-behavior:contain;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:16px;padding:clamp(16px,3vw,28px)}
.practice-dialog::backdrop {background:rgba(19,36,32,.52)}
.practice-dialog section {border-top:1px solid var(--line);padding-block:12px}
.practice-dialog p {line-height:1.55;margin:.65em 0}
.practice-dialog select {max-width:100%;font:inherit;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:8px;padding:7px}
.practice-dialog fieldset {margin-top:10px;border:1px solid var(--line);border-radius:8px;padding:10px}
.practice-dialog audio {max-width:100%}
.radar-grid {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:.6rem;align-items:start;margin:1rem 0}
.radar-card,.radar-overview {border:1px solid var(--line);border-radius:12px;padding:.75rem;overflow-wrap:anywhere}
.radar-overview {margin-top:.75rem;background:var(--surface2)}
.radar-line {display:flex;justify-content:space-between;align-items:baseline;gap:.5rem}
.radar-card>summary {list-style:none}
.radar-card>summary::-webkit-details-marker {display:none}
.radar-line::after {content:"⌄";color:var(--dim)}
.radar-card[open]>summary .radar-line::after {content:"⌃"}
.radar-line strong {flex:1}
.radar-value {font-size:.82rem}
.radar-card summary {cursor:pointer}
.radar-card small {display:block;margin-top:.25rem}
.radar-card progress {display:block;width:100%;height:.5rem;margin:.4rem 0;accent-color:var(--green)}
.radar-trace {margin-top:.75rem}
.radar-trace ol {padding-inline-start:1.3rem}
.radar-trace li {margin:.65rem 0}
.pet-home,.pet-welcome {display:flex;align-items:center;gap:.75rem;flex-wrap:wrap}
.pet-home h2,.pet-home p {margin:0}
.pet-home .btn,.pet-welcome .btn {margin-inline-start:auto}
.pet-mark {background:var(--teal-soft);color:var(--teal);border-radius:50%;width:2.5rem;height:2.5rem;display:grid;place-items:center;font-size:1.5rem}
#petScene {display:block;width:100%;margin:.7rem 0;border-radius:12px}
.pet-lantern,.pet-scarf,.pet-sprout,.pet-flowers {display:none}
[data-room=lantern] .pet-lantern,[data-room=flowers] .pet-flowers,[data-hat=scarf] .pet-scarf,[data-hat=sprout] .pet-sprout {display:inline}
.pet-body {transform-origin:50% 78%}
.pet-leaf,.pet-blossom {display:none}
[data-stage=leaf] .pet-leaf,[data-stage=bloom] .pet-leaf,[data-stage=bloom] .pet-blossom {display:inline}
[data-mood="1"] .pet-eyes {transform:translateY(48px) scaleY(.47)}
[data-mood="2"] .pet-body {transform:rotate(-5deg)}
.pet-goals,.pet-gear {display:grid;gap:.65rem;grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr))}
.pet-goals label {padding:.65rem;background:var(--surface2);border-radius:10px}
.pet-goals progress,.pet-gear select {display:block;width:100%;accent-color:var(--teal);margin-top:.35rem}
.pet-gear {margin-top:1rem}
.backup-page {max-width:38rem;margin:2rem auto;padding:1.4rem;width:calc(100% - 2rem);overflow-wrap:anywhere}
.backup-page input {display:block;max-width:100%;margin:.65rem 0}
@media(prefers-reduced-motion:no-preference){.pet-body {transition:transform .18s ease-out}}

/* Notebook cover and practice cards adapted from the local Home/Nav prototype. */
.dash {background:#194b3c;box-shadow:none}
:root[data-theme="ocean"] .dash {background:#164a5c}
:root[data-theme="cream"] .dash {background:#514634}
:root[data-theme="dark"] .dash {background:#234b3d}
.dash::before {display:none}
.hill-window {position:absolute;inset:0 0 auto auto;width:40%;height:105px;border-bottom-left-radius:80px}
.dash-top {min-height:85px;align-items:flex-start}
.dash h1 {font:600 clamp(24px,5vw,32px)/1.12 Georgia,serif;letter-spacing:-.04em;max-width:7em;margin-top:.32em}
.dash .dash-ring {border-radius:50%;background:#234a3f;color:#fff}
.dash .dash-stat-tile {border:none;border-radius:0;background:transparent;padding:.2rem .4rem}
.dash .dash-stat-tile+.dash-stat-tile {border-inline-start:1px solid #ffffff40}
.dash .stat-ic {display:none}
.dash .dash-stats {margin-top:12px}
.dash .btn-continue {background:#e0ed9b;color:#203a28;box-shadow:none;min-height:44px}
.btn-continue span {margin-inline-start:.5em}
.studio-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem}
.studio-tile {position:relative;font:inherit;min-width:0;text-align:left;display:grid;gap:.2rem;padding:.75rem;border:1px solid var(--line);border-radius:14px;background:var(--surface);color:var(--ink);cursor:pointer}
.studio-tile::after {content:"↗";position:absolute;inset:.65rem .7rem auto auto;color:var(--dim)}
.studio-glyph {display:grid;place-items:center;background:var(--teal-soft);color:var(--teal);border-radius:9px;width:2rem;height:2rem;font:bold 1rem Georgia,serif;margin-bottom:.3rem}
.studio-tile small {color:var(--dim);line-height:1.35}
.studio-tile:focus-visible,.practice-dialog :is(button,select,summary):focus-visible {outline:3px solid var(--teal);outline-offset:2px}
.studio-tile:hover,.studio-tile:focus-visible {border-color:var(--teal)}
.practice-dialog :is(button,select),#englishDialog :is(button,select) {min-height:44px}
.dialog-toolbar {position:sticky;top:0;z-index:2;background:var(--surface);border-bottom:1px solid var(--line);padding:.45rem 0;margin:0 0 .8rem}
.dialog-toolbar h2 {margin:0}
.dialog-toolbar .nb-head {margin:0}
.dialog-toolbar .btn {flex-shrink:0}
#englishDialog {scroll-padding-block:5rem 1rem}
#englishDialog button.english-word {display:inline;min-height:0;line-height:inherit;padding:0 .08em;vertical-align:baseline;text-underline-offset:.2em}
.english-task form {display:grid;gap:.45rem}
.english-task input {min-height:44px;scroll-margin-block:1rem}
.english-feedback {padding:.65rem .8rem;border-radius:8px}
.english-feedback.is-correct {background:var(--green-soft);border-color:var(--green)}
.english-feedback.is-retry {background:var(--amber-soft);border-color:var(--amber)}
.english-feedback p:last-child {margin-bottom:0}
.english-feedback:focus-visible,.english-task h3:focus-visible {outline:2px solid var(--teal);outline-offset:3px}
.dict-lookup-form {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.55rem;align-items:center}
.dict-lookup-form label,.dict-lookup-form input {grid-column:1/-1}
.dict-lookup-form select {font:inherit;min-height:44px;border:1px solid var(--line);border-radius:.65rem;padding:.4rem;background:var(--surface);color:var(--ink)}
.dict-lookup-form button {min-height:44px}
.dict-expanded {overflow-wrap:anywhere}
.dict-entry {border:1px solid var(--line);border-radius:12px;margin:.55rem 0;padding:.65rem .8rem}
.dict-entry summary {cursor:pointer;padding:.3rem 0}
.dict-entry summary small {display:block;margin-top:.15rem}
.dict-pos {margin-inline-start:.55rem;color:var(--teal);font-size:.84rem}
.dict-senses {padding-inline-start:1.4rem;line-height:1.55}
.dict-senses li {margin:.45rem 0}
.dict-senses p {margin:.2rem 0}
.dict-tags {display:block;color:var(--dim);font-size:.78rem}
.dict-related,.dict-pack {display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin:.65rem 0}
.dict-related h3 {flex-basis:100%}
.dict-related .btn,.dict-pack .btn {white-space:normal;text-align:left}
#dictLookupStatus:empty,#dictPackStatus:empty {display:none}
@media(max-height:540px){
  :is(.practice-dialog,#englishDialog) {max-height:calc(100dvh - 16px)}
  .dialog-toolbar {padding-block:.25rem}
}
@media(prefers-reduced-motion:no-preference){
  :is(.practice-dialog,#englishDialog)[open] {animation:dialog-arrive 150ms ease-out}
  @keyframes dialog-arrive {from {opacity:0;transform:translateY(5px)} to {opacity:1;transform:translateY(0)}}
}
@media(min-width:960px) and (max-height:860px){.home-bento-left {position:static}}
@media(prefers-reduced-motion:no-preference){.studio-tile {transition:transform 140ms ease-out}.studio-tile:active {transform:translateY(1px)}}
