/* Compare with your CAD — tokens first, then components. Light by default, dark per system setting. */
:root {
  color-scheme: light dark;
  --bg: #f4f6f9;
  --card: #ffffff;
  --card-head: #ffffff;
  --line: #e2e6ec;
  --line-strong: #cfd6df;
  --text: #121826;
  --muted: #586374;
  --subtle: #7b8594;
  --primary: #2f72b8;
  --primary-hover: #2864a3;
  --primary-text: #ffffff;
  --primary-disabled: #9dbbd9;
  --chip-on-bg: #121826;
  --chip-on-text: #ffffff;
  --input-bg: #ffffff;
  --tile-bg: #f8fafc;
  --good: #047857;
  --bad: #b45309;
  --error: #b91c1c;
  --info-bg: #f5f3ff;
  --info-line: #c4b5fd;
  --info-head: #5b21b6;
  --fabric: #edf1f6;
  --fabric-line: #b8c2cf;
  --piece-s: 58%;
  --piece-l: 72%;
  --piece-line: rgba(18, 24, 38, 0.45);
  --end-line: #121826;
  --other-end: #d9480f;
  --focus: #2f72b8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111725;
    --card: #1b2231;
    --card-head: #1b2231;
    --line: #2b3546;
    --line-strong: #3a4557;
    --text: #e9edf3;
    --muted: #a5aebb;
    --subtle: #808a99;
    --primary: #3a86c8;
    --primary-hover: #4794d6;
    --primary-text: #ffffff;
    --primary-disabled: #2c5679;
    --chip-on-bg: #f3f5f8;
    --chip-on-text: #111725;
    --input-bg: #151c29;
    --tile-bg: #182030;
    --good: #34d399;
    --bad: #fbbf24;
    --error: #f87171;
    --info-bg: #1b1832;
    --info-line: #5b43d6;
    --info-head: #b9a7ff;
    --fabric: #232c3d;
    --fabric-line: #3b4659;
    --piece-s: 52%;
    --piece-l: 66%;
    --piece-line: rgba(10, 14, 22, 0.55);
    --end-line: #e9edf3;
    --other-end: #ff8a4c;
    --focus: #6aa8e0;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* component display rules must not override it */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.page { max-width: 1240px; margin: 0 auto; padding: 32px 32px 48px; }
.num { font-variant-numeric: tabular-nums; }

.banner {
  border: 1px solid var(--bad); border-radius: 10px; padding: 14px 18px; margin-bottom: 20px;
  background: color-mix(in srgb, var(--bad) 12%, transparent); font-size: 15px;
}
.banner code { font: 14px ui-monospace, Menlo, Consolas, monospace; padding: 1px 5px; border-radius: 4px; background: var(--tile-bg); }
.banner a { color: var(--primary); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 22px; }
h1 { font-size: 27px; line-height: 1.2; margin: 0 0 8px; font-weight: 650; letter-spacing: -0.01em; }
.lede { margin: 0; max-width: 72ch; color: var(--text); opacity: 0.92; font-size: 16px; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
}
.btn:focus-visible, .chip:focus-visible, input:focus-visible, .tile-edit:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.primary:disabled { background: var(--primary-disabled); cursor: not-allowed; opacity: 0.85; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover:not(:disabled) { border-color: var(--subtle); }
.btn.secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); padding: 8px 10px; }
.btn.ghost:hover { background: var(--tile-bg); }
.btn.small { padding: 5px 10px; font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 22px; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); background: var(--card-head); }
.card-head h2 { font-size: 18px; margin: 0; font-weight: 650; }
.card-head .sub { margin: 2px 0 0; color: var(--muted); font-size: 14.5px; }
.card-icon { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.head-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.card-body { padding: 22px; }

.drop {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  border: 2px dashed var(--line-strong); border-radius: 10px; padding: 26px 28px;
}
.drop.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.drop.loaded .btn.primary { background: transparent; color: var(--text); border-color: var(--line-strong); }
.drop-hint { color: var(--muted); overflow-wrap: anywhere; }
.drop.loaded .drop-hint { color: var(--text); }
.fineprint { color: var(--muted); font-size: 14px; margin: 14px 0 0; }
.error { color: var(--error); margin: 14px 0 0; font-weight: 500; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-top: 20px; }
.tile { background: var(--tile-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; min-height: 92px; }
.tile-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 23px; font-weight: 650; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile-edit { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 4px; display: inline-flex; }
.tile-edit .icon { width: 15px; height: 15px; }
.tile-edit:hover { color: var(--text); }
.width-form { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.width-form input { width: 96px; }
.unit { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }

.notes { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.notes li::before { content: "•"; margin-right: 8px; color: var(--subtle); }
.notes li.warn { color: var(--bad); }

.options { display: flex; flex-wrap: wrap; gap: 22px 28px; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field-hint { font-size: 13.5px; color: var(--muted); margin: 14px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-weight: 600; font-size: 15px; padding: 7px 15px; border-radius: 999px;
  background: transparent; color: var(--text); border: 1px solid var(--line-strong); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--chip-on-bg); color: var(--chip-on-text); border-color: var(--chip-on-bg); }
.chip:disabled { opacity: 0.55; cursor: not-allowed; }
input[type="number"] {
  font: inherit; font-size: 16px; color: var(--text); background: var(--input-bg);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 12px; width: 150px;
  font-variant-numeric: tabular-nums;
}
input[type="number"]:disabled { opacity: 0.6; }
input::placeholder { color: var(--subtle); }

.progress { margin-top: 22px; }
.progress-row { display: flex; justify-content: space-between; gap: 16px; font-size: 14.5px; }
.bar { height: 6px; border-radius: 999px; background: var(--tile-bg); border: 1px solid var(--line); margin: 8px 0 14px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.4s linear; }
.seeds { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.seeds th:nth-child(1) { width: 64px; }
.seeds th:nth-child(2) { width: 170px; }
.seeds th:nth-child(3) { width: 130px; }
.seeds th:nth-child(4), .seeds td:nth-child(4) { padding-left: 24px; }
.seeds th { text-align: left; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.seeds td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.seeds th.num, .seeds td.num { text-align: right; }
.seeds tr.leader td { font-weight: 650; }

.headline { font-size: 19px; font-weight: 600; margin: 0; }
.verified { font-size: 14px; color: var(--muted); margin: 16px 0 0; }

.marker-row + .marker-row { margin-top: 22px; }
.marker-label { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.marker-label .num { color: var(--text); font-size: 16px; letter-spacing: 0; text-transform: none; }
.marker-view svg { display: block; width: 100%; height: auto; }
.marker-view .fabric { fill: var(--fabric); stroke: var(--fabric-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.marker-view .piece { fill: hsl(var(--h) var(--piece-s) var(--piece-l)); stroke: var(--piece-line); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.marker-view .end { stroke: var(--end-line); stroke-width: 2; vector-effect: non-scaling-stroke; }
.marker-view .other-end { stroke: var(--other-end); stroke-width: 2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }

.infobox {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--info-bg); border: 1px solid var(--info-line); border-radius: 10px; padding: 18px 22px;
}
.infobox .icon { width: 22px; height: 22px; color: var(--info-head); margin-top: 2px; }
.infobox h3 { margin: 0 0 4px; font-size: 17px; color: var(--info-head); font-weight: 650; }
.infobox p { margin: 0; font-size: 14.5px; }
.foot { margin: 22px 0 0; font-size: 14px; }
.foot a { color: var(--primary); }

@media (max-width: 720px) {
  .page { padding: 20px 16px 36px; }
  .page-head { flex-direction: column; gap: 12px; }
  h1 { font-size: 23px; }
  .card-head { flex-wrap: wrap; padding: 16px; }
  .head-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .card-body { padding: 16px; }
  .drop { padding: 18px; }
  .options { gap: 18px; }
  input[type="number"] { width: 130px; }
  .seeds th:nth-child(2), .seeds td:nth-child(2) { display: none; }
}
