:root {
  --cream: #f4efe6;
  --paper: #fffdf8;
  --ink: #1b1a17;
  --soft: #6e6a62;
  --orange: #ff5a1f;
  --teal: #0f9d8a;
  --yellow: #ffc83d;
  --red: #d7263d;
  --steel-1: #dfe3ea;
  --steel-2: #aeb5c2;
  --steel-3: #7c8494;
  --belt-1: #3a3f4a;
  --belt-2: #262a33;
  --belt-3: #171a20;
  --cycle: 9s;
  --app-theme: #24292f;
  --app-theme-light: #3a4048;
  --app-theme-dark: #15181c;
  --app-bg: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: radial-gradient(circle at 1px 1px, rgba(27,26,23,0.12) 1px, transparent 1.5px);
  background-size: 26px 26px;
}

.page { max-width: 1280px; margin: 0 auto; padding: 28px 28px 80px; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }

.logo {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.04em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.logo i { width: 44px; height: 44px; background: url('/icon-3d.png') center / contain no-repeat; flex: none; }

.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; min-width: 0; }

.nav a {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a:hover, .nav a[aria-current="page"] { border-bottom-color: var(--orange); }

.status { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal); }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 0 rgba(15,157,138,0.6); animation: beacon 1.6s ease-out infinite; }
@keyframes beacon { to { box-shadow: 0 0 0 10px rgba(15,157,138,0); } }

.layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr); gap: 32px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 3D factory ---------- */
.factory { position: sticky; top: 28px; background: var(--paper); border: 2px solid var(--ink); border-radius: 24px; height: 640px; overflow: hidden; box-shadow: 8px 8px 0 var(--ink); }
@media (max-width: 980px) {
  .layout > .factory { position: relative; top: auto; height: clamp(230px, 50vw, 420px); background: none; border: 0; border-radius: 0; box-shadow: none; }
  .layout .factory .legend { display: none; }
  .factory .iso { transform: translate(-50%, -50%) scale(var(--s, 0.3)) rotateX(60deg) rotateZ(-45deg); }
}

.factory .label, .blueprint .label { position: absolute; top: 18px; left: 22px; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; z-index: 2; }
.factory .legend { position: absolute; bottom: 16px; left: 22px; right: 22px; display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--soft); z-index: 2; flex-wrap: wrap; gap: 8px; }
.legend b { color: var(--ink); }
.legend span.active b { color: var(--orange); }

.iso { position: absolute; left: 50%; top: 50%; width: 760px; height: 460px; transform: translate(-50%, -34%) scale(var(--s, 0.9)) rotateX(60deg) rotateZ(-45deg); transform-style: preserve-3d; }
@media (max-width: 1200px) { .iso { --s: 0.78; } }
@media (max-width: 980px) { .iso { --s: 0.85; } }
@media (max-width: 560px) { .iso { --s: 0.55; } }

