:root {
  --bg: #0d1014;
  --bg-raised: #151a21;
  --bg-raised-2: #1c232c;
  --line: #262f3a;
  --line-soft: #1e262f;
  --text: #e8edf3;
  --text-dim: #94a3b3;
  --text-faint: #64707e;
  --accent: #ff8a3d;
  --accent-soft: rgba(255, 138, 61, 0.14);
  --ok: #3ddc91;
  --ok-soft: rgba(61, 220, 145, 0.13);
  --ko: #ff5d5d;
  --ko-soft: rgba(255, 93, 93, 0.13);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --maxw: 780px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  background: rgba(13, 16, 20, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: #1a0d03;
}

.brand-name { font-weight: 620; font-size: 0.95rem; }

.topnav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }

.topnav a {
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
}
.topnav a:hover { color: var(--text); background: var(--bg-raised); }
.topnav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.app {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px max(14px, env(safe-area-inset-left)) 60px max(14px, env(safe-area-inset-right));
}

.footer {
  border-top: 1px solid var(--line-soft);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  text-align: center;
}
.footer p {
  max-width: var(--maxw);
  margin: 0 auto;
  font-size: 0.76rem;
  color: var(--text-faint);
}

/* ---------- building blocks ---------- */

.stack { display: flex; flex-direction: column; gap: 18px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 650;
}

