:root {
  /* layout: full-bleed night canvas; recipe workbench docked right, recipe dock along the bottom, brand top-left */
  --night: #04060c;
  --glass: rgba(8, 12, 23, 0.66);
  --line: rgba(168, 192, 255, 0.15);
  --line-strong: rgba(168, 192, 255, 0.3);
  --text: #e9edf6;
  --muted: #8d97b0;
  --gold: #f0c27a;
  --fire: #ff5b3a;
  --display: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --latin: "Cormorant Garamond", "Noto Serif TC", Georgia, serif;
  --body: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  --bench-w: 344px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--text);
  font-family: var(--body);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1.5px solid var(--gold); outline-offset: 2px; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#gl.orbit { cursor: grabbing; }

#fallback { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; z-index: 5; }
#fallback[hidden] { display: none; }
#fallback p { max-width: 30em; font-family: var(--display); font-size: 15px; color: var(--text); }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
body.bare #hud > *:not(#charge):not(#bareExit) { opacity: 0; pointer-events: none; }
#bareExit { position: absolute; right: 20px; bottom: 20px; height: 32px; padding: 0 14px; display: none; background: rgba(8, 12, 23, 0.5); color: var(--muted); font-size: 12px; z-index: 8; }
body.bare #bareExit { display: block; opacity: 0.55; }
body.bare #bareExit:hover { opacity: 1; color: var(--text); }
#hud > * { transition: opacity 0.5s ease; }

/* ---------- brand ---------- */
.brand { position: absolute; top: 26px; left: 32px; pointer-events: none !important; }
.brand h1 {
  margin: 0; font-family: var(--display); font-weight: 900; font-size: 26px; letter-spacing: 0.34em;
  text-shadow: 0 0 24px rgba(240, 194, 122, 0.35);
}
.brand p {
  margin: 4px 0 0; font-family: var(--latin); font-size: 12px; letter-spacing: 0.52em; color: var(--gold); opacity: 0.85;
}

/* ---------- toolbar ---------- */
.tools {
  position: absolute; top: 24px; right: calc(var(--bench-w) + 40px);
  display: flex; gap: 6px; transition: right 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease;
}
body.bench-closed .tools { right: 24px; }
.tool {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px 0 10px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 3px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--muted); font-size: 12px; letter-spacing: 0.08em; white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tool:hover { color: var(--text); border-color: var(--line-strong); }
.tool[aria-pressed="true"] { color: var(--gold); border-color: rgba(240, 194, 122, 0.42); }
.tool[aria-pressed="false"] .wave { opacity: 0.2; }

/* ---------- hint ---------- */
.hint {
  position: absolute; left: 32px; bottom: 86px; margin: 0;
  font-family: var(--display); font-size: 13px; letter-spacing: 0.22em; color: rgba(233, 237, 246, 0.72);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8); pointer-events: none !important;
}
.hint i { display: inline-block; width: 3px; height: 3px; margin: 0 14px 3px; border-radius: 50%; background: var(--gold); }
.hint.gone { opacity: 0 !important; }

/* ---------- workbench ---------- */
.panel {
  background: linear-gradient(180deg, rgba(11, 16, 30, 0.74), rgba(6, 9, 18, 0.68));
  border: 1px solid var(--line); border-radius: 4px;
  backdrop-filter: blur(20px) saturate(1.25); -webkit-backdrop-filter: blur(20px) saturate(1.25);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
#bench {
  position: absolute; top: 16px; right: 16px; bottom: 16px; width: var(--bench-w);
  display: flex; flex-direction: column;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease;
}
body.bench-closed #bench { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }

.bench-head { display: flex; align-items: flex-end; gap: 10px; padding: 16px 16px 12px 18px; border-bottom: 1px solid var(--line); }
.bench-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.eyebrow { font-size: 11px; letter-spacing: 0.3em; color: var(--gold); }
#rname {
  width: 100%; padding: 2px 0 3px; background: none; border: 0; border-bottom: 1px solid transparent;
  font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: 0.12em; user-select: text; -webkit-user-select: text;
}
#rname:hover, #rname:focus { border-bottom-color: var(--line-strong); outline: none; }
.icon-btn { width: 30px; height: 30px; display: grid; place-items: center; background: none; border: 1px solid transparent; border-radius: 3px; color: var(--muted); flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--line); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