.floor { position: absolute; inset: 0; background: linear-gradient(rgba(27,26,23,0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(27,26,23,0.08) 1px, transparent 1px), #ece6da; background-size: 40px 40px; border: 2px solid var(--ink); }

.box { position: absolute; width: var(--w); height: var(--h); transform-style: preserve-3d; transform: translate3d(var(--x, 0px), var(--y, 0px), var(--z, 0px)); }
.box > .f { position: absolute; left: 0; top: 0; outline: 1px solid rgba(27,26,23,0.35); outline-offset: -1px; }
.box > .top { width: var(--w); height: var(--h); transform: translateZ(var(--d)); background: var(--c1); }
.box > .front { top: var(--h); width: var(--w); height: var(--d); transform-origin: top; transform: rotateX(90deg); background: var(--c2); }
.box > .left { width: var(--d); height: var(--h); transform-origin: left; transform: rotateY(-90deg); background: var(--c3); }

.steel { --c1: var(--steel-1); --c2: var(--steel-2); --c3: var(--steel-3); }
.dark { --c1: var(--belt-1); --c2: var(--belt-2); --c3: var(--belt-3); }
.orange-box { --c1: #ff7a48; --c2: var(--orange); --c3: #c53f0f; }
.teal-box { --c1: #3cc2b0; --c2: var(--teal); --c3: #0a6e60; }

.belt { --w: 600px; --h: 90px; --d: 18px; --x: 60px; --y: 195px; }
.belt > .top { background: repeating-linear-gradient(90deg, #4a505c 0 16px, #2f343d 16px 32px); animation: roll 0.6s linear infinite; }
@keyframes roll { to { background-position-x: 32px; } }
.belt > .front, .belt > .left { background: var(--belt-2); }

.pillar { --w: 16px; --h: 16px; --d: 110px; }
.scan-beam { --w: 16px; --h: 156px; --d: 12px; --z: 110px; }
.laser { position: absolute; left: 186px; top: 197px; width: 4px; height: 86px; transform: translateZ(19px); background: var(--orange); box-shadow: 0 0 14px 4px rgba(255,90,31,0.7); animation: laser-blink 0.4s steps(2) infinite; }
@keyframes laser-blink { to { opacity: 0.35; } }

.press-leg { --w: 26px; --h: 26px; --d: 150px; }
.press-top { --w: 26px; --h: 176px; --d: 22px; --z: 150px; }
.press-head { --w: 74px; --h: 74px; --d: 34px; --x: 336px; --y: 203px; animation: stamp var(--cycle) cubic-bezier(.7,0,.3,1) infinite; }
@keyframes stamp {
  0%, 40% { transform: translate3d(336px, 203px, 118px); }
  46%, 52% { transform: translate3d(336px, 203px, 24px); }
  58%, 100% { transform: translate3d(336px, 203px, 118px); }
}

.tank { --w: 34px; --h: 34px; --d: 46px; --z: 96px; }
.tank-post { --w: 14px; --h: 14px; --d: 96px; }
.tank-arm { --w: 14px; --h: 120px; --d: 10px; --z: 96px; }
.tank.teal-box { --c1: color-mix(in srgb, var(--app-theme) 70%, white); --c2: var(--app-theme); --c3: var(--app-theme-dark); }
.drip { position: absolute; left: 512px; top: 236px; width: 8px; height: 8px; border-radius: 50%; background: var(--app-theme); animation: drip 1.2s ease-in infinite; }
.drip:nth-child(2) { animation-delay: 0.4s; left: 518px; }
.drip:nth-child(3) { animation-delay: 0.8s; left: 506px; }
@keyframes drip {
  0% { transform: translateZ(92px) scale(0.6); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateZ(20px) scale(1.1); opacity: 0; }
}

.slab { --w: 64px; --h: 64px; --d: 6px; --c1: #ffffff; --c2: #d8d8d8; --c3: #bdbdbd; animation: slab-run var(--cycle) linear infinite; }
.slab > .top {
  background:
    linear-gradient(#cfcfcf, #cfcfcf) 10px 12px / 44px 5px no-repeat,
    linear-gradient(#e2e2e2, #e2e2e2) 10px 22px / 30px 4px no-repeat,
    linear-gradient(#e2e2e2, #e2e2e2) 10px 30px / 38px 4px no-repeat,
    linear-gradient(var(--orange), var(--orange)) 10px 44px / 18px 8px no-repeat,
    #ffffff;
}
@keyframes slab-run {
  0% { transform: translate3d(70px, 208px, 18px); opacity: 0; }
  4% { opacity: 1; }
  44% { transform: translate3d(341px, 208px, 18px); opacity: 1; }
  47% { transform: translate3d(341px, 208px, 18px); opacity: 0; }
  100% { transform: translate3d(341px, 208px, 18px); opacity: 0; }
}

.cube, .showcase { --c1: var(--app-theme-light); --c2: var(--app-theme); --c3: var(--app-theme-dark); }
.cube { --w: 64px; --h: 64px; --d: 64px; animation: cube-run var(--cycle) linear infinite; }
.cube > .top, .showcase > .top { display: grid; place-items: center; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.4rem; color: #fff; overflow: hidden; }
.cube > .top span, .showcase > .top span { transform: rotate(45deg); }
.cube > .top img, .showcase > .top img { width: 72%; height: 72%; object-fit: contain; transform: rotate(45deg); border-radius: 12%; }
@keyframes cube-run {
  0%, 50% { transform: translate3d(341px, 208px, 18px); opacity: 0; }
  52% { opacity: 1; }
  94% { transform: translate3d(630px, 208px, 18px); opacity: 1; }
  100% { transform: translate3d(660px, 208px, 18px); opacity: 0; }
}

.screenshot { width: 100%; }

.pedestal { --w: 70px; --h: 70px; --d: 12px; --x: 690px; --y: 80px; }
.showcase-wrap { position: absolute; left: 690px; top: 80px; width: 70px; height: 70px; transform-style: preserve-3d; transform: translateZ(12px); }
.showcase { --w: 46px; --h: 46px; --d: 46px; left: 12px; top: 12px; transform-origin: 50% 50%; animation: showcase-spin 7s linear infinite; }
.showcase > .top { font-size: 1rem; }
@keyframes showcase-spin { from { transform: translateZ(0) rotateZ(0deg); } to { transform: translateZ(0) rotateZ(360deg); } }

.halo { position: absolute; left: 690px; top: 80px; width: 70px; height: 70px; border-radius: 50%; border: 2px dashed var(--teal); transform: translateZ(13px) scale(1.4); animation: halo 3s ease-out infinite; }
@keyframes halo { 0% { transform: translateZ(13px) scale(0.9); opacity: 1; } 100% { transform: translateZ(13px) scale(1.9); opacity: 0; } }

.tag { position: absolute; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); background: var(--yellow); border: 2px solid var(--ink); padding: 3px 8px; transform-origin: left bottom; transform: rotateZ(45deg) rotateX(-60deg); white-space: nowrap; }
.tag.active { background: var(--orange); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .factory *, .blueprint * { animation-duration: 0s !important; animation-iteration-count: 1 !important; }
}

/* ---------- Control panel ---------- */
.panel { background: var(--paper); border: 2px solid var(--ink); border-radius: 24px; padding: 32px; box-shadow: 8px 8px 0 var(--ink); display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 560px) { .panel { padding: 22px; } }
@media (max-width: 980px) {
  .layout > .panel { padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
}

h1 { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: clamp(2.2rem, 4vw, 3.2rem); line-height: 0.95; letter-spacing: -0.04em; margin-bottom: 14px; }
h1 em { font-style: normal; color: var(--orange); }
h2 { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.5rem; letter-spacing: -0.03em; margin-bottom: 10px; }
.lede { color: var(--soft); line-height: 1.55; margin-bottom: 28px; }

.field { margin-bottom: 16px; min-width: 0; }
.field label, .field .label { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 6px; }
.field .hint { display: block; font-size: 0.75rem; color: var(--soft); margin-top: 6px; line-height: 1.4; overflow-wrap: anywhere; }

.field input[type="text"], .field input[type="url"], .field select {
  width: 100%; border: 2px solid var(--ink); background: #fff; border-radius: 12px; padding: 13px 14px;
  font-family: inherit; font-size: 1rem; font-weight: 500; color: var(--ink); outline: none; transition: box-shadow 0.15s, transform 0.15s;
}
.field input:focus, .field select:focus { box-shadow: 4px 4px 0 var(--teal); transform: translate(-2px, -2px); }
.field input[aria-invalid="true"] { border-color: var(--red); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }

.colour { display: flex; gap: 8px; align-items: stretch; }
.colour input[type="color"] { width: 50px; flex: none; border: 2px solid var(--ink); border-radius: 12px; padding: 3px; background: #fff; cursor: pointer; }
.colour input[type="text"] { font-family: ui-monospace, "Cascadia Mono", monospace; min-width: 0; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.segmented button { border: 0; background: #fff; font-family: inherit; font-weight: 700; font-size: 0.85rem; padding: 12px 6px; cursor: pointer; color: var(--ink); }
.segmented button + button { border-left: 2px solid var(--ink); }
.segmented button.on, .segmented button[aria-pressed="true"] { background: var(--yellow); }

/* toggle */
.toggle, .field label.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 2px solid var(--ink); border-radius: 12px; padding: 12px 14px; background: #fff; cursor: pointer; position: relative; text-transform: none; letter-spacing: 0; font-size: 1rem; font-weight: 500; margin-bottom: 0; }
.toggle .text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle .text b { font-size: 0.9rem; font-weight: 700; }
.toggle .text small { color: var(--soft); font-size: 0.75rem; line-height: 1.35; }
.toggle .text code { font-size: 0.72rem; background: var(--cream); padding: 0 4px; border-radius: 4px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .knob { flex: none; width: 48px; height: 28px; border: 2px solid var(--ink); border-radius: 999px; background: var(--steel-1); position: relative; transition: background 0.15s; }
.toggle .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform 0.15s; }
.toggle input:checked + .knob { background: var(--teal); }
.toggle input:checked + .knob::after { transform: translateX(20px); background: #fff; }
.toggle input:focus-visible + .knob { box-shadow: 0 0 0 3px var(--yellow); }
.info-card { border: 2px solid var(--ink); border-radius: 12px; padding: 14px; background: #fff; color: var(--soft); font-size: 0.85rem; line-height: 1.5; }

.go {
  margin-top: 8px; border: 2px solid var(--ink); border-radius: 14px; padding: 18px; background: var(--orange); color: #fff;
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink); transition: transform 0.12s, box-shadow 0.12s; width: 100%;
}
.go:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.go:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.go[disabled] { opacity: 0.6; cursor: progress; transform: none; box-shadow: 5px 5px 0 var(--ink); }
.go.secondary { background: #fff; color: var(--ink); }
.go.teal { background: var(--teal); }
#scan-btn, #press-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.go .button-icon { width: 28px; height: 28px; flex: none; object-fit: contain; }

.btn { border: 2px solid var(--ink); border-radius: 10px; padding: 9px 14px; background: #fff; color: var(--ink); font-family: inherit; font-weight: 700; font-size: 0.85rem; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); transition: transform 0.12s, box-shadow 0.12s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--orange); color: #fff; }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }
.btn.link { border: 0; box-shadow: none; padding: 4px 0; text-decoration: underline; }
.btn.link:hover, .btn.link:active { transform: none; box-shadow: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.meter { margin-top: 18px; display: flex; justify-content: space-between; gap: 12px; font-size: 0.75rem; color: var(--soft); flex-wrap: wrap; }
.meter b { color: var(--ink); font-size: 1.1rem; font-family: "Bricolage Grotesque", sans-serif; }

.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps span { flex: 1; height: 6px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; }
.steps span.done { background: var(--teal); }
.steps span.now { background: var(--yellow); }

.notice { border: 2px solid var(--ink); border-radius: 12px; padding: 12px 14px; font-size: 0.85rem; line-height: 1.45; margin-bottom: 16px; background: var(--yellow); }
.notice.error { background: #ffe1e5; border-color: var(--red); color: #7a0f1d; }
.notice.info { background: #e3f6f2; }
.notice.warn { background: #fff4d6; }
.notice ul { padding-left: 18px; margin-top: 4px; }
[hidden] { display: none !important; }

/* icon picker */
.icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; }
.icons button, .icons label {
  aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 14px; background: #fff; display: grid; place-items: center; cursor: pointer; padding: 6px; position: relative; overflow: hidden;
  font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--soft); text-align: center;
}
.icons button img { width: 100%; height: 100%; object-fit: contain; }
.icons button.on { box-shadow: 4px 4px 0 var(--teal); transform: translate(-2px, -2px); }
.icons button.on::after { content: "✓"; position: absolute; right: 4px; bottom: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--teal); color: #fff; font-size: 0.7rem; display: grid; place-items: center; }
.icons label input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.icons label { border-style: dashed; }

/* preview card */
.preview { display: flex; gap: 16px; align-items: center; border: 2px solid var(--ink); border-radius: 16px; padding: 14px; margin-bottom: 18px; background: var(--app-bg); color: var(--ink); }
.preview .titlebar { position: relative; flex: 1; min-width: 0; }
.preview .titlebar .bar { height: 32px; border-radius: 8px 8px 0 0; background: var(--app-theme); display: flex; align-items: center; padding: 0 10px; gap: 6px; color: #fff; font-size: 0.78rem; font-weight: 700; overflow: hidden; }
.preview .titlebar .bar i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.7); flex: none; }
.preview .titlebar .bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.preview .titlebar .bar .dots { margin-left: auto; letter-spacing: 3px; }
.preview .titlebar .body { height: 50px; border: 2px solid var(--ink); border-top: 0; border-radius: 0 0 8px 8px; background: #fff; color: var(--soft); font-size: 0.72rem; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 8px; overflow: hidden; }
.preview .body code { font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
.preview .homeicon { flex: none; width: 84px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 700; text-align: center; }
.preview .homeicon img { width: 64px; height: 64px; border-radius: 16px; border: 2px solid var(--ink); background: #fff; object-fit: cover; }
.preview .homeicon span { max-width: 84px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* result */
.result-url { display: flex; gap: 8px; align-items: stretch; }
.result-url input { flex: 1; min-width: 0; border: 2px solid var(--ink); border-radius: 12px; padding: 12px 14px; font-family: ui-monospace, "Cascadia Mono", monospace; font-size: 0.9rem; background: #fff; color: var(--ink); }
.token { font-family: ui-monospace, "Cascadia Mono", monospace; font-size: 0.8rem; word-break: break-all; background: #fff; border: 2px dashed var(--ink); border-radius: 10px; padding: 10px; }
.manage-key-field { max-width: 560px; margin: 24px 0; }
.manage-key-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.manage-key-controls .token { flex: 1 1 310px; min-width: 0; letter-spacing: 0; }
.manage-key-controls .btn { flex: none; }
#key-status { min-height: 1.4em; }
ol.guide { padding-left: 20px; line-height: 1.6; font-size: 0.9rem; }
ol.guide li + li { margin-top: 4px; }

/* dashboard */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 24px; }
.card { background: var(--paper); border: 2px solid var(--ink); border-radius: 20px; padding: 20px; box-shadow: 6px 6px 0 var(--ink); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card .head { display: flex; gap: 14px; align-items: center; }
.card .head img { width: 56px; height: 56px; border-radius: 14px; border: 2px solid var(--ink); background: #fff; flex: none; object-fit: cover; }
.card .head b { font-family: "Bricolage Grotesque", sans-serif; font-size: 1.15rem; letter-spacing: -0.02em; display: block; overflow-wrap: anywhere; }
.card .head small { color: var(--soft); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { font-size: 0.75rem; color: var(--soft); display: flex; gap: 8px; flex-wrap: wrap; }
.card .meta span { border: 1.5px solid var(--ink); border-radius: 999px; padding: 2px 8px; color: var(--ink); }
.card .meta span.pa { background: var(--yellow); }
.card .theme { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-block; vertical-align: middle; margin-right: 4px; }
.card .actions { margin-top: auto; }
.empty { text-align: center; padding: 60px 20px; color: var(--soft); border: 2px dashed var(--ink); border-radius: 24px; background: var(--paper); }
.empty h2 { color: var(--ink); }

/* edit dialog */
dialog { border: 2px solid var(--ink); border-radius: 24px; padding: 0; margin: auto; background: var(--paper); color: var(--ink); box-shadow: 8px 8px 0 var(--ink); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(27,26,23,0.55); }
dialog form { padding: 28px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- How it works ---------- */
.how > h1 { max-width: 14ch; }
.how > .lede { max-width: 66ch; }

.blueprint { position: relative; background: var(--paper); border: 2px solid var(--ink); border-radius: 24px; box-shadow: 8px 8px 0 var(--ink); padding: 54px 22px 22px; --cycle: 14s; }
@media (max-width: 560px) { .blueprint { padding: 48px 14px 14px; } }

.line-scroll { border: 2px solid var(--ink); border-radius: 14px; background: #ece6da; overflow-x: auto; scrollbar-width: thin; }
.line { display: block; width: 100%; height: auto; }
@media (max-width: 640px) { .line { width: 680px; max-width: none; } }
.line .ink { stroke: var(--ink); stroke-width: 2; }
.line .outline { fill: none; stroke: var(--ink); stroke-width: 2; }
.line .roller { fill: var(--steel-2); stroke: var(--ink); stroke-width: 2; }
.line .steel { fill: var(--steel-1); stroke: var(--ink); stroke-width: 2; }
.line .steel-dark { fill: var(--steel-2); stroke: var(--ink); stroke-width: 2; }
.line .teal { fill: var(--teal); stroke: var(--ink); stroke-width: 2; }
.line .orange { fill: var(--orange); stroke: var(--ink); stroke-width: 2; }
.line .paper { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.line .ink-fill { fill: var(--ink); }
.line .orange-fill { fill: var(--orange); }
.line .ghost { fill: #d8d8d8; }
.line .screen { fill: #fff; }
.line .url-bar { fill: var(--yellow); stroke: var(--ink); stroke-width: 1.5; }
.line .win { fill: none; stroke: #fff; stroke-width: 1.5; }
.line text { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 13px; text-anchor: middle; fill: var(--ink); letter-spacing: 0.04em; pointer-events: none; }
.line .start { text-anchor: start; }
.line .glyph.light { fill: #fff; }
.line .glyph.small { font-size: 10px; font-weight: 500; letter-spacing: 0; }
.line .tiny { font-size: 9px; }
.line .mono { font-family: ui-monospace, "Cascadia Mono", monospace; font-weight: 500; font-size: 11px; letter-spacing: 0; }
.line .plate rect { fill: var(--yellow); stroke: var(--ink); stroke-width: 2; }
.line .plate text { font-size: 11px; letter-spacing: 0.1em; }

.line .belt-stripes { animation: how-roll 0.6s linear infinite; }
@keyframes how-roll { to { transform: translateX(32px); } }

.line .ticket { animation: how-ticket var(--cycle) ease-in infinite; }
@keyframes how-ticket {
  0% { transform: translateY(0); opacity: 0; }
  1% { opacity: 1; }
  5% { transform: translateY(74px); opacity: 1; }
  6%, 100% { transform: translateY(74px); opacity: 0; }
}

.line .stamp-head { animation: how-stamp var(--cycle) cubic-bezier(.7,0,.3,1) infinite; }
@keyframes how-stamp {
  0%, 29% { transform: translateY(0); }
  33%, 36% { transform: translateY(68px); }
  41%, 100% { transform: translateY(0); }
}

.line .unit { animation: how-unit var(--cycle) linear infinite; }
@keyframes how-unit {
  0%, 5% { transform: translate(120px, 224px); opacity: 0; }
  7% { transform: translate(120px, 224px); opacity: 1; }
  26%, 40% { transform: translate(340px, 224px); opacity: 1; }
  56%, 68% { transform: translate(560px, 224px); opacity: 1; }
  78% { transform: translate(680px, 224px); opacity: 1; }
  79%, 100% { transform: translate(680px, 224px); opacity: 0; }
}
.line .fly { transform-box: fill-box; transform-origin: 50% 100%; opacity: 0; animation: var(--cycle) cubic-bezier(.4,0,.6,1) infinite; }
.line .to-laptop { animation-name: how-fly-laptop; }
.line .to-phone { animation-name: how-fly-phone; }
@keyframes how-fly-laptop {
  0%, 78% { transform: translate(680px, 224px) scale(1); opacity: 0; }
  78.5% { opacity: 1; }
  81% { transform: translate(736px, 150px) scale(0.8); opacity: 1; }
  84% { transform: translate(808px, 196px) scale(0.6); opacity: 1; }
  86%, 100% { transform: translate(808px, 196px) scale(0.6); opacity: 0; }
}
@keyframes how-fly-phone {
  0%, 78% { transform: translate(680px, 224px) scale(1); opacity: 0; }
  78.5% { opacity: 1; }
  81% { transform: translate(800px, 120px) scale(0.8); opacity: 1; }
  84% { transform: translate(921px, 212px) scale(0.6); opacity: 1; }
  86%, 100% { transform: translate(921px, 212px) scale(0.6); opacity: 0; }
}
.line .slip { animation: how-slip var(--cycle) linear infinite; }
@keyframes how-slip { 0%, 33% { opacity: 1; } 34%, 100% { opacity: 0; } }
.line .tile { transform-box: fill-box; transform-origin: 50% 100%; animation: how-tile var(--cycle) cubic-bezier(.2,1.4,.5,1) infinite; }
@keyframes how-tile {
  0%, 33% { opacity: 0; transform: scaleY(0.2); }
  34%, 37% { opacity: 1; transform: scaleY(0.2); }
  41%, 100% { opacity: 1; transform: scaleY(1); }
}

.line .signal { fill: none; stroke: var(--teal); stroke-width: 2; stroke-dasharray: 6 6; transform-box: fill-box; transform-origin: center; opacity: 0; animation: how-signal var(--cycle) ease-out infinite; }
.line .signal + .signal { animation-delay: calc(var(--cycle) * 0.05); }
@keyframes how-signal {
  0%, 56% { opacity: 0; transform: scale(0.6); }
  58% { opacity: 1; }
  68%, 100% { opacity: 0; transform: scale(1.35); }
}
.line .address { opacity: 0; animation: how-address var(--cycle) linear infinite; }
@keyframes how-address { 0%, 57% { opacity: 0; } 60%, 68% { opacity: 1; } 71%, 100% { opacity: 0; } }

.line .installed { fill: var(--ink); opacity: 0; animation: how-installed var(--cycle) linear infinite; }
@keyframes how-installed { 0%, 84% { opacity: 0; } 86%, 100% { opacity: 1; } }
.line .arrow { fill: none; stroke: var(--orange); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 6 5; opacity: 0; animation: how-arrow var(--cycle) linear infinite, how-dash 0.5s linear infinite; }
@keyframes how-arrow { 0%, 87% { opacity: 0; } 89%, 99% { opacity: 1; } 100% { opacity: 0; } }
@keyframes how-dash { to { stroke-dashoffset: -11px; } }
.line .browser { opacity: 0.4; animation: how-browser var(--cycle) linear infinite; }
@keyframes how-browser { 0%, 88% { opacity: 0.4; } 90%, 100% { opacity: 1; } }

.stations { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
@media (max-width: 860px) { .stations { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stations { grid-template-columns: minmax(0, 1fr); } }
.station-card { border: 2px solid var(--ink); border-radius: 14px; padding: 16px; background: #fff; box-shadow: 3px 3px 0 var(--ink); min-width: 0; animation: var(--cycle) linear infinite; }
.station-card b { display: inline-block; font-family: "Bricolage Grotesque", sans-serif; font-size: 0.72rem; letter-spacing: 0.12em; background: var(--yellow); border: 2px solid var(--ink); padding: 2px 7px; margin-bottom: 10px; }
.station-card h3 { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; margin-bottom: 6px; }
.station-card p { font-size: 0.85rem; line-height: 1.5; color: var(--soft); overflow-wrap: anywhere; }
.station-card code { font-size: 0.78rem; background: var(--cream); padding: 0 4px; border-radius: 4px; color: var(--ink); }
.station-card[data-stage="feed"] { animation-name: how-card-feed; }
.station-card[data-stage="press"] { animation-name: how-card-press; }
.station-card[data-stage="ship"] { animation-name: how-card-ship; }
.station-card[data-stage="install"] { animation-name: how-card-install; }
@keyframes how-card-feed {
  0%, 25% { box-shadow: 5px 5px 0 var(--orange); transform: translate(-2px, -2px); border-color: var(--orange); }
  28%, 100% { box-shadow: 3px 3px 0 var(--ink); transform: none; border-color: var(--ink); }
}
@keyframes how-card-press {
  0%, 25% { box-shadow: 3px 3px 0 var(--ink); transform: none; border-color: var(--ink); }
  28%, 41% { box-shadow: 5px 5px 0 var(--orange); transform: translate(-2px, -2px); border-color: var(--orange); }
  44%, 100% { box-shadow: 3px 3px 0 var(--ink); transform: none; border-color: var(--ink); }
}
@keyframes how-card-ship {
  0%, 41% { box-shadow: 3px 3px 0 var(--ink); transform: none; border-color: var(--ink); }
  44%, 67% { box-shadow: 5px 5px 0 var(--orange); transform: translate(-2px, -2px); border-color: var(--orange); }
  70%, 100% { box-shadow: 3px 3px 0 var(--ink); transform: none; border-color: var(--ink); }
}
@keyframes how-card-install {
  0%, 67% { box-shadow: 3px 3px 0 var(--ink); transform: none; border-color: var(--ink); }
  70%, 98% { box-shadow: 5px 5px 0 var(--orange); transform: translate(-2px, -2px); border-color: var(--orange); }
  100% { box-shadow: 3px 3px 0 var(--ink); transform: none; border-color: var(--ink); }
}

.board { margin-top: 52px; }
.board .lede { margin-bottom: 22px; }
.facts { list-style: none; display: grid; gap: 16px; }
.facts li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; align-items: start; background: var(--paper); border: 2px solid var(--ink); border-radius: 18px; padding: 20px 22px; box-shadow: 6px 6px 0 var(--ink); min-width: 0; }
@media (max-width: 640px) { .facts li { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 18px; } }
.chip { display: inline-block; justify-self: start; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; background: var(--yellow); border: 2px solid var(--ink); padding: 3px 9px; white-space: nowrap; margin-top: 3px; }
.facts h3 { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; margin-bottom: 6px; }
.facts p { color: var(--soft); line-height: 1.55; font-size: 0.95rem; overflow-wrap: anywhere; }
.facts p a { color: var(--ink); font-weight: 700; }
.facts code { font-size: 0.85em; background: var(--cream); padding: 0 5px; border-radius: 4px; color: var(--ink); }
.placeholder { margin-top: 14px; border: 2px dashed var(--ink); border-radius: 12px; min-height: 150px; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--soft); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; background: repeating-linear-gradient(-45deg, #fff 0 12px, var(--cream) 12px 24px); }
.board .actions { margin-top: 28px; }

footer { margin-top: 48px; font-size: 0.75rem; color: var(--soft); display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
footer a { color: var(--soft); }
.footer-links { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 16px; margin-left: auto; }
