:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #183348;
  background: #f4f7fa;
  --ink: #183348;
  --muted: #64798a;
  --line: #dce6ed;
  --surface: #ffffff;
  --primary: #176d84;
  --primary-strong: #125a71;
  --teal: #15917f;
  --success: #14805f;
  --success-soft: #e9f7f1;
  --danger: #bb3d45;
  --danger-soft: #fff0f1;
  --warning: #a86d1f;
  --shadow: 0 16px 50px rgba(28, 63, 84, 0.09);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 92% 5%, rgba(30, 161, 143, 0.1), transparent 27rem),
    linear-gradient(180deg, #f8fafc 0, #f2f6f9 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  border-bottom: 1px solid rgba(210, 224, 233, 0.86);
  background: rgba(250, 252, 253, 0.9);
  backdrop-filter: blur(16px);
}

.header-inner {
  display: flex;
  width: min(1120px, calc(100% - 36px));
  min-height: 72px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(145deg, #176b85, #1ca18c);
  box-shadow: 0 8px 18px rgba(23, 107, 133, 0.2);
  font: 800 21px/1 Georgia, serif;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.database-status {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.database-status.ready { color: var(--success); }
.database-status.error { color: var(--danger); }

.page-shell {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.loading-card {
  width: min(520px, 100%);
  margin: 14vh auto 0;
  padding: 45px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.loading-card h1 { margin: 20px 0 8px; font-size: 25px; }
.loading-card p { margin: 0; color: var(--muted); }

.loader {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 4px solid #dbe9ee;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.95fr);
  gap: 22px;
  margin-bottom: 22px;
}

.hero-card {
  min-height: 230px;
  padding: 34px;
  overflow: hidden;
  border-radius: 25px;
  color: white;
  background:
    radial-gradient(circle at 95% 10%, rgba(151, 242, 215, 0.24), transparent 13rem),
    linear-gradient(135deg, #155e77, #137f79);
  box-shadow: 0 18px 45px rgba(18, 93, 113, 0.18);
}

.eyebrow {
  margin: 0 0 8px;
  color: #6f8291;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-card .eyebrow { color: #b9ebe2; }
.hero-card h1 { max-width: 550px; margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.08; }
.hero-card > p:not(.eyebrow) { max-width: 620px; margin: 18px 0 22px; color: #dceff0; line-height: 1.58; }

.privacy-chip {
  display: inline-flex;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #e8f7f4;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-card {
  display: flex;
  min-height: 108px;
  padding: 18px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 24px rgba(28, 63, 84, 0.05);
}

.summary-card span { color: var(--muted); font-size: 12px; }
.summary-card strong { color: var(--primary); font-size: 27px; }
.summary-card.accent { border-color: #b9e5dc; background: #edf9f5; }
.summary-card.accent strong { color: var(--success); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.7fr);
  gap: 22px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.setup-panel, .info-panel { padding: 28px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 23px; }
.panel-heading h2, .info-panel h2 { margin: 0; font-size: 22px; }
.count-badge { padding: 7px 10px; border-radius: 999px; color: var(--primary); background: #eaf3f7; font-size: 12px; font-weight: 800; white-space: nowrap; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { color: #496174; font-size: 12px; font-weight: 700; }
.full-width { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }

select, input[type="search"] {
  width: 100%;
  min-height: 45px;
  border: 1px solid #cfdee7;
  border-radius: 11px;
  padding: 9px 12px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

select:focus, input[type="search"]:focus { border-color: #5ca8b4; box-shadow: 0 0 0 3px rgba(42, 142, 154, 0.11); }

.toggle-list { display: grid; gap: 9px; margin: 20px 0; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer; border: 1px solid #e1e9ee; border-radius: 13px; background: #fafcfd; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row > span:last-child { min-width: 0; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.toggle {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #bbc9d2;
  transition: 0.2s ease;
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: 0.2s ease;
  content: "";
}

.toggle-row input:checked + .toggle { background: var(--teal); }
.toggle-row input:checked + .toggle::after { transform: translateX(16px); }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 11px;
  padding: 10px 18px;
  font-weight: 800;
}

.button.primary { color: white; background: linear-gradient(135deg, var(--primary), var(--teal)); box-shadow: 0 8px 18px rgba(23, 109, 132, 0.18); }
.button.primary:hover { filter: brightness(1.04); }
.button.primary:disabled { cursor: not-allowed; opacity: 0.5; box-shadow: none; }
.button.secondary { color: var(--primary); border: 1px solid #bdd3dd; background: #eff6f8; }
.button.large { width: 100%; min-height: 49px; }
.text-button { border: 0; padding: 6px 0; color: var(--primary); background: transparent; font-weight: 700; }
.text-button.danger { margin-top: 18px; color: var(--danger); font-size: 12px; }

.form-message { padding: 10px 12px; border-radius: 9px; color: var(--danger); background: var(--danger-soft); font-size: 12px; }
.database-facts { margin: 20px 0; }
.database-facts div { display: flex; padding: 11px 0; justify-content: space-between; gap: 18px; border-bottom: 1px solid #edf1f4; }
.database-facts dt { color: var(--muted); font-size: 12px; }
.database-facts dd { margin: 0; color: var(--primary); font-weight: 800; }
.info-panel hr { height: 1px; margin: 22px 0; border: 0; background: var(--line); }
.info-panel h3 { margin: 0 0 12px; font-size: 14px; }
.shortcut-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.shortcut-list li { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.shortcut-list li span { margin-left: 5px; }
kbd { min-width: 23px; padding: 3px 6px; text-align: center; border: 1px solid #cedbe3; border-bottom-width: 2px; border-radius: 5px; color: var(--ink); background: #fff; font: 700 11px/1.2 inherit; }

.quiz-view { width: min(900px, 100%); margin: 0 auto; }
.session-topbar { margin-bottom: 18px; }
.session-progress-copy { display: flex; margin: 13px 0 8px; align-items: center; justify-content: space-between; gap: 20px; }
.session-progress-copy strong { font-size: 14px; }
.session-progress-copy span { color: var(--muted); font-size: 12px; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #dfe9ee; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #25a78c); transition: width 0.3s ease; }

.question-card { padding: clamp(24px, 5vw, 48px); border: 1px solid var(--line); border-radius: 25px; background: rgba(255, 255, 255, 0.96); box-shadow: var(--shadow); }
.question-meta { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.type-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 7px; color: #15715f; background: #e5f5ef; font-size: 11px; font-weight: 800; }
.topic-copy { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.question-card h1 { margin: 0; font-size: clamp(22px, 3vw, 30px); line-height: 1.3; }
.answer-hint { margin: 12px 0 24px; color: var(--muted); font-size: 13px; }
.answers-list { display: grid; gap: 11px; }

.answer-option {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  min-height: 58px;
  padding: 13px 16px;
  align-items: center;
  cursor: pointer;
  border: 1px solid #d8e3e9;
  border-radius: 13px;
  background: #fbfcfd;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.answer-option:hover { transform: translateY(-1px); border-color: #98bfca; background: #f6fafb; }
.answer-option:has(input:checked) { border-color: #4d9dac; background: #edf7f8; box-shadow: 0 0 0 2px rgba(48, 142, 154, 0.08); }
.answer-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--teal); }
.answer-number { color: #6e8492; font-size: 11px; font-weight: 800; }
.answer-copy { display: flex; align-items: center; gap: 10px; line-height: 1.43; }
.answer-copy span:last-child { flex: 1; }
.answer-option.correct,
.answer-option.correct:has(input:checked) { border-color: #72bea5; background: var(--success-soft); }
.answer-option.incorrect,
.answer-option.incorrect:has(input:checked) { border-color: #df8a90; background: var(--danger-soft); }
.answer-option.locked { cursor: default; transform: none; }

.feedback { margin-top: 18px; padding: 13px 15px; border-radius: 11px; font-size: 13px; font-weight: 700; }
.feedback.success { color: var(--success); background: var(--success-soft); }
.feedback.error { color: var(--danger); background: var(--danger-soft); }
.question-actions { display: flex; gap: 10px; margin-top: 22px; }
.question-actions .button { min-width: 180px; }

.results-hero { display: grid; grid-template-columns: auto 1fr; gap: 30px; padding: 34px; align-items: center; }
.results-hero h1 { margin: 0; font-size: 30px; }
.results-hero p:not(.eyebrow) { margin: 10px 0 18px; color: var(--muted); line-height: 1.5; }
.result-ring { display: grid; width: 125px; height: 125px; place-items: center; border-radius: 50%; background: conic-gradient(var(--teal) 0%, #dfe9ec 0); }
.result-ring::before { grid-area: 1 / 1; width: 91px; height: 91px; border-radius: 50%; background: white; content: ""; }
.result-ring strong { z-index: 1; grid-area: 1 / 1; color: var(--primary); font-size: 25px; }
.result-actions { display: flex; gap: 10px; }
.review-panel { margin-top: 20px; padding: 28px; }
.review-list { display: grid; gap: 10px; }
.review-item { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfd; }
.review-item summary { padding: 14px 16px; cursor: pointer; font-weight: 700; line-height: 1.4; }
.review-body { padding: 0 16px 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.review-body p { margin: 8px 0; }
.review-body strong { color: var(--ink); }
.empty-review { padding: 28px; text-align: center; border-radius: 14px; color: var(--success); background: var(--success-soft); font-weight: 700; }

@media (max-width: 820px) {
  .hero-grid, .content-grid { grid-template-columns: 1fr; }
  .hero-card { min-height: auto; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .summary-card { min-height: 95px; }
}

@media (max-width: 620px) {
  .header-inner, .page-shell { width: min(100% - 24px, 1120px); }
  .database-status { display: none; }
  .page-shell { padding-top: 24px; }
  .summary-grid, .field-row { grid-template-columns: 1fr 1fr; }
  .summary-card { min-height: 92px; padding: 14px; }
  .summary-card strong { font-size: 22px; }
  .setup-panel, .info-panel, .review-panel { padding: 20px; }
  .question-card { padding: 22px 17px; }
  .question-meta { align-items: flex-start; flex-direction: column; }
  .topic-copy { max-width: 100%; white-space: normal; }
  .question-actions, .result-actions { flex-direction: column; }
  .question-actions .button { width: 100%; }
  .results-hero { grid-template-columns: 1fr; text-align: center; }
  .result-ring { margin: 0 auto; }
}
