:root {
  --bg: #0e1012;
  --panel: #15181b;
  --panel-2: #1b1f23;
  --line: #2a3036;
  --line-soft: #22272c;
  --text: #ece8df;
  --muted: #8b9198;
  --dim: #5d646b;
  --warn: #ffb347;
  --ok: #7bd389;
  --f1: #232f3e;
  --f2: #ff9900;
  --display: "Archivo", ui-sans-serif, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --r: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--display);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--f2); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ───────────── layout ───────────── */
.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  height: 100vh;
  height: 100dvh;
}
.app > * { min-width: 0; } /* let grid columns shrink below their content width */
.panel {
  background: var(--panel);
  overflow-y: auto;
  padding: 20px 18px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.services { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.settings { border-left: 1px solid var(--line); }

/* ───────────── brand ───────────── */
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand-mark { width: 34px; height: 34px; flex: none; fill: none; stroke: var(--f2); stroke-width: 3; transition: stroke .3s; }
.brand h1 {
  margin: 0; font-size: 19px; font-weight: 850; font-stretch: 125%;
  text-transform: uppercase; letter-spacing: .02em; line-height: 1;
}
.brand p { margin: 4px 0 0; font: 11px var(--mono); color: var(--muted); }

.step {
  display: flex; align-items: baseline; gap: 10px;
  margin: 22px 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 800; font-stretch: 125%; text-transform: uppercase; font-size: 12px; letter-spacing: .08em;
}
.step:first-of-type { margin-top: 0; }
.step span { font: 600 11px var(--mono); color: var(--f2); letter-spacing: 0; transition: color .3s; }

/* ───────────── search + chips ───────────── */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 0 10px; height: 40px;
}
.search:focus-within { border-color: var(--f2); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; flex: none; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; height: 100%; }
.search input::placeholder { color: var(--dim); }
.search kbd { font: 11px var(--mono); color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 10px; scrollbar-width: none; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: transparent; border-radius: 99px;
  padding: 4px 10px; font: 500 11.5px var(--mono); color: var(--muted); white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ───────────── service list ───────────── */
.service-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start; }
.svc {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px 9px; border-radius: var(--r);
  border: 1px solid transparent; background: var(--panel-2);
  text-align: center; font-size: 10.5px; line-height: 1.2; color: var(--muted);
  animation: rise .35s both;
}
.svc img { width: 40px; height: 40px; border-radius: 6px; transition: transform .2s; }
.svc:hover { color: var(--text); border-color: var(--line); }
.svc:hover img { transform: translateY(-2px) rotate(-3deg); }
.svc.on { color: var(--text); border-color: var(--svc); box-shadow: inset 0 0 0 1px var(--svc); }
.svc.on::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--svc);
}
.svc span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.count { font: 11px var(--mono); color: var(--dim); margin: 14px 0 0; }
.empty { grid-column: 1 / -1; color: var(--dim); font: 12px var(--mono); padding: 24px 0; text-align: center; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ───────────── stage ───────────── */
.stage { position: relative; overflow: hidden; background:
  radial-gradient(120% 80% at 50% 0%, #1d2227 0%, var(--bg) 60%); }
.viewer { position: absolute; inset: 0; }
.viewer canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.viewer canvas:active { cursor: grabbing; }

.stage-head {
  position: absolute; top: 22px; left: 26px; right: 150px;
  display: flex; gap: 14px; align-items: center; pointer-events: none;
}
.stage-head img { border-radius: 8px; box-shadow: 0 6px 24px #0008; }
.stage-head img:not([src]) { visibility: hidden; }
.eyebrow { margin: 0; font: 500 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stage-head h2 {
  margin: 2px 0 0; font-size: clamp(22px, 3.2vw, 40px); font-weight: 850; font-stretch: 112%;
  line-height: 1; letter-spacing: -.01em; text-shadow: 0 2px 18px #000a;
}

.stage-tools { position: absolute; left: 26px; bottom: 22px; display: flex; gap: 8px; flex-wrap: wrap; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px;
  background: #0e1012cc; border: 1px solid var(--line); backdrop-filter: blur(6px);
}
.seg button {
  border: 0; background: none; padding: 6px 11px; border-radius: 6px;
  font: 500 12px var(--mono); color: var(--muted);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--text); color: var(--bg); }
.seg.wide { display: flex; background: var(--panel-2); }
.seg.wide button { flex: 1; }

.status {
  position: absolute; top: 26px; right: 26px; display: flex; align-items: center; gap: 8px;
  font: 500 11.5px var(--mono); color: var(--muted);
  background: #0e1012cc; border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px;
  backdrop-filter: blur(6px);
}
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status.busy i { background: var(--f2); animation: pulse .9s ease-in-out infinite; }
.status.err { color: var(--warn); border-color: #5a4320; }
.status.err i { background: var(--warn); }
@keyframes pulse { 50% { transform: scale(.5); opacity: .5; } }

.readout {
  position: absolute; right: 26px; bottom: 22px; margin: 0;
  display: grid; grid-template-columns: repeat(4, auto); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.readout div { background: #0e1012e6; padding: 8px 12px; backdrop-filter: blur(6px); }
.readout dt { font: 10px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.readout dd { margin: 2px 0 0; font: 500 13px var(--mono); white-space: nowrap; }

/* ───────────── settings ───────────── */
.hint { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
.hint b { color: var(--text); font-weight: 600; }

.sliders { display: grid; gap: 14px; margin-top: 18px; }
.slider label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.slider output { font: 500 12px var(--mono); color: var(--text); }
.slider output small { color: var(--dim); }
.slider input[type=range] { width: 100%; margin: 7px 0 0; accent-color: var(--f2); height: 18px; }
.slider .sub { font: 10.5px var(--mono); color: var(--dim); }
.slider.hidden { display: none; }
.slider button.reset {
  border: 0; background: none; padding: 0 0 0 6px; color: var(--dim); font: 11px var(--mono); visibility: hidden;
}
.slider.changed button.reset { visibility: visible; }
.slider button.reset:hover { color: var(--f2); }

.filaments { display: grid; gap: 14px; }
.fil-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.fil-head b { display: block; font-size: 13px; }
.fil-head small { font: 11px var(--mono); color: var(--dim); }
.spool {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: radial-gradient(circle, var(--bg) 0 22%, transparent 23%),
              repeating-radial-gradient(circle, #fff1 0 1px, transparent 1px 3px), var(--c, #888);
  box-shadow: inset 0 0 0 2px #0006, 0 0 0 1px var(--line);
}
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw {
  width: 26px; height: 26px; border-radius: 6px; border: 0; padding: 0; background: var(--c);
  box-shadow: inset 0 0 0 1px #ffffff1f; position: relative;
}
.sw:hover { transform: translateY(-1px); }
.sw.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.sw.svc-colour::after {
  content: "AWS"; position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 7.5px var(--mono); color: #fff; letter-spacing: .02em;
}
.sw.custom { overflow: hidden; background: conic-gradient(#f55, #fd5, #5f8, #5cf, #a6f, #f55); }
.sw.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.print-grid label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.print-grid select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; height: 36px; padding: 0 8px;
  font: 500 13px var(--mono);
}
.pause {
  margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  background: var(--panel-2);
}
.pause .big { display: flex; align-items: center; gap: 14px; padding: 14px; }
.pause .layer {
  font: 800 34px/1 var(--display); font-stretch: 125%; color: var(--f2); min-width: 58px; text-align: center;
  transition: color .3s;
}
.pause .big p { margin: 0; font-size: 12.5px; color: var(--muted); }
.pause .big p b { color: var(--text); font-weight: 600; }
.pause ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.pause li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 14px; font: 11.5px var(--mono); color: var(--muted); }
.pause li + li { border-top: 1px solid var(--line-soft); }
.pause li b { color: var(--text); font-weight: 500; text-align: right; }
.pause .warn { padding: 12px 14px; font-size: 12.5px; color: var(--warn); }
.pause .warn button {
  margin-top: 8px; display: block; border: 1px solid #5a4320; background: #2a2114; color: var(--warn);
  border-radius: 6px; padding: 5px 10px; font: 500 12px var(--mono);
}

.downloads { display: grid; gap: 8px; margin-top: 18px; }
.btn {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); text-decoration: none; font-weight: 700;
  transition: transform .15s, background .2s;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn small { margin-left: auto; font: 500 11px var(--mono); opacity: .7; }
.btn:hover { transform: translateY(-1px); border-color: var(--muted); }
.btn.primary { background: var(--f2); border-color: transparent; color: var(--on-f2, #111); }
.btn[aria-disabled=true] { pointer-events: none; opacity: .4; }
.fine { margin: 18px 0 0; font: 10.5px var(--mono); color: var(--dim); }

/* ───────────── responsive ───────────── */
@media (max-width: 1100px) {
  .app { grid-template-columns: 280px minmax(0, 1fr); grid-template-rows: 1fr auto; }
  .settings { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line);
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); column-gap: 28px; }
  .app { height: auto; }
  .stage { min-height: 70vh; }
  .services { max-height: 70vh; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .stage { order: -1; min-height: 78vh; }
  .viewer { top: 70px; bottom: 170px; } /* keep the tile clear of the readout + buttons */
  .services { max-height: none; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
  .settings { display: block; padding: 16px; }
  .service-list { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); max-height: 46vh; overflow-y: auto; }
  .stage-head { left: 16px; right: 16px; top: 16px; }
  .stage-head h2 { font-size: 22px; overflow-wrap: anywhere; }
  .status { top: auto; bottom: 64px; right: 16px; }
  .stage-tools { left: 16px; bottom: 16px; }
  .readout { left: 16px; right: 16px; bottom: 104px; grid-template-columns: repeat(2, 1fr); }
  .readout div { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ───────────── call to builders ───────────── */
:root { --printed: #7bd389; --claimed: #ffb347; }
.drive {
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px 12px 10px; margin-bottom: 22px;
  background: linear-gradient(180deg, #1c2024, var(--panel-2));
}
.drive-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.drive-head b { font-weight: 800; font-stretch: 125%; text-transform: uppercase; font-size: 12px; letter-spacing: .06em; }
.drive-head span { font: 500 12px var(--mono); color: var(--muted); }
.drive-bar { position: relative; height: 8px; border-radius: 99px; background: #0e1012; margin: 10px 0 8px; overflow: hidden; }
.drive-bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
#drive-claimed { background: repeating-linear-gradient(45deg, var(--claimed) 0 4px, #c98a2e 4px 8px); }
#drive-printed { background: var(--printed); }
.drive-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font: 11px var(--mono); color: var(--muted); }
.drive-legend b { color: var(--text); font-weight: 600; }
.drive-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.k-printed { background: var(--printed); }
.k-claimed { background: var(--claimed); }
.status-filter { margin-top: 10px; }
.status-filter button { padding: 5px 4px; font-size: 11.5px; }

/* service tile badges */
.svc .badge {
  position: absolute; top: 5px; left: 5px; height: 16px; min-width: 16px; padding: 0 4px; border-radius: 99px;
  display: grid; place-items: center; font: 700 9.5px var(--mono); color: #111;
}
.svc .badge.claimed { background: var(--claimed); }
.svc .badge.printed { background: var(--printed); }
.svc .crowd { position: absolute; top: 5px; right: 5px; font: 600 9.5px var(--mono); color: var(--muted); }
.svc.on .crowd { right: 18px; }

/* crew card on the stage */
.crew {
  position: absolute; top: 132px; left: 26px; width: min(340px, calc(100% - 52px));
  background: #0e1012e6; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  backdrop-filter: blur(8px); box-shadow: 0 12px 40px #0007; animation: rise .35s both;
}
.crew .state { display: flex; align-items: center; gap: 10px; }
.crew .pip { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--dim); box-shadow: 0 0 0 4px #ffffff0d; }
.crew .pip.printing { background: var(--claimed); }
.crew .pip.printed { background: var(--printed); }
.crew .state p { margin: 0; font-size: 13.5px; }
.crew .state p b { font-weight: 700; }
.crew .state small { display: block; font: 11px var(--mono); color: var(--muted); margin-top: 2px; }
.crew ul { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line-soft);
  display: flex; flex-wrap: wrap; gap: 5px; max-height: 92px; overflow: auto; }
.crew li { font: 11px var(--mono); padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.crew li.printed { border-color: #2e5a37; color: var(--printed); }
.crew li.me { color: var(--text); border-color: var(--muted); }
.crew .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.crew .actions button {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 7px 11px;
  font: 600 12.5px var(--display);
}
.crew .actions button:hover { border-color: var(--muted); }
.crew .actions button.primary { background: var(--f2); color: var(--on-f2, #111); border-color: transparent; }
.crew .actions button.quiet { color: var(--muted); font-weight: 500; }
.crew .you { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); }
.crew .you b { color: var(--text); }

/* claim dialog */
.claim-dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(420px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); box-shadow: 0 30px 80px #000c;
}
.claim-dialog::backdrop { background: #05060799; backdrop-filter: blur(3px); }
.claim-dialog form { padding: 22px; display: grid; gap: 14px; }
.claim-dialog h3 { margin: 2px 0 0; font-size: 22px; font-weight: 850; font-stretch: 112%; line-height: 1.1; }
.cd-lead { margin: -6px 0 0; color: var(--muted); font-size: 13px; }
.claim-dialog label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.claim-dialog label small { font: 400 11px var(--mono); color: var(--dim); }
.claim-dialog input:not([type=radio]) {
  height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); padding: 0 12px; font-weight: 400;
}
.claim-dialog input:focus { outline: 2px solid var(--f2); outline-offset: 1px; }
.claim-dialog fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.claim-dialog .radio {
  display: flex; grid-template-columns: none; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400;
}
.claim-dialog .radio:has(input:checked) { border-color: var(--f2); background: #ffffff06; }
.claim-dialog .radio input { margin: 3px 0 0; accent-color: var(--f2); }
.claim-dialog .radio b { display: block; font-weight: 700; }
.claim-dialog .radio small { font: 11px var(--mono); color: var(--muted); }
.cd-error { margin: 0; color: var(--warn); font-size: 12.5px; min-height: 0; }
.cd-error:empty { display: none; }
.cd-actions { display: flex; justify-content: flex-end; gap: 8px; }
.cd-actions .btn { padding: 10px 16px; }
.cd-actions .btn[disabled] { opacity: .5; pointer-events: none; }

@media (max-width: 720px) {
  .crew { position: static; width: auto; margin: 0 16px; animation: none; }
  .stage { display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 64px; }
  .viewer { bottom: 300px; }
}

/* ───────────── standard-tile lock ───────────── */
.lockbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2);
}
.lockbar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--printed); stroke-width: 1.8; }
.lockbar p { margin: 0; flex: 1; min-width: 0; font-size: 13px; }
.lockbar p b { display: block; font-weight: 700; }
.lockbar p span { display: block; font: 11px var(--mono); color: var(--muted); }
.lockbar button {
  flex: none; border: 1px solid var(--line); background: transparent; border-radius: 7px;
  padding: 6px 10px; font: 600 12px var(--display);
}
.lockbar button:hover { border-color: var(--muted); }
.lockbar.custom { border-color: #5a4320; background: #2a2114; }
.lockbar.custom svg { stroke: var(--warn); }
.lockbar.custom p b { color: var(--warn); }
.lockbar.custom button { border-color: var(--warn); color: var(--warn); }
.shape { border: 0; margin: 0; padding: 0; min-width: 0; transition: opacity .2s; }
.shape:disabled { opacity: .5; }
.shape:disabled * { cursor: not-allowed; }
.shape:disabled .slider button.reset { visibility: hidden; }
.claim-dialog .cd-lead b { color: var(--text); }
