/* Laoshi · 老师 (lǎoshī) — bright, friendly practice app */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --ink: #1b2430;
  --ink-2: #485364;
  --muted: #687384;
  --line: #e5e8ec;
  --line-2: #d2d7de;

  /* Bright green for large text and fills; strong green where small white text sits on it (AA). */
  --green: #12a150;
  --green-edge: #0b7e3d;
  --green-strong: #0a8442;
  --green-strong-edge: #066231;
  --green-ink: #086b35;
  --green-soft: #e4f7eb;
  --green-line: #b4e4c5;

  --blue-strong: #0f6fc0;
  --blue-edge: #0a5596;
  --blue-ink: #0b5ea8;
  --blue-soft: #e7f2fd;
  --blue-line: #b9daf6;

  --coral: #ff6a55;
  --coral-strong: #d6402c;
  --coral-ink: #b0311e;
  --coral-soft: #ffede9;
  --coral-line: #ffc6bb;

  --yellow: #ffc426;
  --yellow-strong: #f0a500;
  --yellow-ink: #7a5000;
  --yellow-soft: #fff6d8;
  --yellow-line: #fbe09a;

  --sans: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --han: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;

  --radius: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --tabbar: 70px;
  --cell: 14px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --press: 150ms;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 16px/1.5 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--blue-ink); text-underline-offset: 3px; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--blue-strong); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

[lang="zh-CN"], .han { font-family: var(--han); }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 100;
  padding: 12px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 18px; height: 18px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.fine { font-size: 0.85rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.center { text-align: center; justify-content: center; }

@media (pointer: coarse) { .kbd-hint { display: none !important; } }

/* ---------- Brand ---------- */

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font: 700 14px/1 var(--han);
  letter-spacing: -0.02em;
  box-shadow: 0 3px 0 var(--green-edge);
}
.brand-mark-lg { width: 76px; height: 76px; border-radius: 22px; font-size: 26px; box-shadow: 0 5px 0 var(--green-edge); }
.brand-py { font-size: 0.78rem; font-weight: 700; color: var(--green-ink); }
.py-inline { font-weight: 600; letter-spacing: 0; text-transform: none; }

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-border: var(--line-2);
  --btn-edge: var(--line-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid var(--btn-border);
  border-radius: 14px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: 0 4px 0 var(--btn-edge);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.15;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--press) var(--ease),
    box-shadow var(--press) var(--ease),
    background-color var(--press) var(--ease),
    border-color var(--press) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 0.9rem; border-radius: 12px; box-shadow: 0 3px 0 var(--btn-edge); }
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 1.125rem; font-weight: 800; border-radius: 16px; }

.btn-primary { --btn-bg: var(--green-strong); --btn-fg: #fff; --btn-border: var(--green-strong); --btn-edge: var(--green-strong-edge); }
.btn-secondary { --btn-fg: var(--ink); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-edge: transparent; --btn-fg: var(--ink-2); box-shadow: none; }
.btn-ghost:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }

/* White CTA on the green practice block */
.btn-cta { --btn-bg: #fff; --btn-fg: var(--green-ink); --btn-border: #fff; --btn-edge: var(--green-strong-edge); box-shadow: 0 5px 0 var(--btn-edge); }
.btn-cta:active:not(:disabled) { transform: translateY(4px); }

/* Blue = listen */
.speak-btn { --btn-bg: var(--blue-soft); --btn-fg: var(--blue-ink); --btn-border: var(--blue-line); --btn-edge: var(--blue-line); }
.btn-icon { width: 48px; padding: 0; flex: none; }
.speak-btn.is-unavailable { opacity: 0.6; }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) { --btn-bg: #08793c; --btn-border: #08793c; }
  .btn-secondary:hover:not(:disabled) { --btn-bg: var(--surface-2); }
  .btn-ghost:hover:not(:disabled) { --btn-bg: var(--surface-2); --btn-fg: var(--ink); }
  .btn-cta:hover:not(:disabled) { --btn-bg: #f2fbf5; }
  .speak-btn:hover:not(:disabled) { --btn-bg: #d9ebfc; }
}

.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--line-2);
  border-top-color: var(--green-strong);
  animation: spin 0.8s linear infinite;
}
.btn-primary.is-busy::after { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--press) var(--ease), transform var(--press) var(--ease);
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--surface-2); color: var(--ink); } }

