:root {
  --navy: #1F3A5F; --navy-deep: #152841;
  --ice: #C9D6E8; --ice-pale: #E8EEF5;
  --amber: #F2A65A; --amber-soft: #FDE8CF;
  --green: #2E7D52; --green-pale: #E3F2E9;
  --red: #C0392B; --red-pale: #FBE9E7;
  --muted: #6B7A8F; --paper: #FFFFFF; --bg: #F2EEE6;
  --shadow: 0 2px 12px rgba(31, 58, 95, 0.10);
  --shadow-lg: 0 8px 32px rgba(31, 58, 95, 0.18);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1c2833; background: var(--bg); line-height: 1.55;
  display: flex; flex-direction: column; min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---- Top bar ---- */
.top-bar {
  background: var(--navy); color: white; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow); flex-wrap: wrap; gap: 8px;
}
.brand { font-size: 16px; font-weight: 700; letter-spacing: 0.4px; }
.brand-sub { font-size: 11px; opacity: 0.65; letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.top-right .who { opacity: 0.85; }
.btn-link { background: none; border: 1px solid rgba(255,255,255,0.4); color: white;
  padding: 5px 12px; border-radius: 6px; font-size: 12px; }
.btn-link:hover { background: rgba(255,255,255,0.12); }

/* ---- Layout ---- */
.wrap { flex: 1; max-width: 1180px; width: 100%; margin: 0 auto; padding: 22px; }
.card { background: var(--paper); border-radius: 12px; box-shadow: var(--shadow); padding: 26px 30px; margin-bottom: 20px; }
.card h2 { color: var(--navy); font-size: 20px; margin-bottom: 12px; }
.card h3 { color: var(--navy); font-size: 15px; margin: 16px 0 8px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---- Auth screen ---- */
.auth-shell { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box { background: var(--paper); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 40px 44px; max-width: 440px; width: 100%; text-align: center; }
.auth-box .logo { font-size: 22px; font-weight: 800; color: var(--navy); letter-spacing: 0.5px; }
.auth-box .logo-sub { font-size: 11px; letter-spacing: 3px; color: var(--amber);
  text-transform: uppercase; margin: 4px 0 24px; font-weight: 700; }
.auth-box p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.btn-primary {
  background: var(--amber); color: #4a2c0a; border: none; font-weight: 700;
  padding: 13px 22px; border-radius: 9px; font-size: 15px; width: 100%; margin-bottom: 10px;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary {
  background: var(--navy); color: white; border: none; font-weight: 600;
  padding: 11px 18px; border-radius: 9px; font-size: 14px;
}
.btn-secondary:hover { background: var(--navy-deep); }
.btn-ghost { background: none; border: 1px solid var(--ice); color: var(--navy);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.btn-ghost:hover { background: var(--ice-pale); }
.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--navy);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--ice);
  border-radius: 8px; font-size: 14px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--amber); }
.auth-error { background: var(--red-pale); color: var(--red); font-size: 13px;
  padding: 9px 12px; border-radius: 7px; margin-bottom: 12px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted);
  font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--ice); }

/* ---- Role banner ---- */
.role-banner {
  background: linear-gradient(135deg, var(--navy), var(--navy-deep));
  color: white; border-radius: 12px; padding: 20px 26px; margin-bottom: 20px;
}
.role-banner .hello { font-size: 18px; font-weight: 700; }
.role-banner .role-line { font-size: 13px; opacity: 0.85; margin-top: 4px; }
.role-banner .emphasis { font-size: 13px; opacity: 0.7; margin-top: 8px; font-style: italic; }
.progress-track { height: 8px; background: rgba(255,255,255,0.18); border-radius: 4px; margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--amber); border-radius: 4px; transition: width 0.4s; }
.progress-label { font-size: 11px; opacity: 0.8; margin-top: 6px; letter-spacing: 0.5px; }

