/* Aligned with french.nusu.town brand tokens */
:root {
  --nus-blue: hsl(210 100% 24%);
  --nus-orange: hsl(25 100% 54%);
  --nus-light-blue: hsl(211 100% 95%);
  --accent-blue: hsl(210 79% 46%);

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: var(--nus-light-blue);
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --ink: #111827;
  --ink-2: #4b5563;
  --ink-3: #9ca3af;
  --blue: var(--nus-blue);
  --blue-soft: var(--nus-light-blue);
  --blue-ring: hsla(210, 100%, 24%, 0.22);
  --ok: #1f8a4d;
  --ok-soft: #e3f5ea;
  --no: #b3251a;
  --no-soft: #fbeae8;
  --warn: #b07b00;
  --accent: #fff4e8;
  --accent-ink: #9a3f00;
  --display: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Space Mono", "SF Mono", Menlo, Consolas, monospace;
  --r: 12px;
  --shadow: 0 10px 30px -18px rgba(0, 30, 70, 0.35);
  --shadow-sm: 0 4px 14px -8px rgba(0, 30, 70, 0.28);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--ink);
  background: linear-gradient(180deg, #f8fafc 0%, #eef4fb 100%);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--nus-blue);
}

/* ── Shell ─────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.brand-with-logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-kicker {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.15;
  color: var(--nus-blue);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.progress-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}

.progress-track {
  width: min(180px, 28vw);
  height: 8px;
  background: #e5e7eb;
  border: none;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--nus-blue);
  transition: width 0.25s ease;
}

main {
  width: min(760px, 100% - 32px);
  margin: 28px auto 80px;
}

/* ── Cards / steps ─────────────────────────────────────── */

.step {
  display: none;
}

.step.active {
  display: block;
  animation: rise 0.28s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}

.card h1,
.card h2 {
  font-family: var(--display);
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--nus-blue);
}

.card h1 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  line-height: 1.2;
}

.card h2 {
  font-size: 1.35rem;
}

.lede {
  color: var(--ink-2);
  margin: 0 0 20px;
  font-size: 15.5px;
}

/* ── Welcome (french.nusu.town style) ──────────────────── */

.welcome-card {
  text-align: left;
}

.welcome-logo-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 20px;
}

.welcome-logo {
  width: min(420px, 100%);
  height: auto;
  display: block;
}

.welcome-title {
  text-align: center;
  color: var(--nus-blue) !important;
  font-size: clamp(1.55rem, 3.2vw, 1.95rem) !important;
  margin-bottom: 10px !important;
}

.welcome-sub {
  text-align: center;
  color: var(--ink-2);
  font-size: 15.5px;
  margin: 0 auto 22px;
  max-width: 36em;
  line-height: 1.55;
}

.info-panel {
  background: var(--nus-light-blue);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 22px;
}

.info-panel-soft {
  background: #f9fafb;
  border: 1px solid var(--line);
}

.info-panel-title {
  font-size: 1rem !important;
  margin: 0 0 10px !important;
  color: var(--nus-blue) !important;
}

.info-list {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--ink-2);
  font-size: 15px;
}

.info-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.info-list li:last-child {
  margin-bottom: 0;
}

.info-list .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nus-orange);
  margin-top: 7px;
  flex-shrink: 0;
}

.choose-heading {
  margin-top: 4px !important;
}

.choose-lede {
  margin-bottom: 14px;
}

.set-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

@media (max-width: 600px) {
  .set-grid {
    grid-template-columns: 1fr;
  }
  .brand-text {
    display: none;
  }
  .card {
    padding: 22px 18px 18px;
  }
}

.set-card {
  text-align: left;
  appearance: none;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 18px 16px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.set-card:hover {
  border-color: var(--nus-blue);
  background: var(--nus-light-blue);
}

.set-card.is-selected {
  border-color: var(--nus-blue);
  background: var(--nus-light-blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
}

.set-badge {
  display: inline-flex;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--nus-blue);
  padding: 3px 10px;
  border-radius: 999px;
}

.set-badge-g {
  background: var(--nus-orange);
}

.set-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--nus-blue);
  margin-top: 4px;
}

.set-desc {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.45;
  flex: 1;
}

.set-select-label {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--nus-blue);
}

.set-card.is-selected .set-select-label {
  color: var(--nus-orange);
}

.set-card.is-selected .set-select-label::before {
  content: "✓ ";
}

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

.actions-register {
  justify-content: space-between;
}

.register-continue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* Unlabeled control next to Continue — intentionally plain */
.admin-key-input {
  width: 7.5rem;
  height: 42px;
  padding: 8px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}

.admin-key-input:focus {
  border-color: #d1d5db;
  box-shadow: none;
}

.btn-xl {
  width: 100%;
  padding: 16px 20px;
  font-size: 17px;
}

.selected-set-pill {
  display: inline-block;
  margin: 0 0 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--nus-light-blue);
  color: var(--nus-blue);
  font-size: 13px;
  font-weight: 600;
}

/* ── Forms ─────────────────────────────────────────────── */

.form-grid {
  display: grid;
  gap: 16px;
}

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