/* ---------- Inputs ---------- */

.input {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 2px solid var(--line-2);
  border-radius: 14px;
  background: #fff;
  font-size: 1rem;
  transition: border-color var(--press) var(--ease), box-shadow var(--press) var(--ease);
}
.input::placeholder { color: #9aa3b0; }
.input:focus { outline: none; border-color: var(--blue-strong); box-shadow: 0 0 0 4px var(--blue-line); }
textarea.input { resize: vertical; min-height: 96px; line-height: 1.5; }
.han-input { font-size: 1.2rem; }

.select {
  appearance: none;
  padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 13px) 52%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 700; color: var(--ink); }
.field { display: block; min-width: 0; }
.hint { display: block; margin-top: 6px; font-size: 0.82rem; color: var(--muted); }

.form-msg {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--coral-soft);
  color: var(--coral-ink);
  font-size: 0.92rem;
  font-weight: 600;
}
.form-msg[data-type="info"] { background: var(--green-soft); color: var(--green-ink); }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card { width: 100%; max-width: 420px; text-align: center; }
.login-brand { display: inline-grid; justify-items: center; gap: 8px; }
.login-title { margin-top: 18px; font-size: 2.5rem; font-weight: 900; line-height: 1.1; letter-spacing: -0.03em; }
.login-sub { margin-top: 6px; color: var(--ink-2); font-size: 1.15rem; font-weight: 600; }
.login-form { display: grid; gap: 12px; margin: 32px 0 18px; text-align: left; }
.login-form .btn-lg { margin-top: 6px; }
.input-row { display: flex; gap: 8px; }
.input-row .btn { flex: none; }

.health,
.speech-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.health { justify-content: center; margin-top: 18px; }
.dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--line-2); }
[data-state="ok"] > .dot { background: var(--green); }
[data-state="bad"] > .dot { background: var(--coral-strong); }
[data-state="checking"] > .dot { background: var(--yellow-strong); animation: pulse 1.2s ease-in-out infinite; }

/* ---------- App shell ---------- */

.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 2px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1040px;
  height: 64px;
  margin: 0 auto;
  padding: 0 calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 12px;
}
.brand-text { display: grid; line-height: 1.1; }
.brand-name { font-size: 1.2rem; font-weight: 900; letter-spacing: -0.02em; }

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.review-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 800;
  font-size: 0.92rem;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--press) var(--ease), border-color var(--press) var(--ease), transform var(--press) var(--ease);
}
.review-chip .icon { color: var(--blue-strong); width: 20px; height: 20px; }
.review-chip:active { transform: scale(0.96); }
.review-chip[aria-current="page"] { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); }
@media (hover: hover) and (pointer: fine) { .review-chip:hover { background: var(--surface-2); } }

.nav-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--coral-strong);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: var(--yellow-ink);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.streak-pill .icon { width: 20px; height: 20px; fill: var(--yellow); stroke: var(--yellow-strong); }

.account { position: relative; }
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 50;
  display: grid;
  gap: 12px;
  width: min(300px, calc(100vw - 24px));
  padding: 16px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px -14px rgba(27, 36, 48, 0.28);
  transform-origin: top right;
  animation: pop 150ms var(--ease);
}
.account-menu .speech-status { color: var(--ink-2); font-weight: 600; }

/* Bottom tab bar (mobile) */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 6px calc(8px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  background: #fff;
  border-top: 2px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  min-width: 0;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--press) var(--ease);
}
.tab-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  transition: background-color var(--press) var(--ease), transform var(--press) var(--ease);
}
.tab .icon { width: 24px; height: 24px; }
.tab:active .tab-icon { transform: scale(0.92); }
.tab[aria-current="page"],
.tab.is-active { color: var(--green-ink); }
.tab[aria-current="page"] .tab-icon,
.tab.is-active .tab-icon { background: var(--green-soft); }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--ink); } }

