/* latsolin: minimal, mobile-first. One LJK-blue accent; green/red only for answer feedback. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #111316);
  --ink: light-dark(#15171c, #ececef);
  --mute: light-dark(#5f6570, #9ba1ab);
  --line: light-dark(#e4e6ec, #272b32);
  --soft: light-dark(#f6f7f9, #181b20);
  --accent: light-dark(#2337c6, #8e9cff);
  --accent-soft: light-dark(#eef0fc, #1b2142);
  --on-accent: light-dark(#ffffff, #111316);
  --ok: light-dark(#14804f, #4fd08e);
  --ok-bg: light-dark(#e6f5ed, #11291d);
  --bad: light-dark(#c43b2f, #ff7d70);
  --bad-bg: light-dark(#fbeae8, #33150f);
  --max-width: 640px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: clip;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: var(--max-width); margin: 0 auto; min-height: 100svh; }
.loading { padding: 40px 16px; color: var(--mute); text-align: center; }
.screen { padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(100px + var(--safe-bottom)); }

/* Logo: the dot of the "i" is an answer-sheet bubble */
.logo { font-weight: 800; font-size: 44px; letter-spacing: -0.045em; line-height: 1; }
.logo.small { font-size: 22px; letter-spacing: -0.03em; }
.logo .dot { position: relative; font-style: normal; }
.logo .dot::after {
  content: ""; position: absolute; left: 50%; top: 0.04em;
  width: 0.24em; height: 0.24em; border-radius: 50%; background: var(--accent); transform: translateX(-50%);
}
.header-bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }

