:root {
  color-scheme: light;
  --ink: #182025;
  --muted: #617078;
  --line: #d7dedc;
  --paper: #fbfbf8;
  --panel: #ffffff;
  --accent: #2f6f73;
  --accent-dark: #1f5054;
  --good: #276749;
  --bad: #a13b2b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(130deg, rgba(47, 111, 115, 0.13), rgba(138, 90, 43, 0.09) 46%, rgba(111, 76, 143, 0.12)),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(420px, 1.18fr);
  align-items: center;
  gap: 48px;
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0;
}

.login-art {
  display: grid;
  place-items: center;
}

.login-art img {
  width: min(100%, 560px);
  filter: drop-shadow(0 24px 36px rgba(24, 32, 37, 0.17));
}

.login-panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(215, 222, 220, 0.9);
  border-radius: 8px;
  padding: 38px;
  box-shadow: 0 24px 80px rgba(24, 32, 37, 0.12);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.3rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-panel h1 {
  margin-bottom: 28px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #34434a;
  font-weight: 700;
}

.password-row,
.gate-questions {
  display: grid;
  gap: 10px;
}

.password-row {
  grid-template-columns: auto;
  justify-content: start;
}

.gate-questions {
  margin-bottom: 16px;
}

.gate-questions label:not(:first-child) {
  margin-top: 10px;
}

input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(47, 111, 115, 0.28);
  outline-offset: 2px;
}

.password-row button,
.primary-button,
.secondary-button {
  border: 0;
  border-radius: 6px;
  padding: 12px 18px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.next-action {
  background: var(--button-accent, var(--accent));
}

.secondary-button {
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent), white 84%);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.form-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--bad);
  font-weight: 700;
}

.quiz-view {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
}

.ghost-button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  font-weight: 800;
}

.menu-button {
  display: none;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
  align-items: start;
}

.category-list,
.question-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 60px rgba(24, 32, 37, 0.08);
}

.category-list {
  padding: 10px;
}

.category-overlay {
  display: none;
}

.main-category + .main-category {
  margin-top: 8px;
}

.menu-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 12px 14px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  font-weight: 850;
}

.menu-toggle[aria-expanded="true"] {
  border-color: rgba(47, 111, 115, 0.18);
  background: rgba(47, 111, 115, 0.08);
}

.menu-toggle[aria-expanded="false"] span:last-child {
  transform: rotate(-90deg);
}

.menu-toggle span:last-child {
  transition: transform 160ms ease;
}

.menu-panel {
  padding: 8px 0 4px 12px;
}

.sub-category {
  border-left: 1px solid rgba(215, 222, 220, 0.9);
  padding-left: 8px;
}

.sub-category + .sub-category {
  margin-top: 8px;
}

.sub-toggle {
  color: #415158;
  font-size: 0.92rem;
}

.quiz-menu {
  padding-left: 8px;
}

.category-card {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 16px;
  text-align: left;
  color: var(--ink);
  background: transparent;
}

.category-card + .category-card {
  margin-top: 8px;
}

.category-card[aria-current="true"] {
  border-color: color-mix(in srgb, var(--category-accent), white 42%);
  background: color-mix(in srgb, var(--category-accent), white 88%);
}

.category-card strong {
  display: block;
  margin: 0 0 8px;
  font-size: 1rem;
}

.category-card span {
  display: block;
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.4;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeec;
}

.meter span {
  display: block;
  height: 100%;
  width: var(--progress);
  background: var(--category-accent);
}

.score-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: #415158;
  font-size: 0.88rem;
  font-weight: 750;
}

.question-panel {
  min-height: 520px;
  padding: 26px;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 22px;
}

.question-meta {
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.question-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  line-height: 1.24;
  font-weight: 850;
}

.pill {
  border-radius: 999px;
  padding: 8px 12px;
  color: #415158;
  background: #e8eeec;
  font-weight: 850;
}

.score-counter {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: #415158;
  font-size: 0.9rem;
  font-weight: 850;
}

.score-counter span {
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(215, 222, 220, 0.9);
}

.score-counter .score-right {
  color: var(--good);
  background: rgba(39, 103, 73, 0.1);
  border-color: rgba(39, 103, 73, 0.3);
}

