:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2f3f56;
  --text: #e8edf4;
  --muted: #8fa3bf;
  --accent: #f59e0b;
  --accent-dim: #b45309;
  --ok: #22c55e;
  --bad: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  background: linear-gradient(135deg, #1a2332 0%, #0f1419 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}

.header h1 { font-size: 1.35rem; font-weight: 700; }

.nav { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.15s;
}

.nav-btn:hover { color: var(--text); background: var(--surface2); }
.nav-btn.active { color: var(--bg); background: var(--accent); font-weight: 600; }

.main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  width: 100%;
}

.view { display: none; }
.view.active { display: block; }

.hero { margin-bottom: 1.75rem; }
.hero h2 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.lead { color: var(--muted); max-width: 62ch; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-primary { border-color: var(--accent-dim); }
.card h3 { margin-bottom: 0.35rem; }
.card p { color: var(--muted); font-size: 0.92rem; margin-bottom: 1rem; }

.parts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.parts-main {
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (max-width: 700px) {
  .parts-main { grid-template-columns: 1fr; }
}

.section-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.65rem;
}

.cards-secondary {
  margin-bottom: 1.5rem;
}

.cards-secondary .card { padding: 1rem 1.15rem; }
.cards-secondary .card h3 { font-size: 1rem; }
.cards-secondary .card p { margin-bottom: 0.75rem; font-size: 0.85rem; }

.part-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: 0.15s;
}

.part-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

.part-btn-main {
  padding: 1.35rem 1.15rem;
  border-color: var(--accent-dim);
  background: linear-gradient(160deg, var(--surface) 0%, #1e2a3d 100%);
}

.part-btn-main .part-num {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.part-btn-main strong {
  display: block;
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.part-btn strong { display: block; margin-bottom: 0.2rem; }
.part-btn span { color: var(--muted); font-size: 0.85rem; }

.parts-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

@media (min-width: 701px) {
  .parts-total { display: none; }
}

.parts-total-val {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.parts-total-lbl {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.summary-bar {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.notice summary { cursor: pointer; color: var(--text); font-weight: 600; }
.notice p { margin-top: 0.75rem; }
.notice code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; }

.btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  transition: 0.15s;
}

.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
.btn-primary:hover { background: #fbbf24; }
.btn-ghost { background: transparent; }
.btn-danger {
  background: transparent;
  color: var(--bad);
  border-color: var(--bad);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.12); }

.danger-zone {
  margin-top: 2rem;
  padding: 1.25rem;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.06);
}
.danger-zone h3 { color: var(--bad); margin-bottom: 0.5rem; }
.danger-zone p { color: var(--muted); font-size: 0.92rem; margin-bottom: 1rem; }

.quiz-launcher {
  padding-top: 0.5rem;
}
.quiz-launcher h2 { margin-bottom: 0.35rem; }
.quiz-launcher .lead { margin-bottom: 1.25rem; color: var(--muted); }

.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.quiz-mode { color: var(--accent); font-weight: 600; font-size: 0.85rem; margin-bottom: 0.5rem; }

.progress-wrap { display: flex; align-items: center; gap: 0.75rem; }
.progress-bar {
  width: 200px;
  height: 8px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.25s; }

.timer {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.question-card, .result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.q-meta { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.5rem; }
.q-text { font-size: 1.15rem; margin-bottom: 1rem; line-height: 1.45; }

.q-images img {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}

.options { display: flex; flex-direction: column; gap: 0.55rem; margin-bottom: 1rem; }

.option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: 0.12s;
  width: 100%;
}

.option:hover:not(:disabled) { border-color: var(--accent); }
.option .letter {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.option.correct { border-color: var(--ok); background: rgba(34, 197, 94, 0.1); }
.option.wrong { border-color: var(--bad); background: rgba(239, 68, 68, 0.1); }
.option:disabled { cursor: default; }

.feedback {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.feedback.ok { background: rgba(34, 197, 94, 0.15); border: 1px solid var(--ok); }
.feedback.bad { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--bad); }

.quiz-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.result-score { font-size: 2rem; font-weight: 800; color: var(--accent); margin: 0.5rem 0; }

.wrong-list, .weak-list, .sessions-list, .question-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.wrong-item, .weak-item, .session-item, .list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
}

.list-item details summary { cursor: pointer; font-weight: 600; }
.list-item .answer-correct { color: var(--ok); margin-top: 0.5rem; }

.weak-item .badge {
  display: inline-block;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-box .val { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.stat-box .lbl { font-size: 0.78rem; color: var(--muted); }

.list-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.list-toolbar select,
.list-toolbar input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  font-size: 0.92rem;
}

.list-toolbar input { flex: 1; min-width: 200px; }

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-name {
  color: var(--muted);
  font-size: 0.9rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.view-login.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 2rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.login-card h2 { margin-bottom: 0.35rem; }
.login-card .lead { margin-bottom: 1.25rem; font-size: 0.95rem; color: var(--muted); }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-form input {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.login-form input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.login-error {
  color: var(--bad);
  font-size: 0.88rem;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .header h1 { font-size: 1.1rem; }
  .progress-bar { width: 120px; }
}
