/* Werkstatt-Bauplan: kühles Alu-Grau, Akzent Königsblau wie Füllertinte. Systemschriften, nichts extern. */
:root {
  --bg: #eceff3;
  --surface: #fafbfc;
  --sunk: #e1e6ec;
  --fg: #141c26;
  --muted: #566373;
  --line: #cdd4dc;
  --accent: #2a44c2;
  --accent-ink: #ffffff;
  --accent-soft: #dde3fa;

  /* Modellfarben (Canvas) */
  --m-alu: #aeb8c3;
  --m-rail: #5f6b78;
  --m-motor: #2a2e35;
  --m-pen: #2a44c2;
  --m-paper: #fdfdfb;
  --m-wood: #c8a77c;
  --m-board: #1f5f46;
  --m-psu: #9aa3ad;
  --m-part: #e0a03a;
  --m-heat: #c4472b;
  --m-bed: #3b4049;
  --m-servo: #2c3e8c;
  --m-ink: #1f3cb0;
  --m-cam: #7a3fb0;

  --f-display: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --surface: #161d26; --sunk: #1d2631; --fg: #e3e8ee; --muted: #93a0af;
    --line: #2b3644; --accent: #8fa3ff; --accent-ink: #0f141a; --accent-soft: #232d55;
    --m-alu: #8994a1; --m-rail: #56616e; --m-motor: #0c0f13; --m-pen: #8fa3ff; --m-paper: #eeeeea;
    --m-wood: #9e8260; --m-board: #1c5440; --m-psu: #7d8692; --m-part: #c98c2e; --m-heat: #b3432a;
    --m-bed: #2c3139; --m-servo: #3b4f9e; --m-ink: #1f3cb0; --m-cam: #a77be0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --surface: #161d26; --sunk: #1d2631; --fg: #e3e8ee; --muted: #93a0af;
  --line: #2b3644; --accent: #8fa3ff; --accent-ink: #0f141a; --accent-soft: #232d55;
  --m-alu: #8994a1; --m-rail: #56616e; --m-motor: #0c0f13; --m-pen: #8fa3ff; --m-paper: #eeeeea;
  --m-wood: #9e8260; --m-board: #1c5440; --m-psu: #7d8692; --m-part: #c98c2e; --m-heat: #b3432a;
  --m-bed: #2c3139; --m-servo: #3b4f9e; --m-ink: #1f3cb0; --m-cam: #a77be0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 var(--f-body);
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding-block: 32px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  gap: 28px;
}

