:root {
  color-scheme: light;
  --paper: #f3eee4;
  --paper-deep: #e8dfd0;
  --card: #fffdf8;
  --ink: #173f38;
  --ink-soft: #526861;
  --teal: #18a58e;
  --teal-dark: #0c7667;
  --coral: #e45e40;
  --gold: #d2a84a;
  --line: rgba(23, 63, 56, 0.14);
  --shadow: 0 18px 50px rgba(41, 51, 45, 0.1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --content: 760px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 6%, rgba(24, 165, 142, 0.1), transparent 24rem),
    linear-gradient(180deg, #f8f4ec 0%, var(--paper) 56%, #eee7da 100%);
  transition: color 180ms ease, background 180ms ease;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --paper: #102620;
  --paper-deep: #19362f;
  --card: #19342d;
  --ink: #ecf4ed;
  --ink-soft: #a9bcb5;
  --teal: #5dd4bd;
  --teal-dark: #8be3d2;
  --coral: #ff8669;
  --gold: #efc66d;
  --line: rgba(236, 244, 237, 0.14);
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.22);
  background:
    radial-gradient(circle at 14% 6%, rgba(93, 212, 189, 0.09), transparent 24rem),
    linear-gradient(180deg, #142b25 0%, #102620 100%);
}

button, textarea, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, var(--content));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: calc(94px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: calc(66px + var(--safe-top));
  padding: calc(12px + var(--safe-top)) 18px 10px;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.topbar::after {
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 1px;
  background: var(--line);
  content: "";
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
}

.brand-mark i {
  position: absolute;
  width: 25px;
  height: 16px;
  border: 1.8px solid var(--teal);
  border-radius: 5px;
  background: color-mix(in srgb, var(--card) 84%, transparent);
  transform: rotate(-8deg) translate(-3px, -5px);
}

.brand-mark i:nth-child(2) { transform: rotate(-1deg); }
.brand-mark i:nth-child(3) { transform: rotate(7deg) translate(3px, 5px); }

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0.12em; }
.brand small { margin-top: 2px; color: var(--ink-soft); font-size: 9px; letter-spacing: 0.16em; }

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.icon-button:last-child { justify-self: end; }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.icon-button:active { background: var(--line); transform: scale(0.96); }

.back-button { justify-self: start; }
.back-button + .brand { margin-left: 0; }
.back-button.is-hidden { display: grid !important; visibility: hidden; }

