:root {
  --bg: #12161c;
  --bg2: #171c24;
  --card: #1c232d;
  --card2: #222a35;
  --line: #2a3340;
  --text: #f3f5f7;
  --muted: #8b95a5;
  --green: #58cc02;
  --green-d: #46a302;
  --blue: #3db4f2;
  --blue-d: #1e90d0;
  --red: #ff5a5a;
  --yellow: #f5c518;
  --orange: #ff9600;
  --purple: #9b6bff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Inter", system-ui, sans-serif;
  --r: 14px;
  --r-lg: 20px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior-y: contain;
}
#app {
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: var(--safe-b);
}
video {
  -webkit-touch-callout: none;
  user-select: none;
}
button, a { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ——— Top nav ——— */
.oson-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 17px;
  white-space: nowrap;
  margin-right: 8px;
}
.logo b { color: var(--green); }
.logo-ico {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--green);
  display: grid; place-items: center;
  color: #0b1200;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.nav-links button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.nav-links button.active {
  background: var(--green);
  color: #fff;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.nav-right .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3db4f2, #58cc02);
}
.lang-mini {
  display: flex;
  gap: 4px;
}
.lang-mini button {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.lang-mini button.active {
  border-color: var(--green);
  color: var(--green);
}

/* ——— Page wrap ——— */
.page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 18px 16px calc(28px + var(--safe-b));
}

/* ——— Home dashboard ——— */
.dash-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.dash-progress .left .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.dash-progress .pct {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
}
.bar {
  height: 10px;
  border-radius: 999px;
  background: #2a3340;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}
.dash-stats {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}
.dash-stats .ok { color: var(--green); }
.dash-stats .bad { color: var(--red); }

.dash-row {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.dash-row.two { grid-template-columns: 1fr 1fr; }
.dash-row.three { grid-template-columns: repeat(3, 1fr); }
.dash-row.misc {
  grid-template-columns: repeat(3, 1fr);
}

.dash-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: left;
  font-weight: 700;
  min-height: 64px;
  transition: transform .08s ease, filter .12s ease;
}
.dash-btn:hover { filter: brightness(1.08); }
.dash-btn:active { transform: scale(.985); }
.dash-btn .ico {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex: 0 0 auto;
  background: rgba(255,255,255,.08);
  font-size: 18px;
}
.dash-btn .txt { display: grid; gap: 2px; }
.dash-btn .txt small {
  color: rgba(255,255,255,.75);
  font-weight: 600;
  font-size: 12px;
}
.dash-btn.wide { justify-content: flex-start; }
.dash-btn.blue { background: #3db4f2; border-color: transparent; color: #fff; }
.dash-btn.green { background: #58cc02; border-color: transparent; color: #fff; }
.dash-btn.gray { background: #3a4452; border-color: transparent; color: #fff; }
.badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid; place-items: center;
}
.badge.orange { background: var(--orange); }

@media (max-width: 800px) {
  .dash-row.two, .dash-row.three, .dash-row.misc { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .dash-progress { grid-template-columns: 1fr; }
}

/* ——— Subpage header ——— */
.sub-head {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.sub-head h1 {
  margin: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}
.back-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--blue);
  font-size: 18px;
  font-weight: 800;
}

/* ——— Tickets ——— */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.tabs button {
  padding: 10px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
}
.tabs button.active {
  border: 1px solid #4a5a70;
  color: #fff;
  background: #243041;
}
.ticket-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.ticket-progress .bar {
  flex: 1;
  height: 28px;
  background: #2a3340;
  position: relative;
}
.ticket-progress .bar > i {
  background: var(--blue);
}
.ticket-progress .bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  z-index: 1;
}
.reset-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #7a1f1f;
  color: #fff;
  font-size: 16px;
}
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.ticket-card {
  min-height: 78px;
  border-radius: 14px;
  padding: 12px 10px;
  background: var(--card2);
  border: 1px solid transparent;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}
.ticket-card .name { font-size: 14px; color: #c8d0dc; }
.ticket-card .score {
  display: flex;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}
.ticket-card.ok {
  background: var(--green);
  color: #fff;
}
.ticket-card.ok .name { color: #fff; }
.ticket-card.warn {
  background: #e6a800;
  color: #fff;
}
.ticket-card.warn .name,
.ticket-card.warn .score { color: #fff; }
.ticket-card.bad {
  background: var(--red);
  color: #fff;
}
.ticket-card.bad .name,
.ticket-card.bad .score { color: #fff; }
@media (max-width: 900px) {
  .ticket-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .ticket-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ——— Topics ——— */
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  margin-bottom: 18px;
  color: var(--muted);
}
.search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-weight: 600;
}
.topic-sec { margin-bottom: 18px; }
.topic-sec h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.topic-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: left;
}
.topic-card .t { font-weight: 700; }
.topic-card .n { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 4px; }
.sign-hero {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.sign-cat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}
.sign-cat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sign-cat-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}
.sign-cat-head .n {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.sign-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.sign-thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #0e131a;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 4px;
}
.mode-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 12px;
}
.mode-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.mode-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
}
.mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ——— Quiz ——— */
.quiz-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.timer {
  margin-left: auto;
  color: var(--yellow);
  font-weight: 800;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.q-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.q-pill {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}
.q-pill.active {
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 0 0 1px var(--blue);
}
.q-pill.ok {
  background: rgba(88,204,2,.18);
  border-color: var(--green);
  color: var(--green);
}
.q-pill.bad {
  background: rgba(255,90,90,.18);
  border-color: var(--red);
  color: var(--red);
}
.quiz-grid {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 18px;
  align-items: start;
}
.q-text {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}
.answers { display: grid; gap: 10px; }
.answer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  text-align: left;
  font-weight: 600;
  line-height: 1.35;
}
.answer:hover:not(:disabled) { border-color: #4a5a70; }
.answer.selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.answer.correct {
  border-color: var(--green);
  background: rgba(88,204,2,.12);
}
.answer.wrong {
  border-color: var(--red);
  background: rgba(255,90,90,.12);
}
.answer .fkey {
  flex: 0 0 auto;
  min-width: 36px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #2b3a4d;
  color: var(--blue);
  font-weight: 800;
  font-size: 12px;
  text-align: center;
}
.media-panel {
  border-radius: 16px;
  background: #0e131a;
  border: 1px solid var(--line);
  min-height: 280px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.media-placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  gap: 10px;
}
.media-placeholder .wm {
  opacity: .25;
  font-weight: 900;
  font-size: 28px;
  letter-spacing: -1px;
}
.media-placeholder .wm b { color: var(--green); }
.photo-wrap {
  background: #0e131a;
}
.photo-wrap img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}
.result-chip {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
}
.result-chip.ok {
  color: var(--green);
  background: rgba(88, 204, 2, 0.14);
}
.result-chip.bad {
  color: var(--red);
  background: rgba(255, 90, 90, 0.14);
}
.quiz-page {
  position: relative;
  padding-bottom: 88px;
}
.quiz-rail {
  position: fixed;
  right: 16px;
  bottom: 88px;
  z-index: 40;
  display: grid;
  gap: 10px;
}
.rail-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid #4a5a70;
  background: #243041;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.rail-btn .rail-ico {
  font-size: 15px;
  line-height: 1;
}
.rail-btn.active {
  border-color: var(--blue);
  background: rgba(59, 130, 246, 0.22);
}
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  animation: sheetFade 0.2s ease;
}
.explain-sheet {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 60;
  width: min(720px, calc(100vw - 24px));
  max-height: min(70vh, 540px);
  overflow: auto;
  padding: 14px;
  border-radius: 18px;
  background: #151c26;
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  transform: translateX(-50%) translateY(110%);
  opacity: 0;
}
.explain-sheet.sheet-in {
  animation: sheetUp 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes sheetUp {
  from {
    transform: translateX(-50%) translateY(110%);
    opacity: 0.4;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}
@keyframes sheetFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.explain-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-tool {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.explain-sheet.video-zoomed {
  width: min(980px, calc(100vw - 12px));
  max-height: 94vh;
  bottom: 8px;
  padding: 12px;
}
.explain-sheet.video-zoomed video {
  max-height: min(72vh, 720px);
}
.explain-sheet-title {
  font-weight: 800;
  font-size: 15px;
}
.sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}
.explain-sheet-body {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.55;
}
.explain-sheet .video-wrap.clip-player {
  border-radius: 12px;
  overflow: hidden;
}
.explain-sheet video {
  max-height: min(48vh, 360px);
}
.video-inline {
  display: grid;
  gap: 10px;
}
.video-inline .video-btn {
  width: fit-content;
}
.video-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.audio-btn, .video-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card2);
  font-weight: 700;
  font-size: 13px;
}
.video-btn {
  border-color: var(--blue);
  color: var(--blue);
}
.quiz-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 800;
}
.btn-primary {
  background: var(--green);
  color: #fff;
}
.btn-ghost {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }

