/* AEMDAW — style.css (v1.1)
 * Dois temas quentes: escuro (madeira e pergaminho) e claro (papel e tinta).
 * Ocre, terracota e verde como cores de acção. Sem cartões flutuantes: secções
 * separadas por filetes, como numa mesa de mistura impressa.
 */

/* ---------- Tema escuro (base) ---------- */
:root {
  --bg: #1a1613;
  --bg-2: #211c18;
  --panel: #262019;
  --well: #14110e;
  --well-beat: #1d1813;
  --line: #3b3128;
  --line-soft: #2e2620;
  --text: #ecdfc6;
  --text-soft: #d6c7ab;
  --muted: #a8977c;
  --faint: #6f6252;
  --ochre: #d4a046;
  --ochre-hi: #e6b863;
  --ochre-soft: #8d6c33;
  --on-accent: #1d150c;
  --terra: #c4673f;
  --green: #8fae62;
  --danger: #e0694a;
  --danger-bg: #3a1d15;
  --danger-text: #f0b39f;
  --clip-bg: #6e3923;
  --clip-border: #8e4c31;
  --clip-text: #f3e5cb;
  --wave: rgba(243, 229, 203, .55);
  --hatch: rgba(196, 103, 63, .08);
  --rec-bg: #3a1f16;
  --mute-bg: #4a3a1c;
  --solo-bg: #2f3a1f;
  --backdrop: rgba(10, 8, 6, .72);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 3px;
  color-scheme: dark;
}

/* ---------- Tema claro ---------- */
:root[data-theme="light"] {
  --bg: #faf6ee;
  --bg-2: #f2ebde;
  --panel: #fffdf8;
  --well: #ebe2d0;
  --well-beat: #e2d6c0;
  --line: #d3c5aa;
  --line-soft: #e4d9c4;
  --text: #2b2219;
  --text-soft: #3d3226;
  --muted: #6b5c48;
  --faint: #998a72;
  --ochre: #a8741f;
  --ochre-hi: #c08a2c;
  --ochre-soft: #ddb977;
  --on-accent: #fffaf0;
  --terra: #a5502d;
  --green: #4d7a2c;
  --danger: #b23b22;
  --danger-bg: #f6e1d8;
  --danger-text: #8f2c17;
  --clip-bg: #edc9ad;
  --clip-border: #c98d68;
  --clip-text: #3a2416;
  --wave: rgba(90, 45, 20, .55);
  --hatch: rgba(165, 80, 45, .10);
  --rec-bg: #f5d9cc;
  --mute-bg: #f3e2bd;
  --solo-bg: #dfeacb;
  --backdrop: rgba(40, 30, 20, .45);
  color-scheme: light;
}

/* Sem JavaScript, segue a preferência do sistema */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #faf6ee; --bg-2: #f2ebde; --panel: #fffdf8; --well: #ebe2d0; --well-beat: #e2d6c0;
    --line: #d3c5aa; --line-soft: #e4d9c4; --text: #2b2219; --text-soft: #3d3226; --muted: #6b5c48;
    --faint: #998a72; --ochre: #a8741f; --ochre-hi: #c08a2c; --ochre-soft: #ddb977; --on-accent: #fffaf0;
    --terra: #a5502d; --green: #4d7a2c; --danger: #b23b22; --danger-bg: #f6e1d8; --danger-text: #8f2c17;
    --clip-bg: #edc9ad; --clip-border: #c98d68; --clip-text: #3a2416; --wave: rgba(90, 45, 20, .55);
    --hatch: rgba(165, 80, 45, .10); --rec-bg: #f5d9cc; --mute-bg: #f3e2bd; --solo-bg: #dfeacb;
    --backdrop: rgba(40, 30, 20, .45);
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; margin: 0; }
a { color: var(--ochre); }
small { font-size: .82em; }
p { margin: .4rem 0; }

:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
input[type=range] { accent-color: var(--ochre); }
input[type=checkbox] { accent-color: var(--ochre); width: 1.05rem; height: 1.05rem; }

.sr, .hp {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--ochre); color: var(--on-accent); padding: .5rem .8rem; z-index: 99; }
.skip:focus { left: .5rem; top: .5rem; }

.hint { color: var(--muted); font-size: .88rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.row.end { justify-content: flex-end; }

/* ---------- Campos e botões ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=range]), select, textarea {
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .45rem .55rem;
  min-height: 2.25rem;
  max-width: 100%;
  color: var(--text);
}
input:not([type=checkbox]):not([type=range]):focus, select:focus, textarea:focus { border-color: var(--ochre-soft); }
textarea { resize: vertical; width: 100%; }

.btn, .tbtn, .mini, .theme-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: .42rem .8rem;
  min-height: 2.25rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover, .tbtn:hover, .mini:hover, .theme-btn:hover { border-color: var(--ochre-soft); background: var(--bg-2); }
.btn:disabled, .tbtn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-busy=true], .tbtn[aria-busy=true] { cursor: progress; }
.btn.primary { background: var(--ochre); border-color: var(--ochre); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--ochre-hi); }
.btn.danger { border-color: var(--danger); color: var(--danger-text); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { padding: .25rem .55rem; min-height: 1.9rem; font-size: .85rem; }
.btn.big { padding: .7rem 1.2rem; font-size: 1rem; }

label { display: block; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); }
label.inline input, label.inline select { color: var(--text); }
label.check { gap: .35rem; }

.notice {
  border-left: 3px solid var(--muted);
  background: var(--bg-2);
  padding: .6rem .8rem;
  margin: .8rem 0;
}
.notice.is-error { border-color: var(--danger); }
.notice.is-ok { border-color: var(--green); }
.notice.is-warn, .notice.is-info { border-color: var(--ochre); }

.ico { width: 12px; height: 12px; display: inline-block; flex: none; }
.ico-theme { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }

/* ---------- Marca, cabeçalho e rodapé comuns ---------- */
.brand { display: inline-flex; align-items: center; gap: .45rem; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; letter-spacing: .04em; color: var(--text); text-decoration: none; }
.mark { width: 18px; height: 18px; display: inline-block; background:
  linear-gradient(var(--ochre), var(--ochre)) 2px 8px / 2px 6px no-repeat,
  linear-gradient(var(--ochre), var(--ochre)) 6px 3px / 2px 12px no-repeat,
  linear-gradient(var(--terra), var(--terra)) 10px 6px / 2px 8px no-repeat,
  linear-gradient(var(--green), var(--green)) 14px 9px / 2px 4px no-repeat; }

.site-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .6rem 1.2rem;
  max-width: 1200px; margin: 0 auto; padding: .9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.1rem; }
.site-nav > a:not(.btn) { color: var(--text-soft); text-decoration: none; font-size: .95rem; }
.site-nav > a:not(.btn):hover { color: var(--ochre); text-decoration: underline; }

