/* Drafting film, graphite ink, one copper accent. */
:root {
  --ground: #eef1ed;
  --ground-2: #e4e8e3;
  --ink: #17201c;
  --ink-2: #4b5751;
  --ink-3: #5c6660;
  --rule: #c5ccc6;
  --rule-strong: #8f9a93;
  --accent: #a8561d;
  --accent-ink: #ffffff;
  --accent-soft: #f3e2d3;
  --warn: #8a5a00;
  --warn-bg: #f6ecd2;
  --field: #f8faf7;
  --stage: #10221b;
  --stage-ink: #d6e4dc;
  --stage-ink-2: #8ea89a;
  --stage-rule: #2b4a3d;
  --sans: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #141917;
    --ground-2: #1b211e;
    --ink: #e3e9e5;
    --ink-2: #aab5ae;
    --ink-3: #87938c;
    --rule: #2e3833;
    --rule-strong: #52605a;
    --accent: #df8a4c;
    --accent-ink: #1a0f06;
    --accent-soft: #3a2616;
    --warn: #e7b85c;
    --warn-bg: #2f2612;
    --field: #101513;
    --stage: #0b1712;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #141917; --ground-2: #1b211e; --ink: #e3e9e5; --ink-2: #aab5ae; --ink-3: #87938c;
  --rule: #2e3833; --rule-strong: #52605a; --accent: #df8a4c; --accent-ink: #1a0f06; --accent-soft: #3a2616;
  --warn: #e7b85c; --warn-bg: #2f2612; --field: #101513; --stage: #0b1712; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 14px/1.45 var(--sans);
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2 { margin: 0; font-weight: 600; }
button { font: inherit; color: inherit; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--rule-strong);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 26px; }
.brand-mark rect { fill: #1d5c40; }
.brand-mark circle { fill: #c8873a; }
.brand-mark path { stroke: #c8873a; stroke-width: 2; }
.brand h1 { font-size: 17px; letter-spacing: 0; font-variation-settings: "wdth" 125; text-transform: none; }
.tagline { margin: 0; color: var(--ink-2); }
.privacy { margin: 0; display: flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 13px; }
.privacy svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
}
.panel {
  overflow-y: auto;
  border-right: 1px solid var(--rule-strong);
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}
.block { padding: 16px 20px 18px; border-bottom: 1px solid var(--rule); }
.block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.block h2 { font-size: 15px; }

/* ---------- controls ---------- */
.field { margin: 0 0 12px; padding: 0; border: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > legend { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; padding: 0; }
.hint { font-weight: 400; color: var(--ink-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; align-items: end; }
.field-row:last-child { margin-bottom: 0; }
.field-row .field { margin: 0; }

select, input[type="number"] {
  width: 100%;
  height: 32px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  padding: 0 8px;
}
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px; background-repeat: no-repeat; }
select:hover, input[type="number"]:hover { border-color: var(--ink-2); }
.unit { display: flex; align-items: stretch; }
.unit input { font-family: var(--mono); font-variant-numeric: tabular-nums; border-right: 0; border-radius: 2px 0 0 2px; min-width: 0; }
.unit span { display: grid; place-items: center; padding: 0 8px; border: 1px solid var(--rule-strong); border-radius: 0 2px 2px 0; color: var(--ink-3); font-size: 12px; background: var(--ground-2); }

.seg { display: flex; border: 1px solid var(--rule-strong); border-radius: 2px; width: fit-content; max-width: 100%; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 6px 14px; font-weight: 500; cursor: pointer; border-right: 1px solid var(--rule); user-select: none; white-space: nowrap; }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--ink); color: var(--ground); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg label:hover input:not(:checked) + span { background: var(--ground-2); }
.seg input:disabled + span { color: var(--ink-3); cursor: not-allowed; background: transparent; }

.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:hover { text-decoration-thickness: 2px; }
.note { margin: 10px 0 0; color: var(--ink-3); font-size: 12.5px; }
.note.tight { margin: 0; }
.note:empty { display: none; }

/* ---------- files ---------- */
.drop {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px dashed var(--rule-strong);
  border-radius: 2px;
  cursor: pointer;
  background: var(--field);
}
.drop:hover, .drop.over { border-color: var(--accent); border-style: solid; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop svg { grid-row: span 2; width: 26px; height: 26px; fill: none; stroke: var(--ink-2); stroke-width: 1.5; }
.drop-main { font-weight: 500; }
.drop-sub { color: var(--ink-3); font-size: 12.5px; }
.demo-line { margin: 8px 0 0; color: var(--ink-3); font-size: 12.5px; }
.credit { display: block; margin-top: 2px; font-size: 12px; }
.credit a { color: inherit; text-underline-offset: 2px; }

table { border-collapse: collapse; width: 100%; }
.layers-wrap { margin-top: 12px; border-top: 1px solid var(--rule); }
.layers-wrap summary { list-style: none; display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; cursor: pointer; font-variant-numeric: tabular-nums; }
.layers-wrap summary::-webkit-details-marker { display: none; }
.summary-action { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; flex: none; }
.layers-wrap[open] .summary-action { color: var(--ink-3); }
.layers { margin-top: 2px; }
.layers th, .assign th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 0 0 4px; border-bottom: 1px solid var(--rule); }
.layers td { padding: 4px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.layers td:first-child { font-family: var(--mono); font-size: 12px; padding-right: 8px; word-break: break-all; }
.layers tr.ignored td:first-child { color: var(--ink-3); }
.layers select { height: 28px; font-size: 13px; }
.layers td:last-child { width: 46%; }

/* ---------- colours ---------- */
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 14px; }
.slot { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 2px; }
.slot[hidden] { display: none; }
.slot input[type="color"] { width: 26px; height: 26px; padding: 0; border: 1px solid var(--rule-strong); border-radius: 2px; background: none; cursor: pointer; }
.slot input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.slot input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 1px; }
.slot input[type="color"]::-moz-color-swatch { border: 0; }
.slot span { font-size: 12.5px; color: var(--ink-2); }
.slot b { font-family: var(--mono); font-weight: 500; color: var(--ink); }

.assign td { padding: 6px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.assign td:first-child { font-weight: 500; }
.assign td:first-child small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.assign td:last-child { text-align: right; }
.assign .seg { margin-left: auto; }
.assign .seg span { padding: 4px 0; width: 38px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.assign .seg .chip { width: 9px; height: 9px; border-color: rgba(0, 0, 0, .35); }
.assign .seg input:checked + span .chip { border-color: rgba(255, 255, 255, .6); }
.assign tr.off td:first-child { color: var(--ink-3); }

/* ---------- advanced ---------- */
.advanced summary { list-style: none; display: flex; justify-content: space-between; align-items: baseline; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary h2::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 8px 2px 1px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease-out; }
.advanced[open] summary h2::before { transform: rotate(45deg); }
.advanced[open] summary { margin-bottom: 14px; }
.summary-val { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- output ---------- */
.warnings { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.warnings:empty { display: none; }
.warnings li { padding: 7px 10px; background: var(--warn-bg); color: var(--warn); font-size: 12.5px; border-radius: 2px; }
.changes, .drills { margin-bottom: 14px; }
.changes caption, .drills caption { text-align: left; font-weight: 500; padding-bottom: 6px; }
.changes caption small, .drills caption small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.changes th, .drills th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 0 8px 4px 0; border-bottom: 1px solid var(--rule); }
.changes td, .drills td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--rule); font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.changes td:last-child { font-family: var(--sans); display: flex; align-items: center; gap: 6px; }
.drills td:last-child { font-family: var(--sans); font-size: 12.5px; }
.drills tr.skipped td { color: var(--ink-3); }
.chip { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .3); flex: none; display: inline-block; }
.ams-note { margin: 0 0 14px; color: var(--ink-2); font-size: 13px; }

.downloads { display: grid; gap: 6px; }
.btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--rule-strong); border-radius: 2px; background: var(--field);
  cursor: pointer; text-align: left; font-weight: 500;
}
.btn:hover { border-color: var(--ink); }
.btn small { font-weight: 400; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.btn .label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.btn .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary small { color: inherit; opacity: .85; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: progress; }
.dl-group { display: grid; gap: 6px; }
.dl-sep { margin: 6px 0 2px; font-size: 12px; color: var(--ink-3); }

/* ---------- stage ---------- */
.stage { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; background: var(--stage); color: var(--stage-ink); overflow: hidden; }
.canvas-wrap { position: relative; min-height: 0; }
.viewport { position: absolute; inset: 0; }
.viewport canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.viewport canvas:active { cursor: grabbing; }

.view-tools { position: absolute; top: 14px; left: 14px; display: flex; border: 1px solid var(--stage-rule); border-radius: 2px; background: rgba(11, 23, 18, .7); }
.view-tools button { background: none; border: 0; border-right: 1px solid var(--stage-rule); color: var(--stage-ink-2); padding: 6px 12px; cursor: pointer; font-weight: 500; }
.view-tools button:last-child { border-right: 0; }
.view-tools button:hover { color: var(--stage-ink); }
.view-tools button[aria-pressed="true"] { color: #10221b; background: var(--stage-ink); }

.empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; max-width: 380px; pointer-events: none; }
.empty-main { margin: 0 0 6px; font-size: 18px; font-weight: 600; font-variation-settings: "wdth" 125; }
.empty-sub { margin: 0; color: var(--stage-ink-2); }
.pointer-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .pointer-fine { display: none; }
  .pointer-touch { display: inline; }
}

