/* Onde Atelier — "ink & neon" theme. Original design. */
:root {
  --bg: #0b0c18; --panel: #13152a; --panel2: #191c36; --line: #2a2e52; --text: #ecebf5; --muted: #9da1c4;
  --mint: #3df2c8; --pink: #ff4fa3; --gold: #ffd166; --ink: #07080f;
  --radius: 14px; --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--gold);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  background: radial-gradient(900px 480px at 85% -10%, rgba(255, 79, 163, .14), transparent 60%),
              radial-gradient(900px 520px at -10% 10%, rgba(61, 242, 200, .10), transparent 60%), var(--bg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
}
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: #111; padding: 6px 10px; border-radius: 6px; z-index: 20; }
.skip:focus { left: 8px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
a { color: var(--mint); }
[hidden] { display: none !important; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px clamp(12px, 3vw, 32px) 6px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 4px 14px rgba(61, 242, 200, .25)); }
h1 { margin: 0; font-size: 1.45rem; font-weight: 800; letter-spacing: .01em;
  background: linear-gradient(90deg, var(--mint), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 1px 0 0; color: var(--muted); font-size: .9rem; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.lang { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .85rem; }

/* Layout: sticky preview on the left, controls on the right */
.layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 16px; padding: 8px clamp(12px, 3vw, 32px) 20px; align-items: start; }
.stage { position: sticky; top: 10px; }
.controls { display: grid; gap: 12px; min-width: 0; }
.panel { min-width: 0; background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: 0 12px 34px rgba(0, 0, 0, .3); }
h2 { margin: 0 0 10px; font-size: .95rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--gold); }
h3 { font-size: .95rem; margin: 14px 0 6px; }
details.panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; border-radius: 8px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2 { margin: 0; }
details.panel > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 6px 4px; transition: transform .15s; }
details.panel[open] > summary { margin-bottom: 12px; }
details.panel[open] > summary::after { transform: rotate(-135deg); margin-bottom: -4px; }