.bench-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 10px; scrollbar-width: thin; scrollbar-color: rgba(168, 192, 255, 0.22) transparent; }
.bench-scroll section { padding: 14px 0 15px; border-bottom: 1px solid rgba(168, 192, 255, 0.08); display: flex; flex-direction: column; gap: 10px; }
.bench-scroll section:last-child { border-bottom: 0; }
.bench-scroll h2 {
  margin: 0; display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
  font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.2em;
}
.bench-scroll h2 b {
  display: inline-grid; place-items: center; width: 18px; height: 18px; align-self: center;
  border: 1px solid rgba(255, 91, 58, 0.7); border-radius: 2px; color: var(--fire);
  font-size: 11px; font-weight: 600; letter-spacing: 0; line-height: 1;
}
.bench-scroll h2 small { font-family: var(--body); font-weight: 400; font-size: 11px; letter-spacing: 0.04em; color: var(--muted); }

/* shells */
.shells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.shell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 4px 4px 7px;
  background: rgba(255, 255, 255, 0.018); border: 1px solid var(--line); border-radius: 3px;
  transition: border-color 0.2s, background 0.2s;
}
.shell canvas { width: 100%; aspect-ratio: 1.12; display: block; }
.shell strong { font-family: var(--display); font-weight: 600; font-size: 12.5px; letter-spacing: 0.1em; line-height: 1.25; white-space: nowrap; }
.shell span { font-size: 9.5px; color: var(--muted); letter-spacing: 0.02em; white-space: nowrap; }
.shell:hover { border-color: var(--line-strong); }
.shell[aria-pressed="true"] { border-color: var(--gold); background: rgba(240, 194, 122, 0.07); box-shadow: inset 0 0 18px rgba(240, 194, 122, 0.08); }

.pad-box { display: flex; flex-direction: column; gap: 8px; }
.pad-box[hidden] { display: none; }
#pad { width: 100%; aspect-ratio: 1.52; display: block; border: 1px dashed var(--line-strong); border-radius: 3px; background: radial-gradient(circle at 50% 50%, rgba(240, 194, 122, 0.06), rgba(0, 0, 0, 0.25)); cursor: crosshair; touch-action: none; }
.pad-row { display: grid; grid-template-columns: 44px 1.25fr 1fr 0.8fr; gap: 5px; }
.pad-row input { height: 34px; padding: 0; text-align: center; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-strong); border-radius: 3px; font-family: var(--display); font-size: 16px; user-select: text; -webkit-user-select: text; min-width: 0; }
.pad-row .btn { height: 34px; padding: 0 4px; letter-spacing: 0.06em; font-size: 12px; }

/* segmented */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button { height: 30px; background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); font-size: 12px; letter-spacing: 0.1em; transition: color 0.2s, background 0.2s; }
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { color: #1a1206; background: var(--gold); font-weight: 600; }
.seg button i { display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; vertical-align: 1px; box-shadow: 0 0 6px currentColor; }

/* chems: 元素週期表式的小磚 */
.chems { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chem {
  --c: #fff;
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 7px 9px;
  background: rgba(255, 255, 255, 0.018); border: 1px solid var(--line); border-radius: 3px; text-align: left; overflow: hidden;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.chem::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--c); box-shadow: 0 0 12px 1px var(--c); opacity: 0.9; }
.chem b { font-family: var(--latin); font-weight: 600; font-size: 19px; line-height: 1; letter-spacing: 0.01em; }
.chem span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chem:hover { border-color: var(--line-strong); }
.chem[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); box-shadow: 0 0 18px -4px var(--c); }
.chem[aria-pressed="true"] span { color: var(--text); }
.chem.none::after { background: repeating-linear-gradient(90deg, var(--muted) 0 3px, transparent 3px 6px); box-shadow: none; opacity: 0.5; }
.chem.none b { font-family: var(--display); font-size: 15px; line-height: 19px; }

/* sliders */
.slider { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.slider > span { font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }
.slider output { min-width: 5.5em; text-align: right; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, var(--gold) var(--p, 50%), rgba(168, 192, 255, 0.2) var(--p, 50%)); }
input[type="range"]::-moz-range-track { height: 2px; background: linear-gradient(90deg, var(--gold) var(--p, 50%), rgba(168, 192, 255, 0.2) var(--p, 50%)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--night); border: 1.5px solid var(--gold); box-shadow: 0 0 10px rgba(240, 194, 122, 0.6); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--night); border: 1.5px solid var(--gold); box-shadow: 0 0 10px rgba(240, 194, 122, 0.6); }

