:root {
  --navy: #1c2e4a;
  --navy-deep: #0f1a2b;
  --blue: #52677d;
  --baby-blue: #a9d8ff;
  --yellow: #d1cfc9;
  --ice: #bdc4d4;
  --paper: #d1cfc9;
  --white: #ffffff;
  --ink: #0f1a2b;
  --muted: #52677d;
  --line: rgba(28, 46, 74, .16);
  --shadow: 0 18px 45px rgba(28, 46, 74, .1);
  --display: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --body: "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--ice); font: 400 15px/1.55 var(--body); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button, a, input, textarea, select { touch-action: manipulation; }
a { color: inherit; }

.app-shell { width: min(1280px, calc(100% - 40px)); min-height: 100vh; margin: 28px auto; background: var(--white); box-shadow: var(--shadow); }
.app-header { min-height: 72px; padding: 12px 28px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; color: var(--white); background: var(--navy); }
.brand { width: fit-content; display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: none; display: grid; place-items: center; position: relative; overflow: hidden; background: var(--white); border-radius: 50%; }
.brand-mark img { position: absolute; height: 114%; width: auto; max-width: none; top: -7%; left: 50%; transform: translateX(-50%); }
.brand-copy { display: grid; line-height: 1; text-transform: uppercase; letter-spacing: .07em; }
.brand-copy small { font: 800 9px/1 var(--mono); }
.brand-copy strong { margin-top: 5px; color: var(--yellow); font: 800 16px/1 var(--display); }
.app-nav { display: flex; gap: 28px; }
.app-nav a { color: rgba(255,255,255,.78); text-decoration: none; font-size: 12px; font-weight: 700; }
.app-nav a[aria-current="page"], .app-nav a:hover { color: var(--white); }
.header-action { justify-self: end; padding: 9px 14px; color: var(--navy-deep); background: var(--baby-blue); border-radius: 6px; text-decoration: none; font-size: 12px; font-weight: 800; }

.app-main { padding: 70px max(34px, calc((100% - 1100px) / 2)) 90px; }
.page-intro { display: grid; grid-template-columns: 1.1fr .9fr; gap: 70px; align-items: end; margin-bottom: 48px; }
.eyebrow { margin: 0 0 14px; color: var(--blue); font: 800 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { color: var(--navy-deep); font-family: var(--display); letter-spacing: -.035em; }
h1 { max-width: 700px; margin: 0; font-size: clamp(43px, 5vw, 68px); line-height: 1.02; }
.page-intro > p { margin: 0 0 7px; color: var(--muted); font-size: 16px; }
.status-line { min-height: 22px; margin: -30px 0 30px; color: var(--blue); font: 700 11px/1.4 var(--mono); }

.panel { padding: 30px; background: var(--white); border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(9,36,84,.06); }
.panel-head { margin-bottom: 24px; display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 25px; }
.panel-head p { margin: 7px 0 0; color: var(--muted); }
.step-tag { flex: none; padding: 7px 9px; color: var(--navy); background: var(--ice); font: 800 9px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }

.project-grid { display: grid; grid-template-columns: 1fr .95fr; gap: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: var(--navy); font: 800 10px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 13px; color: var(--ink); background: #fbfcfe;
  border: 1px solid var(--line); border-radius: 4px; outline: none;
}
.field textarea { min-height: 94px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(169,216,255,.55); }
.field-help { margin: 0; color: var(--muted); font-size: 12px; }

.progress-card { color: var(--white); background: var(--navy); border: 0; box-shadow: var(--shadow); }
.progress-card h2, .progress-card h3 { color: var(--white); }
.progress-card .panel-head p { color: rgba(255,255,255,.62); }
.progress-ring { width: 154px; height: 154px; margin: 12px auto 26px; display: grid; place-items: center; position: relative; border-radius: 50%; background: conic-gradient(var(--baby-blue) var(--progress, 0%), rgba(255,255,255,.12) 0); }
.progress-ring::before { content: ""; width: 118px; height: 118px; position: absolute; border-radius: 50%; background: var(--navy); }
.progress-ring strong { position: relative; color: var(--yellow); font: 800 36px/1 var(--display); }
.progress-copy { text-align: center; color: rgba(255,255,255,.68); font-size: 13px; }
.quick-links { display: grid; gap: 9px; margin-top: 24px; }
.quick-links a { padding: 12px 14px; display: flex; justify-content: space-between; color: var(--white); background: rgba(255,255,255,.08); text-decoration: none; font-weight: 700; }
.quick-links a:hover { background: rgba(255,255,255,.14); }

.deliverables { margin-top: 22px; }
.deliverable-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.deliverable { min-height: 260px; padding: 22px; display: grid; grid-template-rows: auto auto 1fr auto; border: 1px solid var(--line); background: #fbfcfe; }
.deliverable-number { width: fit-content; padding: 4px 8px; color: var(--navy-deep); background: var(--baby-blue); font: 800 30px/1 var(--display); }
.deliverable h3 { margin: 20px 0 8px; font-size: 20px; }
.deliverable p { margin: 0; color: var(--muted); font-size: 13px; }
.check-row { margin-top: 20px; display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 800; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--baby-blue); }

.template-library { margin-top: 22px; }
.template-group { padding: 26px 0; border-top: 1px solid var(--line); }
.template-group:first-of-type { border-top: 0; }
.template-group-heading { margin-bottom: 17px; display: flex; align-items: start; gap: 14px; }
.template-group-heading > span { width: 42px; height: 42px; flex: none; display: grid; place-items: center; color: var(--navy-deep); background: var(--baby-blue); font: 800 18px/1 var(--display); }
.template-group-heading h3 { margin: 0; font-size: 21px; }
.template-group-heading p { margin: 4px 0 0; color: var(--muted); }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.template-card { min-height: 172px; padding: 20px; display: grid; grid-template-rows: auto 1fr auto; color: var(--navy); background: #fbfcfe; border: 1px solid var(--line); text-decoration: none; }
.template-card:hover, .template-card:focus-visible { border-color: var(--blue); box-shadow: inset 4px 0 var(--baby-blue); }
.template-card strong { font-size: 17px; }
.template-card span { margin-top: 8px; color: var(--muted); font-size: 13px; }
.template-card b { margin-top: 20px; color: var(--blue); font: 800 10px/1.3 var(--mono); letter-spacing: .04em; text-transform: uppercase; }

.actions { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 11px; }
.btn { min-height: 44px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; color: var(--navy); background: var(--white); border: 1px solid var(--line); border-radius: 5px; text-decoration: none; font-weight: 800; cursor: pointer; }
.btn:hover { border-color: var(--blue); transform: translateY(-1px); }
.btn.primary { color: var(--navy-deep); background: var(--baby-blue); border-color: var(--baby-blue); }
.btn.blue { color: var(--navy-deep); background: var(--baby-blue); border-color: var(--baby-blue); }
.btn.small { min-height: 36px; padding-inline: 12px; font-size: 12px; }
.btn.danger { color: #9b2c2c; }

.builder-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; align-items: start; }
.builder-sidebar { position: sticky; top: 20px; }
.quiz-template-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.template-choice { min-height: 112px; padding: 16px; display: grid; align-content: start; gap: 8px; text-align: left; color: var(--navy); background: #fbfcfe; border: 1px solid var(--line); cursor: pointer; }
.template-choice:hover, .template-choice:focus-visible { border-color: var(--blue); box-shadow: inset 4px 0 var(--baby-blue); }
.template-choice strong { font-size: 15px; }
.template-choice span { color: var(--muted); font-size: 12px; }
.mini-summary { padding: 24px; color: var(--white); background: var(--navy); }
.mini-summary h2 { margin: 0; color: var(--white); font-size: 22px; }
.summary-list { margin: 22px 0 0; padding: 0; list-style: none; }
.summary-list li { padding: 12px 0; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid rgba(255,255,255,.14); color: rgba(255,255,255,.68); font-size: 13px; }
.summary-list strong { color: var(--yellow); }
.local-gallery { margin-top: 14px; padding: 19px; background: #f4f7fb; border: 1px solid var(--line); }
.local-gallery-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.local-gallery-head h2 { margin: 0; font-size: 19px; }
.local-gallery-head span { color: var(--muted); font: 800 9px/1 var(--mono); text-transform: uppercase; }
#quiz-gallery { display: grid; gap: 8px; margin-top: 14px; }
.gallery-empty { margin: 0; color: var(--muted); font-size: 12px; }
.gallery-item { padding: 12px; background: var(--white); border: 1px solid var(--line); }
.gallery-item strong { display: block; color: var(--navy); font-size: 13px; }
.gallery-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.gallery-item-actions { margin-top: 9px; display: flex; gap: 7px; }
.gallery-item-actions button { min-height: 44px; flex: 1; color: var(--navy); background: var(--white); border: 1px solid var(--line); font-weight: 800; cursor: pointer; }
.question-list { display: grid; gap: 16px; margin-top: 20px; }
.question-card { padding: 24px; border: 1px solid var(--line); background: #fbfcfe; }
.question-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.question-head h3 { margin: 0; font-size: 20px; }
.question-tools { display: flex; gap: 7px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--navy); background: var(--white); border: 1px solid var(--line); cursor: pointer; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.choices { margin-top: 16px; display: grid; gap: 10px; }
.choice-row { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 9px; }
.choice-row input[type="radio"] { width: 18px; height: 18px; accent-color: var(--baby-blue); }
.choice-row input[type="text"] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: var(--white); }

.preview { margin-top: 20px; padding: 28px; color: var(--quiz-ink, var(--ink)); background: var(--quiz-surface, #f4f7fb); border-top: 5px solid var(--quiz-accent, var(--baby-blue)); }
.preview[hidden] { display: none; }
.preview h2 { margin: 0; font-size: 30px; }
.preview-question { margin: 25px 0 16px; font: 800 24px/1.2 inherit; color: var(--quiz-ink, var(--navy)); }
.preview-options { display: grid; gap: 9px; }
.preview-option { padding: 13px 15px; text-align: left; color: var(--quiz-ink, var(--navy)); background: var(--quiz-surface, var(--white)); border: 1px solid var(--line); cursor: pointer; font: inherit; }
.preview-option.selected { border-color: var(--quiz-header, var(--navy)); box-shadow: inset 4px 0 var(--quiz-accent, var(--baby-blue)); }
.preview-result { margin-top: 22px; padding: 18px; color: var(--white); background: var(--quiz-header, var(--navy)); }
.preview-result strong { color: var(--quiz-accent, var(--yellow)); }
.empty-note { padding: 24px; color: var(--muted); text-align: center; border: 1px dashed var(--line); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; padding: 13px 17px; color: var(--white); background: var(--navy-deep); box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: none; opacity: 1; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

@media (max-width: 930px) {
  input, textarea, select { font-size: 16px; }
  .app-header { grid-template-columns: 1fr auto; }
  .app-nav { display: none; }
  .page-intro, .project-grid { grid-template-columns: 1fr; gap: 28px; }
  .deliverable-grid { grid-template-columns: repeat(2, 1fr); }
  .template-grid { grid-template-columns: 1fr; }
  .builder-layout { grid-template-columns: 1fr; }
  .builder-sidebar { position: static; order: -1; }
  .quiz-template-picker { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { width: 100%; margin: 0; }
  .app-header { padding: 11px 17px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-copy small { font-size: 8px; }
  .brand-copy strong { font-size: 13px; }
  .header-action { padding: 8px 10px; font-size: 10px; }
  .app-main { padding: 56px 18px 72px; }
  h1 { font-size: 42px; }
  .page-intro { margin-bottom: 40px; }
  .form-grid, .deliverable-grid { grid-template-columns: 1fr; }
  .panel { padding: 22px 18px; }
  .deliverable { min-height: 230px; }
  .actions .btn { width: 100%; }
  .question-head { align-items: start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
