:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #eef0f3; --border: #d9dde3;
  --text: #1c2330; --muted: #5f6b7a; --accent: #1f6feb; --accent-soft: #e3edff;
  --ok: #1a7f37; --ok-soft: #e3f4e8; --bad: #c62828; --bad-soft: #fdecec;
  --sheet: #ffffff; --ink: #1c2330; --hidden: #8a94a3; --center: #b0741a;
  --feature: #1f6feb; --hl: #e8590c; --dim: #0b7a75; --ghost: #8a94a3;
  --radius: 8px; --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b; --surface: #181d25; --surface-2: #202631; --border: #2e3642;
    --text: #e3e8ef; --muted: #98a3b3; --accent: #5b9bff; --accent-soft: #1b2b45;
    --ok: #4cc26d; --ok-soft: #173222; --bad: #ff6b6b; --bad-soft: #3a1c1c;
    --sheet: #0d1117; --ink: #d7dee8; --hidden: #6b7584; --center: #d99b3d;
    --feature: #5b9bff; --hl: #ff8a3d; --dim: #3fc1b8; --ghost: #6b7584;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); display: flex; flex-direction: column; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 650; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: #fff; }
.tag { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.top-actions form { margin: 0; display: flex; }
.user { align-self: center; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 13px; margin-left: 4px; }

.btn { font: inherit; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 3px 9px; font-size: 13px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 420px; }
.canvas-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.tool { font: inherit; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.tool.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 4px; color: var(--muted); margin-left: 6px; }
.toggle select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 2px 4px; }
.readout { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

.stage { position: relative; flex: 1; min-height: 0; background: var(--sheet); }
#svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#svg.measure { cursor: crosshair; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 20px; margin: 0 0 6px; }
.empty p { max-width: 520px; margin: 4px 0; }
.samples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0 8px; }
.stage.drag { outline: 3px dashed var(--accent); outline-offset: -10px; }
.scale-note { margin-top: 10px !important; padding: 6px 12px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.notes-strip { border-top: 1px solid var(--border); background: var(--surface); padding: 8px 12px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; max-height: 120px; overflow: auto; }

.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--border); }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab { flex: 1; font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px; color: var(--muted); cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.panel { flex: 1; min-height: 0; overflow: auto; padding: 14px; }

.progress { display: flex; gap: 3px; margin-bottom: 12px; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); }
.progress span.done { background: var(--ok); }
.progress span.revealed { background: var(--center); }
.progress span.current { outline: 2px solid var(--accent); outline-offset: 1px; }