.muted { color: var(--text-dim); font-size: 0.9rem; }
.tiny { color: var(--text-faint); font-size: 0.78rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-raised-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: #232c37; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0d03;
}
.btn-primary:hover { background: #ff9a56; }

.btn-block { width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 auto; }

/* ---------- home ---------- */

.hero {
  background: linear-gradient(155deg, #1d242e 0%, #141a21 60%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 18px;
}
.hero h1 { margin-bottom: 8px; }
.hero p { color: var(--text-dim); font-size: 0.95rem; }
.hero .btn-row { margin-top: 16px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.kpi {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}
.kpi-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi-label { font-size: 0.72rem; color: var(--text-faint); margin-top: 2px; }

.tile-list { display: flex; flex-direction: column; gap: 8px; }

.tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
}
.tile:hover { border-color: #35414f; background: var(--bg-raised-2); }

.tile-badge {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.85rem;
}
.tile-body { flex: 1; min-width: 0; }
.tile-title { font-weight: 600; font-size: 0.95rem; }
.tile-sub { font-size: 0.78rem; color: var(--text-faint); }
.tile-meta { flex-shrink: 0; text-align: right; font-size: 0.8rem; color: var(--text-dim); }

.bar {
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
  margin-top: 7px;
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.bar.is-ok > span { background: var(--ok); }

/* ---------- quiz ---------- */

.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.quiz-count { font-size: 0.85rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.quiz-count b { color: var(--text); font-size: 1rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-raised-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.chip.is-warn { color: var(--ko); border-color: rgba(255, 93, 93, 0.4); background: var(--ko-soft); }

.progress-track {
  height: 4px;
  border-radius: 99px;
  background: var(--line-soft);
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-track > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.question {
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
}
.question-hint { font-size: 0.78rem; color: var(--text-faint); margin-bottom: 14px; }

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

.choice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.choice:hover { border-color: #3a4655; }

.choice-key {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-top: 1px;
}

.choice.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.is-selected .choice-key { background: var(--accent); border-color: var(--accent); color: #1a0d03; }

.choice.is-right { border-color: var(--ok); background: var(--ok-soft); }
.choice.is-right .choice-key { background: var(--ok); border-color: var(--ok); color: #052915; }
.choice.is-wrong { border-color: var(--ko); background: var(--ko-soft); }
.choice.is-wrong .choice-key { background: var(--ko); border-color: var(--ko); color: #2a0505; }

.choice[disabled] { cursor: default; }

.verdict {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-raised);
}
.verdict-title { font-weight: 700; font-size: 0.92rem; margin-bottom: 5px; }
.verdict.is-ok { border-color: rgba(61, 220, 145, 0.35); background: var(--ok-soft); }
.verdict.is-ok .verdict-title { color: var(--ok); }
.verdict.is-ko { border-color: rgba(255, 93, 93, 0.35); background: var(--ko-soft); }
.verdict.is-ko .verdict-title { color: var(--ko); }
.verdict p { font-size: 0.9rem; color: var(--text-dim); }

.quiz-actions { margin-top: 18px; }

/* ---------- results ---------- */

.score-card {
  text-align: center;
  padding: 26px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
}
.score-card.is-ok { border-color: rgba(61, 220, 145, 0.4); background: linear-gradient(160deg, rgba(61,220,145,0.12), var(--bg-raised) 70%); }
.score-card.is-ko { border-color: rgba(255, 93, 93, 0.35); background: linear-gradient(160deg, rgba(255,93,93,0.1), var(--bg-raised) 70%); }
.score-value { font-size: 3rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1; }
.score-total { font-size: 1.2rem; color: var(--text-faint); font-weight: 600; }
.score-verdict { margin-top: 8px; font-weight: 650; }
.score-card.is-ok .score-verdict { color: var(--ok); }
.score-card.is-ko .score-verdict { color: var(--ko); }

.review-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 13px 14px;
}
.review-q { font-weight: 600; font-size: 0.93rem; margin-bottom: 8px; }
.review-line { font-size: 0.85rem; display: flex; gap: 7px; }
.review-line .tag { flex-shrink: 0; font-weight: 700; font-size: 0.7rem; letter-spacing: 0.05em; padding-top: 3px; }
.review-line.ko .tag { color: var(--ko); }
.review-line.ok .tag { color: var(--ok); }
.review-explain { margin-top: 8px; font-size: 0.85rem; color: var(--text-dim); border-top: 1px solid var(--line-soft); padding-top: 8px; }

/* ---------- course ---------- */

.course h2 { margin-top: 22px; margin-bottom: 8px; }
.course h2:first-of-type { margin-top: 0; }
.course ul { margin: 0; padding-left: 20px; }
.course li { margin-bottom: 6px; font-size: 0.93rem; color: var(--text-dim); }
.course li b, .course li strong { color: var(--text); font-weight: 620; }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 11px 13px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table th, .table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.table th { color: var(--text-faint); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.table td { color: var(--text-dim); }
.table td:first-child { color: var(--text); font-weight: 550; }

.table-wrap { overflow-x: auto; }

/* ---------- misc ---------- */

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.segmented button {
  flex: 1;
  padding: 8px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: #1a0d03; }

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-decoration: none;
  margin-bottom: 12px;
}
.back-link:hover { color: var(--text); }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 40px auto;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 620px) {
  h1 { font-size: 1.95rem; }
  .app { padding-top: 30px; }
  .hero { padding: 30px 26px; }
  .card { padding: 20px; }
  .btn-row > * { flex: 0 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- visuels ---------- */

.visual {
  margin: 0 0 16px;
  background: #10151b;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.visual-sign svg { width: 132px; height: 132px; }

.visual-signs { flex-wrap: wrap; gap: 10px; }
.visual-cell { text-align: center; }
.visual-cell svg { width: 84px; height: 84px; display: block; }
.visual-key {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.visual-scene { padding: 8px; }
.visual-scene svg { width: 100%; max-width: 420px; height: auto; border-radius: 8px; }

.review-item .visual { padding: 8px; margin-bottom: 10px; }
.review-item .visual-sign svg { width: 74px; height: 74px; }
.review-item .visual-scene svg { max-width: 260px; }
.review-item .visual-cell svg { width: 54px; height: 54px; }

.sign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}
.sign-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.sign-card svg { width: 100%; max-width: 70px; height: auto; }
.sign-card span {
  display: block;
  margin-top: 7px;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--text-dim);
}

@media (max-width: 430px) {
  .topbar { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .brand-name { display: none; }
  .topnav a { padding: 7px 9px; font-size: 0.84rem; }
}