.main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px calc(16px + env(safe-area-inset-right)) calc(var(--tabbar) + 40px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  outline: none;
}

@media (max-width: 599px) {
  .review-chip { padding: 0 10px; }
  .review-chip .chip-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (min-width: 600px) {
  .main { padding-top: 32px; padding-left: 24px; padding-right: 24px; }
}

@media (min-width: 900px) {
  .topbar-inner { height: 72px; padding: 0 24px; gap: 16px; }
  .tabs {
    position: static;
    display: flex;
    gap: 4px;
    margin: 0 auto;
    padding: 0;
    border: 0;
    background: none;
  }
  .tab {
    flex-direction: row;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px 0 10px;
    font-size: 0.95rem;
    transition: color var(--press) var(--ease), background-color var(--press) var(--ease);
  }
  .tab-icon { width: auto; height: auto; background: none !important; }
  .tab .icon { width: 22px; height: 22px; }
  .tab[aria-current="page"],
  .tab.is-active { background: var(--green-soft); }
  .topbar-actions { margin-left: 0; }
  .main { padding-bottom: 72px; }
}

/* ---------- View chrome ---------- */

.view { display: grid; gap: 20px; animation: rise 200ms var(--ease); }
#view-today, #view-review, #view-coach { max-width: 680px; margin: 0 auto; }

.view-head { display: grid; gap: 4px; padding: 4px 2px 2px; }
.kicker { font-size: 0.95rem; font-weight: 800; color: var(--green-ink); }
.view-title { font-size: clamp(1.75rem, 6.5vw, 2.4rem); font-weight: 900; line-height: 1.12; letter-spacing: -0.025em; }
.view-sub { color: var(--ink-2); font-size: 1.02rem; max-width: 52ch; }

.card {
  min-width: 0;
  padding: 20px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-title { font-size: 1.15rem; font-weight: 800; line-height: 1.25; letter-spacing: -0.01em; }
.card-title.lg { font-size: 1.6rem; font-weight: 900; margin: 4px 0 12px; letter-spacing: -0.02em; }
.kicker-sm { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--green-ink); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.actions.spread { justify-content: space-between; }

/* ---------- States ---------- */

.state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-2);
}
.state p { max-width: 48ch; }
.state-title { font-size: 1.1rem; font-weight: 800; color: var(--ink); }
.state-loading { display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--muted); font-weight: 600; }
.state-error { background: var(--coral-soft); border-radius: var(--radius-md); color: var(--coral-ink); }
.state-error .state-title { color: var(--coral-ink); }
.state-empty { border: 2px dashed var(--line-2); border-radius: var(--radius); }
.state .actions { margin-top: 8px; }

.spinner {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  border: 2.5px solid var(--line-2);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  font-size: 0.9rem;
  color: var(--ink-2);
}
.note .icon { margin-top: 2px; color: var(--blue-strong); }
.note > div { display: grid; gap: 4px; min-width: 0; }
.note-more > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -8px 0 -10px;
  color: var(--blue-ink);
  font-weight: 700;
  cursor: pointer;
}
.note-more[open] > summary { margin-bottom: 2px; }

/* Disclosures */
.more { border-top: 2px solid var(--line); padding-top: 4px; }
.more > summary,
.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  list-style: none;
  cursor: pointer;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.more > summary { color: var(--blue-ink); font-weight: 700; }
.more > summary::-webkit-details-marker,
.disclosure > summary::-webkit-details-marker { display: none; }
.more > summary .icon,
.disclosure-icon { transition: transform var(--press) var(--ease); }
.more[open] > summary .icon,
.disclosure[open] .disclosure-icon { transform: rotate(90deg); }
.more-body { display: grid; gap: 14px; padding: 8px 0 4px; }

.disclosure { padding: 0; }
.disclosure > summary { justify-content: space-between; min-height: 64px; padding: 12px 18px 12px 20px; border-radius: calc(var(--radius) - 2px); }
.disclosure-title { display: grid; gap: 2px; min-width: 0; }
.disclosure-icon { color: var(--muted); }
.disclosure-body { padding: 4px 20px 20px; }
@media (hover: hover) and (pointer: fine) { .disclosure > summary:hover { background: var(--surface-2); } }

