:root { --bg:#0e1116; --card:#1a1f27; --ink:#e8ecf2; --muted:#8a94a6; --blue:#5b8cff; --amber:#ffb84d; --pink:#ff6fcf; --green:#4ade80; --red:#f87171; }
* { box-sizing: border-box; }
html, body { overflow-x: clip; margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 -apple-system, system-ui, sans-serif; }
header { display:flex; align-items:center; justify-content:space-between; padding: 14px 16px; gap: 8px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
.pill { max-width: 62vw; background:#232a36; color:#a9bdff; padding:5px 12px; border-radius:999px; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 12px 40px; }
.card { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.drop { display:block; border: 2px dashed #34405a; border-radius: 12px; padding: 26px 12px; text-align:center; cursor:pointer; }
.drop .big { font-size: 18px; font-weight: 600; color: var(--blue); }
.muted { color: var(--muted); font-size: 13px; }
.row { display:flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.field { flex:1; min-width: 90px; display:flex; flex-direction:column; gap:4px; color: var(--muted); font-size: 12px; }
input, select { background:#11151b; color: var(--ink); border:1px solid #2b3342; border-radius: 8px; padding: 9px; font-size: 15px; }
button { background:#262d39; color: var(--ink); border:0; border-radius: 10px; padding: 12px 14px; font-size: 15px; font-weight: 600; cursor:pointer; }
button.primary { background: var(--blue); color: #fff; width: 100%; margin-top: 12px; }
button:disabled { opacity: .4; }
button.on { background: var(--blue); color:#fff; }
.bar { height: 6px; background:#11151b; border-radius: 3px; margin-top: 10px; overflow:hidden; }
.bar div { height:100%; width:0; background: var(--blue); }
.stages { list-style:none; padding:0; margin:0; }
.stages li { display:grid; grid-template-columns: 18px 1fr; column-gap: 8px; padding: 7px 0; }
.stages li .muted { grid-column: 2; }
.stages .dot { width:12px; height:12px; border-radius:50%; background:#3a4356; margin-top:4px; }
.stages .running .dot { background: var(--amber); animation: pulse 1s infinite alternate; }
.stages .done .dot { background: var(--green); }
.stages .failed .dot { background: var(--red); }
.stages .failed .muted { color: var(--red); }
@keyframes pulse { to { opacity: .3; } }
.jobs { list-style:none; padding:0; margin:0; }
.jobs a { display:flex; gap:8px; align-items:center; color: var(--ink); text-decoration:none; padding: 8px 0; border-bottom: 1px solid #232a36; }
.jobs b { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background:#2b3342; }
.tag.ready { background:#1f4d33; color: var(--green); }
.tag.failed { background:#4d1f1f; color: var(--red); }
.tag.running { background:#4d3a1f; color: var(--amber); }

/* bench */
.bench { max-width: 900px; margin: 0 auto; }
.stage { position: relative; background:#000; touch-action: none; }
.stage canvas { display:block; width:auto; height:auto; max-width:100%; max-height:52vh; margin:0 auto; }
.fbar { position:absolute; right:8px; top:8px; display:flex; gap:6px; }
.fbar button { background: rgba(14,17,22,.82); padding: 10px 14px; font-size: 18px; min-width: 48px; }
.chips { position:absolute; left:8px; bottom:8px; display:flex; gap:6px; flex-wrap:wrap; pointer-events:none; }
.chip { background: rgba(14,17,22,.82); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.good { color: var(--green); } .chip.warn { color: var(--amber); } .chip.bad { color: var(--red); }
.timeline { position:relative; height: 44px; background: var(--card); border-radius: 10px; margin: 10px 12px 2px; touch-action:none; }
.timeline .fast { position:absolute; top:0; bottom:0; background: rgba(255,184,77,.18); }
.timeline .key, .timeline .sug { position:absolute; top: 13px; width: 16px; height: 16px; transform: translateX(-50%) rotate(45deg); border-radius: 3px; }
.timeline .key { background: var(--blue); }
.timeline .sug { border: 2px solid var(--blue); }
.timeline .head { position:absolute; top: 2px; bottom: 2px; width: 3px; background:#fff; transform: translateX(-50%); }
.tl-legend { display:flex; justify-content:space-between; padding: 0 14px; }
.controls { display:grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; padding: 8px 12px; }
.ctl { background: var(--card); border-radius: 12px; padding: 10px 12px; }
.ctl .lbl { display:flex; justify-content:space-between; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.ctl input[type=range] { width:100%; padding:0; }
.seg { display:flex; gap: 6px; }
.seg button { flex:1; min-width:0; padding: 8px 4px; font-size: 14px; }
.actions { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; padding: 4px 12px 24px; }
.actions .lock { background: var(--blue); color:#fff; }
.help { padding: 0 14px 30px; }

#view button { font-size: 13px; }
@media (max-width: 520px) { .controls { grid-template-columns: minmax(0,1fr); } }


.tl-legend { flex-wrap: wrap; gap: 2px 12px; font-size: 12px; }
.tl-legend #fcount { color: #fff; font-weight: 600; }
#nlab { display:none; }

.strip-row { display:flex; align-items:stretch; gap:6px; margin: 10px 8px 2px; }
.snav { flex: 0 0 44px; font-size: 26px; padding: 0; border-radius: 10px; }
.strip { flex:1; min-width:0; display:flex; gap:4px; overflow-x:auto; overflow-y:visible; scrollbar-width:none; padding: 6px 6px; background: var(--card); border-radius:10px; }
.strip::-webkit-scrollbar { display:none; }
.fr { position:relative; flex: 0 0 58px; height: 58px; border-radius:6px; overflow:hidden; border: 2px solid transparent; cursor:pointer; background:#000; }
.fr img { width:100%; height:100%; object-fit:cover; display:block; opacity:.8; }
.fr .n { position:absolute; left:2px; bottom:1px; font-size:10px; color:#fff; text-shadow:0 0 3px #000; }
.fr.fast img { filter: sepia(1) saturate(3) hue-rotate(-15deg) brightness(.75); }
.fr.sug { border: 2px dashed var(--blue); }
.fr.set { border: 2px solid var(--blue); }
.fr.set::after { content:"◆"; position:absolute; right:3px; top:0; color: var(--blue); font-size:13px; text-shadow:0 0 3px #000; }
.fr.cur { border: 3px solid #ffd84d !important; box-shadow: 0 0 0 2px #ffd84d, 0 0 14px rgba(255,216,77,.7); z-index:1; }
.fr.cur img { opacity:1; }
.fr.cur .n { left:0; right:0; bottom:0; text-align:center; background:#ffd84d; color:#111; font-weight:800; font-size:13px; text-shadow:none; padding:1px 0; }
.strip:has(.cur) .fr:not(.cur) img { opacity:.55; }
.scrub-row { display:flex; align-items:center; gap:10px; margin: 6px 14px 4px; }
#scrub { flex:1; height: 28px; accent-color:#ffd84d; }
#scrubV { min-width: 42px; text-align:center; font-weight:800; color:#111; background:#ffd84d; border-radius:8px; padding:3px 6px; font-size:14px; }
.tl-legend { align-items:center; }
.lg { display:inline-block; width:11px; height:11px; border-radius:3px; vertical-align:-1px; }
.lg.set { border:2px solid var(--blue); } .lg.sug { border:2px dashed var(--blue); } .lg.fast { background: var(--amber); opacity:.7; }
button.mini { padding: 4px 10px; font-size: 12px; }

.gz-ctl { grid-column: 1 / -1; }
#gzc { display:block; width: 200px; height: 200px; margin: 0 auto; touch-action: none; }

.hctl { grid-column: 1 / -1; }
.hrow { display:grid; grid-template-columns: 2fr 1fr; gap:6px; margin-bottom:8px; }
.hrow button.primary { background: var(--blue); color:#fff; font-weight:600; }
.hgrid { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px 12px; }
@media (max-width: 520px) { .hgrid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } }
.fr.hk::before { content:""; position:absolute; left:4px; top:4px; width:8px; height:8px; border-radius:50%; background:#ff9f43; box-shadow:0 0 3px #000; z-index:1; }

/* hand rotate gizmo: same look as the racket gizmo, beside the hand sliders */
.hwrap { display:grid; grid-template-columns: 200px minmax(0,1fr); gap: 14px; align-items:start; }
.hgzbox { text-align:center; }
#hgz { display:block; width:200px; height:200px; margin:0 auto; touch-action:none; }
.hgzv { margin-top:2px; font-size:12px; }
.hside .lbl { margin-bottom:2px !important; }
.hside > div { margin-bottom: 6px; }
@media (max-width: 520px) { .hwrap { grid-template-columns: minmax(0,1fr); } }

/* keep the picture in view while editing */
.viewcol { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 4px; }
@media (max-width: 899px) { .viewcol .stage canvas { max-height: 34vh; } }
@media (min-width: 900px) {
  .bench { max-width: 1600px; display:grid; grid-template-columns: minmax(0,1.35fr) minmax(400px,1fr); column-gap: 8px; align-items:start; }
  .bench > header { grid-column: 1 / -1; }
  .viewcol .stage canvas { max-height: calc(100vh - 250px); }
  .ctlcol { max-height: calc(100vh - 60px); overflow-y: auto; position: sticky; top: 0; }
  .ctlcol .controls { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
}

/* 3D rotate view */
.stage .c3reset{position:absolute;right:8px;top:8px;z-index:3;background:#21262dcc;color:#e6edf3;border:1px solid #30363d;border-radius:8px;padding:6px 10px;font-size:13px}
.stage .c3msg{position:absolute;display:grid;place-items:center;color:#8b949e;font-size:14px;pointer-events:none}

.how h2 { margin-top: 0; }
.how-steps { padding-left: 20px; margin: 10px 0; }
.how-steps li { margin: 0 0 10px; line-height: 1.45; }
.how-steps li .muted { display: block; font-size: 12px; margin-top: 2px; }
.how-steps li.soon { opacity: .85; }
.how-steps .tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px; border: 1px solid currentColor; margin-left: 6px; opacity: .7; }

/* pipe bench */
.stage canvas, .viewcol .stage canvas { width:100% !important; max-width:none; max-height:none !important; }
.tray .fr { flex: 0 0 76px; height: 92px; display:flex; flex-direction:column; align-items:center; justify-content:flex-start; background:#11151b; }
.tray .fr img { width:76px; height:68px; object-fit:contain; opacity:1; }
.tray .fr .n { position:static; font-size:11px; line-height:1.15; text-align:center; padding:1px 3px 0; text-shadow:none; color: var(--ink); }
.tray .fr:hover, .tray .fr:active { border-color: var(--blue); }
.tray .fr.cu .n { color:#f0a878; } .tray .fr.abs .n { color:#c9cdd6; }
.selname { font-weight:600; font-size:14px; min-height:20px; }
.sel-ctl { grid-column: 1 / -1; }
.bom { margin: 4px 12px 12px; }
.bom table { width:100%; border-collapse:collapse; font-size:13px; color: var(--ink); }
.bom td { padding:6px 4px; border-bottom:1px solid #232a36; vertical-align:top; }
.bom td.q { width:44px; color: var(--amber); font-weight:700; }
.bom .m { color: var(--muted); font-size:12px; }
.chip.ok { color: var(--green); }