.greeting { font-size: 28px; font-weight: 800; margin: 18px 0 4px; }
.title { font-size: 28px; font-weight: 800; margin: 12px 0 6px; }
.subtitle { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.subtitle.spaced { margin-top: 28px; }
.meta { color: var(--mute); font-size: 15px; margin: 0 0 12px; }
.note { color: var(--mute); font-size: 14px; margin-top: 20px; }
.empty { color: var(--mute); }
.message { font-size: 15px; margin: 12px 0; }

/* Buttons */
.btn {
  display: block; width: 100%; min-height: 52px; padding: 12px 20px;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 17px;
}
.btn:disabled { opacity: 0.4; }
.btn.outline { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.outline.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.actions { display: grid; gap: 8px; margin-top: 16px; }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font-size: 15px; text-decoration: underline; }

/* Home */
.today-card { border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 20px 0 28px; }
.today-card h2 { font-size: 18px; margin: 0 0 2px; }
.today-card .meta { margin-bottom: 14px; }
.subject-list { list-style: none; margin: 0; padding: 0; }
.subject-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  width: 100%; min-height: 56px; padding: 12px 0; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line);
}
.subject-row:disabled { color: var(--mute); }
.value { color: var(--mute); font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.weak { font-style: normal; color: var(--bad); font-size: 13px; margin-left: 8px; }
.meter { grid-column: 1 / -1; display: block; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }

/* Bottom navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  max-width: var(--max-width); margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px 8px calc(6px + var(--safe-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.bottom-nav a {
  display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 52px;
  color: var(--mute); text-decoration: none; font-size: 13px;
}
.bottom-nav .icon { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; }
.bottom-nav a.active { color: var(--accent); font-weight: 600; }
.bottom-nav a.active .icon { background: currentColor; }

/* Question screen */
.topbar {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 10px 4px; background: var(--bg);
}
.close { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: none; color: var(--mute); font-size: 26px; line-height: 1; }
.progress { flex: 1; }
.progress b { font-size: 15px; }
.bar { display: block; height: 3px; margin-top: 6px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.content { padding: 4px 16px calc(112px + var(--safe-bottom)); }

.tab { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab button {
  min-height: 44px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--mute); font-weight: 600; font-size: 15px;
}
.tab button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.stimulus h2 { font-size: 19px; margin: 0 0 10px; }
.stimulus p { font-size: 17px; line-height: 1.7; }

.prompt p { font-size: 18px; line-height: 1.55; margin: 4px 0 8px; }
.hint { color: var(--mute); font-size: 14px; margin-bottom: 14px; }
.tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.tag.draft { background: transparent; color: var(--mute); border: 1px dashed var(--mute); }
.tag.active { background: var(--ok-bg); color: var(--ok); }

.option {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px;
  margin-bottom: 8px; padding: 10px 12px; text-align: left; font-size: 17px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.bubble {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px;
  border: 1.5px solid var(--mute); border-radius: 50%; color: var(--mute); font-size: 14px; font-weight: 600;
}
.square .bubble { border-radius: 7px; }
.option[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.option[aria-pressed="true"] .bubble { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.option.correct { border-color: var(--ok); background: var(--ok-bg); box-shadow: none; }
.option.correct .bubble { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: none; }
.option.wrong .bubble { background: var(--bad); border-color: var(--bad); color: #fff; }

.statement { padding: 12px 0; border-bottom: 1px solid var(--line); }
.statement p { font-size: 17px; margin-bottom: 10px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.label-choice { min-height: 48px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 600; font-size: 15px; }
.label-choice[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.label-choice.correct { background: var(--ok); border-color: var(--ok); color: #fff; }
.label-choice.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }

.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; }
.feedback.ok { background: var(--ok-bg); }
.feedback.miss { background: var(--bad-bg); }
.feedback.partial { background: var(--soft); border: 1px solid var(--line); }
.feedback h3 { font-size: 16px; margin: 0 0 6px; }
.feedback p { font-size: 16px; margin-bottom: 8px; }
.feedback .explanation p:last-child { margin-bottom: 0; }
.report { display: inline-block; margin-top: 12px; padding: 12px 0; min-height: 44px; background: none; border: 0; color: var(--mute); font-size: 14px; text-decoration: underline; }
.report:disabled { text-decoration: none; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  max-width: var(--max-width); margin: 0 auto;
  padding: 10px 16px calc(14px + var(--safe-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.dock .actions { margin-top: 0; }

/* Results and progress */
.score-line { font-size: 18px; margin-bottom: 16px; }
.summary { list-style: none; margin: 0; padding: 0; }
.summary li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.summary small { display: block; color: var(--mute); font-size: 13px; }
.mark { font-weight: 700; }
.summary .ok .mark { color: var(--ok); }
.summary .miss .mark { color: var(--bad); }
.summary .partial .mark { color: var(--mute); }

/* Profile */
.field { border: 0; margin: 18px 0 0; padding: 0; }
.field label, .field legend { display: block; padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: 600; }
input[type="text"], select {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.grade-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.elective-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chip { min-height: 48px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
#save-profile { margin-top: 24px; }
.danger-zone { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Tutor mode */
.tutor { padding-bottom: calc(190px + var(--safe-bottom)); }
.filter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin: 8px 0 12px; }
.filter label { display: grid; gap: 4px; font-size: 13px; color: var(--mute); }
.question-card { padding: 18px 0; border-top: 1px solid var(--line); }
.question-card header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; margin-bottom: 4px; }
.question-card header code { font-size: 13px; font-weight: 700; }
.question-card details { margin: 8px 0; padding: 10px 12px; background: var(--soft); border-radius: 10px; font-size: 15px; }
.question-card summary { font-weight: 600; cursor: pointer; min-height: 32px; }
.tutor-options { margin: 6px 0 10px; padding-left: 0; list-style: none; font-size: 16px; }
.tutor-options li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.tutor-options li.key { color: var(--ok); font-weight: 600; }
.tutor-options small { display: block; color: var(--mute); font-weight: 400; font-size: 13px; }
.question-card .explanation { font-size: 15px; color: var(--mute); }
.question-card .explanation p { margin: 4px 0; }
.approve { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 8px; font-weight: 600; }
.approve input { width: 22px; height: 22px; accent-color: var(--accent); }
.command { display: block; margin-bottom: 8px; padding: 8px 10px; border-radius: 8px; background: var(--soft); font-size: 13px; overflow-wrap: anywhere; max-height: 72px; overflow-y: auto; }

@media (min-width: 700px) {
  .screen, .content { padding-left: 24px; padding-right: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
