/* Kyoshi — calm, minimal, premium. No gamification, no clutter. */
:root {
  --bg: #faf9f7;
  --bg-sunk: #f2f0ec;
  --card: #ffffff;
  --ink: #1c1b19;
  --ink-2: #4a4741;
  --muted: #8b8781;
  --line: #e6e2db;
  --line-strong: #d5d0c7;
  --accent: #3f5adf;
  --accent-soft: #eef1fe;
  --accent-ink: #2c40a8;
  --good: #2f8f63;
  --good-soft: #e9f5ef;
  --warn: #b4762a;
  --warn-soft: #fbf1e2;
  --bad: #c0503f;
  --bad-soft: #fbeeeb;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 10px 30px rgba(28, 27, 25, 0.05);
  --shadow-lift: 0 2px 6px rgba(28, 27, 25, 0.06), 0 18px 44px rgba(28, 27, 25, 0.09);
  --font: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --bg-sunk: #0e0e0d;
    --card: #1e1d1b;
    --ink: #eeebe4;
    --ink-2: #c2beb5;
    --muted: #8d887e;
    --line: #302e2a;
    --line-strong: #423f39;
    --accent: #7f92ff;
    --accent-soft: #23264a;
    --accent-ink: #a9b5ff;
    --good: #5cbb8c;
    --good-soft: #16291f;
    --warn: #d69b4e;
    --warn-soft: #2b2113;
    --bad: #e07a68;
    --bad-soft: #2d1a16;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.55), 0 18px 44px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------- structure */
header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
header.scrolled { border-bottom-color: var(--line); }
.header-inner {
  max-width: 860px; margin: 0 auto;
  padding: 14px clamp(18px, 5vw, 32px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  font-weight: 640; font-size: 19px; letter-spacing: -0.025em;
  display: flex; align-items: baseline; gap: 9px; cursor: pointer;
  white-space: nowrap; flex: none;
}
.brand .kanji { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 0.06em; }

nav { display: flex; gap: 2px; }
nav button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 560; letter-spacing: 0.01em;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  transition: color 0.16s, background 0.16s;
}
nav button:hover { color: var(--ink); }
nav button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

main {
  max-width: 860px; margin: 0 auto;
  padding: 22px clamp(18px, 5vw, 32px) 120px;
  animation: rise 0.34s cubic-bezier(0.2, 0.7, 0.3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------- typography */
h1 { font-size: 27px; font-weight: 620; letter-spacing: -0.032em; line-height: 1.22; }
h2 { font-size: 17px; font-weight: 620; letter-spacing: -0.018em; }
h3 { font-size: 14px; font-weight: 620; letter-spacing: -0.01em; }
.eyebrow {
  font-size: 11px; font-weight: 660; letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--muted);
}
.sub { color: var(--muted); font-size: 14.5px; }
.dim { color: var(--muted); }
.tiny { font-size: 12.5px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; } .mt-40 { margin-top: 40px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card.tight { padding: 16px 18px; }
.card.flat { box-shadow: none; background: transparent; }

/* -------------------------------------------------------- effort chooser */
.effort-grid { display: flex; flex-direction: column; gap: 11px; }
.effort {
  display: flex; align-items: center; gap: 18px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform 0.18s cubic-bezier(0.2,0.7,0.3,1), box-shadow 0.18s, border-color 0.18s;
}
.effort:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.effort:active { transform: translateY(0); }
.effort .name { font-size: 19px; font-weight: 630; letter-spacing: -0.022em; }
.effort .blurb { color: var(--muted); font-size: 14px; margin-top: 3px; }
.effort .time {
  font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
  background: var(--bg-sunk); border-radius: 999px; padding: 6px 13px;
}
.effort .mark {
  width: 8px; height: 44px; border-radius: 999px; background: var(--line-strong); flex: none;
  transition: background 0.18s;
}
.effort:hover .mark { background: var(--accent); }
.effort[data-mode="easy"]:hover .mark { background: var(--good); }
.effort[data-mode="hard"]:hover .mark { background: var(--warn); }
.effort.test { background: transparent; box-shadow: none; border-style: dashed; }
.effort.test:hover { background: var(--card); }

/* --------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 580; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-sunk); color: var(--ink-2); white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* ------------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  border-radius: 11px; padding: 10px 17px; font-size: 14.5px; font-weight: 580;
  cursor: pointer; transition: 0.15s; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--bg-sunk); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }

/* --------------------------------------------------------------- inputs */
input[type=text], input[type=date], input[type=password], textarea, select {
  width: 100%; background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: var(--card); }
textarea { resize: vertical; min-height: 110px; line-height: 1.6; font-family: var(--font); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 580; color: var(--ink-2); }
/* Keep an inline badge on the same line as the label text, not stacked above
   the input as its own flex row. */
label.field > .pill { align-self: flex-start; }

/* --------------------------------------------------------------- mastery */
.meter { display: inline-block; width: 88px; height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; flex: none; vertical-align: middle; }
.meter > i { display: block; height: 100%; border-radius: 999px; transition: width 0.6s cubic-bezier(0.2,0.7,0.3,1); }
.m-low > i { background: var(--bad); }
.m-mid > i { background: var(--warn); }
.m-high > i { background: var(--good); }

.concept-row {
  display: flex; align-items: center; gap: 14px; padding: 11px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer; transition: background 0.13s;
  border-radius: 8px;
}
.concept-row:last-child { border-bottom: 0; }
.concept-row:hover { background: var(--bg-sunk); }
.concept-row .pct { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 620; width: 40px; text-align: right; flex: none; }
.concept-row > .grow { flex: 1 1 auto; min-width: 0; }
.pill.compact .ico { display: none; }
.concept-row .meter { width: 88px; flex: none; }

/* ------------------------------------------------------------- sessions */
.progress-track { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-track > i { display: block; height: 100%; background: var(--accent); transition: width 0.4s cubic-bezier(0.2,0.7,0.3,1); }

.prompt-card { padding: 30px 26px; text-align: left; }
.prompt-text { font-size: 21px; font-weight: 560; letter-spacing: -0.018em; line-height: 1.42; }
.answer-text {
  font-size: 16.5px; line-height: 1.65; color: var(--ink-2);
  padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line);
  animation: rise 0.26s ease;
}
.rating-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rating {
  border: 1px solid var(--line-strong); background: var(--card); border-radius: 11px;
  padding: 11px 8px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: 0.14s; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
/* The scheduled interval, stated on the button that would produce it. */
.rating-when {
  font-size: 11px; font-weight: 500; color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.rating:hover .rating-when { color: inherit; opacity: 0.75; }
.rating:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.rating[data-r=again]:hover { border-color: var(--bad); color: var(--bad); }
.rating[data-r=hard]:hover { border-color: var(--warn); color: var(--warn); }
.rating[data-r=good]:hover { border-color: var(--accent); color: var(--accent); }
.rating[data-r=easy]:hover { border-color: var(--good); color: var(--good); }

.choice {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-sm);
  padding: 14px 16px; cursor: pointer; transition: 0.14s; line-height: 1.5;
}
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.choice .key {
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 6px;
  width: 22px; height: 22px; display: grid; place-items: center; flex: none; margin-top: 1px;
}
.choice.correct { border-color: var(--good); background: var(--good-soft); }
.choice.correct .key { border-color: var(--good); color: var(--good); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.wrong .key { border-color: var(--bad); color: var(--bad); }
.choice:disabled { cursor: default; }

.feedback {
  border-left: 2px solid var(--accent); padding: 4px 0 4px 15px;
  font-size: 14.5px; line-height: 1.6; color: var(--ink-2); animation: rise 0.26s ease;
}
.feedback.good { border-color: var(--good); }
.feedback.bad { border-color: var(--bad); }

.chip-list { display: flex; flex-direction: column; gap: 7px; }
.chip {
  display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; color: var(--ink-2);
}
.chip .glyph { flex: none; font-weight: 700; width: 15px; }
.chip.plus .glyph { color: var(--good); }
.chip.minus .glyph { color: var(--warn); }
.chip.alert .glyph { color: var(--bad); }

/* -------------------------------------------------------------- sources */
.source-row {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 0;
  border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.source-row:last-child { border-bottom: 0; }
.level {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  padding: 3px 7px; border-radius: 6px; flex: none; margin-top: 1px;
}
.level.l1 { background: var(--accent-soft); color: var(--accent-ink); }
.level.l2 { background: var(--good-soft); color: var(--good); }
.level.l3 { background: var(--bg-sunk); color: var(--ink-2); }
.level.l4 { background: var(--bg-sunk); color: var(--muted); }
.level.l5 { background: var(--warn-soft); color: var(--warn); }

.evidence {
  background: var(--bg-sunk); border-radius: var(--radius-sm); padding: 13px 15px;
  font-size: 13.5px; line-height: 1.6; color: var(--ink-2);
}

/* --------------------------------------------------------------- tutor */
.tutor-log { display: flex; flex-direction: column; gap: 14px; }
.bubble { border-radius: var(--radius-sm); padding: 14px 16px; font-size: 15px; line-height: 1.62; white-space: pre-wrap; }
.bubble.tutor { background: var(--bg-sunk); }
.bubble.me { background: var(--accent-soft); color: var(--accent-ink); align-self: flex-end; max-width: 82%; }
.cursor::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* --------------------------------------------------------------- misc */
.streak-strip { display: flex; gap: 3px; }
.streak-strip i { width: 9px; height: 26px; border-radius: 3px; background: var(--line); }
.streak-strip i.on { background: var(--good); }
.streak-strip i.today { box-shadow: 0 0 0 2px var(--accent) inset; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.spinner {
  width: 15px; height: 15px; border: 2px solid var(--line-strong);
  border-top-color: var(--accent); border-radius: 999px;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  display: flex; gap: 11px; align-items: flex-start;
  border-radius: var(--radius-sm); padding: 13px 15px; font-size: 13.5px; line-height: 1.55;
  background: var(--warn-soft); color: var(--warn);
}
.banner.info { background: var(--accent-soft); color: var(--accent-ink); }
.banner a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.banner code { font-family: var(--mono); font-size: 0.9em; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

#toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 560; opacity: 0; pointer-events: none;
  transition: 0.28s cubic-bezier(0.2,0.7,0.3,1); z-index: 90; max-width: 88vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.sticky-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line); padding: 13px clamp(18px, 5vw, 32px);
}
.sticky-foot > .inner { max-width: 860px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }

@media (max-width: 620px) {
  h1 { font-size: 23px; }
  .header-inner { padding-left: 16px; padding-right: 16px; gap: 8px; }
  .brand { font-size: 17.5px; gap: 6px; }
  .brand .kanji { display: none; }
  .effort { padding: 17px 18px; gap: 14px; }
  .effort .name { font-size: 17.5px; }
  .prompt-card { padding: 22px 18px; }
  .prompt-text { font-size: 19px; }
  .rating-row { grid-template-columns: repeat(2, 1fr); }
  nav button { padding: 7px 10px; font-size: 12.5px; }
  .concept-row .meter { width: 56px; }
  /* Keep the concept name readable on narrow screens — badges shrink first. */
  .concept-row .pill { padding: 3px 7px; font-size: 11px; }
  .pill.compact .lbl { display: none; }
  .pill.compact .ico { display: inline; }
}

/* Destructive confirmation — only ever the second step, never the first. */
.btn.danger {
  border-color: var(--bad); color: var(--bad); background: transparent;
}
.btn.danger:hover:not(:disabled) { background: var(--bad); color: var(--bg); }

/* ---------------------------------------------------------------- to-do */
.todo-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.todo-row input[type=checkbox] { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; cursor: pointer; }
.todo-row .todo-title { font-weight: 560; font-size: 14.5px; }
.todo-row.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-row a.todo-title:hover { text-decoration: underline; }
details.past > summary { cursor: pointer; list-style: none; }
details.past > summary::-webkit-details-marker { display: none; }
/* label.field is a column; this one reads as a single row: "Studying [All classes v]" */
label.field.study-scope { flex-direction: row; align-items: center; gap: 12px; }
label.field.study-scope > span { flex: none; }
label.field.study-scope select { flex: 1; min-width: 0; }
#nav button { white-space: nowrap; }

/* Six nav items don't fit beside the wordmark on a phone. The wordmark goes
   ("Today" already goes home) and the buttons tighten, so every tab, including
   Settings, stays on screen. The sideways scroll is only a safety net. */
nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
@media (max-width: 480px) {
  .brand { display: none; }
  .header-inner { justify-content: center; }
  nav { gap: 0; }
  nav button { padding: 6px 8px; } /* text stays 12.5px from the 620px block */
}
@media (max-width: 340px) {
  nav button { padding: 6px 6px; }
}
