:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #6b7280;
  --line: #d7dee8;
  --paper: #ffffff;
  --bg: #eef4f8;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #12824a;
  --red: #c2410c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,.78), rgba(255,255,255,.28) 42%, rgba(255,255,255,.7)),
    radial-gradient(circle at top left, rgba(37, 99, 235, .10), transparent 34%),
    var(--bg);
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.panel {
  background: rgba(255, 255, 255, .86);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(28, 42, 64, .12);
}

.narrow { max-width: 440px; margin: 12vh auto 0; }

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1; }
h2 { font-size: 24px; margin-bottom: 18px; }
.stack { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  background: #fff;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-weight: 800;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(22, 32, 51, .12);
}

.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.primary:hover { background: var(--blue-dark); }

.loadingToast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(215, 222, 232, .95);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 14px 34px rgba(28, 42, 64, .16);
  font-weight: 900;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #dbe6f2;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  flex: 0 0 auto;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.topbar > div {
  display: grid;
  gap: 5px;
}

.topbar nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar nav button {
  background: rgba(255, 255, 255, .72);
  border-color: rgba(215, 222, 232, .9);
}

.tab.active {
  border-color: rgba(37, 99, 235, .35);
  color: var(--blue);
  background: #fff;
}

.profileButton {
  color: var(--blue);
  background: #edf5ff;
  border-color: rgba(37, 99, 235, .22);
  cursor: default;
}

.profileButton:disabled {
  opacity: 1;
}

.profileButton.isAdmin {
  cursor: pointer;
}

.profileButton:hover {
  transform: none;
  box-shadow: none;
}

.profileButton.isAdmin:hover {
  background: #fff;
  box-shadow: 0 8px 18px rgba(22, 32, 51, .12);
}

#quizView {
  padding: 0;
  overflow: hidden;
}

.questionLayout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
  min-height: min(680px, calc(100vh - 140px));
}

.imageBox {
  position: relative;
  min-height: 420px;
  background: #fff;
  overflow: hidden;
}

.imageBox img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  display: block;
}

.imageBox img.loading {
  opacity: 0;
}

.imageLoading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.imageLoading .spinner {
  width: 30px;
  height: 30px;
}

.quizPanel {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(22px, 4vw, 44px);
}

.prompt {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
  font-weight: 900;
}

.choices {
  display: grid;
  gap: 12px;
}

.choice {
  min-height: 72px;
  justify-content: flex-start;
  padding: 0 22px;
  font-size: clamp(22px, 3vw, 34px);
  text-align: left;
  background: #fff;
  border: 2px solid transparent;
  box-shadow: 0 10px 24px rgba(28, 42, 64, .10);
}

.choice.correct {
  border-color: rgba(18, 130, 74, .42);
  color: var(--green);
  background: #eefaf3;
}

.choice.wrong {
  border-color: rgba(194, 65, 12, .42);
  color: var(--red);
  background: #fff4ed;
}

.feedback {
  min-height: 34px;
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.feedback.ok { color: var(--green); }
.feedback.no { color: var(--red); }
#nextBtn { width: min(220px, 100%); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.rows {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.row, .summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.row strong { display: block; }
.row span { color: var(--muted); }
.error { color: var(--red); min-height: 22px; margin: 0; }
.message { color: var(--muted); min-height: 22px; margin: 0; }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 16px, 1180px);
    padding: 10px 0 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar nav {
    justify-content: stretch;
  }

  .topbar nav button {
    flex: 1 1 auto;
  }

  .questionLayout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .imageBox {
    min-height: 44vh;
  }

  .quizPanel {
    padding: 18px;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
