/* HocTest Daily — mobile-first PWA */

:root {
  --navy: #16345c;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --radius: 16px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
.app.no-tabbar { padding-bottom: env(safe-area-inset-bottom); }

/* ---------- generic ---------- */
.screen { padding: 16px; animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-soft { background: var(--blue-soft); color: var(--navy); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.hstack { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.code, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
}
pre.code {
  padding: 12px;
  overflow-x: auto;
  white-space: pre;
  margin: 10px 0;
  line-height: 1.55;
}

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--blue); }

/* ---------- welcome / auth ---------- */
.hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
  background: linear-gradient(160deg, #16345c 0%, #1d4e89 60%, #2563eb 100%);
  color: #fff;
}
.hero img { width: 88px; height: 88px; margin-bottom: 16px; }
.hero h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; }
.hero p.sub { opacity: .85; margin: 0 0 28px; }
.hero .feat { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; opacity: .95; }
.hero .feat svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.hero .btn-primary { background: #fff; color: var(--navy); margin-top: 20px; }
.hero .btn-ghost { color: #fff; border-color: rgba(255,255,255,.6); margin-top: 10px; }

.auth-head { padding: 28px 4px 8px; }
.auth-head h2 { margin: 0 0 4px; font-size: 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
}
.field input:focus { outline: none; border-color: var(--blue); }
.form-err { color: var(--red); font-size: 13px; margin: 8px 0; min-height: 18px; }
.demo-note {
  font-size: 12px;
  color: var(--muted);
  background: var(--amber-soft);
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 14px;
}

/* ---------- today ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 6px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px;
  flex: none;
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px;
  font-size: 13px; font-weight: 700;
}
.chip svg { width: 14px; height: 14px; }
.chip.streak { color: var(--amber); }
.chip.xp { color: var(--blue); }

.weekstrip { display: flex; gap: 6px; padding: 10px 16px 4px; }
.weekstrip .d {
  flex: 1; text-align: center; font-size: 11px; color: var(--muted);
}
.weekstrip .dot {
  width: 30px; height: 30px; margin: 4px auto 0;
  border-radius: 50%; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: transparent;
}
.weekstrip .d.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.weekstrip .d.today .dot { border-color: var(--blue); border-style: dashed; }

.lesson-card {
  background: linear-gradient(135deg, var(--navy), #1d4e89);
  color: #fff; border: 0;
  position: relative; overflow: hidden;
}
.lesson-card .badge-day {
  display: inline-block; background: rgba(255,255,255,.18);
  border-radius: 999px; padding: 4px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .4px;
}
.lesson-card h3 { font-size: 20px; margin: 10px 0 6px; }
.lesson-card p { opacity: .85; font-size: 14px; margin: 0 0 14px; }
.lesson-card .meta { display: flex; gap: 12px; font-size: 13px; opacity: .8; margin-bottom: 14px; }
.lesson-card .btn { background: #fff; color: var(--navy); }
.lesson-card.done-card { background: linear-gradient(135deg, #14532d, var(--green)); }

.sec-title { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 18px 0 8px; }

.mini-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.mini-row:last-child { border-bottom: 0; }
.mini-row .ic {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.mini-row .ic svg { width: 19px; height: 19px; }
.ic.green { background: var(--green-soft); color: var(--green); }
.ic.blue { background: var(--blue-soft); color: var(--blue); }
.ic.lock { background: #f1f5f9; color: #94a3b8; }

/* ---------- lesson player ---------- */
.lesson-top {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
}
.icon-btn {
  border: 0; background: none; color: var(--muted);
  width: 34px; height: 34px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 22px; height: 22px; }
.segbar { flex: 1; display: flex; gap: 4px; }
.segbar i {
  flex: 1; height: 6px; border-radius: 99px;
  background: var(--line); transition: background .3s;
}
.segbar i.on { background: var(--blue); }
.segbar i.ok { background: var(--green); }

.video-box {
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b1526;
  aspect-ratio: 16/9;
  position: relative;
  margin-bottom: 14px;
}
.video-box iframe, .video-box video { width: 100%; height: 100%; border: 0; display: block; }
.video-ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #cbd5e1; gap: 10px;
  background: radial-gradient(ellipse at 50% 30%, #1e3a5f, #0b1526);
}
.video-ph .play {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
}
.video-ph .play svg { width: 28px; height: 28px; margin-left: 4px; fill: #fff; }
.video-ph .dur {
  position: absolute; bottom: 10px; right: 12px;
  font-size: 12px; background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 8px;
}

/* ---------- exercises ---------- */
.ex-q { font-size: 18px; font-weight: 800; margin: 4px 0 12px; }
.ex-type { font-size: 12px; font-weight: 800; color: var(--blue); text-transform: uppercase; letter-spacing: .5px; }

.opt {
  display: block; width: 100%; text-align: left;
  background: #fff; border: 2px solid var(--line);
  border-radius: 14px; padding: 13px 14px;
  font-size: 15px; font-family: inherit; cursor: pointer;
  margin-bottom: 10px;
}
.opt .ocode { font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; }
.opt.sel { border-color: var(--blue); background: var(--blue-soft); }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt:disabled { cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chipopt {
  border: 2px solid var(--line); background: #fff;
  border-radius: 999px; padding: 9px 16px;
  font-size: 14.5px; font-weight: 600; font-family: ui-monospace, Menlo, monospace;
  cursor: pointer;
}
.chipopt.sel { border-color: var(--blue); background: var(--blue-soft); }

.blank-slot {
  display: inline-block; min-width: 70px;
  border-bottom: 2.5px dashed var(--blue);
  color: var(--amber); text-align: center; padding: 0 6px;
}
.blank-slot.filled { border-bottom-style: solid; border-color: var(--green); color: #7dd3fc; }

.codeline {
  display: block; width: 100%; text-align: left;
  font-family: ui-monospace, Menlo, monospace; font-size: 13.5px;
  background: #0f172a; color: #e2e8f0;
  border: 2px solid transparent; border-left: 4px solid #334155;
  padding: 10px 12px; cursor: pointer;
}
.codeline:first-child { border-radius: 10px 10px 0 0; }
.codeline:last-child { border-radius: 0 0 10px 10px; }
.codeline.sel { border-color: var(--blue); background: #1e293b; }
.codeline.right { border-color: var(--green); background: #052e16; }
.codeline.wrong { border-color: var(--red); background: #3f0d0d; }
.codeline .ln { display: inline-block; width: 22px; color: #475569; }

.order-pool, .order-ans { display: flex; flex-direction: column; gap: 8px; }
.order-item {
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 11px 13px; font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  cursor: pointer; text-align: left; width: 100%;
}
.order-item .seq {
  display: inline-flex; width: 20px; height: 20px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 800;
  align-items: center; justify-content: center; margin-right: 8px;
  font-family: -apple-system, sans-serif;
}
.order-ans .order-item { border-color: var(--blue); }
.order-empty {
  border: 2px dashed var(--line); border-radius: 12px;
  padding: 16px; color: var(--muted); font-size: 13px; text-align: center;
}
.order-label { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 6px; }

.predict-btns { display: flex; gap: 10px; margin-top: 12px; }
.predict-btns .opt { margin: 0; text-align: center; font-weight: 800; font-size: 16px; }

.match-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match-item {
  border: 2px solid var(--line); background: #fff; border-radius: 12px;
  padding: 11px 10px; font-size: 13.5px; min-height: 58px;
  display: flex; align-items: center; cursor: pointer;
  font-family: inherit; text-align: left; width: 100%;
}
.match-item.l { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.match-item.sel { border-color: var(--blue); background: var(--blue-soft); }
.match-item.paired { border-color: var(--green); background: var(--green-soft); }
.match-item.miss { border-color: var(--red); background: var(--red-soft); }

/* feedback sheet */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  z-index: 90; animation: fade .2s;
}
@keyframes fade { from { opacity: 0 } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  z-index: 95; animation: slideUp .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes slideUp { from { transform: translateY(60%); } }
.sheet .verdict { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; }
.sheet .verdict .vic {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; flex: none;
}
.sheet .verdict .vic svg { width: 19px; height: 19px; }
.sheet.ok .verdict { color: var(--green); }
.sheet.ok .vic { background: var(--green); }
.sheet.no .verdict { color: var(--red); }
.sheet.no .vic { background: var(--red); }
.sheet .explain { font-size: 14px; color: var(--ink); margin: 12px 0 16px; background: var(--bg); padding: 12px; border-radius: 12px; }
.sheet.ok .btn { background: var(--green); color: #fff; }

/* lesson summary */
.summary-hero { text-align: center; padding: 30px 16px 10px; }
.summary-hero .big {
  width: 92px; height: 92px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--green-soft); color: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.summary-hero .big svg { width: 44px; height: 44px; }
.stat-row { display: flex; gap: 10px; }
.stat-box { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 8px; text-align: center; }
.stat-box b { display: block; font-size: 22px; }
.stat-box span { font-size: 12px; color: var(--muted); }
.burst { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 200; border-radius: 2px; animation: fall 1.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .7; } }

/* ---------- roadmap ---------- */
.week-head { font-size: 13px; font-weight: 800; color: var(--muted); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
.day-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; margin-bottom: 8px;
  text-decoration: none; color: inherit;
}
.day-row.locked { opacity: .55; }
.day-num {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
  background: var(--blue-soft); color: var(--blue);
}
.day-row.done .day-num { background: var(--green-soft); color: var(--green); }
.day-row.locked .day-num { background: #f1f5f9; color: #94a3b8; }
.day-row .t { font-weight: 700; font-size: 14.5px; }
.day-row .s { font-size: 12.5px; color: var(--muted); }
.day-row .arrow { color: var(--muted); flex: none; }
.score-pill { font-size: 11px; font-weight: 800; color: var(--green); background: var(--green-soft); border-radius: 999px; padding: 3px 9px; }

/* ---------- profile ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-grid .stat-box b { font-size: 26px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px; background: var(--line);
  transition: .2s; pointer-events: none;
}
.switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { left: 23px; }
