:root {
  --bg: #0d1117; --panel: #161b22; --border: #30363d; --border2: #21262d;
  --text: #e6edf3; --muted: #8b949e; --accent: #58a6ff; --accent2: #3fb950;
  --code-bg: #0d1117; --warn: #d29922;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5; padding: 2rem 1rem;
}
.wrap { max-width: 860px; margin: 0 auto; }
h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 .25rem; }
.sub { color: var(--muted); margin: 0 0 1.5rem; font-size: .9rem; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border); border-radius: 10px; padding: 2.5rem 2rem;
  min-height: 150px; text-align: center; cursor: pointer; transition: .15s; color: var(--muted);
}
.drop svg { width: 34px; height: 34px; margin-bottom: .75rem; opacity: .55; }
.drop:hover svg, .drop.over svg { opacity: 1; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); background: #1c2128; }
.drop input { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .8rem; color: var(--muted); }
.field input, .field select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: .45rem .6rem; font-size: .9rem; width: 150px;
}
button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--accent2); color: #05130a; border: 1px solid transparent; font-weight: 600;
  border-radius: 8px; padding: .62rem 1.25rem; cursor: pointer; font-size: .9rem;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
button:hover:not(:disabled) { background: #4fc264; }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#regen.ok, #regen.ok:hover { background: #2ea043; transform: scale(1.03); }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; }

button.sec { background: #21262d; color: var(--text); border-color: var(--border); }
button.sec:hover:not(:disabled):not(.playing) { background: #2d333b; border-color: #444c56; }
button.sec.playing { background: var(--accent); border-color: var(--accent); color: #04121f; }
button.sec.spk { padding: .5rem .75rem; font-size: 1rem; line-height: 1; }
#preview.playing { background: var(--accent); color: #04121f; }

#exportWav { border-color: rgba(63,185,80,.35); }
#exportWav:hover:not(:disabled) { background: #1b2a20; border-color: var(--accent2); }

/* small ring spinner shown inside a button while a render is in progress,
   with the percent complete rendered in the middle of the ring */
button.has-progress { min-width: 9rem; }
button.sec.spk.has-progress { min-width: 0; padding: .4rem; }
.btn-ring { position: relative; width: 24px; height: 24px; flex: none; }
.btn-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.btn-ring circle { fill: none; stroke-width: 3.2; }
.btn-ring .ring-bg { stroke: rgba(255,255,255,.28); }
.btn-ring .ring-fg {
  stroke: currentColor; stroke-linecap: round; stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--p, 0));
  transition: stroke-dashoffset .12s linear;
}
.btn-ring-pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 7.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.status { font-size: .85rem; color: var(--muted); margin-top: .6rem; min-height: 1.2em; }
canvas { width: 100%; height: 100px; display: block; margin-top: 1rem; border-radius: 6px; background: var(--bg); }
#viz { cursor: pointer; touch-action: none; }
#viz.dragging { cursor: grabbing; }
.viz-time { margin-top: .4rem; font-size: .75rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; overflow-x: auto; font-size: .8rem; font-family: "SF Mono", Consolas, monospace; max-height: 380px; margin: 0; }
.code-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.code-head h2 { font-size: 1rem; margin: 0; }
.out-toggle { cursor: pointer; user-select: none; margin-bottom: 0; gap: 1rem; }
.out-heading { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.out-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: var(--muted); font-size: .7rem; transition: transform .15s; flex: none; }
.out-panel:not(.collapsed) .chevron { transform: rotate(90deg); }
.out-panel:not(.collapsed) .code-head { margin-bottom: .6rem; }
.out-panel.collapsed pre { display: none; }
.out-toggle:hover .out-heading h2 { color: var(--accent); }
.muted-s { font-size: .75rem; color: var(--muted); }
.warn { color: var(--warn); font-size: .8rem; margin-top: .5rem; }
.hidden { display: none; }
.group { padding: .9rem 0; border-top: 1px solid var(--border2); }
.group:first-child { padding-top: 0; border-top: none; }
.group-label { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: .55rem; }
#assignRow { padding: .9rem 0; border-top: 1px solid var(--border2); }
#assignHint { margin-top: .6rem; }
#multiHint { margin-top: .55rem; }
.action-row { border-top: 1px solid var(--border2); padding-top: 1rem; }
code.inline { background: var(--border2); padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }
.site-footer { display: flex; flex-direction: column; align-items: center; gap: .6rem; margin-top: 2.5rem; padding-top: 2rem; border-top: 1px solid var(--border2); }
.gh-btn { display: inline-flex; align-items: center; gap: .5rem; background: var(--panel); border: 1px solid var(--border); color: var(--text); font-size: .85rem; font-weight: 600; padding: .55rem 1.1rem; border-radius: 999px; text-decoration: none; transition: border-color .15s, background .15s, transform .1s; }
.gh-btn:hover { border-color: var(--accent); background: #1c2128; transform: translateY(-1px); }
.gh-btn svg { flex: none; }
.gh-by { color: var(--muted); font-size: .75rem; }