.view { padding: 18px; animation: view-in 260ms ease both; }
.view.is-hidden, .is-hidden { display: none !important; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 344px;
  padding: 27px 25px 20px;
  border: 1px solid rgba(23, 63, 56, 0.08);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(138deg, rgba(255, 255, 255, 0.8), rgba(255, 253, 248, 0.88)),
    var(--card);
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .hero-card { background: linear-gradient(138deg, #21483e, #17312b); }

.hero-copy { position: relative; z-index: 2; max-width: 76%; }
.eyebrow { margin: 0 0 9px; color: var(--teal-dark); font-size: 11px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }

.hero-copy h1,
.page-title h1,
.practice-head h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.hero-copy h1 { font-size: clamp(34px, 9.5vw, 48px); line-height: 1.18; }
.hero-copy h1 em { color: var(--coral); font-style: normal; }
.hero-note { max-width: 235px; margin: 17px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.75; }

.hero-visual {
  position: absolute;
  right: -21px;
  top: 57px;
  width: 176px;
  height: 176px;
}

.orbit {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(24, 165, 142, 0.22);
  border-radius: 50%;
}

.orbit::before, .orbit::after {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(24, 165, 142, 0.12);
  content: "";
}

.orbit::before { left: 13px; top: 39px; }
.orbit::after { right: 15px; bottom: 35px; }
.orbit-b { inset: 24px; border-color: rgba(228, 94, 64, 0.26); }
.orbit-b::before { left: auto; right: -3px; top: 45px; background: var(--coral); box-shadow: 0 0 0 5px rgba(228, 94, 64, 0.12); }
.orbit-b::after { display: none; }

.seal {
  position: absolute;
  left: 49px;
  top: 42px;
  display: grid;
  width: 83px;
  height: 83px;
  place-items: center;
  border: 1px solid rgba(23, 63, 56, 0.11);
  border-radius: 26px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 17px 34px rgba(23, 63, 56, 0.16);
  font-family: "Songti SC", "STSong", serif;
  font-size: 39px;
  font-weight: 900;
  transform: rotate(7deg);
}

.seal span {
  position: absolute;
  right: -10px;
  bottom: -9px;
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--coral);
  font-family: inherit;
  font-size: 19px;
}

.today-strip {
  position: absolute;
  z-index: 3;
  right: 15px;
  bottom: 15px;
  left: 15px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 13px;
  min-height: 61px;
  padding: 9px 9px 9px 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px);
}

.today-strip span { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.today-strip strong { font-size: 23px; }
.today-strip button { min-height: 42px; padding: 0 14px; border: 0; border-radius: 13px; color: #fff; background: var(--ink); font-size: 12px; font-weight: 700; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 5px rgba(228, 94, 64, 0.12); }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 3px 14px;
}

.section-heading span { color: var(--teal-dark); font-size: 10px; font-weight: 800; letter-spacing: 0.15em; }
.section-heading h2 { margin: 4px 0 0; font-size: 21px; letter-spacing: -0.02em; }
.text-button { padding: 8px 0; border: 0; color: var(--coral); background: transparent; font-size: 12px; font-weight: 750; }

.mode-grid { display: grid; gap: 13px; }
.mode-card {
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr;
  grid-template-rows: 1fr auto;
  column-gap: 14px;
  min-height: 180px;
  overflow: hidden;
  padding: 20px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 10px 30px rgba(41, 51, 45, 0.05);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.mode-card:active { transform: scale(0.985); }
.mode-card::after { position: absolute; right: -35px; top: -50px; width: 140px; height: 140px; border: 1px solid var(--line); border-radius: 50%; content: ""; }
.mode-index { color: var(--ink-soft); font-family: "SF Mono", Consolas, monospace; font-size: 10px; letter-spacing: 0.12em; }
.mode-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 15px; color: #fff; background: var(--teal); }
.mode-icon svg { width: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.entries-mode .mode-icon { background: var(--coral); }
.mode-copy { position: relative; z-index: 1; display: block; grid-column: 2; grid-row: 1 / 2; align-self: center; }
.mode-copy small, .mode-copy strong, .mode-copy span { display: block; }
.mode-copy small { margin-bottom: 4px; color: var(--teal-dark); font-size: 10px; font-weight: 750; letter-spacing: 0.08em; }
.entries-mode .mode-copy small { color: var(--coral); }
.mode-copy strong { font-size: 23px; letter-spacing: -0.04em; }
.mode-copy span { margin-top: 7px; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.mode-meta { grid-column: 1 / -1; display: flex; align-items: end; justify-content: space-between; padding-top: 13px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 11px; }
.mode-meta b { color: var(--ink); font-size: 16px; }
.mode-meta i { color: var(--teal); font-size: 22px; font-style: normal; }
.entries-mode .mode-meta i { color: var(--coral); }

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--line);
}
.quick-stats button { min-height: 88px; padding: 13px 8px; border: 0; background: var(--card); text-align: center; }
.quick-stats span, .quick-stats strong, .quick-stats small { display: block; }
.quick-stats span { color: var(--ink-soft); font-size: 10px; }
.quick-stats strong { display: inline; font-size: 26px; letter-spacing: -0.04em; }
.quick-stats small { display: inline; margin-left: 2px; color: var(--ink-soft); font-size: 9px; }

.study-tip { display: flex; gap: 13px; margin: 14px 0 4px; padding: 16px; border: 1px dashed rgba(23, 63, 56, 0.2); border-radius: 18px; background: color-mix(in srgb, var(--card) 58%, transparent); }
.tip-number { display: grid; flex: 0 0 34px; height: 34px; place-items: center; border-radius: 10px; color: #fff; background: var(--ink); font-family: serif; font-weight: 800; }
.study-tip p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.7; }
.study-tip strong { color: var(--ink); }

.practice-view { padding-top: 12px; }
.practice-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 3px 12px; }
.practice-head h1 { font-size: 28px; }
.filter-button { display: inline-flex; min-height: 42px; padding: 0 14px; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); font-size: 12px; font-weight: 700; }
.filter-button svg { width: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }

.session-progress { margin: 0 3px 14px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--ink-soft); font-size: 10px; font-weight: 650; }
.progress-copy strong { color: var(--teal-dark); }
.progress-track { height: 4px; overflow: hidden; border-radius: 99px; background: var(--paper-deep); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #79d8c6); transition: width 240ms ease; }

.practice-card { padding: 17px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow); }
.card-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; color: var(--ink-soft); font-size: 9px; font-weight: 650; }
.module-pill { padding: 6px 9px; border-radius: 99px; color: var(--teal-dark); background: color-mix(in srgb, var(--teal) 12%, transparent); font-weight: 800; }
.source-page { margin-left: auto; font-family: "SF Mono", Consolas, monospace; }

