/*
 * MCQ Form Builder. Direction: exact, calm, schoolroom-practical; the world of exam papers and
 * answer keys. Quiet neutral chrome; the one rich moment is the question card with its ticked
 * answer. Signature: the blue answer-key tick, used only for "correct" and "done".
 * Design tokens follow the MCQ Form Builder artifact. Spacing on a 4px grid.
 * UI pass informed by unslop by Damir Sokolovsky (@heydamir), CC BY 4.0.
 */
:root {
  --ground: #f8f8f7;
  --paper: #fffffd;
  --card: #f0f0ee;
  --raised: #f4f4f2;
  --line: rgba(15, 16, 13, 0.09);
  --line-strong: rgba(15, 16, 13, 0.16);
  --ink: #141512;
  --ink-2: #55564f;
  --ink-3: #7a7b74;
  --blue: #3a6fdc;
  --blue-ink: #2b58b8;
  --blue-soft: #e9effc;
  --warn: #e0691a;
  --warn-ink: #8a3d06;
  --warn-soft: #fbefe5;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --sans: "Inter", "Noto Sans Devanagari", -apple-system, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-sm: 6px;
  --r: 8px;
  --r-card: 12px;
  --r-panel: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 400 14px/20px var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue-ink); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.muted { color: var(--ink-3); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font: 400 12px/16px var(--mono); color: var(--ink-2); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* Header */
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1240px; margin: 0 auto; height: 56px; display: flex; align-items: center; gap: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (min-width: 720px) { .top-inner { padding-left: 32px; padding-right: 32px; } }
.brand { display: flex; align-items: center; gap: 8px; font: 500 15px/20px var(--sans); color: var(--ink); text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: var(--r); color: var(--ink-2); text-decoration: none; font-weight: 500; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.nav a:hover { background: var(--raised); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--card); color: var(--ink); }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--ink-3); font-size: 13px; }
.account #account { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.account img { width: 24px; height: 24px; border-radius: 50%; flex: none; }
.nav a, .account .text-btn { white-space: nowrap; }
@media (max-width: 720px) {
  .top-inner { gap: 8px; }
  .brand { font-size: 0; gap: 0; }
  .nav { gap: 0; }
  .nav a { padding: 6px 8px; }
  .account { gap: 8px; }
  .account #account, .account img { display: none; }
}