/* ---- Episode list ---- */
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ep-tile {
  background: var(--paper); border-radius: 11px; box-shadow: var(--shadow);
  padding: 16px 18px; border-left: 4px solid var(--ice);
  cursor: pointer; transition: transform 0.12s, box-shadow 0.12s;
}
.ep-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.ep-tile.locked { opacity: 0.55; cursor: not-allowed; border-left-color: var(--muted); }
.ep-tile.locked:hover { transform: none; box-shadow: var(--shadow); }
.ep-tile.passed { border-left-color: var(--green); }
.ep-tile.current { border-left-color: var(--amber); }
.ep-tile .ep-num { font-size: 11px; font-weight: 700; color: var(--amber); letter-spacing: 1.5px; }
.ep-tile .ep-title { font-size: 15px; font-weight: 700; color: var(--navy); margin: 4px 0; }
.ep-tile .ep-summary { font-size: 12.5px; color: var(--muted); }
.ep-tile .ep-status { margin-top: 10px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.5px; }
.ep-tile .ep-status.s-locked { color: var(--muted); }
.ep-tile .ep-status.s-todo { color: var(--amber); }
.ep-tile .ep-status.s-passed { color: var(--green); }

/* ---- Synced slide presentation ---- */
.slide-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--navy), var(--navy-deep));
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
  margin: 6px 0 10px; color: white;
}
@supports not (aspect-ratio: 1) { .slide-stage { height: 420px; } }
.slide-inner {
  position: absolute; inset: 0; padding: 7% 8%;
  display: flex; flex-direction: column; justify-content: center;
  opacity: 0; transition: opacity 0.4s ease;
}
.slide-inner.active { opacity: 1; }
.slide-kicker {
  font-size: 12px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--amber); font-weight: 700; margin-bottom: 10px;
}
.slide-h {
  font-size: clamp(22px, 3.6vw, 40px); font-weight: 800; line-height: 1.15;
  margin-bottom: 6px;
}
.slide-sub { font-size: clamp(14px, 1.8vw, 22px); color: var(--ice); margin-bottom: 8px; }
.slide-meta {
  display: inline-block; font-size: clamp(11px, 1.3vw, 14px); color: var(--navy-deep);
  background: var(--amber); padding: 4px 12px; border-radius: 14px;
  font-weight: 700; margin-bottom: 14px;
}
.slide-bullets { list-style: none; margin: 6px 0 0; padding: 0; }
.slide-bullets li {
  font-size: clamp(13px, 1.7vw, 20px); line-height: 1.45; margin-bottom: 12px;
  padding-left: 28px; position: relative; color: #EEF3F8;
}
.slide-bullets li::before {
  content: ""; position: absolute; left: 0; top: 0.5em;
  width: 11px; height: 11px; border-radius: 3px; background: var(--amber);
}
.slide-note {
  margin-top: 16px; font-size: clamp(12px, 1.5vw, 17px); font-style: italic;
  color: var(--ice); border-left: 3px solid var(--amber); padding-left: 14px;
}
.slide-footer {
  position: absolute; bottom: 5%; left: 8%; right: 8%;
  font-size: clamp(10px, 1.2vw, 13px); color: rgba(255,255,255,0.5);
}
.slide-phases { display: flex; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }
.slide-phase {
  flex: 1; min-width: 110px; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 9px;
  padding: 14px 12px; text-align: center; position: relative;
}
.slide-phase .pn {
  font-size: 11px; color: var(--amber); font-weight: 700; letter-spacing: 1px;
}
.slide-phase .pl { font-size: clamp(12px, 1.5vw, 16px); font-weight: 700; margin-top: 4px; }
.slide-phase:not(:last-child)::after {
  content: "›"; position: absolute; right: -9px; top: 50%; transform: translateY(-50%);
  color: var(--amber); font-weight: 700; font-size: 18px; z-index: 2;
}
.slide-progress {
  position: absolute; left: 0; bottom: 0; height: 4px;
  background: var(--amber); transition: width 0.25s linear;
}
.slide-nav {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  margin: 0 0 14px;
}
.slide-dot {
  width: 26px; height: 6px; border-radius: 3px; background: var(--ice);
  border: none; cursor: pointer; padding: 0; transition: background 0.2s;
}
.slide-dot:hover { background: var(--muted); }
.slide-dot.active { background: var(--amber); }
.transcript-toggle {
  background: none; border: 1px solid var(--ice); color: var(--navy);
  font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 7px;
  cursor: pointer; margin-bottom: 6px;
}
.transcript-toggle:hover { background: var(--ice-pale); }

/* ---- Player / quiz ---- */
.player-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.episode-tag { display: inline-block; background: var(--amber); color: #4a2c0a;
  font-size: 11px; letter-spacing: 2px; padding: 3px 10px; border-radius: 12px; font-weight: 700; }