.prompt-grid { display: grid; grid-template-columns: minmax(118px, 0.78fr) minmax(0, 1.22fr); overflow: hidden; border: 1px solid var(--line); border-radius: 20px; }
.prompt-panel, .write-panel { min-width: 0; padding: 15px; }
.prompt-panel { position: relative; display: flex; min-height: 238px; flex-direction: column; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--teal) 7%, var(--card)); }
.prompt-panel::before { position: absolute; right: 11px; bottom: 11px; width: 36px; height: 36px; border: 1px solid color-mix(in srgb, var(--teal) 28%, transparent); border-radius: 50%; content: ""; }
.panel-label { display: block; margin-bottom: 13px; color: var(--teal-dark); font-size: 9px; font-weight: 800; letter-spacing: 0.12em; }
.prompt-panel h2 { margin: auto 0 10px; font-family: "Songti SC", "STSong", serif; font-size: clamp(18px, 5.7vw, 25px); line-height: 1.25; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.prompt-panel p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.write-panel { display: flex; min-height: 238px; flex-direction: column; background: var(--card); }
.write-panel textarea { flex: 1; width: 100%; min-height: 164px; resize: none; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-family: "SF Mono", "PingFang SC", monospace; font-size: 13px; line-height: 1.75; caret-color: var(--coral); }
.write-panel textarea::placeholder { color: color-mix(in srgb, var(--ink-soft) 55%, transparent); }
.input-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--ink-soft); font-size: 8px; }
.input-foot button { padding: 6px; border: 0; color: var(--coral); background: transparent; font-size: 9px; font-weight: 700; }

