:root {
  --ink: #120d08;
  --paper: #e9dcc0;
  --paper-dim: rgba(233, 220, 192, .62);
  --rust: #b0452f;
  --line: rgba(233, 220, 192, .28);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--ink); color: var(--paper);
  font-family: Georgia, "Noto Serif", "Times New Roman", serif;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
#cam { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }

#intro {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 32px 24px;
  background: radial-gradient(ellipse at 50% 40%, #2a1f14 0%, var(--ink) 70%);
  z-index: 10; text-align: center;
}
.intro-inner { max-width: 420px; }
.kicker { letter-spacing: .35em; text-transform: uppercase; font-size: 11px; color: var(--paper-dim); margin: 0 0 18px; }
h1 { font-weight: normal; font-size: clamp(34px, 10vw, 52px); line-height: 1.02; margin: 0 0 22px; letter-spacing: .02em; }
.motto { font-style: italic; color: var(--paper-dim); line-height: 1.5; margin: 0 0 40px; }
#startBtn, .panel-foot button {
  font: inherit; letter-spacing: .3em; text-transform: uppercase; font-size: 13px;
  color: var(--paper); background: transparent; border: 1px solid var(--line);
  padding: 16px 30px; border-radius: 2px; min-height: 48px;
}
#startBtn:not(:disabled):active { background: rgba(233,220,192,.08); }
#startBtn:disabled { opacity: .45; }
.status { font-size: 12px; color: var(--paper-dim); min-height: 1.4em; margin-top: 18px; font-family: ui-monospace, monospace; }

#hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 0 16px calc(22px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
#hud > * { pointer-events: auto; }
.round {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(18,13,8,.35); display: grid; place-items: center; padding: 0;
}
.round svg { width: 22px; height: 22px; fill: none; stroke: var(--paper); stroke-width: 1.5; stroke-linecap: round; }
.rec {
  width: 68px; height: 68px; border-radius: 50%; border: 2px solid var(--paper-dim);
  background: rgba(18,13,8,.3); display: grid; place-items: center; padding: 0;
}
.rec span { width: 48px; height: 48px; border-radius: 50%; background: var(--rust); transition: all .2s; }
.rec.on span { width: 26px; height: 26px; border-radius: 4px; }
/* modo manual: botão grande acima do de gravar */
#tuneBtn {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(104px + env(safe-area-inset-bottom));
  min-width: 190px; padding: 16px 26px; border-radius: 40px; border: 1px solid rgba(233,220,192,.55);
  background: rgba(18,13,8,.55); color: var(--paper); font: 13px Georgia, serif; letter-spacing: .35em; text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}
#tuneBtn:active { background: rgba(201,168,106,.55); }
#recTime {
  position: fixed; top: calc(16px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  font-family: ui-monospace, monospace; font-size: 13px; color: #e8836b; letter-spacing: .1em;
}
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(172px + env(safe-area-inset-bottom));
  background: rgba(18,13,8,.85); border: 1px solid var(--line); padding: 10px 16px; font-size: 13px;
  max-width: calc(100vw - 32px); text-align: center;
}

#panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; max-height: 78vh; overflow-y: auto;
  background: rgba(18,13,8,.94); border-top: 1px solid var(--line);
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
}
.panel-head { display: flex; justify-content: space-between; align-items: center; letter-spacing: .25em; text-transform: uppercase; font-size: 11px; color: var(--paper-dim);
  /* o × fica sempre à vista, mesmo com o painel rolado */
  position: sticky; top: -14px; z-index: 1; margin: -14px -20px 0; padding: 14px 20px 4px; background: rgb(18,13,8); }
.panel-head button { font-size: 28px; background: none; border: 0; color: var(--paper); width: 48px; height: 48px; }
.row { display: grid; grid-template-columns: 112px 1fr 34px; align-items: center; gap: 10px; min-height: 42px; }
.row label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; }
.row output { font-family: ui-monospace, monospace; font-size: 11px; color: var(--paper-dim); text-align: right; }
/* no celular, rolar o painel com o dedo sobre a trilha mudava o valor (o volume ia a 3% sem querer):
   a trilha ignora o toque; só arrastar a bolinha muda o valor */
input[type=range] { width: 100%; height: 36px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none;
  pointer-events: none; touch-action: pan-y; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(233,220,192,.28); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 30px; height: 30px; margin-top: -13px;
  border-radius: 50%; background: #c9a86a; border: 2px solid rgba(18,13,8,.9); box-shadow: 0 0 0 1px rgba(233,220,192,.4); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(233,220,192,.28); }
input[type=range]::-moz-range-thumb { pointer-events: auto; width: 26px; height: 26px; border-radius: 50%; background: #c9a86a; border: 2px solid rgba(18,13,8,.9); }
.panel-foot { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#testStaticBtn, #soundResetBtn, #tiraBtn, #closePanel2 { flex-basis: 100%; }
.panel-foot button { flex: 1; padding: 12px 8px; font-size: 11px; letter-spacing: .2em; }
.sep { height: 1px; background: var(--line); margin: 8px 0; }

.grp { display: flex; gap: 12px; }
/* celulares estreitos: 3 + 3 botões redondos e o de gravar cabem em 360 px */
@media (max-width: 420px) {
  #hud { padding-left: 12px; padding-right: 12px; }
  .grp { gap: 6px; }
  .round { width: 40px; height: 40px; }
  .round svg { width: 19px; height: 19px; }
  .rec { width: 60px; height: 60px; }
  .rec span { width: 42px; height: 42px; }
}
.round.txt { font: 10px ui-monospace, monospace; letter-spacing: .05em; color: var(--paper); }
.round.on { background: rgba(233,220,192,.85); color: var(--ink); }
.round.on svg { stroke: var(--ink); }
#muteBtn .x { display: none; }
#muteBtn.muted .x { display: inline; }
#muteBtn.muted .wave { display: none; }
#dbg { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; z-index: 3; pointer-events: none; }
#dbgInfo {
  position: fixed; left: 12px; top: calc(96px + env(safe-area-inset-top)); z-index: 4; pointer-events: none;
  font: 11px/1.45 ui-monospace, monospace; color: #9dff9d; background: rgba(0,0,0,.55); padding: 6px 8px; white-space: pre;
}
