:root {
  --bg: #0a2a35;
  --bg2: #0d3b4c;
  --card: #f4f9fb;
  --card2: #e8f2f6;
  --text: #0f2430;
  --muted: #5a7280;
  --accent: #1a9fb3;
  --accent2: #0e7a8a;
  --ok: #1b8f5a;
  --bad: #c0392b;
  --warn: #d68910;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 45%, #124e5f 100%);
  color: var(--text);
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 920px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: #e8f6fa;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(10, 42, 53, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 0.72rem;
  opacity: 0.85;
}

.main {
  flex: 1;
  padding: 16px;
  padding-bottom: 32px;
}

.drawer {
  position: fixed;
  inset: 56px 0 auto 0;
  background: rgba(8, 35, 44, 0.97);
  padding: 8px;
  display: grid;
  gap: 4px;
  z-index: 30;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  max-height: calc(100dvh - 56px);
  overflow: auto;
}

.drawer[hidden] {
  display: none !important;
}

.drawer button {
  text-align: left;
  background: transparent;
  border: 0;
  color: #dff3f8;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}

.drawer button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card h1,
.card h2,
.card h3 {
  margin: 0 0 10px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--card2);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat .num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent2);
}

.stat .lbl {
  font-size: 0.75rem;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
}

.btn.secondary {
  background: var(--card2);
  color: var(--text);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #e8f6fa;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.chip {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #dceef3;
  color: #0e4a57;
}

.level-0 { background: #fde8e8; color: #922; }
.level-1 { background: #ffe5d9; color: #a33; }
.level-2 { background: #fff0d9; color: #a65; }
.level-3 { background: #fff8dc; color: #886500; }
.level-4 { background: #e5f7ed; color: #1a6b3f; }
.level-5 { background: #dceefb; color: #145a8a; }

.qcm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.qcm-topic {
  font-weight: 700;
  color: var(--accent2);
}

.q-text {
  font-size: 1.02rem;
  line-height: 1.45;
  white-space: pre-wrap;
  margin-bottom: 14px;
}

.options {
  display: grid;
  gap: 8px;
}

.opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #d5e6ec;
  background: white;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.opt:hover {
  border-color: var(--accent);
}

.opt input {
  margin-top: 3px;
  accent-color: var(--accent2);
}

.opt.selected {
  border-color: var(--accent);
  background: #eef9fc;
}

.opt.correct {
  border-color: var(--ok);
  background: #e8f8ef;
}

.opt.wrong {
  border-color: var(--bad);
  background: #fdeeee;
}

.opt.missed {
  border-color: var(--ok);
  background: #f0fff5;
  opacity: 0.95;
}

.correction {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #c5d8e0;
}

.explain-item {
  margin: 8px 0;
  font-size: 0.92rem;
  line-height: 1.4;
}

.key-point {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  background: #eef9fc;
  border-radius: 8px;
}

.warn-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff4e5;
  border-radius: 8px;
  color: #7a4a00;
  font-size: 0.9rem;
}

.mini-rev {
  margin-top: 10px;
  padding: 10px;
  background: #f0f4ff;
  border-radius: 8px;
  font-size: 0.88rem;
}

.search-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #cfe0e6;
  font-size: 1rem;
  margin-bottom: 12px;
}

.list-item {
  padding: 12px;
  border-radius: 10px;
  background: white;
  border: 1px solid #dce9ee;
  margin-bottom: 8px;
  cursor: pointer;
}

.list-item:hover {
  border-color: var(--accent);
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--warn);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #123844;
  color: #e8f6fa;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  transition: transform 0.25s;
  z-index: 50;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 720px) {
  .drawer {
    position: static;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    background: transparent;
    padding: 0 16px 8px;
    border: 0;
    max-height: none;
  }

  .menu-btn {
    display: none;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    max-width: 1200px;
  }

  .topbar {
    grid-column: 1 / -1;
  }

  .drawer {
    grid-column: 1;
    align-content: start;
  }

  .main {
    grid-column: 2;
  }
}
