:root {
  --navy: #102a68;
  --blue: #1769e8;
  --blue-dark: #0f54c9;
  --ink: #17223b;
  --muted: #65708b;
  --line: #dce3ee;
  --soft: #f4f7fb;
  --paper: #fffdf7;
  --coral: #ff654f;
  --ok: #0f7a4a;
  --shadow: 0 18px 50px rgba(16, 42, 104, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f7f9fd 0%, #eef2f8 48%, #f7f9fd 100%);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; }
a { color: var(--blue); }
h1, h2, h3 { font-family: "Manrope", sans-serif; color: var(--navy); letter-spacing: -0.03em; }
h1 { font-size: clamp(1.7rem, 3vw, 2.35rem); margin: 0 0 0.4em; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.8rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 4;
}
.header-inner, main {
  width: min(760px, calc(100vw - 32px));
  margin-left: auto;
  margin-right: auto;
}
.header-inner.wide, main.wide { width: min(1080px, calc(100vw - 32px)); }
.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: var(--navy);
}
.brand img { width: 104px; height: auto; display: block; }
.brand-rule {
  width: 1px;
  height: 22px;
  background: var(--line);
  flex: none;
}
.brand-product {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.site-nav { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.nav-email { color: var(--muted); }
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 18px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.site-footer p { margin: 0; }
main { padding: 28px 0 64px; flex: 1; }
body.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.home main {
  flex: 1;
  padding: 72px 0 64px;
}
.home-panel { max-width: 34rem; }
.home-panel h1 { margin-bottom: 0.55em; }
.home-panel .lede { margin: 0 0 1.35rem; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 700;
}
.lede { font-size: 1.05rem; line-height: 1.55; color: #31405f; max-width: 42rem; }
.muted { color: var(--muted); }
.hero-card, .paper-head, .card-form, .score-sheet {
  background: var(--paper);
  border: 1px solid #ece6d6;
  box-shadow: var(--shadow);
  padding: 28px 28px 32px;
}
.hero-card { margin-top: 24px; }
.paper-head { margin-bottom: 18px; border-top: 6px solid var(--navy); }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  margin: 18px 0 0;
}
.meta-row dt { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.meta-row dd { margin: 4px 0 0; font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 600; color: var(--navy); }

.flash { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; }
.flash.error { background: #fff1ee; color: #9b2214; }
.flash.ok { background: #eaf7ef; color: var(--ok); }
.notice { background: #eef4ff; border-left: 4px solid var(--blue); padding: 14px 16px; }

.field { margin: 0 0 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; color: #4c5b79; }
.course-combo { position: relative; }
.course-menu {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 280px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(16, 42, 104, 0.12);
}
.course-option {
  display: block;
  width: 100%;
  text-align: left;
  background: white;
  border: 0;
  border-bottom: 1px solid var(--soft);
  border-radius: 0;
  padding: 10px 14px;
  color: var(--navy);
  font-weight: 500;
}
.course-option:hover, .course-option[aria-selected="true"] { background: var(--soft); }
.course-empty { margin: 0; padding: 10px 14px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 232, 0.14);
}
.otp-input { font-family: "IBM Plex Mono", ui-monospace, monospace; letter-spacing: 0.4em; font-size: 1.3rem; text-align: center; }
.primary, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: white;
  text-decoration: none;
  font-weight: 700;
}
.primary:hover, .button-link:hover { background: var(--blue-dark); }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
@keyframes spin { to { transform: rotate(360deg); } }
button.is-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}
button.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.05em;
  height: 1.05em;
  margin: -0.525em 0 0 -0.525em;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.text-button.is-loading::after {
  border-color: rgba(16, 42, 104, 0.2);
  border-top-color: var(--navy);
}
.text-button.danger.is-loading::after {
  border-color: rgba(255, 101, 79, 0.25);
  border-top-color: var(--coral);
}
.text-button { background: none; border: 0; color: var(--blue); padding: 0; font-weight: 600; }
.text-button.danger { color: var(--coral); }
.inline-form { display: inline; }
.check, .radio-inline { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; }
.check input, .radio-inline input { width: auto; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 20px; }
.table-wrap { overflow: auto; background: white; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--soft); }
.cell-muted { color: var(--muted); font-size: 12px; margin-top: 4px; }
.empty { color: var(--muted); text-align: center; }

.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--soft);
  color: var(--navy);
}
.chip.pass, .status-live { background: #e5f6ec; color: var(--ok); }
.chip.fail, .status-closed { background: #ffe8e3; color: #9b2214; }
.status-draft { background: #eef2f8; }

.exam-sheet { display: grid; gap: 16px; }
.question-block {
  background: var(--paper);
  border: 1px solid #ece6d6;
  padding: 0;
  overflow: hidden;
}
.question-block header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border-bottom: 1px dashed #e2dccb;
}
.q-index {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  color: var(--navy);
  background: #efe8d4;
  padding: 6px 8px;
  min-width: 2.4rem;
  text-align: center;
}
.q-points { font-size: 12px; color: var(--muted); white-space: nowrap; }
.option-list { display: grid; }
.option-row {
  display: grid;
  grid-template-columns: 20px 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid #f0eadc;
  cursor: pointer;
}
.option-row.readonly { grid-template-columns: 36px 1fr; cursor: default; }
.option-row:hover:not(.readonly) { background: #f8f4e8; }
.option-row input { width: auto; }
.option-letter {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  color: var(--navy);
}
.option-row.is-correct { background: #e9f7ee; }
.option-row.is-wrong { background: #ffece8; }
.submit-bar, .take-head { display: flex; justify-content: space-between; gap: 12px; align-items: end; flex-wrap: wrap; }
.timer { font-family: "IBM Plex Mono", ui-monospace, monospace; color: var(--navy); margin: 0; }
.score-figure { font-family: "Manrope", sans-serif; font-size: clamp(3rem, 8vw, 5rem); font-weight: 800; color: var(--navy); margin: 8px 0; line-height: 1; }
.score-figure span { font-size: 0.4em; color: var(--muted); }
.score-percent { font-size: 1.2rem; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.status-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.builder-question { background: white; border: 1px solid var(--line); padding: 14px 16px; margin-bottom: 10px; }
.plain-options { margin: 8px 0 0; padding-left: 18px; }
.plain-options .correct { font-weight: 700; color: var(--ok); }
.option-edit { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 8px 0 24px; }
.stat-row div { background: white; border: 1px solid var(--line); padding: 16px; color: var(--muted); }
.stat-row span { display: block; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 1.6rem; color: var(--navy); margin-bottom: 4px; }

@media (max-width: 720px) {
  .grid-3, .stat-row { grid-template-columns: 1fr 1fr; }
  .question-block header { grid-template-columns: auto 1fr; }
  .q-points { grid-column: 2; }
  .toolbar { flex-direction: column; align-items: start; }
}

@media print {
  body { background: white; }
  .no-print, .site-header, .site-footer { display: none !important; }
  .question-block, .score-sheet, .paper-head { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