/* ---------- Badges & bars ---------- */

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badges.center { justify-content: center; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-2);
}
.badge.subtle { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.badge.m0 { background: var(--coral-soft); color: var(--coral-ink); }
.badge.m1 { background: var(--yellow-soft); color: var(--yellow-ink); }
.badge.m2 { background: var(--green-soft); color: var(--green-ink); }
.badge.m3 { background: var(--blue-soft); color: var(--blue-ink); }
.badge.lit { font-style: italic; }

.bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 10px 0 4px; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width 400ms var(--ease); }

/* ---------- Today ---------- */

.practice {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 22px 22px 24px;
  border-radius: 24px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 0 var(--green-edge);
  margin-bottom: 6px;
}
/* Every text inside the block is ≥19px bold so white on green meets AA large-text contrast. */
.practice-label { font-size: 1.2rem; font-weight: 800; padding-right: 56px; }
.practice-count { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; font-size: 1.2rem; font-weight: 800; }
.practice-n { font-size: 4rem; font-weight: 900; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.practice-big { font-size: 1.2rem; font-weight: 800; line-height: 1.35; padding-right: 56px; }
.practice .btn { margin-top: 18px; }
.practice-icon {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
}
.practice-icon .icon { width: 26px; height: 26px; stroke-width: 2.4; }

.nudge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--yellow-soft);
  color: var(--yellow-ink);
  font-weight: 700;
}
.nudge .icon { fill: var(--yellow); stroke: var(--yellow-strong); }

.phrase-card { display: grid; gap: 12px; }
.phrase-card .card-head { margin-bottom: 0; }
.phrase-main { display: flex; align-items: flex-start; gap: 16px; }
.phrase-main .btn-icon { width: 56px; min-height: 56px; border-radius: 16px; }
.phrase-main .btn-icon .icon { width: 26px; height: 26px; }
.phrase-text { display: grid; gap: 4px; min-width: 0; }
.phrase-hanzi { font: 600 clamp(1.9rem, 7.5vw, 2.6rem)/1.2 var(--han); letter-spacing: 0.02em; overflow-wrap: anywhere; }
.phrase-pinyin { font-size: 1.15rem; font-weight: 700; color: var(--blue-ink); }
.phrase-meaning { font-size: 1.05rem; color: var(--ink-2); }

.quote {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
}
.quote p { font-size: 1.1rem; }
.quote cite { display: block; margin-top: 4px; font-style: normal; font-size: 0.85rem; font-weight: 600; color: var(--muted); }

.challenge { color: var(--ink-2); }
.challenge strong { color: var(--ink); }