/* Kopf */
.head { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: end; }
.eyebrow { margin: 0 0 6px; font: 600 12px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 0; font: 700 clamp(34px, 6vw, 56px)/1 var(--f-display); letter-spacing: -0.02em; }
.lede { margin: 12px 0 0; max-width: 60ch; color: var(--muted); font-size: 16px; }
.specs { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.specs div { background: var(--surface); padding: 10px 12px; }
.specs dt { font: 600 11px/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.specs dd { margin: 4px 0 0; font: 600 14px/1.3 var(--f-mono); font-variant-numeric: tabular-nums; }

/* Abschnitte */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 16px; min-width: 0; }
.block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
h2 { margin: 0; font: 700 22px/1.2 var(--f-display); letter-spacing: -0.01em; text-wrap: balance; }
h3 { margin: 0 0 6px; font: 700 16px/1.3 var(--f-display); }
.sub { margin: 0; font: 500 13px/1.4 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.note { margin: 0; font-size: 13px; color: var(--muted); }
.prose { display: grid; gap: 10px; align-content: start; max-width: 60ch; min-width: 0; }
.prose p { margin: 0; }

/* Bedienelemente */
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn, .btn, .chip {
  font: 600 13px/1 var(--f-body); color: var(--fg); background: var(--surface);
  border: 0; padding: 9px 12px; cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn { border: 1px solid var(--line); border-radius: 8px; }
.btn:hover, .seg-btn:hover:not([aria-pressed="true"]) { background: var(--sunk); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; display: inline-flex; align-items: center; gap: 7px; }
.chip .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.chip:disabled { opacity: .4; cursor: default; }

/* Modell */
.model-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; }
.viewer { position: relative; background: var(--sunk); border-radius: 10px; overflow: hidden; min-width: 0; }
#cv { display: block; width: 100%; aspect-ratio: 4 / 3.2; max-height: 72vh; touch-action: pan-y; cursor: grab; }
#cv.dragging { cursor: grabbing; }
.hint { position: absolute; left: 10px; bottom: 8px; margin: 0; font: 500 11px/1.3 var(--f-mono); color: var(--muted); pointer-events: none; }
.tip { position: absolute; pointer-events: none; background: var(--fg); color: var(--bg); font: 600 12px/1.35 var(--f-body); padding: 6px 8px; border-radius: 6px; max-width: 260px; transform: translate(12px, 12px); }
.info { display: grid; gap: 14px; align-content: start; min-width: 0; }
.info h3 { font-size: 18px; }
.info p { margin: 0; color: var(--muted); }
.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini td { padding: 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.mini td:last-child { text-align: right; font-family: var(--f-mono); white-space: nowrap; padding-left: 10px; font-variant-numeric: tabular-nums; }

/* Draufsicht */
.two { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.svgbox { background: var(--sunk); border-radius: 10px; padding: 8px; min-width: 0; }
#top { display: block; width: 100%; height: auto; max-height: 560px; }
#top text { font-family: var(--f-mono); }

/* Zuschnitt */
.cuts { display: grid; gap: 10px; overflow-x: auto; }
.cut { display: grid; grid-template-columns: 210px minmax(0, 1fr) 48px; gap: 12px; align-items: center; min-width: 520px; }
.cut-name { font-size: 14px; }
.cut-name small { display: block; color: var(--muted); font: 500 12px/1.3 var(--f-mono); }
.cut-track { position: relative; height: 26px; }
.cut-bar { height: 100%; border-radius: 3px; background: linear-gradient(180deg, var(--m-alu), var(--m-rail)); display: flex; align-items: center; padding-left: 8px; font: 600 12px/1 var(--f-mono); color: #10151b; }
.cut-bar.p2020 { height: 66%; margin-top: 4px; }
.cut-qty { font: 700 15px/1 var(--f-mono); text-align: right; }
.cut-scale { display: grid; grid-template-columns: 210px minmax(0, 1fr) 48px; gap: 12px; min-width: 520px; }
.cut-scale .ticks { position: relative; height: 18px; border-top: 1px solid var(--line); }
.cut-scale span { position: absolute; top: 3px; transform: translateX(-50%); font: 500 11px/1 var(--f-mono); color: var(--muted); }

/* Teileliste */
.pgroup { border-top: 1px solid var(--line); padding-top: 12px; }
.pgroup + .pgroup { margin-top: 16px; }
.pgroup-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.pgroup-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.pgroup-head .dot { width: 12px; height: 12px; border-radius: 3px; }
.tag { font: 600 11px/1 var(--f-mono); letter-spacing: .04em; padding: 4px 7px; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.tag.later { background: var(--accent-soft); color: var(--accent); }
.tbl-wrap { overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.ptable th { text-align: left; font: 600 11px/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; }
.ptable td { padding: 8px; border-top: 1px solid var(--line); vertical-align: top; }
.ptable td.num { font-family: var(--f-mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ptable td.price { text-align: right; }
.ptable th.price { text-align: right; }
.ptable small { color: var(--muted); }
.ptable tr.done td:not(.chk) { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Ablauf */
.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; counter-reset: f; }
.flow li { position: relative; background: var(--sunk); border-radius: 10px; padding: 12px; counter-increment: f; min-width: 0; }
.flow li::before { content: counter(f); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 700 12px/1 var(--f-mono); margin-bottom: 8px; }
.flow li:not(:last-child)::after { content: "→"; position: absolute; right: -10px; top: 14px; color: var(--accent); font: 700 14px/1 var(--f-mono); }
.flow b { display: block; font: 700 14px/1.3 var(--f-display); }
.flow span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }

/* Phasen */
.phases { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; counter-reset: p; }
.phases li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; counter-increment: p; padding-bottom: 14px; position: relative; }
.phases li::before { content: counter(p); width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--accent); color: var(--accent); display: grid; place-items: center; font: 700 14px/1 var(--f-mono); background: var(--surface); position: relative; z-index: 1; }
.phases li:not(:last-child)::after { content: ""; position: absolute; left: 16px; top: 32px; bottom: 0; width: 2px; background: var(--line); }
.phases li.later::before { border-style: dashed; }
.phases b { font: 700 15px/1.3 var(--f-display); }
.phases p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.open { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.foot a { color: var(--muted); }

@media (max-width: 900px) {
  .head, .model-grid, .two { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow li::after { display: none; }
}
@media (max-width: 480px) {
  .block { padding: 14px; }
  .flow { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* Überwachung */
.watch { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.watch li { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-width: 0; }
.watch li:not(:last-child)::after { content: "→"; position: absolute; right: -10px; top: 14px; color: var(--m-cam); font: 700 14px/1 var(--f-mono); }
.watch b { display: block; font: 700 14px/1.3 var(--f-display); }
.watch span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.watch .where { font: 600 11px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--m-cam); margin: 0 0 6px; }
@media (max-width: 900px) { .watch { grid-template-columns: repeat(2, minmax(0, 1fr)); } .watch li::after { display: none; } }
@media (max-width: 480px) { .watch { grid-template-columns: minmax(0, 1fr); } }
