/* Square Edge site + app. Tokens from DESIGN.md v0.1. Dark is the default theme. */
@font-face { font-family: "Archivo"; src: url("../fonts/Archivo-var.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root, :root[data-theme="dark"] {
  --app: #0F1317; --chrome: #161B21; --panel: #12171C; --surface: #161B21; --surface-2: #1B2128;
  --line: #262E37; --line-2: #2F3842; --dash: #3A434D;
  --ink: #E6EAEE; --ink-2: #B4BDC6; --muted: #8C96A0;
  --accent: #0052A5; --accent-deep: #003F7F; --accent-text: #00BFFF; --accent-tint: #13283F;
  --vp: #1D232A; --grid-minor: #232A32; --grid-major: #2D353E; --part-fill: #222A33; --dim: #8C96A0; --dim-text: #D6DCE2;
  --cut: #00BFFF; --hole: #00A500; --mark: #999999; --info: #FFFFFF;
  --err-line: #FF003F; --err-fill: #A50029; --err-text: #FF7F7F; --err-bg: #241A1D; --err-line-soft: #5A2A33;
  --ok-bg: #13283F; --chip-auto-ink: #7FBFFF; --btn-2: #1F262E; --btn-2-line: #3A434D;
  --float: 0 4px 10px rgba(0,0,0,0.28);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --app: #E9EDF1; --chrome: #FFFFFF; --panel: #F4F6F8; --surface: #FFFFFF; --surface-2: #F7F9FA;
  --line: #E3E7EB; --line-2: #D5DBE1; --dash: #AEB7C0;
  --ink: #141A21; --ink-2: #3C4651; --muted: #5B6570;
  --accent-text: #0052A5; --accent-tint: #E6EEF7;
  --vp: #FBFCFD; --grid-minor: #EEF1F4; --grid-major: #E0E5EA; --part-fill: #FFFFFF; --dim: #39424C; --dim-text: #141A21;
  --cut: #0052A5; --hole: #007F00; --mark: #666666; --info: #000000;
  --err-text: #A50029; --err-bg: #FFF2F4; --err-line-soft: #F2B8C4;
  --ok-bg: #E6EEF7; --chip-auto-ink: #0052A5; --btn-2: #FFFFFF; --btn-2-line: #C5CCD3;
  --float: 0 4px 12px rgba(0,0,0,0.16);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--app); color: var(--ink); font: 400 15px/1.55 "Archivo", system-ui, sans-serif; }
