:root {
  --bg: #f3efe4;
  --bg-deep: #e5dcc6;
  --card: rgba(255, 252, 245, 0.82);
  --card-strong: #fffaf0;
  --ink: #1f2a28;
  --muted: #5d655f;
  --line: rgba(31, 42, 40, 0.12);
  --accent: #bd4f28;
  --accent-dark: #8d3416;
  --forest: #234b44;
  --ok: #1f7a53;
  --bad: #b43d2d;
  --shadow: 0 24px 80px rgba(50, 37, 15, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(189, 79, 40, 0.18), transparent 28%),
    radial-gradient(circle at right 20%, rgba(35, 75, 68, 0.16), transparent 32%),
    linear-gradient(180deg, #f7f1e2 0%, #efe5d1 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.page-glow {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.55;
  pointer-events: none;
}

.page-glow-a {
  width: 20rem;
  height: 20rem;
  top: 7rem;
  right: 8%;
  background: rgba(189, 79, 40, 0.22);
}

.page-glow-b {
  width: 26rem;
  height: 26rem;
  bottom: 2rem;
  left: 4%;
  background: rgba(35, 75, 68, 0.16);
}

.topbar,
.shell {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 0.9rem;
  background: var(--ink);
  color: #fff;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topnav-user {
  color: var(--muted);
}

.topnav-logout {
  color: var(--accent-dark);
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto 4rem;
}

.shell-auth {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 7rem);
}

.auth-layout {
  width: 100%;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
}

.card,
.hero-card,
.auth-card {
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.hero-card,
.auth-card,
.card {
  padding: 1.6rem;
}

.hero-card h1,
.page-header h1,
.dashboard-hero h1 {
  margin: 0.3rem 0 0.9rem;
  font-family: "Newsreader", serif;
  font-size: clamp(2.4rem, 4vw, 4.4rem);
  line-height: 0.95;
  font-weight: 700;
}

.hero-copy,
.muted,
.auth-foot,
.submit-bar p {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: var(--accent-dark);
}

.hero-metrics,
.stat-grid {
  display: grid;
  gap: 1rem;
}

.hero-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 2rem;
}

.hero-metrics div,
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hero-metrics strong,
.stat-card strong,
.score-panel strong {
  font-size: 2rem;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field input {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  font: inherit;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.3rem;
  border-radius: 999px;
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.button-secondary {
  background: rgba(35, 75, 68, 0.09);
  color: var(--forest);
}

.button-danger {
  background: var(--bad);
  color: #fff;
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 1rem 1.15rem;
  border-radius: 16px;
}

.flash-error {
  background: rgba(180, 61, 45, 0.12);
  color: var(--bad);
}

.flash-success {
  background: rgba(31, 122, 83, 0.12);
  color: var(--ok);
}

.dashboard-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.2rem;
  align-items: start;
}

.stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.section-grid,
.exam-stack {
  display: grid;
  gap: 1.2rem;
  margin-top: 1.4rem;
}

.section-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-card,
.question-card {
  display: grid;
  gap: 1rem;
}

.is-hidden {
  display: none !important;
}

.section-head,
.question-meta,
.table-head,
.table-row,
.submit-bar,
.two-col {
  display: flex;
  gap: 1rem;
}

.section-head,
.question-meta,
.submit-bar {
  justify-content: space-between;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(189, 79, 40, 0.12);
  color: var(--accent-dark);
  font-size: 0.84rem;
}

.badge-contrast {
  background: rgba(35, 75, 68, 0.12);
  color: var(--forest);
}

.badge-success {
  background: rgba(31, 122, 83, 0.14);
  color: var(--ok);
}

.badge-danger {
  background: rgba(180, 61, 45, 0.14);
  color: var(--bad);
}

.two-col {
  align-items: stretch;
  margin-top: 1.4rem;
}

.two-col > * {
  flex: 1;
}

.attempt-list {
  display: grid;
  gap: 0.8rem;
}

.attempt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.58);
  border-radius: 18px;
}

.attempt-row > div:last-child {
  display: grid;
  justify-items: end;
  gap: 0.4rem;
}

.attempt-row p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.profile-list {
  display: grid;
  gap: 0.85rem;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.58);
  border-radius: 18px;
}

.profile-row p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.profile-row-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
}

.accent-card {
  background: linear-gradient(145deg, rgba(35, 75, 68, 0.92), rgba(29, 38, 36, 0.96));
  color: #f8f1e4;
}

.accent-card .eyebrow,
.accent-card p {
  color: rgba(248, 241, 228, 0.82);
}

.danger-card {
  background: linear-gradient(145deg, rgba(180, 61, 45, 0.12), rgba(141, 52, 22, 0.16));
}