.foot { color: var(--faint); font-size: .82rem; text-align: center; padding: 1.4rem 1rem 2rem; border-top: 1px solid var(--line-soft); }
.foot a { color: var(--muted); }
.foot-note { display: block; margin-top: .2rem; }

/* ---------- Página principal ---------- */
.hero {
  max-width: 1200px; margin: 0 auto; padding: 3.5rem 1rem 3rem;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 3rem; align-items: center;
}
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.5rem); line-height: 1.08; }
.hero .lede { font-size: 1.15rem; max-width: 34rem; }
.hero .row { margin-top: 1.4rem; }
.hero-art { margin: 0; padding: 1.2rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.art-row { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr); gap: .7rem; align-items: center; margin: .45rem 0; }
.art-name { font-family: var(--serif); font-size: .9rem; color: var(--muted); }
.art-steps { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; }
.art-steps i { display: block; aspect-ratio: 1 / 1.2; background: var(--well); border: 1px solid var(--line-soft); border-radius: 2px; }
.art-steps i.beat { background: var(--well-beat); }
.art-steps i.on { background: var(--ochre); border-color: var(--ochre-hi); }
.art-steps i.soft { background: var(--ochre-soft); }
.hero-art figcaption { font-size: .85rem; color: var(--muted); margin-top: .9rem; font-family: var(--serif); font-style: italic; }

