/* Assembly: workshop floor, graphite belts, painted machines */
@font-face { font-family: "Young Serif"; font-display: swap; src: url(../fonts/young-serif-latin-400-normal.woff2) format("woff2"); }

:root {
  --bg: #E7EAE3;
  --card: #FFFFFF;
  --ink: #23272B;
  --muted: #5F676E;
  --line: #CDD2C9;
  --belt: #2A2D30;
  --belt2: #555B60;
  --mark: #F2B705;
  --add: #2A9D8F;
  --mul: #3A6EA5;
  --sq: #8E5BB5;
  --split: #5C6670;
  --boost: #E07A1F;
  --oc: #D7263D;
  --display: "Young Serif", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16191B; --card: #202427; --ink: #E7EAE3; --muted: #9AA2A8; --line: #33393E; --belt: #0E1012; --belt2: #3A4045; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); line-height: 1.45; min-height: 100vh; }
a { color: inherit; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 14px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 0; }
.back { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.icon-btn:hover { background: var(--card); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 0 10px; }
h1 { font-family: var(--display); font-weight: 400; font-size: 2.2rem; margin: 0; line-height: 1; }
.sub { margin: 0; color: var(--muted); font-size: 0.95rem; }

.hud { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 10px; }
.hud p { margin: 0; }
.hud .out b { font-family: var(--display); font-weight: 400; font-size: 2rem; font-variant-numeric: tabular-nums; }
.hud .out span { color: var(--muted); }
.hud .best { color: var(--muted); font-size: 0.9rem; text-align: right; }
.hud .best b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- the factory floor ---------- */
.floor { background: var(--card); border-radius: 18px; padding: 14px 10px; display: flex; flex-direction: column; align-items: stretch; box-shadow: 0 1px 0 var(--line); overflow-x: auto; }
.chain { display: flex; flex-direction: column; align-items: stretch; min-width: 0; }
.end { align-self: center; border-radius: 12px; padding: 8px 16px; font-weight: 800; text-align: center; border: 2px solid var(--belt); min-width: 140px; }
.end small { display: block; font-weight: 600; color: var(--muted); font-size: 0.78rem; }
.end.src { background: var(--bg); }
.end.dst { background: var(--belt); color: var(--card); }
.end.dst small { color: #BFC5C9; }

.seg { position: relative; height: 46px; display: flex; justify-content: center; }
.belt { width: 10px; height: 100%; border-radius: 2px; background: repeating-linear-gradient(to bottom, var(--belt) 0 7px, var(--belt2) 7px 12px); animation: run var(--dur, 1s) linear infinite; }
.seg.dead .belt { animation: none; opacity: .35; }
@keyframes run { from { background-position: 0 0; } to { background-position: 0 12px; } }
.flow { position: absolute; left: calc(50% + 12px); top: 50%; transform: translateY(-50%); font-size: 0.78rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; pointer-events: none; }
.flow b { color: var(--ink); }
.slot { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--belt); background: var(--mark); font-weight: 900; font-size: 1.2rem; line-height: 1; cursor: pointer; display: none; color: var(--belt); }
.placing .slot { display: block; }
.placing .flow { opacity: .25; }

.mach { align-self: center; position: relative; border: 0; border-radius: 12px; padding: 7px 10px 6px; min-width: 76px; color: #fff; cursor: pointer; text-align: center; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.mach .op { display: block; font-weight: 900; font-size: 1.15rem; line-height: 1.1; }
.mach .spd { display: block; font-size: 0.72rem; opacity: .9; font-variant-numeric: tabular-nums; }
.mach.add { background: var(--add); } .mach.mul { background: var(--mul); } .mach.sq { background: var(--sq); } .mach.split { background: var(--split); }
.mach.busy { outline: 3px solid var(--mark); outline-offset: 2px; }
.mach.busy .spd::after { content: " · backed up"; }
.mach.sel { outline: 3px solid var(--ink); outline-offset: 3px; }
.can-up .mach.ok { animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 0 0 4px var(--mark); } }
.badge { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 6px; border-radius: 999px; padding: 2px 8px; font-size: 0.72rem; font-weight: 800; color: #fff; white-space: nowrap; }
.badge.b { background: var(--boost); } .badge.o { background: var(--oc); }

.lanes { display: flex; gap: 6px; align-items: stretch; }
.lane { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; background: color-mix(in srgb, var(--bg) 55%, transparent); border-radius: 12px; padding: 0 2px; }
.lane > .chain { flex: 1; }
.lane > .chain > .seg:last-child { flex: 1 0 46px; height: auto; }
.join { align-self: stretch; height: 8px; border-radius: 4px; background: var(--split); margin: 0 18%; }
.floor.small { padding: 10px 6px; margin-bottom: 14px; }
.floor.small .mach { cursor: default; }

/* ---------- tray ---------- */
.actions { display: flex; gap: 8px; justify-content: center; margin: 10px 0 0; }
.tray { margin-top: 12px; }
.tray-h { margin: 8px 0 6px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; min-height: 44px; }
.chips .mach { min-width: 64px; }
.chips .mach.sel { outline: 3px solid var(--mark); }
.chips .empty { color: var(--muted); font-size: 0.85rem; align-self: center; }
.up { border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 800; color: #fff; cursor: pointer; }
.up.b { background: var(--boost); } .up.o { background: var(--oc); }
.up.sel { outline: 3px solid var(--mark); outline-offset: 2px; }

.tools { display: flex; gap: 8px; margin: 14px 0 0; }
.tool { border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 18px; font-weight: 700; cursor: pointer; }
.tool.wide { width: 100%; margin-bottom: 12px; }
.go { width: 100%; border: 0; border-radius: 16px; padding: 14px; background: var(--ink); color: var(--card); font-weight: 800; font-size: 1.1rem; cursor: pointer; }
.tools .go { flex: 1; }
.fine { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 10px 0 0; }

.card { background: var(--card); border-radius: 20px; padding: 20px 18px; box-shadow: 0 1px 0 var(--line); }
.done { margin-top: 14px; }
.kicker { margin: 0; color: var(--muted); font-weight: 600; }
.big { font-family: var(--display); font-size: 2.6rem; line-height: 1; margin: 6px 0 6px; font-variant-numeric: tabular-nums; }
.big small { font-size: 1.1rem; color: var(--muted); }
.res-line { margin: 0 0 14px; }

/* ads */
.ad-inline { margin-top: 26px; }
.ad-slot { display: block; margin: 0 auto; overflow: hidden; }
.ad-banner { width: 100%; max-width: 728px; min-height: 100px; }
.ad-slot.placeholder { border: 1.5px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; }
.ad-slot.placeholder::before { content: "Ad space " attr(data-size); }
.ad-slot.collapsed { min-height: 0; }
.ad-slot ins[data-ad-status="unfilled"] { display: none !important; }
.ad-label { font-size: 11px; color: var(--muted); text-align: center; margin: 0 0 4px; }

.foot { display: flex; justify-content: center; gap: 22px; padding: 26px 0 40px; color: var(--muted); font-size: 0.9rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dlg { border: 0; border-radius: 16px; padding: 22px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
.dlg::backdrop { background: rgba(10, 12, 14, .5); }
.dlg h2 { font-family: var(--display); font-weight: 400; margin: 0 0 10px; font-size: 1.6rem; }
.dlg p { color: var(--muted); }
.dlg .x { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); width: 40px; height: 40px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; background: var(--bg); border-radius: 10px; padding: 10px; }
.stats dt { color: var(--muted); font-size: 0.85rem; }
.stats dd { margin: 0; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .belt { animation: none; } .can-up .mach.ok { animation: none; box-shadow: 0 0 0 4px var(--mark); } .toast { transition: none; } }
@media (max-width: 380px) { .mach { min-width: 62px; padding: 6px 6px 5px; } .flow { font-size: 0.7rem; } }