::selection { background: #0052A5; color: #FFFFFF; }
:focus-visible { outline: 2px solid #3D8BFF; outline-offset: 2px; }
a { color: var(--accent-text); text-underline-offset: 3px; }
h1, h2, h3 { font-weight: 500; line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(28px, 4vw, 44px); }
h2 { font-size: clamp(22px, 2.6vw, 30px); }
h3 { font-size: 18px; }
p { margin: 0; }
.mono, code, kbd, .num { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums slashed-zero; }
.note { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; letter-spacing: 0.01em; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--chrome); border-bottom: 1px solid var(--line-2); }
.topbar-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; min-height: 60px; padding: 0 20px; max-width: 1440px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 500; }
.brand svg { flex: 0 0 auto; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; flex: 1 1 auto; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: 14px; padding: 6px 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.mark-cut { stroke: var(--cut); } .mark-hole { stroke: var(--hole); } .mark-mark { stroke: var(--mark); }

/* ---------- buttons, toggles, chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 7px; border: 1px solid var(--btn-2-line); background: var(--btn-2); color: var(--ink); font: 500 14px/1 "Archivo", sans-serif; text-decoration: none; cursor: pointer; transition: background-color 200ms cubic-bezier(.16,1,.3,1), transform 200ms cubic-bezier(.16,1,.3,1); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent-deep); color: #FFFFFF; box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.12); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent-text); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 6px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.seg { display: inline-flex; padding: 2px; border-radius: 7px; background: var(--app); border: 1px solid var(--line-2); }
.seg button { min-width: 44px; min-height: 30px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font: 400 12px "IBM Plex Mono", monospace; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--accent-text); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.theme-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--app); color: var(--ink); font: 400 13px "Archivo", sans-serif; cursor: pointer; }
.chip { display: inline-block; font: 400 11px/1.3 "IBM Plex Mono", monospace; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
.chip-auto { color: var(--chip-auto-ink); background: var(--accent-tint); }
.chip-fixed, .chip-ok { color: #FFFFFF; background: var(--accent); }
.chip-call, .chip-err { color: #FFFFFF; background: var(--err-fill); }
.chip-neutral { color: var(--ink-2); background: var(--surface-2); }
.bubble { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 10px; background: var(--err-fill); box-shadow: 0 0 0 1.5px var(--err-line); color: #FFFFFF; font: 400 12px "IBM Plex Mono", monospace; flex: 0 0 auto; }
.bubble.done { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent-text); color: var(--accent-text); }

/* ---------- sections ---------- */
.section { padding: 72px 0; border-top: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; margin-bottom: 28px; }
.lede { font-size: 17px; color: var(--ink-2); max-width: 62ch; }
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.textbox { font: 400 12px/1.6 "IBM Plex Mono", monospace; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.sheet { border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); padding: 12px; }
.sheet-in { border: 1px dashed var(--dash); border-radius: 6px; padding: 28px; }

/* ---------- hero (tool first) ---------- */
.hero { padding: 48px 0 56px; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 32px; align-items: center; }
.hero h1 { max-width: 18ch; }
.hero .lede { margin-top: 14px; }
.drop { margin-top: 26px; }
.drop-zone { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.drop-zone.drag { background: var(--accent-tint); }
.trust { margin-top: 14px; }
.hero-view { border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); background: var(--vp); aspect-ratio: 16 / 10; }
.check-result { margin-top: 16px; display: none; }
.check-result.show { display: block; }
.result-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* ---------- stretch demo ---------- */
.stretch-view { border-radius: 10px; border: 1px solid var(--line-2); background: var(--vp); overflow: hidden; }
.stretch-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }

/* ---------- steps strip ---------- */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; counter-reset: s; }
@media (max-width: 760px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.step { padding: 16px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); }
.step .n { font: 400 11px "IBM Plex Mono", monospace; color: #FFFFFF; background: var(--accent); width: 18px; height: 18px; border-radius: 2px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.step p { font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }

/* ---------- pricing ---------- */
.price { font-size: 30px; font-weight: 500; margin: 8px 0 4px; }
.price small { font-size: 14px; color: var(--muted); font-weight: 400; }
.card ul { margin: 14px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.card li + li { margin-top: 6px; }

/* ---------- docs (reading pages) ---------- */
.doc { padding: 48px 0 80px; }
.doc .prose { max-width: 70ch; }
.prose h1 { margin-bottom: 12px; }
.prose h2 { margin: 36px 0 10px; font-size: 22px; }
.prose h3 { margin: 26px 0 8px; }
.prose p, .prose li { color: var(--ink-2); font-size: 16px; line-height: 1.7; }
.prose p + p { margin-top: 14px; }
.prose ul, .prose ol { padding-left: 20px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 16px 0; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--muted); font-weight: 500; }
.prose code { font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.prose .meta { margin-bottom: 26px; }
.draft-flag { display: inline-block; margin-bottom: 18px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line-2); background: var(--chrome); padding: 40px 0; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; }
.footer a { color: var(--ink-2); text-decoration: none; display: block; padding: 3px 0; font-size: 14px; }
.footer a:hover { color: var(--ink); }

/* ---------- app ---------- */
.app-body { display: flex; flex-direction: column; min-height: 100vh; }
.rail { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px; flex: 1 1 520px; }
.rail button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font: 400 13px "Archivo", sans-serif; cursor: pointer; }
.rail button[aria-current="step"] { background: var(--accent-tint); color: var(--accent-text); font-weight: 500; }
.rail button:disabled { color: var(--muted); cursor: default; opacity: 1; }
.rail .box { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 2px; font: 400 10px "IBM Plex Mono", monospace; border: 1px solid var(--dash); }
.rail .box.on { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.rail .sep { width: 12px; height: 1px; background: var(--dash); }
.rail .count { font: 400 12px/18px "IBM Plex Mono", monospace; color: #FFFFFF; background: var(--err-fill); padding: 1px 7px; border-radius: 10px; }
.app-main { flex: 1 1 auto; display: flex; }
.panel-step { flex: 1 1 auto; display: none; }
.panel-step.on { display: flex; }
.workspace { display: flex; flex-wrap: wrap; gap: 1px; background: var(--line-2); width: 100%; }
.col-parts { flex: 1 1 268px; background: var(--panel); min-width: 0; max-height: calc(100vh - 61px); overflow: auto; }
.col-view { flex: 999 1 620px; background: var(--surface); min-width: 0; display: flex; flex-direction: column; }
.col-insp { flex: 1 1 340px; background: var(--surface); min-width: 0; display: flex; flex-direction: column; max-height: calc(100vh - 61px); }
.col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.col-head h2 { font-size: 15px; }
.part-row { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; width: 100%; }
.part-row[aria-pressed="true"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent-text); }
.part-row .pid { font: 500 12.5px "IBM Plex Mono", monospace; }
.part-row .sub { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 12px 6px 6px; font: 400 12px "IBM Plex Mono", monospace; color: var(--ink-2); text-transform: uppercase; }
.parts-list { padding: 6px 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.viewport { position: relative; flex: 1 1 auto; min-height: 440px; background: var(--vp); overflow: hidden; }
.viewport svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.layers { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.layers button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: 400 11px "IBM Plex Mono", monospace; cursor: pointer; text-decoration: line-through; }
.layers button[aria-pressed="true"] { background: var(--surface); color: var(--ink); text-decoration: none; }
.swatch { width: 14px; height: 2px; display: inline-block; }
.statusbar { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 7px 14px; border-top: 1px solid var(--line); background: var(--surface-2); font: 400 12px "IBM Plex Mono", monospace; color: var(--ink-2); }
.insp-scroll { flex: 1 1 auto; overflow: auto; }
.insp-actions { position: sticky; bottom: 0; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; font-size: 12.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: "IBM Plex Mono", monospace; }
.issue { padding: 10px 8px; border-radius: 7px; }
.issue[aria-selected="true"] { background: var(--err-bg); box-shadow: inset 0 0 0 1px var(--err-line-soft); }
.issue button.pick { all: unset; cursor: pointer; display: flex; gap: 10px; width: 100%; box-sizing: border-box; }
.issue .t { font-size: 13.5px; font-weight: 500; }
.issue .d { font-size: 12.5px; color: var(--ink-2); }
.center-step { width: 100%; padding: 32px 24px; display: flex; justify-content: center; }
.center-step > div { width: 100%; max-width: 980px; display: flex; flex-direction: column; gap: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px; }
.table td { padding: 9px 8px; border-top: 1px solid var(--line); font-family: "IBM Plex Mono", monospace; }
.empty { padding: 28px; color: var(--ink-2); }
.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; width: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(0); transition: transform 300ms cubic-bezier(.16,1,.3,1); }
.banner-err { padding: 14px 16px; border-radius: 8px; background: var(--err-bg); border: 1px solid var(--err-line-soft); color: var(--ink); }
.banner-ok { padding: 14px 16px; border-radius: 8px; background: var(--ok-bg); color: var(--ink); }

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

/* ---------- app 0.3: files, set up, nest ---------- */
.center-step > div.wide { max-width: 1180px; }
.step-title { font-size: 22px; }
.card-title { font-size: 17px; }
.sec-title { font-size: 15px; }
.sec-title.pad { padding: 14px 16px 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-gap.tight { gap: 6px; }
.row-gap.align-end { align-items: flex-end; gap: 14px; }
.small { font-size: 12.5px; }
.field { min-height: 36px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: 400 13px "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums slashed-zero; max-width: 100%; }
select.field { font-family: "Archivo", system-ui, sans-serif; padding-right: 6px; }
.field-sm { min-height: 30px; font-size: 12.5px; padding: 0 8px; }
.num-in { width: 72px; }
.table-wrap { overflow-x: auto; }
.table td.pid { font-weight: 500; white-space: nowrap; }
.table td.fname { font-family: "Archivo", sans-serif; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table.files td { vertical-align: middle; }
.table td.small { font-family: "Archivo", sans-serif; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.row-text { display: flex; flex-direction: column; min-width: 0; }
.insp-head { padding: 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.insp-sec { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.issue-list { list-style: none; margin: 0; padding: 0 8px 10px; }
.issue-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.issue-head { display: flex; justify-content: space-between; gap: 8px; }
ul.plain { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; }
.file-list { margin: 0; padding: 0; list-style: none; columns: 2 260px; font-size: 12.5px; color: var(--ink-2); }
.file-list li { padding: 2px 0; }
.textbox { white-space: pre-line; }
.plate-host { position: relative; width: 100%; }
.viewport .plate-host { position: absolute; inset: 24px; width: auto; }
.viewport .plate-host svg, .plate-host svg { width: 100%; height: 100%; display: block; }
.sheet-fig { margin: 4px 0 0; display: flex; flex-direction: column; gap: 6px; }
.sheet-fig .plate-host { border-radius: 6px; background: var(--vp); }
.nest-part:hover path:first-of-type { stroke-width: 2.2; }
.nest-layout { display: flex; flex-wrap: wrap; gap: 1px; background: var(--line-2); width: 100%; align-items: stretch; }
.nest-settings { flex: 1 1 320px; max-width: 380px; background: var(--panel); display: flex; flex-direction: column; max-height: calc(100vh - 61px); position: sticky; top: 61px; }
.nest-form { flex: 1 1 auto; overflow: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.nest-results { flex: 999 1 560px; min-width: 0; background: var(--app); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.fs { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fs legend { padding: 0 0 6px; }
.grid-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
.grid-fields .field { width: 100%; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.toggle input { accent-color: #0052A5; width: 16px; height: 16px; }
.plate-list { display: flex; flex-wrap: wrap; gap: 6px; }
.plate-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 2px 2px 9px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line-2); font-size: 12.5px; }
.chip-x { all: unset; cursor: pointer; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; color: var(--muted); }
.chip-x:hover { background: var(--surface-2); color: var(--ink); }
.chip-x:focus-visible { outline: 2px solid #3D8BFF; outline-offset: 1px; }
.saved { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; padding: 14px 16px; border-radius: 8px; background: var(--ok-bg); }
.saved .big { font-size: 26px; font-weight: 500; color: var(--accent-text); }
.saved.worse { background: var(--surface-2); }
.saved.worse .big { color: var(--ink); }
.table.compare tr.mine td { color: var(--ink); }
.table.compare tr.mine td.rowname { color: var(--accent-text); }
.table.compare td.rowname { font-family: "Archivo", sans-serif; font-weight: 500; white-space: nowrap; }
@media (max-width: 760px) {
  .nest-settings { max-width: none; position: static; max-height: none; }
  .nest-results { padding: 14px 12px; }
  .grid-fields { grid-template-columns: 1fr 1fr; }
}
/* A step panel shows only when it is the current step (center-step sets display, so this must win). */
.panel-step:not(.on) { display: none; }
.table td.nowrap { white-space: nowrap; }
.insp-head h2 { font-size: 17px; }
/* Panels may shrink below their widest content; wide tables scroll inside their card instead. */
.panel-step, .nest-results, .card { min-width: 0; }