.prose-block { max-width: 1200px; margin: 0 auto; padding: 2.6rem 1rem; border-top: 1px solid var(--line); }
.prose-block h2 { font-size: 1.7rem; margin-bottom: 1.2rem; }
.prose-block h2::after { content: ""; display: block; width: 2.6rem; height: 2px; background: var(--ochre); margin-top: .4rem; }
.features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6rem 3rem; margin: 0; }
.features dt { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; margin-bottom: .25rem; }
.features dd { margin: 0; color: var(--text-soft); }
.steps-list { list-style: none; counter-reset: passo; padding: 0; margin: 0; max-width: 46rem; }
.steps-list li { counter-increment: passo; position: relative; padding: .55rem 0 .55rem 3rem; border-bottom: 1px dashed var(--line-soft); }
.steps-list li::before { content: counter(passo); position: absolute; left: 0; top: .3rem; font-family: var(--serif); font-size: 1.6rem; color: var(--ochre); line-height: 1; }
.faq { max-width: 46rem; }
.faq details { border-top: 1px solid var(--line-soft); padding: .7rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--line-soft); }
.faq summary { cursor: pointer; font-family: var(--serif); font-size: 1.08rem; }
.faq details p { color: var(--text-soft); margin-top: .5rem; }
.hero-tut { margin-top: 1.1rem; font-size: .98rem; }
.hero-tut a { color: var(--text); font-weight: 600; text-decoration-color: var(--ochre); text-underline-offset: 3px; }
.play-dot { display: inline-block; width: 0; height: 0; border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent var(--ochre); margin-right: .45rem; vertical-align: 0; }
.tut-teaser .lede { max-width: 46rem; }
.tut-chapters { max-width: 46rem; padding-left: 1.4rem; margin: 1rem 0 1.4rem; }
.tut-chapters li { margin: .35rem 0; color: var(--text-soft); }
.tut-chapters li::marker { font-family: var(--serif); color: var(--ochre); }
.tut-chapters strong { color: var(--text); }
.closing { max-width: 1200px; margin: 0 auto; padding: 2.6rem 1rem 3rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.closing-line { font-family: var(--serif); font-size: 1.4rem; margin: 0; }

.site-foot { border-top: 1px solid var(--line); background: var(--bg-2); padding: 1.6rem 1rem 1.8rem; }
.foot-cols { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 2rem; font-size: .92rem; }
.foot-cols a { color: var(--text-soft); }
.powered { max-width: 1200px; margin: 1rem auto 0; padding-top: .8rem; border-top: 1px solid var(--line-soft); text-align: center; color: var(--muted); font-size: .88rem; }
.powered a { color: var(--ochre); font-weight: 600; }

/* ---------- Arranque e acesso ---------- */
.boot { min-height: 60vh; display: grid; place-items: center; font-family: var(--serif); color: var(--muted); font-size: 1.15rem; padding: 2rem; text-align: center; }

.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth .site-head { width: 100%; }
.auth-inner { width: 100%; max-width: 34rem; margin: 0 auto; padding: 2.5rem 1rem 2rem; flex: 1; }
.auth-head { border-bottom: 1px solid var(--line); padding-bottom: 1.2rem; margin-bottom: 1rem; }
.kicker { text-transform: uppercase; letter-spacing: .18em; font-size: .75rem; color: var(--ochre); margin: 0 0 .4rem; }
.auth h1 { font-size: clamp(2.6rem, 9vw, 3.6rem); line-height: 1; }
.lede { font-family: var(--serif); font-size: 1.08rem; color: var(--text-soft); margin-top: .8rem; }

.tabs { display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; border-bottom: 1px solid var(--line-soft); margin-bottom: .6rem; }
.tabs [role=tab] {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .45rem 0; color: var(--muted); cursor: pointer;
}
.tabs [role=tab][aria-selected=true] { color: var(--text); border-bottom-color: var(--ochre); }

.pane label, .dlg label { margin: .8rem 0; font-size: .92rem; color: var(--muted); }
.pane label input:not([type=checkbox]):not([type=radio]), .pane label textarea, .dlg label input:not([type=checkbox]):not([type=radio]), .dlg label textarea { display: block; width: 100%; margin-top: .3rem; color: var(--text); }
.dlg label.inline, .pane label.inline { margin: .25rem 0; }
.dlg label.inline input[type=checkbox], .dlg label.inline input[type=radio], .pane label.inline input[type=checkbox] { flex: none; margin: 0; }
.pane label small { color: var(--faint); }
.pane .btn.primary { margin-top: .5rem; }

/* ---------- Barra de transporte ---------- */
.transport {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: .5rem 1rem;
  padding: .55rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.proj-name input { width: 15rem; font-family: var(--serif); font-size: 1rem; background: transparent !important; border-color: transparent !important; border-bottom-color: var(--line) !important; border-radius: 0 !important; }
.tgroup { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.tgroup + .tgroup { border-left: 1px solid var(--line-soft); padding-left: 1rem; }
.tgroup input[type=number] { width: 4.4rem; font-family: var(--mono); }
.tbtn.strong { border-color: var(--ochre-soft); }
.clock { font-family: var(--mono); font-size: .95rem; background: var(--well); border: 1px solid var(--line-soft); padding: .3rem .55rem; border-radius: var(--radius); min-width: 9.5rem; text-align: center; }

.ico-play { width: 0; height: 0; border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent var(--green); }
.ico-pause { border-left: 4px solid var(--ochre); border-right: 4px solid var(--ochre); width: 11px; }
.ico-stop { background: var(--text); }
.ico-rec { background: var(--terra); border-radius: 50%; }
.ico-rewind { border-left: 2px solid var(--text); position: relative; }
.ico-rewind::after { content: ""; position: absolute; left: 1px; top: 1px; border-style: solid; border-width: 5px 8px 5px 0; border-color: transparent var(--text) transparent transparent; }
#btn-play[aria-pressed=true] { border-color: var(--green); }
#btn-record[aria-pressed=true] { border-color: var(--terra); background: var(--rec-bg); }
body.is-recording #btn-record .ico-rec { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 15rem; max-width: calc(100vw - 16px); background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; padding: .4rem; overflow-y: auto; overscroll-behavior: contain; box-sizing: border-box;
}
.menu-list button, .menu-list .menu-link { background: none; border: 0; text-align: left; padding: .55rem .6rem; cursor: pointer; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.menu-list button:hover, .menu-list .menu-link:hover { background: var(--bg-2); }
.who { margin: .2rem .6rem .5rem; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line-soft); padding-bottom: .5rem; }

.statusbar {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  padding: .35rem 1rem; font-size: .88rem; color: var(--text-soft);
  border-bottom: 1px solid var(--line-soft); background: var(--bg);
}
#status-text { flex: 1; min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--green); }
.dot.play { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.dot.rec { background: var(--terra); animation: pulse 1s infinite; }
.dot.busy { background: var(--ochre); animation: pulse 1.2s infinite; }
.dot.error { background: var(--danger); }
.dirty { margin-left: auto; color: var(--ochre); font-size: .82rem; }

/* ---------- Secções do estúdio ---------- */
main#main { max-width: 1400px; margin: 0 auto; padding: 0 1rem 1rem; }
.block { padding: 1.4rem 0 1.2rem; border-bottom: 1px solid var(--line); }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .6rem 1rem; margin-bottom: .4rem; }
.block-head h2 { font-size: 1.35rem; }
.block-head h2::after { content: ""; display: block; width: 2.2rem; height: 2px; background: var(--ochre); margin-top: .3rem; }
.block-tools { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; }

/* ---------- Sequenciador ---------- */
.tracks { margin-top: .8rem; }
.track {
  display: grid;
  grid-template-columns: minmax(240px, 290px) 1fr;
  gap: .8rem 1.2rem;
  align-items: start;
  padding: .7rem 0;
  border-top: 1px dashed var(--line-soft);
}
.track:first-child { border-top: 0; }
.track.muted .steps { opacity: .45; }
.track.missing .tsample { border-color: var(--danger); }
.tctl { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.trow { display: flex; gap: .35rem; align-items: center; min-width: 0; }
.tname { flex: 1; min-width: 0; font-family: var(--serif); background: transparent !important; border-color: transparent !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; padding-left: 0 !important; }
.tsample { flex: 1; min-width: 0; }
.mini { min-height: 2rem; min-width: 2rem; padding: 0 .4rem; justify-content: center; font-weight: 600; font-family: var(--mono); }
.tmute[aria-pressed=true] { background: var(--mute-bg); border-color: var(--ochre); color: var(--ochre); }
.tsolo[aria-pressed=true] { background: var(--solo-bg); border-color: var(--green); color: var(--green); }
.tdel:hover { border-color: var(--danger); color: var(--danger); }
.knobs label { display: flex; align-items: center; gap: .35rem; flex: 1; font-size: .8rem; color: var(--muted); min-width: 0; }
.knobs input[type=range] { width: 100%; min-width: 0; }

.tfx { border-top: 1px dotted var(--line-soft); padding-top: .3rem; }
.tfx summary { cursor: pointer; font-size: .82rem; color: var(--muted); list-style-position: inside; }
.tfx summary .fx-on { color: var(--ochre); }
.fxgrid label { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr) 3.8rem; gap: .4rem; align-items: center; font-size: .8rem; color: var(--muted); margin: .25rem 0; }
.fxgrid input[type=range] { width: 100%; min-width: 0; }
.fxgrid output { font-family: var(--mono); font-size: .75rem; text-align: right; color: var(--text); }

/* passos quadrados e compactos: no máximo 36 px, alinhados à esquerda */
.steps { display: grid; gap: 4px; align-self: center; --cell: 36px; }
.steps.s8 { grid-template-columns: repeat(8, minmax(0, var(--cell))); }
.steps.s16, .steps.s32 { grid-template-columns: repeat(16, minmax(0, var(--cell))); }
.step {
  appearance: none;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  background: var(--well);
  aspect-ratio: 1 / 1;
  min-height: 0;
  min-width: 0;
  padding: 0;
  cursor: pointer;
  transition: background-color .06s;
}
.step.beat { background: var(--well-beat); border-color: var(--line); }
.step:hover { border-color: var(--ochre-soft); }
.step.on { background: var(--ochre); border-color: var(--ochre-hi); }
.step.soft { background: var(--ochre-soft); border-color: var(--ochre); }
.step.now { box-shadow: inset 0 0 0 2px var(--green); }
.step.on.now, .step.soft.now { box-shadow: inset 0 0 0 2px var(--text); }

/* ---------- Padrões, notas e arranjo (v3) ---------- */
.mini-out { font-family: var(--mono); font-size: .8rem; min-width: 2.6rem; color: var(--text); }
.pat-tabs { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pat-label { font-size: .85rem; color: var(--muted); padding: 0 .55rem; }
.pat-tabs [data-pat] { background: transparent; border: 0; border-left: 1px solid var(--line); min-width: 2.3rem; min-height: 2.25rem; cursor: pointer; font-family: var(--serif); font-weight: 600; color: var(--muted); }
.pat-tabs [data-pat][aria-pressed=true] { background: var(--ochre); color: var(--on-accent); }
.pat-tabs [data-pat]:hover:not([aria-pressed=true]) { background: var(--bg-2); color: var(--text); }
.tnotes[aria-pressed=true] { background: var(--mute-bg); border-color: var(--ochre); color: var(--ochre); }
.tgrid { display: flex; flex-direction: column; gap: 4px; align-self: center; min-width: 0; width: 100%; }
.tgrid > .steps, .tgrid > .notes { align-self: stretch; width: 100%; }
.notes { display: grid; gap: 4px; --cell: 36px; }
.notes.s8 { grid-template-columns: repeat(8, minmax(0, var(--cell))); }
.notes.s16, .notes.s32 { grid-template-columns: repeat(16, minmax(0, var(--cell))); }
select.tnote { min-height: 1.9rem !important; padding: 0 .1rem !important; font-size: .72rem; text-align: center; min-width: 0; width: 100%; appearance: none; -webkit-appearance: none; background-image: none; }
select.tnote.idle { opacity: .35; }

.arr { position: relative; height: 30px; border-bottom: 1px solid var(--line); background: var(--panel); }
.arr-name { position: sticky; left: 4px; top: 8px; font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .12em; pointer-events: none; z-index: 1; display: inline-block; }
.arr-cell { position: absolute; top: 3px; height: 23px; border: 1px solid var(--line); border-radius: 2px; cursor: pointer; font-family: var(--serif); font-weight: 600; font-size: .85rem; line-height: 1; padding: 0; color: var(--text); background: var(--well); z-index: 2; }
.arr-cell.pA { background: color-mix(in srgb, var(--ochre) 35%, var(--well)); border-color: var(--ochre); }
.arr-cell.pB { background: color-mix(in srgb, var(--terra) 35%, var(--well)); border-color: var(--terra); }
.arr-cell.pC { background: color-mix(in srgb, var(--green) 35%, var(--well)); border-color: var(--green); }
.arr-cell.pD { background: color-mix(in srgb, var(--muted) 35%, var(--well)); border-color: var(--muted); }
.arr-cell.px { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--hatch) 5px 7px); color: var(--faint); }
.arr-cell.now { box-shadow: 0 0 0 2px var(--text); }

.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin: 0; padding: .55rem 1rem; background: var(--bg-2); border-bottom: 1px solid var(--line-soft); border-left: 3px solid var(--ochre); font-size: .92rem; }