/* drawing title block, bottom right */
.titleblock {
  position: absolute; right: 14px; bottom: 14px; margin: 0;
  display: grid; grid-template-columns: auto auto; min-width: 250px;
  border: 1px solid var(--stage-ink-2); background: rgba(11, 23, 18, .82);
  font-size: 12px;
}
.titleblock > div { display: contents; }
.titleblock dt, .titleblock dd { margin: 0; padding: 5px 9px; border-bottom: 1px solid var(--stage-rule); }
.titleblock dt { color: var(--stage-ink-2); border-right: 1px solid var(--stage-rule); }
.titleblock dd { color: var(--stage-ink); text-align: right; }
.titleblock .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.titleblock .tb-title { grid-column: 1 / -1; font-family: var(--sans); font-weight: 600; font-size: 13px; text-align: left; color: var(--stage-ink); font-variation-settings: "wdth" 125; }
.titleblock > div:last-child dt, .titleblock > div:last-child dd { border-bottom: 0; }

/* section view (layer plan), bottom left */
.section-view {
  display: flex; align-items: center; gap: 28px;
  padding: 12px 16px; border-top: 1px solid var(--stage-rule);
  font-size: 12px; overflow-x: auto;
}
.sv-head { display: grid; gap: 6px; width: 22ch; flex: none; }
.section-view h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--stage-ink); font-variation-settings: "wdth" 125; }
.section-view h3 span { margin-left: 6px; font-weight: 400; font-size: 12px; color: var(--stage-ink-2); font-variation-settings: "wdth" 100; }
.section-view p { margin: 0; color: var(--stage-ink-2); }
/* narrow stage: heading row above the drawing instead of beside it */
.stage { container-type: inline-size; }
@container (max-width: 680px) {
  .section-view { flex-direction: column; align-items: flex-start; gap: 6px; }
  .sv-head { display: flex; flex-wrap: wrap; gap: 4px 14px; width: auto; align-items: baseline; }
}
.section-view svg { display: block; overflow: visible; flex: none; }
.section-view text { font-family: var(--mono); font-size: 11px; fill: var(--stage-ink-2); }
.section-view text.lbl { font-family: var(--sans); fill: var(--stage-ink); font-size: 12px; }
.section-view line { stroke: var(--stage-ink-2); stroke-width: 1; }
.section-view .chg { stroke: #e9a26a; stroke-dasharray: 3 2; }
.section-view text.chg-t { fill: #e9a26a; }

.busy { position: absolute; top: 14px; right: 14px; display: flex; align-items: center; gap: 8px; padding: 5px 10px; font-size: 12.5px; color: var(--stage-ink); background: rgba(11, 23, 18, .82); border: 1px solid var(--stage-rule); }
.busy span { width: 10px; height: 10px; border: 1.5px solid var(--stage-ink-2); border-top-color: #e9a26a; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dropveil { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(16, 34, 27, .55); border: 3px solid var(--accent); pointer-events: none; }
.dropveil p { padding: 10px 18px; background: var(--ground); color: var(--ink); font-weight: 600; }
.dock {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px; background: var(--ground); border-top: 1px solid var(--rule-strong);
}
.dock .btn { flex: 1; min-width: 0; }
.dock.away { display: none; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* short desktop windows: keep the drawing overlays compact */
@media (min-width: 821px) and (max-height: 720px) {
  .titleblock { min-width: 220px; font-size: 11.5px; }
  .titleblock dt, .titleblock dd { padding: 3px 8px; }
  .section-view { padding: 8px 16px; }
  .view-tools button { padding: 4px 10px; }
}

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .topbar { grid-template-columns: auto 1fr; }
  .tagline { display: none; }
  .privacy { justify-self: end; }
}
@media (max-width: 820px) {
  body { height: auto; }
  .topbar { padding: 10px 16px; gap: 12px; }
  .privacy { font-size: 12px; }
  .layout { display: flex; flex-direction: column-reverse; }
  .stage { display: flex; flex-direction: column; }
  .canvas-wrap { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
  .viewport { position: relative; inset: auto; height: 52vh; min-height: 300px; }
  .panel { border-right: 0; overflow: visible; }
  .block { padding: 14px 16px 16px; }
  .titleblock { position: static; margin: 0 16px; min-width: 0; }
  .section-view { gap: 12px 20px; }
  /* on phones the panel sits below the preview, so pin the dock to the screen */
  .dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px; }
  body:has(.dock:not([hidden]):not(.away)) { padding-bottom: 58px; }
  .busy { top: 14px; }
  .slot { padding: 6px; gap: 6px; }
  .slot span { font-size: 12px; white-space: nowrap; }
}
@media (max-width: 400px) {
  .slot .w { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0s !important; }
}