.mini-progress {
  display: grid;
  gap: 8px;
  padding: 18px 20px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.meters { display: grid; gap: 14px; }
@media (min-width: 480px) { .meters { grid-template-columns: 1fr 1fr; gap: 20px; } }
.meter { min-width: 0; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; font-weight: 700; color: var(--ink-2); }
.meter-val { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter .bar { height: 10px; margin: 8px 0 0; background: #dfe3e9; }
.link-more {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-weight: 800;
  color: var(--blue-ink);
  text-decoration: none;
  border-radius: 10px;
}
@media (hover: hover) and (pointer: fine) { .link-more:hover { text-decoration: underline; } }

/* ---------- Stats ---------- */

.stats-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stat {
  min-width: 0;
  padding: 16px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
}
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.stat-value { margin-top: 6px; font-size: 2rem; font-weight: 900; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-unit { margin-left: 6px; font-size: 0.9rem; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.stat-sub { margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.stat .bar { height: 8px; }
.accent-streak .stat-label .icon { fill: var(--yellow); stroke: var(--yellow-strong); }

/* ---------- Calendar ---------- */

.cal {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.cal-months, .cal-grid { display: grid; gap: 4px; }
.cal-months { font-size: 0.7rem; color: var(--muted); text-transform: capitalize; height: 14px; }
.cal-months span { white-space: nowrap; overflow: visible; }
.cal-grid { grid-template-rows: repeat(7, var(--cell)); }
.cal-days { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: 4px; font-size: 0.68rem; color: var(--muted); line-height: var(--cell); }
.cal-cell {
  display: inline-block;
  width: var(--cell);
  height: var(--cell);
  border-radius: 4px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.cal-cell.on { background: var(--green); box-shadow: none; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-cell.on.today { box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 4px var(--green); }
.cal-cell.future { opacity: 0.35; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 0.8rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .cal-cell { width: 12px; height: 12px; }

/* ---------- Vocabulary ---------- */

.toolbar { display: grid; gap: 12px; }
.toolbar-filters { display: flex; gap: 10px; min-width: 0; }
.toolbar-filters .input[type="search"] { flex: 1; min-width: 0; }
.toolbar-filters .select { width: auto; flex: none; }
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (min-width: 760px) {
  .toolbar { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}

.add-form { display: grid; gap: 16px; border-color: var(--green-line); }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 720px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}
.radio-group { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.radio-group .label { width: 100%; }
.radio {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 14px;
  border: 2px solid var(--line-2);
  border-radius: 14px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--press) var(--ease), background-color var(--press) var(--ease);
}
.radio:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.radio:has(input:focus-visible) { outline: 3px solid var(--blue-strong); outline-offset: 2px; }
.radio input { accent-color: var(--green-strong); margin: 0; width: 18px; height: 18px; }
.radio small { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }

.list-meta { font-size: 0.88rem; font-weight: 600; color: var(--muted); min-height: 1.2em; }

.word-list { display: grid; gap: 12px; }
@media (min-width: 760px) { .word-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.word-list > .state { grid-column: 1 / -1; }

.word {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  padding: 16px 16px 16px 18px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
}
.word-top { display: flex; align-items: center; gap: 14px; }
.word-hanzi { font: 600 1.9rem/1.15 var(--han); min-width: 0; overflow-wrap: anywhere; }
.word-text { flex: 1; min-width: 0; }
.word-pinyin { font-size: 1.05rem; font-weight: 700; color: var(--blue-ink); }
.word-meaning { color: var(--ink-2); }
.word-context { font-size: 0.92rem; color: var(--ink-2); padding-top: 10px; border-top: 2px solid var(--line); }
.word-source { font-size: 0.85rem; font-weight: 600; color: var(--muted); }

/* ---------- Review ---------- */

.review-setup, .review-card, .review-summary { width: 100%; }

.steps { margin: 0 0 18px; padding-left: 22px; color: var(--ink-2); display: grid; gap: 4px; }
.steps li::marker { color: var(--green-ink); font-weight: 800; }
.setup-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.inline-field { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; font-weight: 700; color: var(--ink-2); }
.inline-field .select { width: auto; }

.review-card { display: grid; gap: 20px; }
.review-top { display: flex; align-items: center; gap: 12px; }
.review-top .bar { flex: 1; height: 14px; margin: 0; }
.btn.review-back { flex: none; gap: 4px; padding: 0 12px 0 8px; }
.review-count { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.review-prompt { text-align: center; padding: 14px 0 0; display: grid; gap: 10px; outline: none; }
.review-meaning { font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 900; line-height: 1.2; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.review-instr { text-align: center; color: var(--ink-2); font-weight: 600; }

.answer {
  display: grid;
  gap: 10px;
  padding: 22px 18px;
  text-align: center;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  outline: none;
  animation: rise 180ms var(--ease);
}
.answer-hanzi { font: 600 clamp(2.5rem, 10vw, 3.6rem)/1.15 var(--han); letter-spacing: 0.04em; overflow-wrap: anywhere; }
.answer-pinyin { font-size: 1.4rem; font-weight: 800; color: var(--blue-ink); }
.answer .quote { text-align: left; max-width: 48ch; margin: 4px auto 0; background: #fff; }

.grades-wrap { display: grid; gap: 14px; }
.grades-q { font-size: 1.15rem; font-weight: 800; text-align: center; }
.grades { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.g0 { --g-key: var(--coral-strong); --g-key-fg: #fff; --g-soft: var(--coral-soft); --g-line: var(--coral-line); --g-ink: var(--coral-ink); }
.g1 { --g-key: var(--yellow); --g-key-fg: #4a3200; --g-soft: var(--yellow-soft); --g-line: var(--yellow-line); --g-ink: var(--yellow-ink); }
.g2 { --g-key: var(--green-strong); --g-key-fg: #fff; --g-soft: var(--green-soft); --g-line: var(--green-line); --g-ink: var(--green-ink); }
.g3 { --g-key: var(--blue-strong); --g-key-fg: #fff; --g-soft: var(--blue-soft); --g-line: var(--blue-line); --g-ink: var(--blue-ink); }

.grade {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  align-content: start;
  gap: 6px 10px;
  min-height: 96px;
  padding: 14px;
  text-align: left;
  border: 2px solid var(--g-line);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: 0 4px 0 var(--g-line);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--press) var(--ease),
    box-shadow var(--press) var(--ease),
    background-color var(--press) var(--ease);
}
.grade:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--g-line); background: var(--g-soft); }
.grade:disabled { opacity: 0.5; cursor: wait; }
@media (hover: hover) and (pointer: fine) { .grade:hover:not(:disabled) { background: var(--g-soft); } }
.grade-key {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--g-key);
  color: var(--g-key-fg);
  font-weight: 900;
  font-size: 0.95rem;
}
.grade-title { font-weight: 800; line-height: 1.2; color: var(--ink); }
.grade-desc { grid-column: 1 / -1; font-size: 0.84rem; color: var(--ink-2); line-height: 1.35; }

.graded { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; font-weight: 800; color: var(--ink-2); }
.graded .icon { color: var(--green-strong); }

.chip { padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 800; white-space: nowrap; background: var(--g-soft); color: var(--g-ink); }

.mnemonic {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--yellow-soft);
  border: 2px solid var(--yellow-line);
}
.mnemonic-title { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; font-weight: 800; color: var(--ink); }
.mnemonic-title .icon { color: var(--yellow-strong); }
.mnemonic ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); font-size: 0.94rem; }

.summary-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sum {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 4px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  background: var(--g-soft);
  text-align: center;
}
.sum-n { font-size: 1.8rem; font-weight: 900; line-height: 1; color: var(--g-ink); }
.sum-l { font-size: 0.78rem; font-weight: 700; color: var(--ink-2); }
.summary-line { margin: 16px 0 6px; font-weight: 700; }
.cheer { color: var(--ink-2); margin-bottom: 14px; }
.summary-list { list-style: none; padding: 0; margin: 0 0 16px; }
.summary-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 2px solid var(--line); min-width: 0; }
.summary-list .han { font-size: 1.3rem; }
.summary-list .chip { margin-left: auto; }
.review-summary .fine { margin-bottom: 14px; }
.review-summary .form-msg { margin-bottom: 14px; }

/* ---------- Segmented ---------- */

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--surface-2);
  max-width: 100%;
}
.seg {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--press) var(--ease), color var(--press) var(--ease), transform var(--press) var(--ease);
}
.seg:active { transform: scale(0.97); }
.seg[aria-pressed="true"] { background: #fff; color: var(--green-ink); box-shadow: 0 2px 0 var(--line-2); }
@media (hover: hover) and (pointer: fine) { .seg:hover { color: var(--ink); } }
.segmented.small .seg { padding: 0 12px; font-size: 0.85rem; }
.seg[data-status="learning"][aria-pressed="true"] { background: var(--yellow-soft); color: var(--yellow-ink); box-shadow: 0 2px 0 var(--yellow-line); }
.seg[data-status="mastered"][aria-pressed="true"] { background: var(--green-soft); color: var(--green-ink); box-shadow: 0 2px 0 var(--green-line); }

/* ---------- Coach ---------- */

.coach-form { display: grid; gap: 14px; }
.coach-form .segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 520px) { .coach-form .segmented { display: inline-flex; justify-self: start; } }
.coach-hint { color: var(--ink-2); font-size: 0.92rem; }
.coach-form .form-actions { justify-content: space-between; }
.coach-form .more { padding-top: 0; border-top: 0; }

.coach-log-wrap { display: grid; gap: 0; }
.coach-log-wrap .card-head { margin-bottom: 10px; }
.coach-log {
  display: grid;
  gap: 12px;
  max-height: min(58vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
  border-radius: var(--radius-md);
}

.msg {
  max-width: 88%;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: #fff;
}
.msg-user { justify-self: end; background: var(--blue-soft); border-color: var(--blue-line); border-bottom-right-radius: 6px; }
.msg-user .msg-meta { color: var(--blue-ink); }
.msg-user .msg-source { color: var(--ink-2); }
.msg-coach { justify-self: start; border-bottom-left-radius: 6px; }
.msg-error { background: var(--coral-soft); border-color: var(--coral-line); color: var(--coral-ink); }
.msg-offline { background: var(--yellow-soft); border-color: var(--yellow-line); }
.msg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: -6px -8px 0 0; }
.msg-meta { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.msg-head .msg-meta { margin-bottom: 0; }
.msg-source { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.msg-text + .msg-text { margin-top: 8px; }
.msg .state { padding: 6px 0; }

/* ---------- Progress ---------- */

.hero { display: grid; gap: 6px; background: var(--green-soft); border-color: var(--green-line); }
.hero-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px 24px; }
.hero .stat-label { color: var(--green-ink); }
.hero-number { font-size: clamp(3rem, 12vw, 4.4rem); font-weight: 900; line-height: 1; letter-spacing: -0.04em; margin-top: 6px; color: var(--green-ink); font-variant-numeric: tabular-nums; }
.hero-of { font-size: 0.38em; color: var(--ink-2); letter-spacing: 0; font-weight: 800; }
.hero-deadline { text-align: right; }
.hero-date { font-size: 1.1rem; font-weight: 800; }
.hero .bar { height: 14px; background: #fff; }
.hero .stat-sub { color: var(--ink-2); }

.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.kv { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.kv dt { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.kv dd { margin: 4px 0 0; font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.projection { margin: 14px 0; font-size: 1.05rem; font-weight: 700; }

.struct-list { list-style: none; margin: 0; padding: 0; }
.struct {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 0;
  border-bottom: 2px solid var(--line);
}
.struct:last-child { border-bottom: 0; }
.struct-text { display: flex; align-items: center; gap: 14px; min-width: 0; }
.struct-han { font: 600 1.4rem var(--han); min-width: 2.4em; }
.struct-title { font-weight: 700; }
.s-mastered .struct-han { color: var(--green-ink); }
.s-learning .struct-han { color: var(--yellow-ink); }
.s-pending .struct-han { color: var(--muted); }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  z-index: 60;
  right: 16px;
  bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
  left: 16px;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 440px;
  padding: 6px 6px 6px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 14px 30px -12px rgba(27, 36, 48, 0.5);
  font-size: 0.95rem;
  font-weight: 600;
  animation: rise 180ms var(--ease);
}
.toast-error { background: var(--coral-strong); }
.toast-close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .toast-close:hover { background: rgba(255, 255, 255, 0.14); } }
@media (min-width: 900px) {
  .toasts { bottom: 24px; justify-items: end; }
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  .card { padding: 18px 16px; }
  .disclosure { padding: 0; }
  .disclosure > summary { padding: 12px 14px 12px 16px; }
  .disclosure-body { padding: 4px 16px 18px; }
  .kv-grid { grid-template-columns: 1fr; }
  .summary-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar-actions .btn { flex: 1; }
  .hero-deadline { text-align: left; }
  .msg { max-width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .stat-value { font-size: 1.75rem; }
  .setup-actions .btn { width: 100%; }
  .struct .segmented { width: 100%; }
  .struct .seg { flex: 1 1 auto; }
}

@media (max-width: 359px) {
  .grades { grid-template-columns: 1fr; }
  .btn.review-back { width: 44px; padding: 0; }
  .review-back-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .brand-name { font-size: 1.05rem; }
  .brand-mark { width: 36px; height: 36px; font-size: 13px; }
}

/* ---------- Motion ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner, .btn.is-busy::after { animation: spin 1.6s linear infinite !important; }
}