.choices { border: 0; padding: 0; margin: .6rem 0; }
.choices legend { font-size: .92rem; color: var(--muted); margin-bottom: .3rem; }
.dlg label.choice, label.choice { display: flex; gap: .7rem; align-items: flex-start; margin: 0; padding: .6rem .2rem; border-top: 1px solid var(--line-soft); cursor: pointer; color: var(--text); }
label.choice:last-child { border-bottom: 1px solid var(--line-soft); }
label.choice input { margin-top: .25rem; width: auto !important; display: inline !important; flex: none; accent-color: var(--ochre); }
label.choice span { display: flex; flex-direction: column; }
label.choice strong { font-family: var(--serif); }
label.choice small { color: var(--muted); font-size: .85rem; }
label.choice:has(input:disabled) { opacity: .5; cursor: not-allowed; }

.master .quick .row { margin: .4rem 0; }
#m-compare[aria-pressed=true] { background: var(--rec-bg); border-color: var(--terra); }
.readout { font-family: var(--mono); font-size: .85rem; margin: .5rem 0 .2rem; color: var(--text); }

/* ---------- Ferramentas secundárias, marcadores, ciclo e automação (v1.3) ---------- */
.block-tools.sub { margin: .2rem 0 .4rem; padding-top: .35rem; border-top: 1px dotted var(--line-soft); justify-content: flex-start; }
.inline-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.inline-group input[type=number] { width: 4.2rem; font-family: var(--mono); }
#btn-cycle[aria-pressed=true] { border-color: var(--green); background: var(--solo-bg); }

.markers { position: relative; height: 22px; border-bottom: 1px solid var(--line-soft); background: var(--bg-2); }
.marker {
  position: absolute; top: 2px; height: 18px; max-width: 140px; padding: 0 .35rem 0 .45rem;
  border: 0; border-left: 2px solid var(--terra); background: color-mix(in srgb, var(--terra) 18%, transparent);
  color: var(--text); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; z-index: 3;
}
.marker:hover, .marker:focus-visible { background: color-mix(in srgb, var(--terra) 32%, transparent); }
.cycle-band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--green) 22%, transparent); border-left: 2px solid var(--green); border-right: 2px solid var(--green); pointer-events: none; }

.auto-lane { position: relative; height: 64px; border-top: 1px solid var(--line); background: var(--panel); }
.auto-svg { display: block; touch-action: none; cursor: crosshair; }
.auto-base { stroke: var(--faint); stroke-dasharray: 3 4; stroke-width: 1; }
.auto-line { fill: none; stroke: var(--ochre); stroke-width: 2; }
.auto-line.off { stroke: var(--faint); stroke-dasharray: 5 4; }
.auto-pt { fill: var(--bg); stroke: var(--ochre); stroke-width: 2; cursor: grab; }
.auto-pt:hover { fill: var(--ochre); }
.auto-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; padding: .5rem 0 .2rem; }
.auto-tools select { max-width: 18rem; }