.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; background: var(--surface); }
.card.muted { color: var(--muted); }
.card h3 { margin: 2px 0 8px; font-size: 16px; }
.stage-label { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.card .instruction { margin: 0 0 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea, .chat-form textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; width: 100%; }
.field textarea { min-height: 110px; font-family: var(--mono); font-size: 12.5px; }
.options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.option { display: flex; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; cursor: pointer; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.feedback { margin-top: 12px; padding: 10px 12px; border-radius: 6px; white-space: pre-wrap; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback.info { background: var(--surface-2); color: var(--text); }
.feedback .ann { display: block; margin-top: 6px; font-family: var(--mono); color: var(--text); }
.feedback .ann-note { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
details.why { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
details.why summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.iso { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.iso span { font-size: 11.5px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--muted); }

.step-list { list-style: none; margin: 0; padding: 0; }
.step-list .stage-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px; }
.step-list li.step { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.step-list li.step:hover { background: var(--surface-2); }
.step-list li.step.current { background: var(--accent-soft); }
.dot { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: 11px; }
.dot.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.dot.revealed { background: var(--center); border-color: var(--center); color: #fff; }

.a-section { margin-bottom: 16px; }
.a-section h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.feat { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; cursor: default; }
.feat:hover { border-color: var(--hl); }
.feat b { font-family: var(--mono); font-size: 12.5px; }
.feat p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.proc { border-left: 3px solid var(--accent); padding: 4px 10px; margin-bottom: 10px; }
.proc ul { margin: 4px 0; padding-left: 18px; }
.warn { color: var(--center); }

.chat { display: flex; flex-direction: column; }
.chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--accent-soft); }
.msg.assistant { align-self: flex-start; background: var(--surface-2); }
.chat-form { display: flex; gap: 6px; margin-top: 10px; }
.small { font-size: 12px; color: var(--muted); }

svg .ink { stroke: var(--ink); fill: none; vector-effect: non-scaling-stroke; stroke-width: 1.3; }
svg .hidden-line { stroke: var(--hidden); stroke-dasharray: 5 3; }
svg .center-line { stroke: var(--center); stroke-dasharray: 12 3 2 3; stroke-width: .8; }
svg .cut-line { stroke: var(--accent); stroke-dasharray: 16 3 2 3 2 3; stroke-width: 1.4; }
svg .hatch { fill: url(#hatch45); stroke: none; }
svg .hatch-line { stroke: var(--hidden); stroke-width: 0.8; vector-effect: non-scaling-stroke; }
svg .hl { stroke: var(--hl); stroke-width: 3; }
svg .feat-hover { stroke: var(--feature); stroke-width: 2.4; }
svg .view-box { fill: none; stroke: var(--accent); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; stroke-width: 1; opacity: .6; }
svg .view-label { fill: var(--accent); font-family: var(--font); font-weight: 600; }
svg .dim { stroke: var(--dim); fill: none; vector-effect: non-scaling-stroke; stroke-width: 1; }
svg .dim-arrow { fill: var(--dim); stroke: none; }
svg .dim-text { fill: var(--dim); font-family: var(--mono); }
#svg { user-select: none; -webkit-user-select: none; } /* dragging/double-clicking shouldn't select text */
svg .dim-movable { cursor: move; }
svg .dim-hit { stroke: transparent; stroke-width: 10; vector-effect: non-scaling-stroke; pointer-events: stroke; }
svg .dim-movable:hover .dim { stroke: var(--hl); }
svg .dim-movable:hover .dim-arrow, svg .dim-movable:hover .dim-text { fill: var(--hl); }
svg .ghost .dim { stroke: var(--ghost); stroke-dasharray: 4 3; }
svg .ghost .dim-arrow, svg .ghost .dim-text { fill: var(--ghost); }
svg .snap { fill: var(--feature); opacity: .55; }
svg .measure-line { stroke: var(--hl); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
svg .measure-pt { fill: var(--hl); }

/* ---- "feedback opens soon" page (shown until the Google Form link is set) ---- */
body.page { display: block; height: auto; min-height: 100%; }
.soon { max-width: 560px; margin: 0 auto; padding: 80px 16px; text-align: center; }
.soon h1 { font-size: 24px; margin: 0 0 8px; }
.soon p { color: var(--muted); margin: 0 0 20px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* ---- sign-in page ---- */
.soon.signin { max-width: 800px; padding-top: 48px; }
.signin .brand { justify-content: center; font-size: 18px; margin-bottom: 28px; }
.signin .demo { width: 80%; margin: 32px auto 0; }
@media (max-width: 600px) { .signin .demo { width: 100%; } }
.signin .demo video { display: block; width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; background: #000;
  border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0, 0, 0, .12); }
.signin .demo figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); }
.signin-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.btn.signin-with { gap: 10px; padding: 10px 20px; min-width: 260px; justify-content: center; background: var(--surface); font-weight: 600; }
.soon p.signin-error { color: var(--bad); background: var(--bad-soft); border-radius: 6px; padding: 8px 12px; }
.soon p.privacy { margin-top: 28px; font-size: 12.5px; }
.soon p.privacy a, .policy a:not(.btn) { color: var(--accent); }

/* ---- usage page (/admin) ---- */
.usage { max-width: 1100px; margin: 0 auto; padding: 40px 16px 64px; }
.usage h1 { font-size: 26px; margin: 20px 0 4px; }
.usage h2 { font-size: 17px; margin: 28px 0 8px; }
.usage .note { color: var(--muted); margin: 0; }
.usage .table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.usage table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.usage th, .usage td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.usage th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.usage tbody tr:last-child td { border-bottom: 0; }
.usage td small { color: var(--muted); }
.usage tr.none td { color: var(--muted); font-style: italic; }
.usage .back { margin-top: 28px; }

/* ---- privacy policy ---- */
.policy { max-width: 720px; margin: 0 auto; padding: 48px 16px 64px; line-height: 1.6; }
.policy h1 { font-size: 26px; margin: 24px 0 4px; }
.policy h2 { font-size: 17px; margin: 28px 0 6px; }
.policy .updated { color: var(--muted); margin-top: 0; }
.policy ul { padding-left: 20px; }
.policy li { margin-bottom: 6px; }
.policy .back { margin-top: 32px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .side { border-left: 0; border-top: 1px solid var(--border); }
  .topbar { flex-wrap: wrap; }
}
