:root {
  --bg: #0f1216; --panel: #161a20; --panel2: #1c2129; --line: #2a313b;
  --text: #dfe5ec; --muted: #8b97a6; --accent: #3d9eff; --accent2: #1f6fd1;
  --warn: #f5a524; --err: #e5484d; --ok: #30a46c;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 13px; }
header { height: 46px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.brand small { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.logo { color: var(--accent); margin-right: 4px; }
.status { color: var(--muted); font-size: 12px; }
main { display: flex; height: calc(100% - 46px); }
#panel { width: 340px; min-width: 300px; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 12px 24px; }
section { border-bottom: 1px solid var(--line); padding: 10px 0 12px; }
section:last-child { border-bottom: 0; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 2px 0 10px; font-weight: 600; }
h2 span { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-size: 11px; margin-right: 6px; }
label { display: block; color: var(--muted); font-size: 12px; margin: 6px 0; }
label.check { display: flex; align-items: center; gap: 6px; color: var(--text); }
input[type=number], select { width: 100%; margin-top: 3px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font: inherit; }
input[type=number]:focus, select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row > label { flex: 1; min-width: 0; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.btns.small button { padding: 4px 9px; font-size: 12px; }
button { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; font: inherit; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent2); border-color: var(--accent2); }
button.primary:hover:not(:disabled) { background: var(--accent); }
.drop { display: block; border: 1.5px dashed var(--line); border-radius: 8px; padding: 16px; text-align: center; cursor: pointer; color: var(--text); background: var(--panel2); }
.drop.over, .drop:hover { border-color: var(--accent); }
.drop input { display: none; }
.drop small { color: var(--muted); }
.kv { font-size: 12px; color: var(--muted); margin: 8px 0 2px; line-height: 1.6; }
.kv b { color: var(--text); font-weight: 500; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--text); font-weight: 500; float: right; }
.presets { display: flex; gap: 6px; margin-top: 8px; }
.presets select { margin: 0; flex: 1; }
#stage { position: relative; flex: 1; min-width: 0; }
#viewer { position: absolute; inset: 0; }
.toolbar { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; pointer-events: none; }
.toolbar > * { pointer-events: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button.on { background: var(--accent2); }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; color: var(--text); }
label.inline input[type=range] { width: 110px; }
.info { position: absolute; right: 10px; bottom: 10px; max-width: 380px; background: rgba(22,26,32,.92); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.info:empty { display: none; }
.info b { color: var(--text); font-weight: 500; }
.info .warn { color: var(--warn); margin-top: 4px; }
.info .err { color: var(--err); }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 3px 0 2px; }
.bar > div { height: 100%; background: var(--ok); }
.busy { position: absolute; inset: 0; display: none; place-items: center; background: rgba(15,18,22,.45); }
.busy.on { display: grid; }
.busy > * { grid-area: 1 / 1; }
.busy span { margin-top: 70px; color: var(--text); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
[data-show].hidden, [data-show-eq].hidden, [data-for].hidden { display: none !important; }
.booterr { position: fixed; left: 50%; top: 60px; transform: translateX(-50%); z-index: 50; max-width: 760px; background: #3a1d1d; border: 1px solid #b44; color: #fdd; padding: 12px 16px; border-radius: 8px; font-size: 13px; line-height: 1.5; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.booterr code { color: #fff; }
@media (max-width: 820px) {
  main { flex-direction: column-reverse; }
  #panel { width: 100%; height: 50%; }
  #stage { height: 50%; }
}

input[type=text] { width: 100%; margin-top: 3px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font: inherit; }
input[type=text]:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
label small { color: var(--muted); font-weight: 400; }
.pieces { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.piece { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.piece i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.piece .nm { flex: 1; min-width: 0; }
.piece .nm small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.piece button { padding: 3px 8px; font-size: 12px; }
[data-show-mode].hidden { display: none !important; }
.info .ok { color: var(--ok); }

.hint { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.45; margin: 4px 0 6px; }
#segBox.hidden, #exSteps.hidden { display: none; }
.segtab { width: 100%; border-collapse: collapse; margin: 4px 0; font-size: 12px; }
.segtab td, .segtab th { padding: 2px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.segtab td:first-child, .segtab th:first-child { text-align: left; }
.segtab tr.cur td { color: var(--text); font-weight: 500; }