.page-header {
  margin-bottom: 1.4rem;
}

.table-card {
  display: grid;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) 0.7fr 0.7fr 0.8fr 0.9fr 0.7fr auto;
  align-items: center;
  gap: 1rem;
}

.table-head {
  padding: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table-row {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.table-cell {
  min-width: 0;
}

.table-cell-title strong {
  display: block;
}

.table-action {
  justify-self: end;
}

.question-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.question-image {
  width: 100%;
  max-width: 520px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.options,
.review-list {
  display: grid;
  gap: 0.8rem;
}

.option-card,
.review-option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(31, 42, 40, 0.08);
}

.option-card input {
  margin-top: 0.15rem;
}

.option-card-correct {
  border-color: rgba(31, 122, 83, 0.35);
  background: rgba(31, 122, 83, 0.08);
}

.option-card-wrong {
  border-color: rgba(180, 61, 45, 0.35);
  background: rgba(180, 61, 45, 0.08);
}

.review-option-correct {
  border-color: rgba(31, 122, 83, 0.35);
  background: rgba(31, 122, 83, 0.08);
}

.review-option-wrong {
  border-color: rgba(180, 61, 45, 0.35);
  background: rgba(180, 61, 45, 0.08);
}

.feedback-box,
.help-box,
.score-panel,
.empty-card {
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
}

.help-box {
  margin-top: 1rem;
}

.score-panel {
  align-self: center;
}

.question-ok {
  border: 1px solid rgba(31, 122, 83, 0.2);
}

.question-ko {
  border: 1px solid rgba(180, 61, 45, 0.18);
}

.exam-mode-card,
.mode-grid,
.mode-actions,
.question-actions {
  display: grid;
  gap: 1rem;
}

.mode-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-option {
  display: grid;
  gap: 0.5rem;
  text-align: left;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  border: 1px solid rgba(16, 38, 66, 0.12);
  background: rgba(255, 255, 255, 0.66);
  color: inherit;
  cursor: pointer;
}

.mode-option.is-active {
  border-color: rgba(28, 89, 147, 0.45);
  background: rgba(28, 89, 147, 0.08);
}

.mode-option span {
  color: var(--muted);
}

.mode-actions {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.question-actions {
  grid-template-columns: repeat(2, auto);
  justify-content: start;
}

@media (max-width: 900px) {
  .auth-layout,
  .dashboard-hero,
  .section-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
  }

  .topnav {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .mode-grid,
  .mode-actions,
  .question-actions {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100% - 1rem, 1180px);
    margin-bottom: 2rem;
  }

  .hero-card,
  .auth-card,
  .card {
    padding: 1.25rem;
  }

  .section-head,
  .question-meta,
  .submit-bar,
  .attempt-row,
  .profile-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .attempt-row > div:last-child,
  .profile-row-metrics {
    width: 100%;
    justify-content: flex-start;
    justify-items: start;
  }

  .submit-bar .button,
  .attempt-row .badge {
    align-self: flex-start;
  }

  .table-head {
    display: none;
  }

  .table-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem 1rem;
    padding: 1.1rem 0;
  }

  .table-cell {
    display: grid;
    gap: 0.35rem;
  }

  .table-cell::before {
    content: attr(data-label);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .table-cell-title,
  .table-action {
    grid-column: 1 / -1;
  }

  .table-action {
    width: 100%;
    justify-self: stretch;
  }
}

@media (max-width: 640px) {
  .page-glow {
    display: none;
  }

  .topbar {
    gap: 0.85rem;
  }

  .brand {
    gap: 0.7rem;
  }

  .topnav a,
  .topnav-user {
    font-size: 0.95rem;
  }

  .hero-metrics,
  .stat-grid,
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .question-card h2 {
    font-size: 1.12rem;
  }

  .button,
  .mode-option {
    width: 100%;
  }

  .profile-row-metrics .badge {
    width: auto;
  }

  .question-actions .button {
    width: 100%;
  }

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

  .question-image {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 0.9rem 0.75rem;
  }

  .shell {
    width: calc(100% - 0.75rem);
  }

  .hero-card,
  .auth-card,
  .card {
    padding: 1rem;
    border-radius: 20px;
  }

  .hero-card h1,
  .page-header h1,
  .dashboard-hero h1 {
    font-size: clamp(2rem, 9vw, 2.8rem);
  }

  .badge {
    max-width: 100%;
    white-space: normal;
  }

  .option-card,
  .review-option,
  .feedback-box,
  .help-box,
  .score-panel,
  .empty-card {
    padding: 0.9rem;
  }
}