/* ---------- Misturador ---------- */
.mixer { display: flex; flex-direction: column; gap: 0; margin-top: .4rem; }
.strip {
  display: grid; grid-template-columns: minmax(6rem, 10rem) minmax(5rem, 1fr) 14px minmax(7rem, 1.4fr) 4.6rem minmax(4rem, .8fr) auto;
  gap: .4rem .7rem; align-items: center; padding: .35rem 0; border-top: 1px dashed var(--line-soft);
}
.strip:first-child { border-top: 0; }
.strip-name { font-family: var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-meter { width: 100%; height: 10px; }
.strip-ctl input { width: 100%; }
.strip .mx-db { font-family: var(--mono); font-size: .78rem; text-align: right; }
.strip-ms { display: inline-flex; gap: .3rem; align-items: center; }
.master-strip { border-top: 1px solid var(--line); margin-top: .2rem; padding-top: .55rem; }
.master-strip .strip-name { font-weight: 600; color: var(--ochre); }
.clip-led { width: 12px; height: 12px; border-radius: 50%; border: 0; padding: 0; background: var(--danger); cursor: pointer; }
.clip-led[hidden] { display: inline-block !important; visibility: hidden; }
.mx-mute[aria-pressed=true] { background: var(--mute-bg); border-color: var(--ochre); color: var(--ochre); }
.mx-solo[aria-pressed=true] { background: var(--solo-bg); border-color: var(--green); color: var(--green); }
.tag { font-size: .72rem; padding: .05rem .4rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

/* ---------- Medição no Master ---------- */
.corr { position: relative; display: inline-block; width: 100%; height: 10px; border: 1px solid var(--line-soft); background: linear-gradient(90deg, color-mix(in srgb, var(--danger) 35%, var(--well)), var(--well) 50%, color-mix(in srgb, var(--green) 35%, var(--well))); }
.corr-dot { position: absolute; top: -3px; width: 4px; height: 14px; margin-left: -2px; left: 50%; background: var(--text); transition: left .1s; }
.corr-dot.bad { background: var(--danger); }
.spectrum { display: block; width: 100%; height: 90px; background: var(--well); border: 1px solid var(--line-soft); color: var(--ochre); margin: .4rem 0; }
#m-mono[aria-pressed=true], #ref-ab[aria-pressed=true] { background: var(--rec-bg); border-color: var(--terra); }

/* ---------- Diálogos novos ---------- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.dlg .grid2 label select, .dlg label select { display: block; width: 100%; margin-top: .3rem; color: var(--text); }
.checks { display: flex; flex-direction: column; gap: .3rem; margin: .4rem 0; }
.checks label.inline { color: var(--text); }
pre.report { white-space: pre-wrap; font-family: var(--mono); font-size: .78rem; background: var(--well); border: 1px solid var(--line-soft); padding: .6rem .7rem; max-height: 16rem; overflow: auto; margin: .6rem 0 .4rem; }
pre.report.logs { max-height: 28rem; }
.missing-row { border-top: 1px solid var(--line-soft); padding: .6rem 0; }
.missing-row select { max-width: 16rem; }
.facts.keys dt { font-family: var(--mono); }
.dlg label small.hint { display: block; margin-top: .25rem; }
.tuner-note { font-family: var(--serif); font-size: 3rem; text-align: center; margin: .4rem 0; }
.tuner-scale { position: relative; height: 18px; margin: .6rem 0; border: 1px solid var(--line); background: linear-gradient(90deg, var(--well), color-mix(in srgb, var(--green) 30%, var(--well)) 45%, color-mix(in srgb, var(--green) 30%, var(--well)) 55%, var(--well)); }
.tuner-needle { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; left: 50%; background: var(--terra); transition: left .12s; }
.tuner-needle.ok { background: var(--green); }
#dlg-tuner .hint { text-align: center; }

/* ---------- Gravação ---------- */
.rec-live { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .6rem 0; }
.rec-lamp { width: 12px; height: 12px; border-radius: 50%; background: var(--terra); animation: pulse 1s infinite; }
.rec-review audio { width: 100%; max-width: 32rem; margin-top: .4rem; }
progress { width: 100%; max-width: 32rem; height: 8px; accent-color: var(--ochre); margin-top: .6rem; }

/* ---------- Linha do tempo ---------- */
.tl-wrap { overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); background: var(--well); margin-top: .8rem; -webkit-overflow-scrolling: touch; }
.timeline { position: relative; min-width: 100%; }
.ruler { position: relative; height: 26px; border-bottom: 1px solid var(--line); cursor: pointer; background: var(--bg-2); }
.tick { position: absolute; bottom: 0; width: 1px; height: 7px; background: var(--faint); }
.tick.bar { height: 100%; background: var(--line); }
.tick.bar span { position: absolute; left: 4px; top: 3px; font: 11px var(--mono); color: var(--muted); }
.song-end { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--terra); }
.lanes { position: relative; touch-action: pan-x; }
.lane { position: relative; height: 64px; border-bottom: 1px solid var(--line-soft); }
.lane.drop { background: color-mix(in srgb, var(--ochre) 18%, transparent); box-shadow: inset 0 0 0 2px var(--ochre); }
.lane.lane-muted .clip { opacity: .45; }
.tl-drop-hint { margin: .2rem 0 .4rem; }
.lane:last-child { border-bottom: 0; }
.lane { display: flex; align-items: flex-end; }
/* o nome da pista fica por cima dos clips, em baixo à esquerda, e acompanha o deslocamento */
/* cabeça de cada pista: botão de ouvir só esta pista e nome (abre o canal no misturador) */
.lane-head { position: sticky; left: 4px; z-index: 4; display: inline-flex; align-items: center; gap: 3px; margin: 0 0 3px; max-width: calc(100% - 8px); pointer-events: none; }
.lane-play, .lane-name { pointer-events: auto; }
.lane-play { flex: none; width: 22px; height: 18px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 2px; background: color-mix(in srgb, var(--panel) 88%, transparent); cursor: pointer; }
.lane-play .ico { width: 9px; height: 9px; transform: scale(.8); }
.lane-play .ico-play { border-width: 5px 0 5px 8px; }
.lane-play:disabled { opacity: .35; cursor: default; }
.lane-play[aria-pressed=true] { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.lane-play:focus-visible, .lane-name:focus-visible { outline: 2px solid var(--ochre); outline-offset: 1px; }
.lane-name { padding: 0 .3rem; font: inherit; font-size: 10px; line-height: 16px; color: var(--muted); background: color-mix(in srgb, var(--panel) 82%, transparent); border: 0; border-radius: 2px; text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; cursor: pointer; }
.lane-name:hover { color: var(--text); text-decoration: underline; }
.lane.lane-live { background: color-mix(in srgb, var(--green) 8%, transparent); }
.lane.lane-live .lane-name { color: var(--text); }
.strip.flash { animation: stripflash 1.6s ease-out; }
@keyframes stripflash { 0%, 40% { box-shadow: 0 0 0 3px var(--ochre); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Modo simples e janelas a pedido */
body.ui-simple .adv { display: none !important; }
.block.win-off { display: none !important; }
.win-close { flex: none; width: 1.5rem; height: 1.5rem; margin-left: .3rem; display: inline-grid; place-items: center; padding: 0; background: transparent; border: 1px solid transparent; border-radius: 2px; color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.win-close:hover { border-color: var(--line); color: var(--text); }
.views [data-view].is-off { opacity: .62; }
.views [data-view].is-off:hover { opacity: 1; }
.mode-btn { border-style: dashed; }
.mode-btn[aria-pressed=true] { border-style: solid; border-color: var(--green); }
.simple-note { border-left-color: var(--green); }

/* Editor de áudio: ocupa o ecrã inteiro */
dialog.editor-dlg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; border-radius: 0; }
.ed { display: flex; flex-direction: column; min-height: 100%; padding: .6rem 1rem 1rem; box-sizing: border-box; }
.ed-file { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.ed-open { max-width: 48rem; padding: 1rem 0; }
.ed-open .row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.ed-open label { max-width: 100%; flex-wrap: wrap; }
.ed-open select { max-width: 100%; min-width: 0; }
.ed-work { display: flex; flex-direction: column; gap: .5rem; }
.ed-bar, .ed-sel { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
.ed-grp { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.ed-bar .tbtn { min-width: 2.3rem; justify-content: center; }
.ed-over { display: block; width: 100%; height: 38px; background: var(--well); border: 1px solid var(--line-soft); border-top-color: var(--ochre); border-radius: var(--radius); color: color-mix(in srgb, var(--muted) 70%, transparent); cursor: pointer; touch-action: none; }
.ed-view { position: relative; height: clamp(170px, 34vh, 340px); background: var(--well); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: text; touch-action: none; user-select: none; }
.ed-view:focus-visible { outline: 2px solid var(--ochre); outline-offset: 1px; }
.ed-ruler { position: absolute; left: 0; top: 0; width: 100%; height: 20px; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.ed-wave { position: absolute; left: 0; top: 20px; width: 100%; height: calc(100% - 20px); color: var(--green); }
.ed-selbox { position: absolute; top: 20px; bottom: 0; background: color-mix(in srgb, var(--ochre) 24%, transparent); border-left: 2px solid var(--ochre); border-right: 2px solid var(--ochre); pointer-events: none; }
.ed-cur { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--text); pointer-events: none; }
.ed-needle { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--terra); pointer-events: none; }
.ed-needle::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); border-style: solid; border-width: 8px 6px 0; border-color: var(--terra) transparent transparent; }
.ed-sel input[type=number] { width: 6.5rem; }
.ed-slen { font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.ed-tip { margin: 0; }
.ed-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr)); gap: .6rem; }
.ed-tools fieldset { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0; padding: .5rem .6rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); }
.ed-tools legend { font-weight: 600; font-size: .82rem; padding: 0 .3rem; }
.ed-tools .hint { flex-basis: 100%; margin: 0 0 .2rem; font-size: .78rem; }
.ed-tools input[type=number] { width: 4.5rem; }
.ed-join { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; flex-basis: 100%; }
.ed-join select { max-width: 14rem; min-width: 0; }
.ed-join label { max-width: 100%; flex-wrap: wrap; }
#ed-prog { width: 100%; }
.ed-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .4rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.ed-foot #ed-info { flex: 1 1 14rem; }
.ed-foot input#ed-name { width: 16rem; max-width: 100%; }
@media (max-width: 700px) {
  .ed { padding: .4rem .6rem .8rem; }
  .ed-bar .lbl { display: none; }
  .ed-view { height: 180px; }
  .ed-tools { grid-template-columns: 1fr; }
  .ed-sel input[type=number] { width: 5.2rem; }
  .ed-foot input#ed-name { width: 100%; }
  .ed-join select { max-width: 100%; }
}
.beyond { position: absolute; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, var(--hatch) 6px 7px); pointer-events: none; }
.clip {
  position: absolute; top: 3px; height: 57px;
  background: var(--clip-bg);
  border: 1px solid var(--clip-border);
  border-radius: 6px;
  color: var(--clip-text);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  z-index: 2;
}
.clip:active { cursor: grabbing; }
.clip.sel { box-shadow: 0 0 0 2px var(--ochre); z-index: 3; }
.clip.muted { opacity: .4; }
.clip.missing { border-style: dashed; opacity: .7; }
.clip-head { position: absolute; left: 0; right: 0; top: 0; height: 16px; padding: 0 20px; background: rgba(0, 0, 0, .14); pointer-events: none; z-index: 1; overflow: hidden; }
.clip-name { display: block; font-size: 11px; line-height: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wave { position: absolute; left: 0; bottom: 1px; height: 38px; color: var(--wave); pointer-events: none; }
/* pegas: pontas para aparar e quadradinhos para as entradas e saídas suaves */
.clip-trim { position: absolute; top: 0; bottom: 0; width: 8px; z-index: 2; cursor: ew-resize; }
.clip-trim.l { left: 0; }
.clip-trim.r { right: 0; }
.clip-trim::after { content: ""; position: absolute; top: 22px; bottom: 10px; width: 2px; border-radius: 1px; background: currentColor; opacity: 0; }
.clip-trim.l::after { left: 2px; }
.clip-trim.r::after { right: 2px; }
.clip:hover .clip-trim::after, .clip.sel .clip-trim::after { opacity: .55; }
.clip-fh { position: absolute; top: 2px; width: 9px; height: 9px; z-index: 3; background: var(--panel); border: 1px solid currentColor; border-radius: 2px; cursor: ew-resize; opacity: 0; }
.clip-fh.in { left: 9px; }
.clip-fh.out { right: 9px; }
.clip:hover .clip-fh, .clip.sel .clip-fh { opacity: 1; }
.clip-fade { position: absolute; top: 16px; bottom: 0; background: rgba(0, 0, 0, .32); pointer-events: none; z-index: 1; }
.clip-fade.in { left: 0; clip-path: polygon(0 0, 0 100%, 100% 0); }
.clip-fade.out { right: 0; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.clip.dragging { opacity: .88; z-index: 6; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.drag-tip { position: fixed; z-index: 90; padding: .15rem .45rem; font: 600 .75rem/1.4 var(--mono); background: var(--text); color: var(--panel); border-radius: 3px; pointer-events: none; white-space: nowrap; }
.drag-tip[hidden] { display: none; }
@media (hover: none) {
  /* ecrã táctil: pegas sempre visíveis no clip seleccionado e mais largas */
  .clip-trim { width: 14px; }
  .clip.sel .clip-fh { width: 14px; height: 14px; }
  .clip-fh.in { left: 15px; }
  .clip-fh.out { right: 15px; }
}
@media (max-width: 700px) {
  .lane { height: 58px; }
  .clip { height: 52px; }
  .wave { height: 34px; }
}
.playhead, .cursor { position: absolute; top: 0; bottom: 0; width: 2px; pointer-events: none; z-index: 5; }
.playhead { background: var(--green); display: none; }
.playhead.on { display: block; }
.cursor { width: 0; border-left: 1px dashed var(--ochre); }
/* Agulha da linha do tempo: cabeça triangular em cima, para se ver bem onde está a tocar */
.playhead { margin-left: -1px; }
.ph-head { position: absolute; top: 0; left: 50%; width: 0; height: 0; transform: translateX(-50%); border-style: solid; border-width: 9px 7px 0; border-color: var(--green) transparent transparent; }
.cursor .ph-head { border-width: 6px 5px 0; border-top-color: var(--ochre); margin-left: -.5px; }
.clip.now { box-shadow: inset 0 0 0 2px var(--green); }
.clip.now.sel { box-shadow: inset 0 0 0 2px var(--green), 0 0 0 2px var(--ochre); }

/* Leitor interno: barra fixa em baixo, visível a partir de qualquer janela do estúdio */
.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--panel); border-top: 2px solid var(--line); box-shadow: 0 -6px 18px rgba(0, 0, 0, .18); padding: .45rem .8rem .5rem; }
.player.on { border-top-color: var(--green); }
.player[hidden] { display: none; }
body.has-player { padding-bottom: var(--player-h, 8rem); }
.pl-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; max-width: 1400px; margin: 0 auto; }
.pl-btns { display: flex; gap: .3rem; }
.pl-btns .tbtn { min-width: 2.3rem; justify-content: center; }
.pl-info { flex: 1 1 12rem; min-width: 0; display: flex; align-items: baseline; gap: .5rem; }
.pl-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.pl-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pl-src { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.pl-time { font-family: var(--mono); font-size: .9rem; padding: .2rem .5rem; border: 1px solid var(--line-soft); background: var(--well); border-radius: var(--radius); white-space: nowrap; }
.pl-opts { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; }
.pl-vol input { width: 6rem; }
.pl-wave { position: relative; max-width: 1400px; margin: .4rem auto 0; height: 42px; background: var(--well); border: 1px solid var(--line-soft); border-radius: var(--radius); cursor: pointer; touch-action: none; overflow: hidden; }
.pl-wave:focus-visible { outline: 2px solid var(--ochre); outline-offset: 1px; }
.pl-wave canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; color: color-mix(in srgb, var(--muted) 55%, transparent); }
.pl-done { position: absolute; left: 0; top: 0; bottom: 0; width: 0; overflow: hidden; background: color-mix(in srgb, var(--green) 12%, transparent); pointer-events: none; }
.pl-done canvas { width: auto; color: var(--green); }
.pl-needle { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: var(--green); pointer-events: none; }
.pl-needle::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); border-style: solid; border-width: 7px 6px 0; border-color: var(--green) transparent transparent; }
.pl-hint { max-width: 1400px; margin: .3rem auto 0; font-size: .75rem; }
#lib-body tr.is-loaded td:first-child { box-shadow: inset 3px 0 0 var(--ochre); }
#lib-body tr.is-playing td:first-child { box-shadow: inset 3px 0 0 var(--green); }
#lib-body tr.is-playing .lname::after { content: "  ▸ a tocar no leitor"; font-size: .75rem; color: var(--green); font-weight: 600; }
@media (max-width: 700px) {
  /* no telemóvel: botões só com ícone, tempo e Fechar na primeira linha; nome e Repetir na segunda */
  #player { padding: .4rem .6rem .45rem; }
  #player .pl-hint, #player .pl-src, #player .pl-tag, #player .pl-vol, #player #pl-add, #player .pl-btns .lbl { display: none; }
  #player .pl-opts { display: contents; }
  #player .pl-btns { order: 1; }
  #player .pl-time { order: 2; margin-left: auto; font-size: .82rem; }
  #player #pl-close { order: 3; }
  #player .pl-info { order: 4; flex: 1 1 0; }
  #player .pl-loop { order: 5; }
  #player .pl-wave { height: 36px; margin-top: .3rem; }
}