/* Preview */
.preview {
  position: relative; display: grid; place-items: center; padding: 14px; border-radius: 12px; min-height: 260px;
  background: repeating-conic-gradient(#101225 0 25%, #0d0f1f 0 50%) 0 0 / 22px 22px; border: 1px solid var(--line);
}
.preview canvas {
  display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 290px); min-height: 0;
  border-radius: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
}
.badge { position: absolute; right: 12px; top: 10px; background: rgba(7, 8, 15, .75); color: var(--muted); font-size: .75rem; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.drop-hint { position: absolute; inset: 8px; display: grid; place-items: center; border: 2px dashed var(--mint); border-radius: 12px; background: rgba(7, 8, 15, .78); color: var(--mint); font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .15s; }
.preview.drag .drop-hint { opacity: 1; }

/* Transport */
.transport { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.play {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px 0 14px; border-radius: 99px; cursor: pointer;
  border: 0; font: inherit; font-weight: 800; color: var(--ink); background: linear-gradient(90deg, var(--mint), #8ff7de);
  box-shadow: 0 6px 22px rgba(61, 242, 200, .3);
}
.play svg { width: 22px; height: 22px; fill: currentColor; }
.play .ico-pause, .play.on .ico-play { display: none; }
.play.on .ico-pause { display: block; }
.play.on { background: linear-gradient(90deg, var(--pink), #ff8cc4); box-shadow: 0 6px 22px rgba(255, 79, 163, .3); }
.play:disabled { opacity: .5; cursor: not-allowed; }
.seek { flex: 1; min-width: 0; }
.seek input { width: 100%; }
.times { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.track { flex: 1; min-width: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.sources { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.note { color: var(--muted); font-size: .82rem; margin: 10px 0 0; }
.warn { background: rgba(255, 209, 102, .1); border: 1px solid rgba(255, 209, 102, .45); color: #ffe3a3; border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin: 0 0 10px; }

/* Controls */
select, input[type=number], input[type=text] {
  background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; font: inherit; min-height: 38px; width: 100%; min-width: 0;
}
input[type=number] { width: 96px; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--mint); min-height: 26px; margin: 0; }
input[type=color] { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--ink); padding: 3px; cursor: pointer; }
.btn {
  appearance: none; border: 1px solid var(--line); background: #22264a; color: var(--text); border-radius: 10px;
  padding: 8px 13px; font: inherit; font-weight: 650; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; gap: 7px; transition: background .12s, border-color .12s;
}
.btn:hover { background: #2b3060; border-color: #3c4277; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.ghost { background: transparent; }
.btn.accent { background: linear-gradient(180deg, #ff5fae, #e23d8d); border-color: #ff7fbe; color: #fff; }
.btn.accent:hover { background: linear-gradient(180deg, #ff74b9, #ea4a97); }
.btn.big { min-height: 46px; padding: 0 18px; font-size: 1rem; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: .86rem; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.btn.file:focus-within { box-shadow: var(--focus); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; margin-top: 12px; }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > label, .field .lbl { color: var(--muted); font-size: .82rem; display: flex; justify-content: space-between; gap: 8px; }
.field output { color: var(--text); font-variant-numeric: tabular-nums; }
.wide-field, .checks { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--mint); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quick { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.actions { margin-top: 12px; }
.muted { color: var(--muted); } .small-text { font-size: .8rem; overflow-wrap: anywhere; }

/* Segmented radios */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink); font-weight: 650; font-size: .9rem; }
.seg small { color: var(--muted); font-weight: 500; }
.seg input:checked + span { border-color: var(--mint); background: rgba(61, 242, 200, .12); color: #c9fff1; }
.seg input:checked + span small { color: #9fe9d6; }
.seg input:focus-visible + span { box-shadow: var(--focus); }
.ratio { display: inline-block; border: 2px solid currentColor; border-radius: 3px; opacity: .8; }
.r11 { width: 14px; height: 14px; } .r916 { width: 10px; height: 17px; } .r169 { width: 18px; height: 11px; } .r45 { width: 13px; height: 16px; }

/* Presets */
.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.preset { display: grid; gap: 6px; padding: 6px; border-radius: 11px; border: 1px solid var(--line); background: var(--ink); color: var(--text); font: inherit; font-size: .85rem; font-weight: 650; cursor: pointer; text-align: left; }
.preset:hover { border-color: #4a508a; }
.preset[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.preset .sw { height: 38px; border-radius: 7px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; padding: 6px; }
.preset .sw i { width: 6px; border-radius: 3px; height: 40%; } .preset .sw i:nth-child(2) { height: 85%; } .preset .sw i:nth-child(3) { height: 60%; }

/* Export */
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
progress { flex: 1; height: 12px; accent-color: var(--pink); }
#exportPct { font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
body.exporting .stage .preview { box-shadow: 0 0 0 2px var(--pink) inset; }

/* Footer, dialog, toast */
.foot { padding: 4px clamp(12px, 3vw, 32px) 28px; color: var(--muted); font-size: .85rem; }
dialog { max-width: min(560px, 92vw); background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
dialog::backdrop { background: rgba(4, 5, 12, .7); }
dialog h2 { text-transform: none; letter-spacing: 0; font-size: 1.15rem; }
dialog ol { padding-left: 1.2em; } dialog li { margin: 4px 0; }
.keys { list-style: none; padding: 0; }
kbd { display: inline-block; min-width: 1.8em; text-align: center; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--ink); font: 600 .82rem ui-monospace, Menlo, Consolas, monospace; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); background: #0f1124; border: 1px solid var(--mint); color: var(--text); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; max-width: 92vw; z-index: 30; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stage { position: static; }
  .preview canvas { max-height: 62vh; }
}
@media (max-width: 520px) {
  .top { padding-top: 12px; }
  .tagline { font-size: .8rem; }
  .preview { padding: 8px; min-height: 200px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .play .play-label { display: none; }
  .play { padding: 0 14px; }
  .btn.big { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
