:root {
  color-scheme: dark;
  --bg: #070910;
  --panel: rgba(17, 20, 31, .86);
  --panel-2: rgba(22, 25, 39, .78);
  --line: rgba(255,255,255,.09);
  --text: #f4f6ff;
  --muted: #9299ad;
  --blue: #4da3ff;
  --violet: #8d68ff;
  --pink: #ff4fc7;
  --green: #53e6af;
  --danger: #ff5b6e;
  --radius: 22px;
  --shadow: 0 28px 80px rgba(0,0,0,.38);
}
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; background:var(--bg); color:var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height:100vh; overflow-x:hidden; }
button, input, textarea, select { font:inherit; }
button { color:inherit; }
.ambient { position:fixed; inset:auto; pointer-events:none; filter:blur(70px); opacity:.22; z-index:0; border-radius:50%; }
.ambient-a { width:420px; height:420px; background:var(--blue); top:-160px; left:-120px; }
.ambient-b { width:540px; height:540px; background:var(--pink); right:-260px; top:18%; opacity:.12; }
.topbar { position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between; gap:20px; padding:16px max(24px, calc((100vw - 1460px)/2)); border-bottom:1px solid var(--line); background:rgba(7,9,16,.76); backdrop-filter:blur(20px); }
.brand { display:flex; align-items:center; gap:12px; color:var(--text); text-decoration:none; }
.brand-mark { width:42px; height:42px; display:grid; place-items:center; border-radius:13px; font-weight:900; letter-spacing:-.08em; background:linear-gradient(135deg, rgba(77,163,255,.24), rgba(255,79,199,.23)); border:1px solid rgba(255,255,255,.12); box-shadow:inset 0 0 25px rgba(255,255,255,.03); }
.brand strong { display:block; letter-spacing:.07em; font-size:.94rem; }
.brand small { display:block; color:var(--muted); font-size:.69rem; margin-top:2px; }
.top-status { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.pill { border:1px solid var(--line); color:var(--muted); border-radius:999px; padding:7px 10px; font-size:.69rem; font-weight:800; letter-spacing:.06em; background:rgba(255,255,255,.025); }
.pill.success { color:var(--green); border-color:rgba(83,230,175,.22); }
.app-shell { position:relative; z-index:1; max-width:1460px; margin:0 auto; padding:28px 24px 60px; display:grid; grid-template-columns:minmax(0, 1.7fr) minmax(310px,.68fr); gap:18px; }
.panel { background:linear-gradient(180deg, rgba(19,22,34,.94), rgba(12,15,24,.92)); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); overflow:hidden; }
.workspace, .controls, .output { padding:24px; }
.wide { grid-column:1 / -1; }
.panel-head { display:flex; justify-content:space-between; gap:20px; align-items:flex-start; margin-bottom:18px; }
.panel-head.compact { margin-bottom:16px; align-items:center; }
.eyebrow { display:block; color:#8d95aa; font-size:.67rem; letter-spacing:.17em; font-weight:900; margin-bottom:7px; }
h1,h2,p { margin-top:0; }
h1 { margin-bottom:0; font-size:clamp(1.35rem,2vw,2rem); letter-spacing:-.035em; }
h2 { margin-bottom:0; font-size:1.2rem; letter-spacing:-.025em; }
.counter-wrap { min-width:102px; text-align:right; color:var(--muted); font-size:.83rem; }
.counter-wrap strong { color:var(--text); font-size:1.1rem; margin-right:4px; }
.editor-tools { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px; }
button, .file-btn { border:0; cursor:pointer; transition:.18s ease; }
button:disabled { cursor:not-allowed; opacity:.35; }
.ghost { border:1px solid var(--line); background:rgba(255,255,255,.035); border-radius:10px; padding:9px 12px; font-size:.78rem; font-weight:750; color:#cbd0df; }
.ghost:hover:not(:disabled), .file-btn:hover { background:rgba(255,255,255,.07); border-color:rgba(255,255,255,.16); }
.file-btn { display:inline-flex; align-items:center; }
#textInput { width:100%; min-height:460px; resize:vertical; border:1px solid var(--line); outline:none; border-radius:16px; background:rgba(3,5,10,.68); color:var(--text); padding:20px; line-height:1.68; font-size:1rem; caret-color:var(--pink); }
#textInput:focus { border-color:rgba(141,104,255,.55); box-shadow:0 0 0 3px rgba(141,104,255,.08); }
#textInput::placeholder { color:#5f6679; }
.editor-foot { display:flex; justify-content:space-between; gap:12px; color:var(--muted); font-size:.76rem; margin-top:11px; }
.controls { align-self:start; position:sticky; top:88px; }
.field { display:grid; gap:8px; color:var(--muted); font-size:.76rem; margin-bottom:16px; }
.field > span, .slider-field b { color:#dce0eb; font-weight:760; }
select, .rule-add input { width:100%; border:1px solid var(--line); background:#0c0f18; color:var(--text); border-radius:11px; padding:11px 12px; outline:none; }
.toggle-row { display:flex; align-items:center; justify-content:space-between; gap:16px; border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:15px 0; margin:3px 0 16px; }
.toggle-row.minor { margin-top:18px; }
.toggle-row strong { display:block; font-size:.82rem; letter-spacing:.03em; }
.toggle-row small { display:block; color:var(--muted); font-size:.7rem; margin-top:3px; }
.switch input { display:none; }
.switch span { display:block; width:44px; height:24px; border-radius:999px; background:#242838; position:relative; border:1px solid rgba(255,255,255,.08); }
.switch span:after { content:""; position:absolute; width:18px; height:18px; left:2px; top:2px; border-radius:50%; background:#798095; transition:.2s ease; }
.switch input:checked + span { background:linear-gradient(90deg,rgba(77,163,255,.7),rgba(255,79,199,.7)); }
.switch input:checked + span:after { left:22px; background:white; }
.slider-field { display:grid; gap:8px; margin:14px 0; }
.slider-field > span { display:flex; justify-content:space-between; color:var(--muted); font-size:.76rem; }
.slider-field output { color:#a9b0c2; }
input[type="range"] { accent-color:var(--violet); width:100%; }
.engine-card { border:1px solid rgba(77,163,255,.13); background:linear-gradient(135deg, rgba(77,163,255,.065), rgba(141,104,255,.04)); border-radius:14px; padding:14px; margin:18px 0; }
.engine-card-head { display:flex; justify-content:space-between; color:#7f8aa2; font-size:.62rem; font-weight:850; letter-spacing:.12em; margin-bottom:7px; }
.engine-card strong { font-size:.9rem; }
.engine-card p { color:var(--muted); font-size:.72rem; line-height:1.5; margin:6px 0 0; }
.action { width:100%; min-height:46px; border-radius:12px; font-weight:850; margin-top:9px; }
.primary { background:linear-gradient(100deg, var(--blue), var(--violet) 52%, var(--pink)); box-shadow:0 10px 30px rgba(141,104,255,.18); color:white; border-radius:11px; padding:11px 16px; font-weight:850; }
.primary:hover { filter:brightness(1.08); transform:translateY(-1px); }
.secondary { background:#171b28; border:1px solid rgba(255,255,255,.1); border-radius:11px; padding:11px 16px; font-weight:800; }
.secondary:hover { background:#202535; }
.output-head { flex-wrap:wrap; }
.render-actions { display:flex; gap:8px; }
.progress-wrap { margin:6px 0 16px; }
.progress-track { height:8px; border-radius:999px; overflow:hidden; background:#090c13; border:1px solid rgba(255,255,255,.06); }
.progress-bar { width:0%; height:100%; background:linear-gradient(90deg,var(--blue),var(--violet),var(--pink)); transition:width .2s ease; }
.progress-meta { display:flex; justify-content:space-between; color:var(--muted); font-size:.72rem; margin-top:7px; }
.error-detail { margin:-3px 0 16px; border:1px solid rgba(255,91,110,.24); background:rgba(255,91,110,.07); color:#ffc1c9; border-radius:11px; padding:10px 12px; font-size:.74rem; line-height:1.5; }
#waveform { width:100%; height:150px; display:block; border:1px solid var(--line); border-radius:14px; background:linear-gradient(180deg, rgba(77,163,255,.035), rgba(255,79,199,.02)); }
#audioPlayer { width:100%; margin-top:13px; accent-color:var(--violet); }
.chunk-reader { margin-top:20px; border-top:1px solid var(--line); padding-top:16px; }
.chunk-reader-head { display:flex; justify-content:space-between; color:#d8dceb; font-size:.78rem; margin-bottom:10px; }
.chunk-reader-head span { color:var(--muted); }
.chunk-list { max-height:290px; overflow:auto; display:grid; gap:7px; padding-right:4px; }
.chunk-item { border:1px solid var(--line); background:rgba(255,255,255,.02); border-radius:11px; padding:10px 12px; display:grid; grid-template-columns:58px 1fr auto; gap:11px; align-items:start; transition:.16s ease; }
.chunk-item.active { border-color:rgba(141,104,255,.5); background:rgba(141,104,255,.08); }
.chunk-index { color:#697086; font-size:.66rem; font-weight:850; }
.chunk-text { font-size:.78rem; color:#cfd3df; line-height:1.45; }
.chunk-meta { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.chunk-meta span { border:1px solid var(--line); border-radius:999px; padding:4px 6px; color:#8991a6; font-size:.61rem; white-space:nowrap; }
.empty { color:var(--muted); font-size:.78rem; }
dialog { border:0; padding:0; color:var(--text); background:transparent; max-width:min(640px, calc(100vw - 32px)); width:100%; }
dialog::backdrop { background:rgba(2,4,9,.78); backdrop-filter:blur(8px); }
.dialog-card { background:#111521; border:1px solid var(--line); border-radius:20px; padding:22px; box-shadow:var(--shadow); }
.dialog-head { display:flex; justify-content:space-between; gap:15px; align-items:flex-start; }
.icon-btn { background:rgba(255,255,255,.04); border:1px solid var(--line); border-radius:10px; width:36px; height:36px; font-size:1.5rem; line-height:1; }
.muted { color:var(--muted); line-height:1.5; font-size:.82rem; }
.rule-add { display:grid; grid-template-columns:1fr auto 1fr auto; gap:8px; align-items:center; }
.rule-list { display:grid; gap:7px; margin:15px 0; max-height:230px; overflow:auto; }
.rule-row { display:grid; grid-template-columns:1fr auto 1fr auto; gap:8px; align-items:center; border:1px solid var(--line); border-radius:10px; padding:9px 10px; font-size:.78rem; }
.rule-row span { color:var(--muted); }
.rule-row button { background:transparent; color:var(--danger); }
.dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
#shareUrl { width:100%; min-height:120px; resize:vertical; border:1px solid var(--line); background:#090c13; color:#cfd4df; border-radius:11px; padding:12px; }
.toast { position:fixed; z-index:50; left:50%; bottom:24px; transform:translate(-50%,20px); opacity:0; pointer-events:none; background:#171b27; border:1px solid var(--line); color:#e9ecf6; padding:11px 14px; border-radius:11px; box-shadow:var(--shadow); font-size:.78rem; transition:.2s ease; }
.toast.show { opacity:1; transform:translate(-50%,0); }
@media (max-width: 960px) {
  .app-shell { grid-template-columns:1fr; }
  .wide { grid-column:auto; }
  .controls { position:static; }
  #textInput { min-height:360px; }
}
@media (max-width: 620px) {
  .topbar { align-items:flex-start; padding:14px 16px; }
  .brand small, #privacyPill { display:none; }
  .app-shell { padding:18px 12px 42px; }
  .workspace,.controls,.output { padding:17px; }
  .rule-add { grid-template-columns:1fr; }
  .rule-add > span { display:none; }
  .chunk-item { grid-template-columns:44px 1fr; }
  .chunk-meta { grid-column:2; justify-content:flex-start; }
  .render-actions { width:100%; }
  .render-actions button { flex:1; }
}

.build-pill { opacity:.82; }
.engine-mode-field { margin-top:12px; }
.engine-mode-field select { width:100%; }

/* v0.1.3 worker-runtime controls */
button.danger:not(:disabled){border-color:rgba(255,90,120,.42);color:#ff9ab1}
button.danger:not(:disabled):hover{background:rgba(255,90,120,.09)}

/* v0.1.4 performance visibility */
#perfPill.success{color:var(--green);border-color:rgba(83,230,175,.22)}
#perfPill.warning{color:#ffd37a;border-color:rgba(255,211,122,.22)}