.score-counter .score-wrong {
  color: var(--bad);
  background: rgba(161, 59, 43, 0.1);
  border-color: rgba(161, 59, 43, 0.3);
}

.complete-score {
  justify-content: center;
  margin: 14px 0 4px;
}

.quiz-timer-line {
  width: fit-content;
  margin: 0;
  border: 1px solid rgba(215, 222, 220, 0.9);
  border-radius: 999px;
  padding: 7px 10px;
  color: #415158;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
  font-weight: 850;
}

.choices {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}

.choice-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}

.choice-button:hover {
  border-color: color-mix(in srgb, var(--accent), white 28%);
}

.choice-button.correct {
  border-color: rgba(39, 103, 73, 0.55);
  background: rgba(39, 103, 73, 0.1);
}

.choice-button.incorrect {
  border-color: rgba(161, 59, 43, 0.55);
  background: rgba(161, 59, 43, 0.1);
}

.choice-button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px currentColor;
}

.feedback {
  min-height: 28px;
  display: grid;
  gap: 4px;
  border-radius: 8px;
  padding: 0;
  color: var(--muted);
  font-weight: 750;
}

.feedback.good {
  color: var(--good);
  background: rgba(39, 103, 73, 0.08);
  padding: 14px;
}

.feedback.bad {
  color: var(--bad);
  background: rgba(161, 59, 43, 0.08);
  padding: 14px;
}

.feedback span {
  color: #415158;
  font-weight: 650;
  line-height: 1.45;
}

.question-actions,
.complete-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}

.complete-actions {
  justify-content: center;
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.restart-action {
  justify-self: flex-start;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 32, 37, 0.45);
  z-index: 10;
}

.modal {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(24, 32, 37, 0.22);
}

.modal h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.empty-state,
.complete-state {
  display: grid;
  min-height: 450px;
  place-items: center;
}

.complete-state div,
.empty-state div {
  width: min(720px, 100%);
}

.empty-state {
  text-align: center;
}

.complete-state {
  text-align: left;
}

.complete-state > div {
  text-align: center;
}

.complete-state h2,
.empty-state h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 4vw, 2.7rem);
}

.complete-state p,
.empty-state p {
  color: var(--muted);
  line-height: 1.55;
}

.quiz-review {
  margin-top: 28px;
  text-align: left;
}

.quiz-review h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1.05rem;
}

.quiz-review ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.review-item.is-correct {
  border-color: rgba(39, 103, 73, 0.32);
  background: rgba(39, 103, 73, 0.07);
}

.review-item.is-wrong {
  border-color: rgba(161, 59, 43, 0.34);
  background: rgba(161, 59, 43, 0.07);
}

.review-status {
  min-height: 100%;
  border-radius: 999px;
}

.review-item.is-correct .review-status {
  background: var(--good);
}

.review-item.is-wrong .review-status {
  background: var(--bad);
}

.review-item strong,
.review-item span {
  display: block;
}

.review-item strong {
  color: var(--ink);
  line-height: 1.35;
}

.review-item span {
  margin-top: 6px;
  color: #415158;
  font-weight: 700;
  line-height: 1.35;
}

@media (max-width: 820px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-view {
    gap: 24px;
  }

  .login-art img {
    max-height: 280px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .menu-button {
    display: inline-grid;
    place-items: center;
  }

  .workspace {
    display: block;
  }

  .category-overlay {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(24, 32, 37, 0.42);
    z-index: 8;
  }

  .category-list {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(360px, 86vw);
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    z-index: 9;
    border-radius: 0;
    border-left: 0;
    border-top: 0;
    border-bottom: 0;
    box-shadow: 18px 0 60px rgba(24, 32, 37, 0.22);
  }

  .category-list.is-open {
    transform: translateX(0);
  }

  .question-panel {
    width: 100%;
  }

  .question-header {
    flex-direction: column;
  }

  .question-meta {
    justify-items: start;
  }

  .score-counter {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .password-row {
    grid-template-columns: 1fr;
  }

  .menu-panel,
  .quiz-menu {
    padding-left: 6px;
  }

  .login-panel,
  .question-panel {
    padding: 20px;
  }

  .question-actions,
  .nav-actions,
  .modal-actions {
    width: 100%;
  }

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

  .nav-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .restart-action,
  .nav-actions button,
  .modal-actions button {
    width: 100%;
  }
}