@media (max-width: 560px) {
  .form-grid.two {
    grid-template-columns: 1fr;
  }
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label.field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

label.field span em {
  font-style: normal;
  font-weight: 500;
  color: var(--ink-3);
}

input[type="text"],
input[type="email"],
input[type="tel"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

input:focus,
textarea:focus {
  box-shadow: 0 0 0 3px var(--blue-ring);
  border-color: var(--nus-blue);
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
}

.hint {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 4px;
}

.error-banner {
  display: none;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--no-soft);
  border: 1.5px solid var(--no);
  border-radius: 10px;
  color: var(--no);
  font-size: 14px;
  font-weight: 500;
}

.error-banner.show {
  display: block;
}

/* ── Buttons ───────────────────────────────────────────── */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  background: #f3f4f6;
  color: var(--ink);
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
}

.btn:hover:not(:disabled) {
  background: #e5e7eb;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--nus-blue);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #002a5c;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--nus-light-blue);
  color: var(--nus-blue);
}

/* ── Questions (discrete) ──────────────────────────────── */

.q-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.q-num {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--nus-blue);
  letter-spacing: 0.02em;
}

.q-level {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
}

.q-prompt {
  font-size: 1.12rem;
  font-weight: 600;
  margin: 0 0 18px;
  line-height: 1.4;
}

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

.choice {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.choice:hover {
  border-color: var(--nus-blue);
  background: var(--nus-light-blue);
}

.choice:has(input:checked),
.choice.selected {
  background: var(--nus-light-blue);
  border-color: var(--nus-blue);
  box-shadow: 0 0 0 2px var(--blue-ring);
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1.5px solid #d1d5db;
  background: #fff;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--nus-blue);
}

.choice.selected .choice-key {
  background: var(--nus-blue);
  border-color: var(--nus-blue);
  color: #fff;
}

.choice-text {
  padding-top: 3px;
  font-size: 15px;
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
}

/* ── Writing ───────────────────────────────────────────── */

.writing-prompt {
  background: var(--nus-light-blue);
  border: 1px solid #dbe7f8;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.writing-prompt h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: var(--nus-blue);
}

.writing-prompt ol {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  color: var(--ink-2);
  font-size: 14.5px;
}

.writing-prompt li {
  margin-bottom: 4px;
}

.starters {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff;
  border-left: 3px solid var(--nus-orange);
  font-size: 13.5px;
  color: var(--ink-2);
}

.word-count {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 6px;
}

/* ── Result ────────────────────────────────────────────── */

.result-score {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 0 8px;
}

.result-score .num {
  font-size: 3.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--nus-blue);
}

.result-score .den {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--ink-2);
}

.result-note {
  background: var(--ok-soft);
  border: 1.5px solid var(--ok);
  border-radius: 12px;
  padding: 14px 16px;
  color: #145c34;
  font-size: 14.5px;
  margin: 18px 0;
}

.result-meta {
  font-size: 14px;
  color: var(--ink-2);
}

.result-meta dt {
  font-weight: 600;
  color: var(--ink);
  margin-top: 10px;
}

.result-meta dd {
  margin: 2px 0 0;
}

.footer-note {
  margin-top: 28px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}

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

/* ── Set G continuous narrative ────────────────────────── */

.narrative-card {
  padding-bottom: 18px;
}

.story-block {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--line);
}

.story-block:last-of-type {
  border-bottom: none;
}

.story-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.story-band {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  background: var(--nus-blue);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
}

.story-range {
  font-size: 12.5px;
  color: var(--ink-3);
  font-family: var(--mono);
}

.story-text {
  font-size: 1.05rem;
  line-height: 1.75;
  margin: 0 0 16px;
  color: var(--ink);
}

.blank-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1em;
  margin: 0 2px;
  padding: 1px 7px;
  border: 1.5px solid var(--nus-blue);
  border-radius: 8px;
  background: var(--nus-light-blue);
  font-family: var(--mono);
  font-size: 0.92em;
  font-weight: 700;
  color: var(--nus-blue);
  cursor: pointer;
  vertical-align: baseline;
  line-height: 1.4;
}

.blank-chip:hover {
  background: #dbeafe;
}

.blank-chip.is-filled {
  background: var(--nus-orange);
  border-color: var(--nus-orange);
  color: #fff;
}

.blank-chip.is-focus {
  outline: 3px solid var(--blue-ring);
}

.story-options {
  display: grid;
  gap: 12px;
}

.blank-block {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px 10px;
  background: #fff;
  scroll-margin-top: 90px;
}

.blank-block.is-focus {
  border-color: var(--nus-blue);
  box-shadow: 0 0 0 2px var(--blue-ring);
}

.blank-block-title {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--ink-2);
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.blank-block-title strong {
  font-family: var(--mono);
  color: var(--nus-blue);
  font-size: 14px;
}

.blank-status {
  color: var(--ink-3);
  font-size: 12.5px;
}

.choices.compact {
  gap: 8px;
}

.choices.compact .choice {
  padding: 9px 11px;
  grid-template-columns: 30px 1fr;
  gap: 10px;
}

.choices.compact .choice-text {
  font-size: 14px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  margin-top: 8px;
  padding-top: 14px;
  background: linear-gradient(180deg, transparent, var(--surface) 28%);
  align-items: center;
  gap: 12px;
}

@media (max-width: 560px) {
  .sticky-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .sticky-actions .hint {
    order: 2;
  }
}