.reveal-button, .sheet-start { display: flex; width: 100%; min-height: 54px; margin-top: 14px; padding: 0 18px; align-items: center; justify-content: space-between; border: 0; border-radius: 17px; color: #fff; background: var(--ink); font-weight: 750; }
.reveal-button svg { width: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.reveal-button:active, .sheet-start:active { transform: scale(0.99); }

.answer-panel { margin-top: 14px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line)); border-radius: 20px; background: color-mix(in srgb, var(--teal) 5%, var(--card)); animation: answer-in 220ms ease both; }
@keyframes answer-in { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.answer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.answer-head span, .answer-head strong { display: block; }
.answer-head span { color: var(--teal-dark); font-size: 9px; font-weight: 800; letter-spacing: 0.12em; }
.answer-head strong { margin-top: 3px; font-size: 12px; }
.answer-head button { display: grid; width: 36px; height: 36px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: var(--card); }
.answer-head svg { width: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.subject-answer { display: grid; gap: 9px; padding: 14px; }
.subject-line { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; }
.subject-line > span { padding: 5px 0; border-radius: 8px; color: var(--teal-dark); background: color-mix(in srgb, var(--teal) 12%, transparent); text-align: center; font-size: 9px; font-weight: 800; }
.subject-line.credit > span { color: var(--coral); background: color-mix(in srgb, var(--coral) 10%, transparent); }
.subject-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.subject-tags i { padding: 6px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); font-size: 10px; font-style: normal; line-height: 1.35; }
.entry-answer { margin: 0; padding: 15px; white-space: pre-wrap; border: 0; color: var(--ink); background: transparent; font-family: "SF Mono", "PingFang SC", monospace; font-size: 12px; line-height: 1.8; }
.entry-answer .debit { color: var(--teal-dark); }
.entry-answer .credit { color: var(--coral); }

.rating-block { padding: 14px; border-top: 1px solid var(--line); }
.rating-block > span { display: block; margin-bottom: 10px; color: var(--ink-soft); font-size: 10px; font-weight: 700; }
.rating-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.rating-grid button { display: flex; min-height: 58px; padding: 8px; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 13px; background: var(--card); text-align: left; }
.rating-grid i { display: grid; flex: 0 0 24px; width: 24px; height: 24px; place-items: center; border-radius: 8px; color: #fff; background: var(--coral); font-style: normal; font-weight: 800; }
.rating-grid button:nth-child(2) i { color: var(--ink); background: var(--gold); }
.rating-grid button:nth-child(3) i { background: var(--teal); }
.rating-grid span, .rating-grid small { display: block; }
.rating-grid span { font-size: 10px; font-weight: 750; }
.rating-grid small { margin-top: 2px; color: var(--ink-soft); font-size: 7px; font-weight: 500; }

.practice-nav { display: grid; grid-template-columns: 1fr 0.85fr 1fr; gap: 9px; margin-top: 13px; }
.practice-nav button { display: flex; min-height: 48px; padding: 0 11px; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 15px; background: color-mix(in srgb, var(--card) 86%, transparent); font-size: 10px; font-weight: 700; }
.practice-nav svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.practice-nav #favoriteButton.is-active { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 36%, var(--line)); background: color-mix(in srgb, var(--coral) 8%, var(--card)); }
.practice-nav #favoriteButton.is-active svg { fill: currentColor; }

.page-title { margin: 6px 3px 20px; }
.page-title h1 { font-size: 34px; }
.progress-hero { display: grid; grid-template-columns: 142px 1fr; gap: 16px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--card); box-shadow: var(--shadow); }
.mastery-ring { display: grid; width: 132px; height: 132px; place-items: center; border-radius: 50%; background: conic-gradient(var(--teal) 0%, var(--paper-deep) 0); transition: background 300ms ease; }
.mastery-ring::before { position: absolute; width: 103px; height: 103px; border-radius: 50%; background: var(--card); content: ""; }
.mastery-ring span { position: relative; text-align: center; font-size: 13px; }
.mastery-ring strong { font-size: 34px; }
.mastery-ring small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 9px; }
.progress-metrics { display: grid; gap: 9px; }
.progress-metrics div { padding: 9px 11px; border-left: 2px solid var(--teal); border-radius: 0 10px 10px 0; background: color-mix(in srgb, var(--teal) 6%, transparent); }
.progress-metrics span, .progress-metrics strong, .progress-metrics small { display: inline; }
.progress-metrics span { display: block; color: var(--ink-soft); font-size: 8px; }
.progress-metrics strong { font-size: 20px; }
.progress-metrics small { margin-left: 3px; color: var(--ink-soft); font-size: 8px; }
.section-heading.compact { margin-top: 25px; }
.module-progress-list { display: grid; gap: 9px; }
.module-row { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.module-row-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; font-size: 11px; }
.module-row-head span { color: var(--ink-soft); }
.module-row-track { height: 6px; border-radius: 99px; background: var(--paper-deep); }
.module-row-track i { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.weak-list { display: grid; gap: 8px; }
.weak-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); }
.weak-item > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: #fff; background: var(--coral); font-size: 10px; font-weight: 800; }
.weak-item strong, .weak-item small { display: block; }
.weak-item strong { font-size: 11px; }
.weak-item small { margin-top: 3px; color: var(--ink-soft); font-size: 8px; }
.weak-item button { padding: 7px 9px; border: 0; border-radius: 9px; color: var(--teal-dark); background: color-mix(in srgb, var(--teal) 10%, transparent); font-size: 9px; font-weight: 750; }
.data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 24px 0 8px; }
.data-actions button { min-height: 48px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); font-size: 10px; font-weight: 700; }
.data-actions .danger { color: var(--coral); }

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, var(--content));
  min-height: calc(70px + var(--safe-bottom));
  margin: 0 auto;
  padding: 7px 12px calc(7px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 91%, transparent);
  box-shadow: 0 -12px 34px rgba(23, 63, 56, 0.06);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  transition: transform 180ms ease;
}
.bottom-nav button { display: grid; place-items: center; align-content: center; gap: 3px; border: 0; color: var(--ink-soft); background: transparent; font-size: 8px; }
.bottom-nav svg { width: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; }
.bottom-nav button.is-active { color: var(--teal-dark); font-weight: 800; }
.bottom-nav button.is-active svg { stroke-width: 2.2; }
body.keyboard-open .bottom-nav { transform: translateY(110%); }