/* toggles */
.toggles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.toggles button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 8px; background: rgba(255, 255, 255, 0.018); border: 1px solid var(--line); border-radius: 3px; text-align: left; transition: border-color 0.2s, background 0.2s; }
.toggles em { font-style: normal; font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: 0.16em; }
.toggles span { font-size: 10.5px; color: var(--muted); }
.toggles button:hover { border-color: var(--line-strong); }
.toggles button[aria-pressed="true"] { border-color: var(--gold); background: rgba(240, 194, 122, 0.09); }
.toggles button[aria-pressed="true"] em { color: var(--gold); }

/* footer buttons */
.bench-foot { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.bench-foot .btn { grid-column: span 2; }
.btn { height: 36px; padding: 0 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line-strong); border-radius: 3px; font-size: 12.5px; letter-spacing: 0.12em; white-space: nowrap; transition: background 0.2s, border-color 0.2s, transform 0.1s; }
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(233, 237, 246, 0.5); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  grid-column: span 3; height: 44px; border: 0;
  background: linear-gradient(180deg, #ff7a4d, #e8391f); color: #fff8f0;
  font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: 0.5em; text-indent: 0.5em;
  box-shadow: 0 6px 26px -6px rgba(255, 91, 58, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.primary:hover { background: linear-gradient(180deg, #ff8d62, #f0452a); }

.bench-foot .btn.salvo { grid-column: span 1; height: 44px; padding: 0; border-color: rgba(240, 194, 122, 0.6); color: var(--gold); font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.2em; text-indent: 0.2em; }
.bench-foot .btn.salvo:hover { background: rgba(240, 194, 122, 0.14); }
.icon-btn svg circle { fill: currentColor; stroke: none; }

/* ---------- recipe dock ---------- */
#dock {
  position: absolute; left: 24px; right: calc(var(--bench-w) + 40px); bottom: 20px;
  display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px; scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 28px), transparent);
  transition: right 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease;
}
#dock::-webkit-scrollbar { display: none; }
body.bench-closed #dock { right: 24px; }
.chip {
  flex: none; display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 14px 0 10px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 3px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-family: var(--display); font-size: 13px; letter-spacing: 0.14em; white-space: nowrap;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.chip i { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 10px 0 var(--g, #fff); }
.chip kbd { font-family: var(--latin); font-size: 12px; color: var(--muted); margin-left: 2px; }
.chip:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.chip.demo { padding: 0 16px; border-color: rgba(240, 194, 122, 0.7); color: var(--gold); background: rgba(40, 30, 14, 0.72); }
.chip.demo svg { width: 12px; height: 12px; fill: currentColor; }
.chip[aria-pressed="true"] { border-color: var(--gold); background: rgba(40, 30, 14, 0.7); }
.chip .del { display: grid; place-items: center; width: 18px; height: 18px; margin: 0 -6px 0 0; border-radius: 50%; color: var(--muted); font-family: var(--body); font-size: 13px; line-height: 1; }
.chip .del:hover { color: var(--fire); background: rgba(255, 91, 58, 0.14); }
.dock-sep { flex: none; width: 1px; margin: 8px 6px; background: var(--line-strong); }

/* ---------- tabs, drone pane ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { height: 40px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-family: var(--display); font-size: 13.5px; letter-spacing: 0.24em; text-indent: 0.24em; transition: color 0.2s, border-color 0.2s; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane[hidden] { display: none; }
.pane-name { font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: 0.12em; padding: 2px 0 3px; }
.text-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.text-row input, #stage input {
  height: 38px; padding: 0 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-strong); border-radius: 3px;
  font-family: var(--display); font-size: 15px; letter-spacing: 0.12em; user-select: text; -webkit-user-select: text; min-width: 0;
}
.text-row input::placeholder { color: rgba(141, 151, 176, 0.7); }
.text-row .btn { height: 38px; padding: 0 16px; border-color: rgba(240, 194, 122, 0.6); color: var(--gold); }
.dfonts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dfonts button { height: 38px; background: rgba(255, 255, 255, 0.018); border: 1px solid var(--line); border-radius: 3px; font-size: 15px; transition: border-color 0.2s, background 0.2s; white-space: nowrap; overflow: hidden; }
.dfonts button:hover { border-color: var(--line-strong); }
.dfonts button[aria-pressed="true"] { border-color: var(--gold); background: rgba(240, 194, 122, 0.09); color: var(--gold); }
.dfonts.has-user { grid-template-columns: repeat(5, 1fr); }
.dfonts.has-user button { font-size: 13px; }
.btn.file { height: 34px; font-size: 12px; letter-spacing: 0.08em; }
.dshapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dshapes button, .dmodes button { height: 36px; background: rgba(255, 255, 255, 0.018); border: 1px solid var(--line); border-radius: 3px; font-family: var(--display); font-size: 13px; letter-spacing: 0.16em; transition: border-color 0.2s, background 0.2s; }
.dshapes button:hover, .dmodes button:hover { border-color: var(--line-strong); }
.dshapes button[aria-pressed="true"], .dmodes button[aria-pressed="true"] { border-color: var(--gold); background: rgba(240, 194, 122, 0.09); color: var(--gold); }
.dmodes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dmodes button { height: auto; padding: 7px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; letter-spacing: 0.1em; }
.dmodes i { width: 34px; height: 6px; border-radius: 3px; box-shadow: 0 0 10px rgba(255, 255, 255, 0.15); }
#paneDrone .bench-foot .btn { grid-column: span 2; }

.demoji { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.demoji button { height: 34px; padding: 0; background: rgba(255, 255, 255, 0.018); border: 1px solid var(--line); border-radius: 3px; font-size: 17px; line-height: 1; transition: border-color 0.2s, background 0.2s; }
.demoji button:hover { border-color: var(--gold); background: rgba(240, 194, 122, 0.08); }
#dPad { width: 100%; aspect-ratio: 1.52; display: block; border: 1px dashed var(--line-strong); border-radius: 3px; background: radial-gradient(circle at 50% 50%, rgba(120, 160, 255, 0.07), rgba(0, 0, 0, 0.25)); cursor: crosshair; touch-action: none; }

/* ---------- timeline ---------- */
#tl { position: absolute; left: 24px; right: calc(var(--bench-w) + 40px); bottom: 20px; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 8px; transition: right 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease; z-index: 2; }
#tl[hidden] { display: none; }
body.bench-closed #tl { right: 24px; }
body.tl-open #dock, body.tl-open .hint { display: none; }
.tl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tl-bar .btn { height: 30px; padding: 0 10px; font-size: 12px; letter-spacing: 0.06em; }
.btn.gold { border-color: rgba(240, 194, 122, 0.6); color: var(--gold); }
.btn.gold:hover { background: rgba(240, 194, 122, 0.14); }
.tl-bar .btn[aria-pressed="true"] { border-color: var(--gold); background: rgba(240, 194, 122, 0.12); color: var(--gold); }
.tl-bar .btn:disabled { opacity: 0.35; cursor: default; }
.tl-time { min-width: 9.5em; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text); }
.tl-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 2px; }
.tl-len { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-left: auto; }
.tl-len input { width: 4.2em; height: 28px; padding: 0 4px; text-align: right; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-strong); border-radius: 3px; font-variant-numeric: tabular-nums; user-select: text; -webkit-user-select: text; }
.tl-scroll { overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: 3px; background: rgba(0, 0, 0, 0.28); scrollbar-width: thin; scrollbar-color: rgba(168, 192, 255, 0.3) transparent; }
.tl-canvas { position: relative; min-width: 100%; padding-left: 58px; cursor: text; }
.tl-ruler { position: relative; height: 20px; border-bottom: 1px solid var(--line); }
.tl-ruler i { position: absolute; bottom: 0; width: 1px; height: 5px; background: var(--line-strong); }
.tl-ruler i.major { height: 9px; background: rgba(233, 237, 246, 0.5); }
.tl-ruler span { position: absolute; top: 1px; transform: translateX(4px); font-size: 10px; font-variant-numeric: tabular-nums; color: var(--muted); pointer-events: none; }
.tl-lane { position: relative; height: 34px; border-bottom: 1px solid rgba(168, 192, 255, 0.08); }
.tl-lane:last-of-type { border-bottom: 0; }
.tl-lane[data-lane="auto"] { height: 24px; }
.tl-name { position: sticky; left: 0; z-index: 3; display: inline-flex; align-items: center; width: 58px; height: 100%; margin-left: -58px; padding-left: 8px; background: rgba(8, 12, 23, 0.94); border-right: 1px solid var(--line); font-size: 11px; letter-spacing: 0.1em; color: var(--muted); pointer-events: none; }
.tl-chip, .tl-block { position: absolute; padding: 0; border: 0; cursor: grab; touch-action: none; }
.tl-chip.fire { width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 8px var(--c, #fff); border: 1px solid rgba(255, 255, 255, 0.55); }
.tl-chip.salvo { height: 16px; margin-left: -9px; padding: 0 5px; border-radius: 8px; background: var(--c, var(--gold)); color: #120c04; font-size: 10px; font-weight: 700; line-height: 16px; box-shadow: 0 0 8px var(--c, var(--gold)); }
.tl-chip.recall { top: 7px; width: 18px; height: 20px; margin-left: -9px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line-strong); color: var(--text); font-size: 11px; line-height: 18px; }
.tl-block { top: 6px; height: 22px; padding: 0 8px; border-radius: 3px; background: linear-gradient(90deg, rgba(60, 150, 255, 0.5), rgba(150, 80, 255, 0.28)); border: 1px solid rgba(140, 180, 255, 0.6); color: #eef3ff; font-family: var(--display); font-size: 11.5px; letter-spacing: 0.08em; line-height: 20px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-block.auto { top: 4px; height: 16px; background: repeating-linear-gradient(115deg, rgba(240, 194, 122, 0.42) 0 6px, rgba(240, 194, 122, 0.2) 6px 12px); border-color: rgba(240, 194, 122, 0.7); font-size: 10px; line-height: 14px; color: #fff3dd; }
.tl-chip.autoend { top: 4px; width: 8px; height: 16px; margin-left: -4px; border-radius: 2px; background: var(--gold); cursor: ew-resize; }
.tl-chip.sel, .tl-block.sel { outline: 2px solid #fff; outline-offset: 1px; z-index: 2; }
.tl-head { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px solid var(--fire); pointer-events: none; z-index: 4; }
.tl-head::before { content: ""; position: absolute; top: 0; left: -5.5px; border: 5px solid transparent; border-top: 7px solid var(--fire); }
#tlInfo { min-height: 1.6em; }

/* ---------- music popover ---------- */
#musicPop { position: absolute; top: 66px; right: calc(var(--bench-w) + 40px); width: 268px; padding: 12px; display: flex; flex-direction: column; gap: 10px; z-index: 3; transition: right 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
#musicPop[hidden] { display: none; }
body.bench-closed #musicPop { right: 24px; }
.mlist { display: flex; flex-direction: column; gap: 4px; }
.mlist button { display: flex; align-items: baseline; gap: 10px; padding: 8px 10px; background: none; border: 1px solid transparent; border-radius: 3px; text-align: left; }
.mlist button strong { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: 0.16em; }
.mlist button span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mlist button:hover { border-color: var(--line); }
.mlist button[aria-pressed="true"] { border-color: var(--gold); background: rgba(240, 194, 122, 0.08); }
.mlist button[aria-pressed="true"] strong { color: var(--gold); }
.btn.file { display: grid; place-items: center; cursor: pointer; }
.btn.file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.btn.file:focus-within { outline: 1.5px solid var(--gold); outline-offset: 2px; }
.fine { margin: 0; font-size: 11px; line-height: 1.6; color: var(--muted); }

/* ---------- record button ---------- */
#tRec .dot { fill: var(--fire); stroke: none; }
#tRec[aria-pressed="true"] { color: #fff; border-color: var(--fire); background: rgba(255, 91, 58, 0.22); }
#tRec[aria-pressed="true"] .dot { animation: blink 1s steps(2) infinite; }
#recLabel { font-variant-numeric: tabular-nums; }
@keyframes blink { 50% { opacity: 0.15; } }

/* ---------- replay stage ---------- */
#stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at center, rgba(4, 6, 12, 0.35), rgba(4, 6, 12, 0.72)); z-index: 6; }
#stage[hidden] { display: none; }
.stage-card { width: min(420px, 100%); padding: 30px 28px 26px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.stage-card h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 900; font-size: 28px; letter-spacing: 0.2em; text-indent: 0.2em; text-shadow: 0 0 24px rgba(240, 194, 122, 0.4); text-wrap: balance; }
.stage-card .fine:empty { display: none; }
.stage-btns { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; margin-top: 10px; }
.stage-btns .btn.primary { grid-column: auto; }

/* ---------- charge ring ---------- */
#charge {
  position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  border: 1px solid rgba(240, 194, 122, 0.85); box-shadow: 0 0 18px rgba(240, 194, 122, 0.5), inset 0 0 14px rgba(240, 194, 122, 0.25);
  opacity: 0; transform: translate(var(--x, 0), var(--y, 0)) scale(var(--s, 0.2)); pointer-events: none !important; transition: opacity 0.15s !important;
}
#charge.on { opacity: 1; }

/* ---------- toast ---------- */
#toast {
  position: absolute; left: 50%; top: 76px; transform: translate(-50%, -12px); padding: 9px 18px; z-index: 7;
  background: rgba(8, 12, 23, 0.9); border: 1px solid rgba(240, 194, 122, 0.45); border-radius: 3px;
  font-family: var(--display); font-size: 13px; letter-spacing: 0.14em; opacity: 0; pointer-events: none !important;
  transition: opacity 0.3s, transform 0.3s !important; max-width: min(90vw, 560px); text-align: center; user-select: text; -webkit-user-select: text;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1340px) {
  .tool span { display: none; }
  .tool { padding: 0; width: 36px; justify-content: center; }
  #tRec[aria-pressed="true"] { width: auto; padding: 0 10px; }
  #tRec[aria-pressed="true"] span { display: inline; }
}

/* ---------- narrow screens: workbench becomes a bottom sheet ---------- */
@media (max-width: 760px) {
  /* 手機：品牌在第一列，工具列獨立第二列；面板都做成矮的底部抽屜，上方留給夜空 */
  .brand { top: 12px; left: 14px; }
  .brand h1 { font-size: 17px; letter-spacing: 0.2em; }
  .brand p { display: none; }
  .tools, body.bench-closed .tools { top: 42px; left: 12px; right: 12px; gap: 5px; justify-content: flex-start; flex-wrap: wrap; }
  .tool { width: 38px; height: 34px; padding: 0; justify-content: center; }
  .tool span { display: none; }
  #tRec[aria-pressed="true"] { width: auto; padding: 0 10px; }
  #tRec[aria-pressed="true"] span { display: inline; }
  #musicPop, body.bench-closed #musicPop { top: 84px; left: 12px; right: 12px; width: auto; }
  #toast { top: 88px; }
  .hint { left: 16px; right: 16px; bottom: 76px; font-size: 11.5px; letter-spacing: 0.1em; }
  .hint i { margin: 0 7px 3px; }
  #bench { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(54%, 500px); }
  body.bench-closed #bench { transform: translateY(calc(100% + 16px)); }
  #dock, body.bench-closed #dock { left: 8px; right: 8px; bottom: 12px; }
  body:not(.bench-closed) #dock, body:not(.bench-closed) .hint { opacity: 0; pointer-events: none; }
  .btn.primary, .bench-foot .btn.salvo { height: 38px; }
  .bench-head { padding: 10px 14px 8px 16px; }
  .tabs button { height: 36px; }

  #tl, body.bench-closed #tl { left: 8px; right: 8px; bottom: 8px; padding: 8px; gap: 6px; }
  body:not(.bench-closed) #tl { display: none; }
  .tl-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 8px; }
  .tl-bar::-webkit-scrollbar { display: none; }
  .tl-bar > * { flex: none; }
  .tl-bar #tlClose { order: -2; margin-right: 2px; }
  .tl-bar #tlPlay { order: -1; }
  .tl-time { min-width: 0; font-size: 11.5px; }
  .tl-len { margin-left: 0; }
  .tl-lane { height: 30px; }
  .tl-lane[data-lane="auto"] { height: 22px; }
  .tl-block { top: 4px; }
  #tlInfo { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; min-height: 0; font-size: 10.5px; }
  #bareExit { right: 12px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01s !important; }
}
