/* MSCP Rounds — study client */
:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --ink: #1e2422;
  --ink-soft: #55605c;
  --line: #e2ddd3;
  --accent: #0f766e;      /* teal */
  --accent-ink: #0b5a54;
  --accent-wash: #dcefec;
  --good: #1a7f45;
  --good-wash: #e0f2e6;
  --bad: #b4362f;
  --bad-wash: #f7e3e1;
  --gold: #a8730d;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,30,28,.05), 0 6px 20px rgba(20,30,28,.06);
  --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181a;
    --surface: #1c2124;
    --surface-2: #242a2d;
    --ink: #e9ece9;
    --ink-soft: #a4b0ac;
    --line: #2f373a;
    --accent: #35c9b8;
    --accent-ink: #7fded2;
    --accent-wash: #16302e;
    --good: #4ecb7f;
    --good-wash: #16302099;
    --bad: #f0817a;
    --bad-wash: #3a201e99;
    --gold: #e0b25a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 22px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0; }
p { margin: .4rem 0; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .7rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--ink); transition: background .15s, border-color .15s, transform .05s;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { padding: .4rem .7rem; min-height: 36px; font-size: .9rem; }
.btn-block { width: 100%; }

/* ---------- login ---------- */
#view-login { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.75rem; width: 100%; max-width: 380px;
}
.field { display: block; margin: 1rem 0; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.field input, .search {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); font: inherit; min-height: 44px;
}
.field input:focus, .search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--bad); font-size: .9rem; margin-top: .5rem; }

/* ---------- brand / topbar ---------- */
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-mark {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 7px;
  background: var(--accent); color: #fff; font-size: .8rem; font-weight: 800;
}
.as-button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 2rem); background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topnav { display: flex; gap: .25rem; }
.navlink { background: none; border: 0; font: inherit; font-weight: 600; color: var(--ink-soft); cursor: pointer; padding: .45rem .7rem; border-radius: 8px; }
.navlink:hover { color: var(--ink); background: var(--surface-2); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 2rem) 5rem; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.15rem; margin: 1rem 0;
}
fieldset.card { border: 1px solid var(--line); }
legend { font-weight: 700; padding: 0 .35rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.wrap-actions { gap: .5rem; }

.hero { margin: .5rem 0 1rem; }
.hero h1 { font-size: 1.7rem; }

.pill {
  font-size: .78rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft);
}
.pill.on { background: var(--accent-wash); color: var(--accent-ink); }

/* meters */
.meter { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: .8rem 0 .5rem; position: relative; }
.meter.thin { height: 7px; margin: .6rem 0; }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-ink)); border-radius: 999px; transition: width .3s ease; }
.meter-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; color: var(--ink-soft); }
.meter-legend b { color: var(--ink); }

/* tiles */
.tile-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-top: 1rem; }
.tile {
  text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .9rem; cursor: pointer; font: inherit; color: inherit;
}
.tile:hover { border-color: var(--accent); }
.tile-title { font-weight: 700; }

/* ---------- setup ---------- */
.setup-head { display: flex; align-items: center; gap: .75rem; margin: .25rem 0 1rem; }
.setup-head h1 { margin: 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: .25rem; gap: .25rem; }
.seg.small { border-radius: 10px; }
.seg-btn {
  border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: .5rem .9rem; border-radius: 999px; cursor: pointer; min-height: 40px;
}
.seg.small .seg-btn { border-radius: 8px; padding: .45rem .75rem; }
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.chip-row, .chip-cloud { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
  padding: .45rem .8rem; border-radius: 999px; cursor: pointer; min-height: 38px;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip .cnt { opacity: .65; font-size: .8em; margin-left: .35rem; }
.chip.active .cnt { opacity: .85; }

.scope-panel { margin-top: .8rem; }
.scope-count { margin-top: .8rem; font-weight: 600; }
.cat-list { max-height: 300px; overflow: auto; margin-top: .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.cat-item { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.cat-item:last-child { border-bottom: 0; }
.cat-item input { width: 18px; height: 18px; accent-color: var(--accent); }
.cat-item .cnt { margin-left: auto; color: var(--ink-soft); font-size: .85rem; }

/* switch */
.switch-row { display: flex; align-items: flex-start; gap: .7rem; cursor: pointer; margin-top: .5rem; }
.switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch { flex: 0 0 auto; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; transition: background .15s; margin-top: 1px; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch-row input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.sticky-actions {
  position: sticky; bottom: 0; padding: .9rem 0 .3rem; margin-top: 1rem;
  background: linear-gradient(180deg, transparent, var(--paper) 35%);
}

/* ---------- quiz ---------- */
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.quiz-meta { display: flex; align-items: center; gap: .6rem; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.2rem; margin: .4rem 0 1rem; }
.qcat { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700; color: var(--accent-ink); }
.qstem { font-family: var(--serif); font-size: 1.28rem; line-height: 1.42; font-weight: 600; margin: .5rem 0 1.1rem; }
.choices { display: grid; gap: .6rem; }
.choice {
  display: flex; align-items: flex-start; gap: .75rem; text-align: left; width: 100%;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
  padding: .85rem .9rem; border-radius: var(--radius-sm); cursor: pointer; transition: border-color .12s, background .12s;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice .key {
  flex: 0 0 auto; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--surface-2); color: var(--ink-soft); font-weight: 700; font-size: .85rem;
}
.choice .txt { padding-top: 1px; }
.choice.correct { border-color: var(--good); background: var(--good-wash); }
.choice.correct .key { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-wash); }
.choice.wrong .key { background: var(--bad); color: #fff; }
.choice.dim { opacity: .6; }

.reveal { margin-top: 1.1rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.verdict { font-weight: 800; margin-bottom: .4rem; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--bad); }
.explanation { font-family: var(--serif); white-space: pre-wrap; }
.quiz-actions { position: sticky; bottom: 0; padding: .6rem 0 .3rem; background: linear-gradient(180deg, transparent, var(--paper) 40%); }

/* ---------- summary ---------- */
.summary-card { text-align: center; padding: 2rem 1.25rem; }
.big-score { font-size: 3rem; font-weight: 800; letter-spacing: -.02em; margin: .5rem 0; }
.summary-card .card-actions { justify-content: center; }

/* ---------- stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 1rem 0; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem; text-align: center;
}
.stat .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.01em; }
.stat .lbl { font-size: .78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.table { display: grid; gap: .5rem; margin-top: .8rem; }
.trow { display: grid; grid-template-columns: 1fr auto; gap: .5rem .8rem; align-items: center; }
.trow .tname { font-weight: 600; font-size: .92rem; }
.trow .tbar { grid-column: 1 / -1; }
.trow .tnums { color: var(--ink-soft); font-size: .82rem; white-space: nowrap; }
.missed-list { display: grid; gap: .6rem; margin-top: .5rem; }
.missed { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; }
.missed .mq { font-size: .92rem; }
.missed .mmeta { font-size: .8rem; color: var(--bad); font-weight: 600; margin-top: .2rem; }
.danger-card { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: 999px;
  font-size: .9rem; box-shadow: var(--shadow); z-index: 50; max-width: 90vw;
}

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .tile-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat .num { font-size: 1.35rem; }
  .qstem { font-size: 1.18rem; }
  .brand-text { display: none; }
}
@media (min-width: 900px) {
  :root { --maxw: 780px; }
}