.inspector { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .7rem 0 .2rem; border-bottom: 1px dashed var(--line-soft); }
.inspector strong { font-family: var(--serif); }
.inspector input[type=number] { width: 6rem; font-family: var(--mono); }

/* ---------- Master ---------- */
.master { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 2rem; }
.master fieldset { border: 0; border-top: 1px solid var(--line-soft); margin: .6rem 0 0; padding: .6rem 0 0; min-width: 0; }
.master legend { font-family: var(--serif); color: var(--ochre); padding: 0 .4rem 0 0; }
.master label { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr) 4.6rem; gap: .6rem; align-items: center; margin: .45rem 0; font-size: .88rem; color: var(--muted); }
.master input[type=range], .master select { width: 100%; }
.master output { font-family: var(--mono); font-size: .8rem; color: var(--text); text-align: right; }
.meter-row { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); gap: .6rem; align-items: center; font-size: .88rem; color: var(--muted); margin: .5rem 0; }
.meter { display: inline-block; width: 7rem; height: 8px; background: var(--well); border: 1px solid var(--line-soft); position: relative; overflow: hidden; vertical-align: middle; }
.meter.wide { width: 100%; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--green); }
.meter-fill.hot { background: var(--danger); }
.reduce .meter-fill { background: var(--ochre); }

