:root {
  --brand: #0f2a54;
  --brand-2: #1e4aa0;
  --accent: #f5a524;
  --good: #2fa27c;
  --good-bg: #e7f6ef;
  --bad: #d94a4a;
  --bad-bg: #fde8e8;
  --text: #1a2236;
  --muted: #667085;
  --line: #e5e7ec;
  --card: #ffffff;
  --bg: #f5f7fb;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(15, 42, 84, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #dfe4ee;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  min-height: 100%;
}

.app-shell {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

@media (min-width: 480px) {
  .app-shell {
    margin: 16px 0;
    min-height: calc(100vh - 32px);
    border-radius: 28px;
    overflow: hidden;
  }
}

/* Header */
.app-header {
  background: var(--brand);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: #2a4779; color: #fff;
  font-weight: 600; font-size: 13px; cursor: pointer;
}

/* Stats bar */
.stats-bar {
  background: #fff3d6;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  font-size: 14px;
  border-bottom: 1px solid #f1e3b8;
}
.flame { font-size: 16px; }
.cpd-pill {
  background: var(--brand);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 6px;
  font-size: 13px;
}

/* Main view */
.view {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 100px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
  text-transform: uppercase;
  margin: 14px 0 8px;
}

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

.progress-card .row { display: flex; justify-content: space-between; align-items: baseline; }
.progress-card .title { font-weight: 700; font-size: 15px; }
.progress-card .percent { font-size: 13px; color: var(--muted); }
.progress-bar {
  height: 8px; background: #e9edf5; border-radius: 999px; overflow: hidden; margin-top: 10px;
}
.progress-bar > span { display: block; height: 100%; background: var(--brand-2); border-radius: 999px; transition: width .4s; }

.days { display: flex; gap: 8px; margin-top: 14px; }
.day-dot {
  flex: 1; aspect-ratio: 1; max-width: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #e9edf5; color: #8892a6;
  font-weight: 700; font-size: 12px;
}
.day-dot.done { background: var(--brand); color: #fff; }

/* Scenario */
.scenario .tag {
  display: inline-block;
  background: #fff3d6; color: #8a6300;
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  padding: 4px 8px; border-radius: 6px; margin-bottom: 10px;
}
.scenario .q { font-size: 15.5px; font-weight: 600; line-height: 1.45; margin-bottom: 14px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  text-align: left; width: 100%;
  border: 1px solid var(--line); background: #fff;
  padding: 12px 14px; border-radius: 10px;
  font-size: 14.5px; cursor: pointer;
  transition: background .15s, border-color .15s;
  display: flex; justify-content: space-between; align-items: center;
}
.option:hover:not(:disabled) { border-color: var(--brand-2); }
.option.correct { background: var(--good-bg); border-color: var(--good); }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); }
.option .check { color: var(--good); font-weight: 700; }
.option .cross { color: var(--bad); font-weight: 700; }
.option:disabled { cursor: default; }

.explanation {
  margin-top: 12px;
  background: var(--good-bg);
  border-left: 3px solid var(--good);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
}
.explanation.bad { background: var(--bad-bg); border-left-color: var(--bad); }
.explanation strong { display: block; margin-bottom: 2px; }

.primary-btn {
  margin-top: 14px;
  width: 100%;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.primary-btn:disabled { opacity: 0.5; cursor: default; }
.ghost-btn {
  background: transparent; border: 1px solid var(--line);
  padding: 10px; border-radius: 10px; font-size: 14px;
  cursor: pointer; color: var(--text);
}

/* Module list */
.module-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line);
  margin-bottom: 10px; cursor: pointer;
  box-shadow: var(--shadow);
}
.module-row .icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: #eaf0fb; color: var(--brand-2);
  display: grid; place-items: center; font-size: 20px; flex: 0 0 40px;
}
.module-row .meta { flex: 1; min-width: 0; }
.module-row .meta .t { font-weight: 700; font-size: 14.5px; }
.module-row .meta .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.module-row .progress-bar { margin-top: 8px; }
.module-row .chev { color: #b5bcca; }

/* Badges */
.badge-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.badge {
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 8px; text-align: center;
  box-shadow: var(--shadow);
}
.badge .emoji { font-size: 28px; }
.badge .name { font-size: 12px; font-weight: 700; margin-top: 4px; }
.badge .desc { font-size: 10.5px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.badge.locked { opacity: 0.35; filter: grayscale(1); }

/* Settings */
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px;
}
.setting-row .label { font-size: 14px; font-weight: 600; }
.setting-row .val { font-size: 13px; color: var(--muted); }

/* Tab bar */
.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tab {
  border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px; color: #9aa3b4; cursor: pointer;
  font-size: 11px;
}
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab.active { color: var(--brand); }
.tab.active svg { fill: var(--brand); }

/* Complete screen */
.complete {
  text-align: center; padding: 30px 10px;
}
.complete .big { font-size: 42px; }
.complete h2 { margin: 6px 0 4px; }
.complete p { color: var(--muted); margin: 0 0 16px; }
.complete .rewards { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }
.reward-pill {
  background: #fff; border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
}

/* Briefing */
.intro-card .intro-title { font-size: 18px; font-weight: 800; margin-top: 6px; }
.intro-card .intro-sub { font-size: 13.5px; color: var(--muted); margin: 2px 0 6px; }
.intro-card .intro-heading {
  font-size: 13px; font-weight: 700; color: var(--brand);
  margin-top: 14px; letter-spacing: 0.2px;
}
.intro-card .intro-body { font-size: 14px; line-height: 1.55; margin-top: 4px; }
.intro-sources { margin: 6px 0 4px; padding-left: 20px; font-size: 13.5px; line-height: 1.6; }
.intro-sources a { color: var(--brand-2); text-decoration: none; }
.intro-sources a:hover { text-decoration: underline; }

.toast {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: #1a2236; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none;
  z-index: 20;
}
.toast.show { opacity: 1; }