.episode-title { font-size: 25px; color: var(--navy); font-weight: 700; margin: 8px 0 4px; }
.episode-summary { color: var(--muted); font-size: 14px; font-style: italic; margin-bottom: 16px; }
audio { width: 100%; margin: 6px 0 14px; }
.audio-warn { background: #FFF8E1; border-left: 4px solid var(--amber); padding: 9px 13px;
  font-size: 12.5px; margin-bottom: 14px; border-radius: 4px; color: #5d4037; }
.dialogue { max-height: 320px; overflow-y: auto; padding: 4px; margin-bottom: 8px;
  border: 1px solid var(--ice-pale); border-radius: 8px; }
.line { display: flex; gap: 12px; margin: 12px; }
.speaker { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 13px; }
.speaker.maya { background: var(--amber); color: #4a2c0a; }
.speaker.sam { background: var(--navy); }
.line-name { font-weight: 700; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.line-text { font-size: 14.5px; }

/* ---- Quiz ---- */
.quiz-intro { background: var(--ice-pale); border-radius: 10px; padding: 16px 20px; margin: 14px 0; }
.q-card { border: 1.5px solid var(--ice); border-radius: 11px; padding: 20px 22px; margin-bottom: 14px; }
.q-progress { font-size: 11px; font-weight: 700; color: var(--amber); letter-spacing: 1.5px; }
.q-stem { font-size: 16px; font-weight: 600; color: var(--navy); margin: 8px 0 14px; }
.q-opts { display: flex; flex-direction: column; gap: 9px; }
.q-opt {
  text-align: left; padding: 12px 15px; border: 1.5px solid var(--ice); border-radius: 9px;
  background: var(--paper); font-size: 14.5px; transition: all 0.12s;
}
.q-opt:hover:not(:disabled) { border-color: var(--amber); background: var(--amber-soft); }
.q-opt:disabled { cursor: default; }
.q-opt.correct { border-color: var(--green); background: var(--green-pale); font-weight: 600; }
.q-opt.wrong { border-color: var(--red); background: var(--red-pale); }
.q-feedback { margin-top: 14px; padding: 13px 16px; border-radius: 9px; font-size: 14px; }
.q-feedback.right { background: var(--green-pale); color: var(--green); }
.q-feedback.wrong { background: var(--red-pale); color: var(--red); }
.q-feedback .expl { color: #1c2833; margin-top: 6px; }
.q-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.weakness-box { background: #FFF8E1; border-left: 4px solid var(--amber);
  padding: 14px 18px; border-radius: 8px; margin: 14px 0; font-size: 14px; }
.weakness-box ul { margin: 8px 0 0 20px; }

/* ---- Result ---- */
.result-score { font-size: 48px; font-weight: 800; text-align: center; margin: 10px 0; }
.result-score.pass { color: var(--green); }
.result-score.fail { color: var(--red); }
.result-banner { text-align: center; font-size: 16px; font-weight: 700; margin-bottom: 8px; }

/* ---- Director dashboard ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--paper); border-radius: 11px; box-shadow: var(--shadow); padding: 18px 20px; }
.kpi .kpi-val { font-size: 30px; font-weight: 800; color: var(--navy); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
table.records { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.records th { background: var(--navy); color: white; text-align: left; padding: 10px 12px; font-size: 12px; letter-spacing: 0.5px; }
table.records td { padding: 9px 12px; border-bottom: 1px solid var(--ice-pale); }
table.records tr:hover td { background: var(--ice-pale); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.pill.done { background: var(--green-pale); color: var(--green); }
.pill.partial { background: var(--amber-soft); color: #8a5418; }
.pill.none { background: var(--ice-pale); color: var(--muted); }

/* ---- Footer ---- */
.footer { text-align: center; color: var(--muted); font-size: 11.5px; padding: 18px;
  border-top: 1px solid var(--ice); background: var(--paper); }

/* ---- Print (training record export) ---- */
@media print {
  .top-bar, .footer, .q-actions, .btn-primary, .btn-secondary, .btn-ghost, audio, .dialogue { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

@media (max-width: 600px) {
  .wrap { padding: 14px; }
  .card { padding: 18px 18px; }
  .auth-box { padding: 30px 24px; }
}
