/* Exam Panic -- mobile-first, no framework. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #d9dde5;
  --text: #16191f;
  --muted: #5f6672;
  --accent: #1a73e8;
  --accent-ink: #ffffff;
  --good: #188038;
  --good-bg: #e6f4ea;
  --bad: #c5221f;
  --bad-bg: #fce8e6;
  --warn: #b06000;
  --warn-bg: #fef7e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  --nav-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1e2126;
    --surface-2: #272b32;
    --border: #363b44;
    --text: #e6e8ec;
    --muted: #9aa3b0;
    --accent: #6ba5f5;
    --accent-ink: #10131a;
    --good: #7fd39b;
    --good-bg: #16301f;
    --bad: #f4a09c;
    --bad-bg: #3a1c1a;
    --warn: #f0c674;
    --warn-bg: #33290f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

button { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* ------------------------------------------------------------------ layout */

#app { max-width: 820px; margin: 0 auto; padding: 0 14px calc(var(--nav-h) + 28px); }

@media (min-width: 760px) {
  #app { padding-bottom: 40px; padding-top: 8px; }
}

header.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}

header.bar h1 { font-size: 19px; margin: 0; flex: 1; letter-spacing: -.2px; }
header.bar .sub { font-size: 13px; color: var(--muted); font-weight: 400; }

/* ------------------------------------------------------------- bottom nav */

nav#tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--nav-h);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}

nav#tabs button {
  flex: 1;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

nav#tabs button .ico { font-size: 19px; line-height: 1; }
nav#tabs button[aria-selected="true"] { color: var(--accent); font-weight: 600; }

@media (min-width: 760px) {
  nav#tabs {
    position: static;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
  }
  nav#tabs button { flex-direction: row; gap: 8px; padding: 12px 8px; font-size: 14px; }
  nav#tabs button[aria-selected="true"] { background: var(--surface-2); }
}

/* ---------------------------------------------------------------- generic */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 11px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  min-height: 46px;
}

.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 7px 11px; min-height: 0; font-size: 13px; font-weight: 500; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

select, input[type="text"], input[type="password"], input[type="search"] {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 12px;
  width: 100%;
  min-height: 46px;
}

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.bad  { background: var(--bad-bg);  color: var(--bad); }

.banner {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
  background: var(--warn-bg);
  color: var(--warn);
}

/* ----------------------------------------------------------------- login */

#login-view { max-width: 380px; margin: 12vh auto 0; }
#login-view h1 { font-size: 26px; margin: 0 0 4px; }
#login-error { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* ----------------------------------------------------------------- drill */

.progress-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.progress-track {
  flex: 1;
  height: 9px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--good);
  border-radius: 999px;
  transition: width .35s ease;
}

.streak { font-weight: 700; font-size: 15px; white-space: nowrap; }

.qmeta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.qtext { font-size: 17px; line-height: 1.45; margin: 0 0 16px; white-space: pre-wrap; }

.options { display: flex; flex-direction: column; gap: 9px; }

.option {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }

.option .letter {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.option .otext { flex: 1; }

.option.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.option.selected .letter { background: var(--accent); color: var(--accent-ink); }

.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.correct .letter { background: var(--good); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .letter { background: var(--bad); color: #fff; }

.verdict {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  animation: rise .18s ease;
}

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.verdict.ok  { background: var(--good-bg); }
.verdict.no  { background: var(--bad-bg); }
.verdict h3 { margin: 0 0 6px; font-size: 16px; }
.verdict.ok h3 { color: var(--good); }
.verdict.no h3 { color: var(--bad); }
.verdict p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.5; }

/* ---------------------------------------------------------------- browse */

.qlist-item { border-bottom: 1px solid var(--border); padding: 13px 0; }
.qlist-item:last-child { border-bottom: 0; }
.qlist-item .qhead { cursor: pointer; display: flex; gap: 9px; align-items: flex-start; }
.qlist-item .qbody { margin-top: 11px; }
.qlist-item .opt { padding: 7px 10px; border-radius: 8px; font-size: 14px; margin-bottom: 5px; }
.qlist-item .opt.is-answer { background: var(--good-bg); color: var(--good); font-weight: 600; }

/* ----------------------------------------------------------------- stats */

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat { background: var(--surface-2); border-radius: 12px; padding: 13px; }
.stat .n { font-size: 25px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 3px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .name { width: 40%; flex: none; }
.bar-row .track { flex: 1; height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); }
.bar-row .val { width: 54px; text-align: right; flex: none; color: var(--muted); }

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

.deck-grid { display: grid; gap: 10px; }
@media (min-width: 620px) { .deck-grid { grid-template-columns: 1fr 1fr; } }

.deck-card { text-align: left; display: block; width: 100%; }
.deck-card .t { font-weight: 600; margin-bottom: 3px; }

#slide-img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: block;
}

.slide-nav { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.slide-nav .count { flex: 1; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }

.hit { padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.hit:last-child { border-bottom: 0; }
.hit .where { font-size: 12px; color: var(--accent); margin-bottom: 3px; }
.hit .snip { font-size: 13.5px; color: var(--muted); }

/* ------------------------------------------------------------------ exam */

.exam-q { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.exam-q:last-child { border-bottom: 0; }
.exam-timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.score-big { font-size: 44px; font-weight: 800; line-height: 1; }