/* ---------- Biblioteca e tabelas ---------- */
.table-wrap { overflow-x: auto; margin-top: .6rem; }
table.lib { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.lib th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
table.lib td { padding: .55rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.lib tr.off td { opacity: .55; }
.lname { font-family: var(--serif); }
td.acts { display: flex; flex-wrap: wrap; gap: .3rem; }

/* ---------- Diálogos ---------- */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0; width: calc(100% - 24px); max-width: 38rem; max-height: calc(100vh - 32px);
}
dialog::backdrop { background: var(--backdrop); }
.dlg { padding: 1rem 1.2rem 1.2rem; }
.dlg.wide { max-width: none; }
#dlg-admin { max-width: 68rem; }
#dlg-confirm { max-width: 26rem; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .6rem; margin-bottom: .6rem; }
.dlg h2 { font-size: 1.25rem; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 .3rem; }
.x:hover { color: var(--text); }
.plist-items { list-style: none; padding: 0; margin: .8rem 0 0; }
.plist-items li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; padding: .7rem 0; border-top: 1px solid var(--line-soft); }
.plist-items li.current strong::before { content: "● "; color: var(--green); }
.pmeta { display: flex; flex-direction: column; min-width: 0; }
.pmeta strong { font-family: var(--serif); overflow-wrap: anywhere; }
.pact { display: flex; gap: .4rem; flex-wrap: wrap; }
.msg { border-top: 1px solid var(--line-soft); padding: .8rem 0; }
.msg.unread header strong::before { content: "● "; color: var(--ochre); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .4rem 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; margin-top: 1rem; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }

/* ---------- Ecrãs médios ---------- */
@media (max-width: 1100px) {
  .master { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 2rem; padding-top: 2.4rem; }
  .features { grid-template-columns: 1fr; gap: 1.2rem; }
}

/* ---------- Tablets e telemóveis ---------- */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .site-head { padding: .7rem .75rem; }
  .site-nav { width: 100%; gap: .5rem .9rem; }
  .site-nav .btn.primary { margin-left: auto; }
  .prose-block, .closing { padding-left: .75rem; padding-right: .75rem; }
  .hero { padding-left: .75rem; padding-right: .75rem; }
  .art-row { grid-template-columns: 3.4rem minmax(0, 1fr); gap: .4rem; }
  .art-steps { gap: 2px; }
  .transport { padding: .5rem .75rem; gap: .45rem .6rem; position: static; }
  .tgroup + .tgroup { border-left: 0; padding-left: 0; }
  .tgroup { width: 100%; order: 3; }
  .proj-name { width: 100%; order: 2; }
  .proj-name input { width: 100%; }
  .transport .brand { order: 1; }
  .tbtn .lbl { font-size: .85rem; }
  .clock { min-width: 0; flex: 1; }
  main#main { padding: 0 .75rem 1rem; }
  .track { grid-template-columns: 1fr; gap: .5rem; }
  .steps.s8, .steps.s16, .steps.s32 { grid-template-columns: repeat(8, minmax(0, 40px)); }
  .notes.s8, .notes.s16, .notes.s32 { grid-template-columns: repeat(8, minmax(0, 40px)); }
  .pat-tabs { width: 100%; }
  .pat-tabs [data-pat] { flex: 1; }
  .banner { padding: .55rem .75rem; }
  .strip { grid-template-columns: minmax(0, 1fr) 14px auto; grid-template-areas: 'name led ms' 'meter meter meter' 'vol vol db' 'pan pan pan'; gap: .3rem .5rem; }
  .strip-name { grid-area: name; } .clip-led { grid-area: led; } .strip-ms, .strip > .hint, .strip > label.inline { grid-area: ms; justify-self: end; }
  .strip-meter { grid-area: meter; } .strip-ctl:not(.pan) { grid-area: vol; } .strip .mx-db { grid-area: db; } .strip-ctl.pan { grid-area: pan; }
  .grid2 { grid-template-columns: 1fr; }
  .auto-tools select { max-width: 100%; }
  .block-tools.sub label.inline { flex-wrap: wrap; max-width: 100%; }
  .block-tools.sub select, .block-tools.sub input[type=search] { max-width: 100%; min-width: 0; }
  #lib-filter { width: 100%; }
  .master { grid-template-columns: 1fr; }
  .master label { grid-template-columns: 4.8rem minmax(0, 1fr) 4rem; }
  .meter-row { grid-template-columns: 4.8rem minmax(0, 1fr); }
  .statusbar { padding: .35rem .75rem; }
  .dirty { margin-left: 0; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: .5rem; }
  .auth-inner { padding-top: 1.6rem; }
  table.lib thead { display: none; }
  table.lib, table.lib tbody { display: block; }
  table.lib tr { display: block; padding: .55rem 0; border-bottom: 1px solid var(--line-soft); }
  table.lib td { display: inline-block; border: 0; padding: .1rem .8rem .1rem 0; color: var(--muted); }
  table.lib td:first-child { display: block; color: var(--text); }
  table.lib td.acts { display: flex; padding-top: .4rem; }
}