@media (max-width: 900px) {
  .quiz-grid {
    grid-template-columns: 1fr;
  }
  .quiz-grid > .media-panel {
    order: -1;
  }
  .quiz-rail {
    right: 12px;
    bottom: 78px;
  }
  .explain-sheet {
    bottom: 12px;
    width: calc(100vw - 16px);
    max-height: 68vh;
  }
}

/* clip player */
.video-wrap.clip-player {
  border-top: 1px solid var(--line);
  background: #0b1016;
}
.clip-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,.7);
}
.clip-range { color: rgba(255,255,255,.45); font-variant-numeric: tabular-nums; }
.video-wrap video {
  width: 100%;
  max-height: 280px;
  display: block;
  background: #000;
  cursor: pointer;
}
.clip-bar { padding: 8px 12px 12px; }
.clip-track {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  display: flex;
  align-items: center;
}
.clip-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  pointer-events: none;
}
.clip-track i {
  position: relative;
  z-index: 1;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  pointer-events: none;
}
.clip-track:active {
  filter: brightness(1.15);
}
.video-wrap.clip-player:fullscreen,
.video-wrap.clip-player:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.video-wrap.clip-player:fullscreen video,
.video-wrap.clip-player:-webkit-full-screen video {
  max-height: none;
  height: auto;
  flex: 1;
  object-fit: contain;
}
.clip-times {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.45);
  font-variant-numeric: tabular-nums;
}

.result-card {
  text-align: center;
  padding: 40px 20px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
}
.result-card .score {
  font-size: 48px;
  font-weight: 900;
  margin: 10px 0;
}
.result-card .score.pass { color: var(--green); }
.result-card .score.fail { color: var(--red); }
.empty, .loading {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}
.spinner {
  width: 28px; height: 28px;
  margin: 0 auto 12px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 60;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff;
  color: #111;
  font-weight: 700;
  max-width: min(420px, calc(100% - 24px));
}
.body p { margin: 0 0 8px; }
.body ul, .body ol { padding-left: 1.2em; }