/* Page */
.page { max-width: 1240px; margin: 0 auto; padding-block: 32px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 24px; }
@media (min-width: 720px) { .page { padding-left: 32px; padding-right: 32px; } }
.page.narrow { max-width: 816px; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between; min-height: 40px; }
.page-title { margin: 0; font: 500 32px/36px var(--serif); letter-spacing: -0.01em; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px; border: 0; border-radius: var(--r); font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color 150ms var(--ease), transform 120ms var(--ease); }
.btn:active:not([disabled]) { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #2a2b27; }
.btn-secondary { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-secondary:hover { background: var(--raised); }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.text-btn { background: none; border: 0; padding: 4px 0; color: var(--ink-2); font-weight: 500; font-size: 13px; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.text-btn:hover { color: var(--ink); }
.text-btn.danger:hover { color: var(--warn-ink); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: var(--r); background: none; color: var(--ink-3); cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.icon-btn:hover { background: var(--raised); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .stat-label { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.field input, .field textarea, .input { width: 100%; height: 36px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--paper); padding: 0 12px; color: var(--ink); }
.field textarea { height: auto; padding: 8px 12px; resize: vertical; }
.field.small input { width: 96px; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.more summary { cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 4px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+"; width: 12px; color: var(--ink-3); }
.more[open] summary::before { content: "–"; }
.more[open] { display: flex; flex-direction: column; gap: 12px; }

/* Status */
.status { font-size: 13px; color: var(--ink-2); }
.status.error { color: var(--warn-ink); }
.warn-line { font-size: 13px; color: var(--warn-ink); background: var(--warn-soft); border-radius: var(--r); padding: 8px 12px; }
.note { font-size: 13px; color: var(--warn-ink); }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-3); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--r-sm); background: var(--card); color: var(--ink-2); font-size: 12px; line-height: 16px; white-space: nowrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); border-radius: var(--r); padding: 8px 16px; font-weight: 500; box-shadow: var(--shadow-float); z-index: 20; max-width: calc(100% - 32px); }

/* Tabs */
.tabs { display: inline-flex; gap: 4px; background: var(--card); border-radius: var(--r); padding: 4px; align-self: flex-start; }
.tab { border: 0; background: none; border-radius: var(--r-sm); padding: 4px 12px; color: var(--ink-2); font-weight: 500; cursor: pointer; font-variant-numeric: tabular-nums; transition: background-color 150ms var(--ease); }
.tab[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }

/* Start screen */
.workspace { display: flex; flex-direction: column; gap: 24px; }
.paper .page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Builder */
.paper { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-chip { font: 400 13px/20px var(--mono); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36ch; }
.example-tag { padding: 2px 8px; border-radius: var(--r-sm); background: var(--blue-soft); color: var(--blue-ink); font-size: 12px; line-height: 16px; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
@media (max-width: 960px) { .builder { grid-template-columns: minmax(0, 1fr); } }
.builder-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.builder-side { position: sticky; top: 24px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 960px) { .builder-side { position: static; } }
.side-foot { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-panel); background: var(--paper); text-align: center; transition: border-color 150ms var(--ease), background-color 150ms var(--ease); }
.drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop-title { font: 500 15px/20px var(--sans); }
.drop .row { margin-top: 8px; justify-content: center; }
.paste { display: flex; flex-direction: column; gap: 8px; }
.paste textarea { width: 100%; min-height: 200px; resize: vertical; border: 1px solid var(--line-strong); border-radius: var(--r-card); background: var(--paper); padding: 12px; font: 400 13px/20px var(--mono); }
.review { display: flex; flex-direction: column; gap: 12px; }
.review-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Question cards (the moment) */
.qscroll { height: clamp(360px, calc(100vh - 240px), 760px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.qscroll.small { height: auto; max-height: 420px; background: var(--ground); }
.sec-row { padding: 12px 8px 4px; }
.sec-row h3 { margin: 0; font: 500 18px/24px var(--serif); }
.sec-row p { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }
.q { background: var(--card); border-radius: var(--r-card); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
/* Cards outside the scroll box skip layout and paint until scrolled near. */
.qscroll > .q { content-visibility: auto; contain-intrinsic-size: auto 200px; }
.q.flagged { box-shadow: inset 0 0 0 1px rgba(224, 105, 26, 0.35); }
.q-head { display: flex; align-items: center; gap: 8px; }
.q-head .spacer { flex: 1; }
.q-num { min-width: 24px; height: 24px; padding: 0 6px; border-radius: var(--r-sm); background: var(--paper); display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.q-text { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.q-word { margin: 0; font-size: 13px; color: var(--ink-3); }
.q-word b { font-weight: 500; color: var(--ink-2); text-decoration: underline; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
@media (max-width: 560px) { .opts { grid-template-columns: minmax(0, 1fr); } }
.opt { display: flex; align-items: center; gap: 8px; min-width: 0; text-align: left; background: var(--paper); border: 0; border-radius: var(--r); padding: 6px 8px; box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; transition: box-shadow 150ms var(--ease); }
.opt:hover:not(.static) { box-shadow: inset 0 0 0 1px var(--line-strong); }
.opt.static { cursor: default; }
.lbl { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--raised); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.otext { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tick { flex: none; width: 18px; height: 18px; opacity: 0; }
.tick circle { fill: var(--blue); }
.tick path { fill: none; stroke: var(--paper); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.opt.is-correct { box-shadow: inset 0 0 0 2px var(--blue); }
.opt.is-correct .lbl { background: var(--blue); color: var(--paper); }
.opt.is-correct .tick { opacity: 1; }
.opt.is-alt { box-shadow: inset 0 0 0 1px var(--warn); }
.q-foot { display: flex; align-items: center; gap: 16px; }
.q-foot .btn { height: 32px; }
.edit-field { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--paper); padding: 6px 8px; }
textarea.edit-field { min-height: 64px; resize: vertical; font-weight: 500; }
.edit-opt { display: flex; align-items: center; gap: 8px; }

/* Made form: the two links */
.made { display: flex; flex-direction: column; gap: 4px; }
.made-head { display: flex; align-items: center; gap: 8px; font-weight: 500; padding-bottom: 4px; }
.made-head .tick { opacity: 1; }
.link-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.link-row .link-url { margin-right: 4px; }
.link-label { flex: none; width: 64px; font-size: 12px; color: var(--ink-3); }
.link-url { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 13px/20px var(--mono); color: var(--blue-ink); }
code.link-url { color: var(--ink); }

/* Forms */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 160px)); gap: 12px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font: 500 28px/32px var(--sans); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stat b { font-size: 22px; line-height: 28px; } }
.form-list { display: flex; flex-direction: column; gap: 8px; }
.form-row { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.form-row.failed { border-color: rgba(224, 105, 26, 0.35); }
.form-head { display: flex; align-items: flex-start; gap: 12px; width: 100%; }
.form-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.form-title h3 { margin: 0; font: 500 15px/20px var(--sans); overflow-wrap: anywhere; }
.links { display: flex; flex-direction: column; gap: 0; width: 100%; max-width: 560px; }
.form-row .qscroll { width: 100%; }

/* Connectors */
.section { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.section h2 { margin: 0; font: 500 15px/20px var(--sans); }
.hint { margin: 0; color: var(--ink-3); font-size: 13px; }
.hint b { color: var(--ink-2); font-weight: 500; }
.rows { display: flex; flex-direction: column; }
.item-row { display: flex; align-items: center; gap: 12px; min-height: 40px; border-top: 1px solid var(--line); }
.secret { display: flex; flex-direction: column; gap: 4px; background: var(--blue-soft); border-radius: var(--r); padding: 8px 12px; }
.code { margin: 8px 0 0; overflow-x: auto; background: var(--ground); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; font: 400 12px/18px var(--mono); white-space: pre; }

.consent { gap: 20px; }
.grants { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.grants li { display: flex; align-items: center; gap: 8px; }
.grants li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); flex: none; }

/* Hero: sign-in and the empty home screen. The visual is the page's one rich moment. */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 540px); gap: 64px; align-items: center; min-height: calc(100vh - 57px - 96px); }
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; min-width: 0; }
.hero-copy > .drop, .hero-copy > .paste, .hero-copy > .status { width: 100%; }
.hero-title { margin: 0; max-width: 17ch; font: 500 60px/62px var(--serif); letter-spacing: -0.03em; text-wrap: balance; }
.hero .drop { padding: 32px 24px; align-items: flex-start; text-align: left; }
.hero .drop .row { justify-content: flex-start; }
.hero .start-links { justify-content: flex-start; }
.hero-visual { position: relative; height: 460px; }
.sheet { position: absolute; left: 0; top: 0; width: 68%; height: 360px; padding: 24px 20px 20px 52px; border-radius: 4px; transform: rotate(-3deg); transform-origin: top left;
  background-color: #fffef8;
  background-image: linear-gradient(to right, transparent 39px, rgba(207, 72, 72, 0.4) 39px, rgba(207, 72, 72, 0.4) 40px, transparent 40px),
    repeating-linear-gradient(to bottom, transparent 0 27px, rgba(58, 111, 220, 0.14) 27px 28px);
  background-position: 0 0, 0 52px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 32px rgba(40, 30, 10, 0.1); font: 400 13px/28px var(--sans); color: #2c2b27; }
.sheet p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head { display: flex; justify-content: space-between; height: 28px; margin-bottom: 0; font: 500 15px/28px var(--serif); }
.sheet-o { color: #57564f; }
.sheet-key { margin-top: 0 !important; font: italic 500 16px/28px var(--serif); color: #b23a3a; }
.formcard { position: absolute; right: 0; bottom: 0; width: 60%; padding: 20px; background: var(--paper); border-radius: var(--r-panel); border-top: 6px solid var(--blue); box-shadow: var(--shadow-float); display: flex; flex-direction: column; gap: 12px; }
.formcard-title { font: 500 18px/24px var(--serif); }
.formcard-q { font-weight: 500; }
.formcard-opts { display: flex; flex-direction: column; gap: 4px; }
.fo { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line); }
.fo::before { content: ""; width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); flex: none; }
.fo.on { box-shadow: inset 0 0 0 2px var(--blue); }
.fo.on::before { box-shadow: inset 0 0 0 4px var(--blue); }
.fo .tick { margin-left: auto; opacity: 1; }
.formcard-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); font: 400 13px/20px var(--mono); color: var(--blue-ink); }
.formcard-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; }
@media (max-width: 960px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; min-height: 0; }
  .hero-title { font-size: 44px; line-height: 48px; }
  .hero-visual { height: 400px; max-width: 520px; width: 100%; }
}
@media (max-width: 560px) {
  .hero-title { font-size: 36px; line-height: 40px; }
  .hero-visual { height: 360px; }
  .sheet { width: 84%; height: 300px; font-size: 12px; }
  .formcard { width: 80%; padding: 16px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