@media (max-width: 380px) {
  .tbtn { padding: .4rem .55rem; }
  .tgroup input[type=number] { width: 3.8rem; }
  .theme-btn .lbl { display: none; }
}

body.is-playing .statusbar { color: var(--text); }

/* ---------- v1.3.2: modelos de projecto agrupados por estilo ---------- */
.tpl-group { margin: .9rem 0 0; }
.tpl-group-name { font-family: var(--serif); font-weight: 600; font-size: 1rem; margin: 0 0 .2rem; color: var(--text); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); column-gap: 1.2rem; }
.tpl-grid label.choice:last-child { border-bottom: 0; }
#dlg-new { max-width: 44rem; }

/* ---------- v1.3: páginas de texto (manual e privacidade) ---------- */
.doc { max-width: 46rem; margin: 0 auto; padding: 2.4rem 1rem 3rem; line-height: 1.65; }
.doc-head { padding-bottom: 1.6rem; border-bottom: 1px solid var(--line); }
.doc-head h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.15; }
.doc-toc { margin-top: 1.4rem; }
.doc-toc ol { margin: 0; padding-left: 1.4rem; columns: 2 15rem; column-gap: 2rem; }
.doc-toc li { break-inside: avoid; padding: .15rem 0; }
.doc-toc a { color: var(--text-soft); }
.doc-sec { padding: 2rem 0 .4rem; border-bottom: 1px solid var(--line-soft); scroll-margin-top: 1rem; }
.doc-sec:last-child { border-bottom: 0; }
.doc-sec h2 { font-size: 1.45rem; margin-bottom: .9rem; }
.doc-sec h2::after { content: ""; display: block; width: 2.6rem; height: 2px; background: var(--ochre); margin-top: .4rem; }
.doc-sec h3 { font-size: 1.1rem; margin: 1.3rem 0 .4rem; }
.doc-sec p, .doc-sec ul, .doc-sec ol { margin: 0 0 1rem; }
.doc-sec li { margin-bottom: .45rem; }
.doc-sec code { font-family: var(--mono); font-size: .88em; background: var(--well); padding: .05rem .3rem; border-radius: 2px; overflow-wrap: anywhere; }
.doc-dl { margin: 0 0 1rem; }
.doc-dl dt { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; margin-top: 1rem; }
.doc-dl dd { margin: .2rem 0 0; padding-left: 1rem; border-left: 2px solid var(--line-soft); }
.table-wrap { overflow-x: auto; margin: 0 0 1rem; -webkit-overflow-scrolling: touch; }
.doc-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.doc-table th, .doc-table td { text-align: left; vertical-align: top; padding: .5rem .6rem .5rem 0; border-bottom: 1px solid var(--line-soft); }
.doc-table thead th { border-bottom: 1px solid var(--line); font-weight: 600; }
.doc-table tbody th { font-weight: 400; color: var(--text-soft); width: 60%; }
@media (max-width: 480px) {
  .doc { padding-top: 1.6rem; }
  .doc-table { font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.dl-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 1rem 0 .3rem; color: var(--muted); }

/* Iniciar a partir de um estilo */
.start-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; border-left-color: var(--ochre); }
.start-strip > span:first-child { flex: 1 1 22rem; }
.start-acts { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.linkish { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkish:hover { color: var(--ochre); }
.dn-style { margin: .2rem 0 .6rem; }
dialog.start-dlg { width: min(56rem, calc(100vw - 16px)); max-width: calc(100vw - 16px); }
.ds-intro { margin: 0 0 .7rem; }
.ds-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin-bottom: .6rem; }
.ds-filter label { max-width: 100%; flex-wrap: wrap; }
.ds-filter select { min-width: 14rem; max-width: 100%; }
.ds-list { list-style: none; margin: 0; padding: 0; max-height: min(58vh, 34rem); overflow-y: auto; border-top: 1px solid var(--line-soft); }
.ds-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem .2rem; border-bottom: 1px solid var(--line-soft); }
.ds-list li.is-playing { background: color-mix(in srgb, var(--green) 9%, transparent); }
.ds-main { flex: 1 1 20rem; min-width: 0; }
.ds-main strong { display: block; }
.ds-meta { display: block; font-size: .8rem; color: var(--muted); font-family: var(--mono); }
.ds-desc { margin: .25rem 0 0; font-size: .88rem; }
.ds-prog { display: block; height: 3px; margin-top: .4rem; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.ds-list li:not(.is-playing) .ds-prog { visibility: hidden; }
.ds-bar { display: block; height: 100%; width: 0; background: var(--green); }
.ds-act { display: flex; gap: .4rem; flex: none; }
.ds-act .ds-play { min-width: 6.5rem; }
@media (max-width: 560px) {
  .ds-act { width: 100%; }
  .ds-act .btn { flex: 1 1 0; }
  .ds-list { max-height: 52vh; }
}

/* v1.9: limites da conta na lista de projectos e ligação ao painel no menu */
.plist-limit.is-full, .plist-exp { color: var(--terra); }
.menu-list a.menu-link { display: block; padding: .45rem .6rem; color: inherit; text-decoration: none; border-radius: 2px; }
.menu-list a.menu-link:hover, .menu-list a.menu-link:focus-visible { background: var(--well); }
.menu-list a.menu-link[hidden] { display: none; }