.sheet-backdrop { position: fixed; z-index: 50; inset: 0; background: rgba(7, 24, 20, 0.38); backdrop-filter: blur(4px); }
.filter-sheet { position: fixed; z-index: 60; right: 0; bottom: 0; left: 0; width: min(100%, var(--content)); max-height: 88vh; margin: 0 auto; padding: 9px 19px calc(22px + var(--safe-bottom)); overflow-y: auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 28px 28px 0 0; background: var(--card); box-shadow: 0 -30px 80px rgba(7, 24, 20, 0.22); transform: translateY(105%); transition: transform 220ms cubic-bezier(0.25, 0.8, 0.25, 1); }
.filter-sheet.is-open { transform: none; }
.sheet-handle { width: 42px; height: 4px; margin: 2px auto 17px; border-radius: 99px; background: var(--line); }
.sheet-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 20px; }
.sheet-head span { color: var(--teal-dark); font-size: 9px; font-weight: 800; letter-spacing: 0.12em; }
.sheet-head h2 { margin: 4px 0 0; font-size: 22px; }
.sheet-head button { padding: 8px; border: 0; color: var(--coral); background: transparent; font-size: 11px; font-weight: 800; }
.field-label { display: block; margin: 13px 2px 7px; color: var(--ink-soft); font-size: 9px; font-weight: 700; }
.filter-sheet select { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 14px; outline: 0; color: var(--ink); background: var(--paper); font-size: 11px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; margin-top: 9px; padding: 10px 2px; border-top: 1px solid var(--line); }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 11px; }
.toggle-row small { margin-top: 4px; color: var(--ink-soft); font-size: 8px; }
.switch { position: relative; flex: 0 0 48px; width: 48px; height: 29px; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--paper-deep); transition: 180ms ease; }
.switch i::after { position: absolute; left: 3px; top: 3px; width: 23px; height: 23px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(23, 63, 56, 0.18); content: ""; transition: 180ms ease; }
.switch input:checked + i { background: var(--teal); }
.switch input:checked + i::after { transform: translateX(19px); }
.session-size { display: flex; align-items: center; justify-content: space-between; padding: 13px 2px; border-top: 1px solid var(--line); font-size: 10px; font-weight: 700; }
.session-size div { display: flex; gap: 5px; }
.session-size button { min-width: 44px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font-size: 9px; }
.session-size button.is-active { border-color: var(--teal); color: #fff; background: var(--teal); }
.sheet-start { margin-top: 10px; justify-content: center; background: var(--teal-dark); }

.toast { position: fixed; z-index: 100; right: 20px; bottom: calc(86px + var(--safe-bottom)); left: 20px; width: min(calc(100% - 40px), 430px); margin: 0 auto; padding: 12px 16px; border-radius: 13px; color: #fff; background: rgba(23, 63, 56, 0.95); box-shadow: 0 10px 35px rgba(7, 24, 20, 0.22); opacity: 0; pointer-events: none; text-align: center; font-size: 10px; font-weight: 700; transform: translateY(10px); transition: 180ms ease; }
.toast.is-visible { opacity: 1; transform: none; }

@media (min-width: 620px) {
  .view { padding-right: 28px; padding-left: 28px; }
  .hero-card { min-height: 370px; padding: 36px; }
  .hero-visual { right: 20px; top: 56px; transform: scale(1.18); }
  .today-strip { right: 25px; bottom: 24px; left: 25px; }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .mode-card { min-height: 210px; }
  .prompt-grid { grid-template-columns: minmax(200px, 0.85fr) 1.3fr; }
  .prompt-panel, .write-panel { min-height: 300px; padding: 23px; }
}

@media (max-width: 370px) {
  .view { padding: 13px; }
  .hero-card { min-height: 330px; padding: 23px 19px 18px; }
  .hero-copy h1 { font-size: 31px; }
  .hero-visual { right: -42px; transform: scale(0.86); }
  .prompt-grid { grid-template-columns: 112px minmax(0, 1fr); }
  .prompt-panel, .write-panel { padding: 12px; }
  .rating-grid button { padding: 6px; gap: 4px; }
  .rating-grid i { display: none; }
  .progress-hero { grid-template-columns: 120px 1fr; padding: 14px; }
  .mastery-ring { width: 112px; height: 112px; }
  .mastery-ring::before { width: 88px; height: 88px; }
}

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

/* Fibo-inspired compact study layout */
:root {
  --paper: #f5f6f8;
  --paper-deep: #eceef3;
  --card: #ffffff;
  --ink: #1c1c22;
  --ink-soft: #6e707b;
  --teal: #5a4fcf;
  --teal-dark: #5145b5;
  --coral: #e65f46;
  --gold: #e4ae3f;
  --line: #e3e5ea;
  --shadow: 0 8px 24px rgba(35, 35, 50, 0.055);
  --radius-xl: 16px;
  --radius-lg: 14px;
  --radius-md: 12px;
}

html { background: var(--paper); }

body {
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body[data-theme="dark"] {
  --paper: #17171c;
  --paper-deep: #24242b;
  --card: #202027;
  --ink: #f3f3f5;
  --ink-soft: #aaaab4;
  --teal: #958bff;
  --teal-dark: #afa8ff;
  --coral: #ff826c;
  --gold: #f0c463;
  --line: #34343d;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  background: var(--paper);
}

.app-shell { padding-bottom: calc(86px + var(--safe-bottom)); }

.topbar {
  min-height: calc(58px + var(--safe-top));
  padding: calc(8px + var(--safe-top)) 16px 7px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
}

.topbar::after { right: 16px; left: 16px; }
.brand { gap: 8px; }
.brand-mark { width: 29px; height: 29px; }
.brand-mark i { width: 21px; height: 14px; border-color: var(--teal); }
.brand strong { font-size: 14px; letter-spacing: 0.06em; }
.brand small { font-size: 8px; letter-spacing: 0.12em; }
.icon-button { width: 40px; height: 40px; }
.view { padding: 16px; }

.hero-card {
  min-height: 0;
  padding: 22px;
  overflow: visible;
  border-color: var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .hero-card { background: var(--card); }
.hero-copy { max-width: none; }
.eyebrow { margin-bottom: 7px; color: var(--teal-dark); font-size: 10px; letter-spacing: 0.08em; }
.hero-copy h1, .page-title h1, .practice-head h1 {
  font-family: inherit;
  letter-spacing: -0.025em;
}
.hero-copy h1 { font-size: 24px; line-height: 1.25; }
.hero-copy h1 em { color: var(--teal-dark); }
.hero-note { max-width: none; margin-top: 9px; font-size: 12px; line-height: 1.65; }

.sync-chip {
  display: inline-flex;
  min-height: 32px;
  margin-top: 13px;
  padding: 0 11px;
  align-items: center;
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--teal) 25%, var(--line));
  border-radius: 99px;
  color: var(--teal-dark);
  background: color-mix(in srgb, var(--teal) 6%, var(--card));
  font-size: 10px;
  font-weight: 700;
}
.sync-chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync-chip[data-state="error"] i, .sync-chip[data-state="offline"] i { background: var(--gold); }

.today-strip {
  position: static;
  min-height: 54px;
  margin-top: 18px;
  padding: 6px 6px 6px 13px;
  border-color: var(--line);
  border-radius: 12px;
  background: var(--paper);
  backdrop-filter: none;
}
.today-strip span { font-size: 11px; }
.today-strip strong { font-size: 20px; }
.today-strip button { min-height: 40px; border-radius: 10px; background: var(--teal); font-size: 11px; }
.pulse-dot { background: var(--teal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 13%, transparent); }

.section-heading { margin: 24px 2px 12px; }
.section-heading span { color: var(--teal-dark); font-size: 9px; letter-spacing: 0.1em; }
.section-heading h2 { margin-top: 3px; font-size: 18px; }
.text-button { color: var(--teal-dark); font-size: 11px; }
.mode-grid { gap: 11px; }
.mode-card {
  grid-template-columns: 42px 1fr;
  min-height: 144px;
  padding: 18px;
  border-radius: 14px;
  box-shadow: none;
}
.mode-card::after { display: none; }
.mode-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--teal); }
.entries-mode .mode-icon { background: #7369dc; }
.mode-copy strong { font-size: 20px; }
.mode-copy span { margin-top: 5px; font-size: 11px; line-height: 1.55; }
.mode-copy small, .entries-mode .mode-copy small { color: var(--teal-dark); font-size: 9px; }
.mode-meta { padding-top: 11px; font-size: 10px; }
.mode-meta b { font-size: 14px; }
.mode-meta i, .entries-mode .mode-meta i { color: var(--teal); }

.quick-stats { margin-top: 11px; border-radius: 14px; }
.quick-stats button { min-height: 76px; }
.quick-stats strong { font-size: 23px; }
.study-tip { margin-top: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.tip-number { background: var(--teal); }

.fold-card {
  margin-top: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.fold-card summary {
  display: flex;
  min-height: 64px;
  padding: 13px 15px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}
.fold-card summary::-webkit-details-marker { display: none; }
.fold-card summary > span { min-width: 0; flex: 1; }
.fold-card summary strong, .fold-card summary small { display: block; }
.fold-card summary strong { font-size: 12px; }
.fold-card summary small { margin-top: 4px; overflow: hidden; color: var(--ink-soft); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.fold-card summary > b { color: var(--teal-dark); font-size: 9px; font-weight: 700; }
.fold-card summary > i { color: var(--ink-soft); font-size: 20px; font-style: normal; transform: rotate(90deg); transition: transform 160ms ease; }
.fold-card:not([open]) summary > i { transform: none; }
.fold-card[open] summary { border-bottom: 1px solid var(--line); }
.sync-content { padding: 15px; }
.sync-content > p { margin: 0 0 13px; color: var(--ink-soft); font-size: 10px; line-height: 1.65; }
.sync-code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.sync-code-row input {
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  font-family: "SF Mono", Consolas, monospace;
  font-size: 16px;
}
.sync-code-row input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 12%, transparent); }
.sync-code-row button, .sync-actions button {
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-size: 10px;
  font-weight: 700;
}
.sync-content > small { display: block; margin-top: 8px; color: var(--ink-soft); font-size: 8px; line-height: 1.5; }
.sync-actions { display: grid; grid-template-columns: 1.25fr 1fr; gap: 8px; margin-top: 13px; }
.sync-actions button:first-child { border-color: var(--teal); color: #fff; background: var(--teal); }

.recent-list { display: grid; }
.recent-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; min-height: 60px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.recent-item:last-child { border-bottom: 0; }
.recent-item > span { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; color: var(--teal-dark); background: color-mix(in srgb, var(--teal) 10%, var(--card)); font-size: 10px; font-weight: 800; }
.recent-item strong, .recent-item small { display: block; }
.recent-item strong { font-size: 10px; }
.recent-item small { margin-top: 3px; color: var(--ink-soft); font-size: 8px; line-height: 1.4; }
.recent-item time { color: var(--ink-soft); font-size: 8px; white-space: nowrap; }
.empty-history { padding: 18px 15px; color: var(--ink-soft); font-size: 10px; text-align: center; }

.practice-view { padding-top: 10px; }
.practice-head { padding-bottom: 10px; }
.practice-head h1 { font-size: 23px; }
.filter-button { border-radius: 11px; }
.practice-card { padding: 14px; border-radius: 16px; box-shadow: none; }
.prompt-grid { grid-template-columns: 1fr; border-radius: 13px; }
.prompt-panel, .write-panel { min-height: 0; padding: 15px; }
.prompt-panel { border-right: 0; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--teal) 5%, var(--card)); }
.prompt-panel::before { display: none; }
.prompt-panel h2 { margin: 12px 0 8px; font-family: inherit; font-size: 20px; }
.prompt-panel p { font-size: 11px; }
.panel-label { margin-bottom: 8px; color: var(--teal-dark); font-size: 9px; }
.write-panel { min-height: 255px; }
.write-panel textarea {
  min-height: 190px;
  font-family: "SF Mono", "PingFang SC", monospace;
  font-size: 16px;
  line-height: 1.7;
}
.input-foot { font-size: 9px; }
.input-foot button { font-size: 10px; }
.reveal-button, .sheet-start { min-height: 50px; border-radius: 12px; background: var(--teal); }
.answer-panel { border-radius: 13px; }
.entry-answer { font-size: 13px; }
.rating-grid button { border-radius: 11px; }
.practice-nav button { border-radius: 11px; }

.page-title { margin-bottom: 14px; }
.page-title h1 { font-size: 24px; }
.progress-hero { grid-template-columns: 112px 1fr; padding: 15px; border-radius: 14px; box-shadow: none; }
.mastery-ring { width: 104px; height: 104px; }
.mastery-ring::before { width: 80px; height: 80px; }
.mastery-ring strong { font-size: 27px; }
.progress-metrics div { background: var(--paper); }
.module-row, .weak-item { border-radius: 12px; }
.data-actions button { border-radius: 11px; }

.bottom-nav {
  min-height: calc(66px + var(--safe-bottom));
  padding-top: 6px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow: 0 -5px 18px rgba(35, 35, 50, 0.04);
}
.bottom-nav button.is-active { color: var(--teal-dark); }
.filter-sheet { border-radius: 18px 18px 0 0; }
.filter-sheet select { font-size: 16px; }
.toast { background: rgba(31, 29, 48, 0.95); font-size: 11px; }

@supports (-webkit-touch-callout: none) {
  input, textarea, select { font-size: 16px !important; }
}

@media (min-width: 620px) {
  .view { padding: 24px 28px; }
  .hero-card { min-height: 0; padding: 24px; }
  .today-strip { position: static; }
  .mode-card { min-height: 154px; }
  .prompt-grid { grid-template-columns: minmax(210px, 0.82fr) minmax(0, 1.3fr); }
  .prompt-panel, .write-panel { min-height: 310px; padding: 22px; }
  .prompt-panel { border-right: 1px solid var(--line); border-bottom: 0; }
  .write-panel textarea { min-height: 230px; }
}

@media (max-width: 370px) {
  .view { padding: 13px; }
  .hero-card { min-height: 0; padding: 18px; }
  .hero-copy h1 { font-size: 22px; }
  .prompt-grid { grid-template-columns: 1fr; }
  .prompt-panel, .write-panel { padding: 14px; }
  .progress-hero { grid-template-columns: 98px 1fr; }
  .mastery-ring { width: 92px; height: 92px; }
  .mastery-ring::before { width: 71px; height: 71px; }
}
