:root {
  color-scheme: dark;
  font-family: -apple-system, "PingFang SC", "PingFang TC", "PingFang HK", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans CJK TC", sans-serif;
  background: #101519;
  color: #edf4f5;
  --surface: #1b242a;
  --border: #3a4a52;
  --accent: #92e0ce;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button, .button {
  min-height: 56px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
button:disabled { opacity: .45; }
button:active, button.pressed { filter: brightness(.78); }
button.primary { background: var(--accent); color: #112724; font-weight: 700; border-color: transparent; }
#record[data-state="recording"], #record[data-state="tail"] { background: #ff9a92; color: #351411; }
input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #141d22;
  color: inherit;
}
.row { display: flex; align-items: center; gap: 6px; }
#studio {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
           max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  gap: 6px;
  max-width: 1050px;
  margin: 0 auto;
}
.toolbar { display: grid; gap: 6px; }
.toolbar .row { flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; position: relative; }
.button input { position: absolute; inset: 0; width: 100%; opacity: 0; }
.button:focus-within { outline: 2px solid var(--accent); }
#script, #prompter { flex: 1 1 0; min-height: 0; overflow: auto; line-height: 1.55; }
#script { resize: none; }
#prompter { white-space: pre-wrap; overflow-wrap: anywhere; padding: 6px 10px; }
.deck { display: grid; gap: 4px; flex: 0 0 auto; }
.time-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: #b7cace; font-variant-numeric: tabular-nums; font-size: 14px; }
.zoom { display: flex; gap: 4px; }
.zoom button, .scroll-row button { min-height: 44px; }
#wave { display: block; width: 100%; height: clamp(44px, 10vh, 92px); border-radius: 8px; touch-action: none; }
#scroll { flex: 1; min-width: 0; min-height: 40px; margin: 0; accent-color: var(--accent); touch-action: pan-x; }
.controls, .actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.controls button, .actions button { padding: 0 3px; font-size: 14px; }
.actions { grid-template-columns: 1.35fr 1fr 1fr; }
.preview { display: flex; align-items: center; min-height: 28px; gap: 5px; width: fit-content; }
.preview input { accent-color: var(--accent); }
progress { width: 100%; accent-color: var(--accent); }
#status, #auth-status, #list-status { margin: 0; color: #c2d4d9; overflow-wrap: anywhere; font-size: 14px; }
#status:empty { display: none; }
#countdown {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 24px;
  background: rgb(12 21 24 / 96%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#count-number { font-size: clamp(100px, 32vw, 220px); line-height: 1; color: var(--accent); }
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
           max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.auth form { display: grid; gap: 12px; width: min(100%, 420px); padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.auth h1, dialog h2 { margin: 0; font-size: 22px; }
.auth label { display: grid; gap: 5px; }
dialog { width: min(92%, 620px); max-height: 80vh; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: inherit; }
dialog::backdrop { background: rgb(0 0 0 / 65%); }
dialog header { justify-content: space-between; }
dialog ul { list-style: none; margin: 0; padding: 0; }
dialog li { border-bottom: 1px solid var(--border); padding: 10px 0; overflow-wrap: anywhere; }
dialog small { display: block; color: #b7cace; }
@media (orientation: landscape) and (max-height: 500px) {
  #studio { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .deck { grid-column: 2; grid-row: 1 / 3; overflow: auto; }
  #script, #prompter { grid-column: 1; grid-row: 2; }
}
