/* hermes-learn — one stylesheet, no framework, light + dark.
 * Optimised for a phone held one-handed during a five-minute drill: big tap
 * targets, one column, nothing that needs a hover to be usable.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16191d;
  --muted: #5d6672;
  --line: #e2e6ec;
  --accent: #2f6bd8;
  --accent-ink: #ffffff;
  --ok: #1f8a53;
  --ok-bg: #e8f6ee;
  --bad: #c0392b;
  --bad-bg: #fdecea;
  --warn: #8a6d1f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1c2027;
    --ink: #e8ebef;
    --muted: #99a3b0;
    --line: #2c323b;
    --accent: #5b93f0;
    --accent-ink: #0d1117;
    --ok: #4cc98a;
    --ok-bg: #163023;
    --bad: #f27c6e;
    --bad-bg: #33201d;
    --warn: #d8b95c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

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

.topbar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 600; text-decoration: none; color: var(--ink); }
.crumb { color: var(--muted); font-size: .9rem; }
.crumb::before { content: "/"; margin-right: .75rem; color: var(--line); }
.logout { margin-left: auto; font-size: .85rem; color: var(--muted); }

.wrap { max-width: 720px; margin: 0 auto; padding: 1.25rem 1rem 6rem; }

h1 { font-size: 1.5rem; margin: 0 0 .35rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.page-head { margin-bottom: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card.empty { text-align: center; }
.grid { display: grid; gap: 1rem; }

/* --------------------------------------------------------------- buttons */

.btn, button {
  font: inherit;
  padding: .6rem 1rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover, button:hover { border-color: var(--accent); }
.btn.primary, button.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn.ghost { background: transparent; color: var(--muted); }
.btn.tiny { min-height: 34px; padding: .25rem .6rem; font-size: .85rem; }
.btn.tiny.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
button:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .8rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0 0; }
.done { color: var(--ok); font-weight: 600; align-self: center; }

/* ---------------------------------------------------------------- meters */

.meter {
  height: 8px; border-radius: 999px; background: var(--line);
  overflow: hidden; margin: .5rem 0 .25rem;
}
.meter.big { height: 12px; }
.meter.thin { height: 5px; margin: .3rem 0; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.meter-fill.ok { background: var(--ok); }
.meter-label { margin: 0; font-size: .85rem; color: var(--muted); }

.stats { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem 1.1rem;
         padding: 0; margin: .6rem 0 0; font-size: .9rem; color: var(--muted); }
.stats strong { color: var(--ink); }

/* -------------------------------------------------------------- outcomes */

.outcomes, .lessons, .docs { list-style: none; padding: 0; margin: 0; }
.outcomes li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.outcomes li:last-child { border-bottom: 0; }
.outcome-row { display: flex; gap: .75rem; align-items: baseline; }
.outcome-text { flex: 1; }
.outcome-pct { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.outcome-pct.ok { color: var(--ok); font-weight: 600; }

.lessons { counter-reset: none; }
.lessons li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.lessons li:last-child { border-bottom: 0; }
.lessons li.locked { opacity: .6; }
.lesson-main { display: flex; gap: .75rem; align-items: baseline; }
.lesson-main a, .lesson-main span:first-child { flex: 1; }

.docs li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.doc-status {
  display: inline-block; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .04em; padding: .1rem .45rem; border-radius: 6px;
  background: var(--line); color: var(--muted); margin-right: .4rem;
}
.doc-status.used { background: var(--ok-bg); color: var(--ok); }
.doc-status.failed { background: var(--bad-bg); color: var(--bad); }

/* ----------------------------------------------------------------- study */

.study-progress { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.study-progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.study-count { font-size: .85rem; color: var(--muted); margin: .5rem 0 1rem; }

.prompt { font-size: 1.25rem; line-height: 1.4; margin: 0 0 1rem; }

textarea, input[type=text], input[type=password], input[type=file] {
  width: 100%; font: inherit; padding: .65rem .75rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); resize: vertical;
}
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; margin: .9rem 0 .3rem; font-weight: 600; font-size: .92rem; }

.options { display: grid; gap: .5rem; }
.option { text-align: left; justify-content: flex-start; padding: .75rem 1rem; width: 100%; }
.option.chosen { border-width: 2px; }
.option.right { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.option:disabled { opacity: 1; cursor: default; }

.btn.mic.recording { background: var(--bad); color: #fff; border-color: var(--bad); }

.verdict { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.verdict .grade { font-weight: 600; margin: 0 0 .4rem; }
.verdict.right .grade { color: var(--ok); }
.verdict.wrong .grade { color: var(--bad); }
.verdict .answer { font-size: 1.05rem; margin: .2rem 0; }
.verdict .correction { color: var(--muted); margin: .2rem 0; }
.verdict .explain { color: var(--muted); font-size: .92rem; margin: .5rem 0 0;
                    padding-left: .7rem; border-left: 2px solid var(--line); }
.verdict .warn { color: var(--warn); font-size: .88rem; }
.override { border-top: 1px dashed var(--line); padding-top: .6rem; }
.note { font-size: .88rem; color: var(--warn); margin: .6rem 0 0; }
.finish { text-align: center; padding: 1rem 0; }

/* ----------------------------------------------------------------- prose */

.prose { line-height: 1.65; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose code { background: var(--bg); padding: .1rem .3rem; border-radius: 5px;
              font-size: .9em; border: 1px solid var(--line); }
.prose pre { background: var(--bg); padding: .8rem; border-radius: 10px;
             overflow-x: auto; border: 1px solid var(--line); }
.prose pre code { border: 0; background: none; padding: 0; }
.prose blockquote { margin: .8rem 0; padding-left: .9rem;
                    border-left: 3px solid var(--line); color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .4rem .6rem; text-align: left; }
.snippet { font-size: 1.02rem; }

.error { color: var(--bad); background: var(--bad-bg); padding: .6rem .8rem;
         border-radius: 8px; }
.ok-banner { color: var(--ok); background: var(--ok-bg); padding: .6rem .8rem;
             border-radius: 8px; }
.login { max-width: 340px; margin: 3rem auto; }

/* ------------------------------------------------------------------ chat */

.chat {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 30;
  width: min(400px, calc(100vw - 2rem));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-toggle { width: 100%; border: 0; border-radius: 0; justify-content: center; }
.chat.collapsed .chat-body,
.chat.collapsed .chat-toggle-close { display: none; }
.chat:not(.collapsed) .chat-toggle-open { display: none; }
.chat-body { display: flex; flex-direction: column; }
.chat-log { max-height: min(46vh, 340px); overflow-y: auto; padding: .8rem;
            display: flex; flex-direction: column; gap: .55rem; }
.chat-hint { color: var(--muted); font-size: .88rem; margin: 0; }
.msg { padding: .5rem .7rem; border-radius: 10px; font-size: .95rem;
       max-width: 92%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.msg.bot.pending { color: var(--muted); font-style: italic; }
.msg.bot.error { color: var(--bad); }
.msg p:first-child { margin-top: 0; }
.msg p:last-child { margin-bottom: 0; }
.chat-form { display: flex; gap: .4rem; padding: .6rem; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; }

@media (max-width: 520px) {
  .chat { right: .5rem; left: .5rem; bottom: .5rem; width: auto; }
  .prompt { font-size: 1.15rem; }
  .wrap { padding-bottom: 7rem; }
}
