/* Paging PWA - plain CSS, no build step.
   Contrast ratios noted next to tokens are WCAG 2.1 against the surface they sit on. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #0f172a;
  --muted: #526071;          /* 6.42 on surface, 5.71 on surface-2 */
  --line: #d9e0e8;           /* dividers only, never the sole boundary of a control */
  --line-strong: #7b899b;    /* control borders: 3.56 on surface, 3.29 on bg */
  --field-bg: #ffffff;
  --accent: #0f5c8c;         /* 7.17 on surface */
  --accent-press: #0b4a72;
  --accent-ink: #ffffff;     /* 7.17 on accent */
  --accent-soft: #e2eef7;
  --ok: #146c3d;             /* 5.61 on ok-soft (was #1a7f4b, 4.35) */
  --ok-soft: #e1f3e8;
  --ok-fill: #146c3d;        /* white text 6.48 */
  --warn: #855400;           /* 5.76 on warn-soft (was #9a6400, 4.48) */
  --warn-soft: #fff1d6;
  --bad: #b42318;            /* 5.59 on bad-soft, 6.57 on surface */
  --bad-soft: #fde8e6;
  --bad-fill: #b42318;       /* white text 6.57 */
  --fill-ink: #ffffff;
  --topbar-bg: #0f5c8c;      /* iOS black-translucent status bar text is always white */
  --topbar-ink: #ffffff;     /* 7.17 */
  --topbar-line: #0f5c8c;
  --avatar-bg: #ffffff;
  --avatar-ink: #0f5c8c;
  --backdrop: rgba(15, 23, 42, 0.5);
  --radius: 14px;
  --radius-sm: 12px;
  --tap: 56px;
  --nav-h: 64px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2c;
    --surface-2: #1b2638;
    --text: #e7edf5;
    --muted: #9fb0c3;          /* 7.70 on surface, 6.86 on surface-2 */
    --line: #27354a;
    --line-strong: #6b7d96;    /* 4.06 on surface, 3.62 on surface-2 */
    --field-bg: #0e1626;
    --accent: #4aa8e4;         /* 6.51 on surface, 4.91 on accent-soft (was #3b9ddb, 4.31) */
    --accent-press: #74bdec;
    --accent-ink: #06121f;     /* 7.19 on accent */
    --accent-soft: #15344d;
    --ok: #4cc585;
    --ok-soft: #113524;
    --ok-fill: #19703f;        /* white text 6.12 (white on #4cc585 was 2.18) */
    --warn: #f3b94b;
    --warn-soft: #3b2b08;
    --bad: #ff7a6e;
    --bad-soft: #43150f;
    --bad-fill: #c62f25;       /* white text 5.48 (white on #ff7a6e was 2.54) */
    --topbar-bg: #131c2c;
    --topbar-ink: #e7edf5;
    --topbar-line: #27354a;
    --avatar-bg: #1b2638;
    --avatar-ink: #e7edf5;
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: none;
  }
}

/* Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}
/* Paint the iOS standalone status-bar area so its white text stays readable on every screen. */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: env(safe-area-inset-top, 0px); background: var(--topbar-bg); pointer-events: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 2px; }
img, audio, video { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(16px + env(safe-area-inset-right, 0px), (100% - 688px) / 2) 8px max(16px + env(safe-area-inset-left, 0px), (100% - 688px) / 2);
  min-height: calc(env(safe-area-inset-top, 0px) + 64px);
  background: var(--topbar-bg); color: var(--topbar-ink); border-bottom: 1px solid var(--topbar-line);
}
.topbar h1 { flex: 1; min-width: 0; margin: 0; font-size: 20px; letter-spacing: -0.01em; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { min-width: var(--tap); }
.topbar :focus-visible { outline-color: var(--topbar-ink); }
.topbar .iconbtn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--avatar-bg); color: var(--avatar-ink); font-size: 17px; font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 12px; border-radius: 999px;
  font-size: 15px; font-weight: 700; line-height: 1.2; white-space: nowrap; border: 1px solid transparent;
}
.pill::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
/* Pills: tinted fill + border in the text color, so the pill edge is >= 3:1 on any surface. */
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: currentColor; }
.pill.bad { color: var(--bad); background: var(--bad-soft); border-color: currentColor; }
.pill.bad::before {
  content: "!"; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bad); color: var(--bad-soft); font-size: 13px; font-weight: 800; line-height: 1;
}
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: currentColor; }
.pill.neutral { color: var(--muted); background: var(--surface-2); border-color: var(--line-strong); }
.iconbtn {
  min-width: 44px; min-height: 44px; border: 0; background: transparent; border-radius: 10px; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
}
.iconbtn:active { background: var(--surface-2); }
.topbar .iconbtn:active { background: var(--surface-2); color: var(--text); }

main {
  max-width: 720px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.topbar ~ main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 32px); }
#app > main:first-child { padding-top: calc(env(safe-area-inset-top, 0px) + 16px); }

/* Live status card: idle (neutral), now playing (blue), offline (solid red), connecting (amber) */
.statusbar {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; margin-bottom: 16px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.statusbar .row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 32px; }
.statusbar strong { font-size: 18px; line-height: 1.3; }
.statusbar .label { color: var(--muted); font-size: 15px; }
.statusbar .playing { flex: 1 1 100%; font-size: 18px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
:is(.statusbar.now-playing, .statusbar:has(.progress)) {
  background: var(--accent-soft); border: 2px solid var(--accent); padding: 15px; box-shadow: none;
}
:is(.statusbar.now-playing, .statusbar:has(.progress)) .row > .label:first-child {
  color: var(--accent); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}
.statusbar.offline { background: var(--bad-fill); border-color: var(--bad-fill); color: var(--fill-ink); box-shadow: none; }
.statusbar.offline .label, .statusbar.offline a { color: inherit; }
.statusbar.offline .row::before {
  content: "!"; flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fill-ink); color: var(--bad-fill); font-size: 18px; font-weight: 800; line-height: 1;
}
.statusbar.disconnected { background: var(--warn-soft); border-color: var(--warn); box-shadow: none; }
.statusbar.disconnected .row::before {
  content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--warn); border-right-color: transparent; animation: spin 0.9s linear infinite;
}
.progress { height: 8px; background: var(--surface); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.5s linear; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; min-width: 0; }
.field label { font-size: 15px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background-color: var(--field-bg); font-size: 17px; line-height: 1.3;
  outline: 2px solid transparent; outline-offset: 2px; /* transparent outline shows up in forced-colors mode */
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
textarea { min-height: 96px; resize: vertical; }
::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--surface-2); color: var(--muted); cursor: not-allowed; }
select {
  appearance: none; -webkit-appearance: none; text-overflow: ellipsis; white-space: nowrap;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 23px) 50%, calc(100% - 17px) 50%; background-size: 6px 6px; background-repeat: no-repeat;
  padding-right: 48px;
}
input[type=file] { width: 100%; min-height: 48px; font-size: 15px; color: var(--muted); }
input[type=file]::file-selector-button {
  min-height: 44px; margin-right: 12px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
input[type=file]::-webkit-file-upload-button {
  min-height: 44px; margin-right: 12px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-bottom: 8px; line-height: 1.3; cursor: pointer; }
.check input { flex: none; width: 24px; height: 24px; margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 8px 24px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 17px; line-height: 1.2;
  text-align: center; text-decoration: none; -webkit-user-select: none; user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:active { background: var(--accent-press); border-color: var(--accent-press); }
.btn.danger { background: var(--bad-fill); color: var(--fill-ink); border-color: var(--bad-fill); }
.btn.danger:active { background: var(--bad-fill); filter: brightness(0.88); }
/* First step of a destructive flow (opens a confirm sheet): quieter than the final solid red. */
.btn.danger-outline { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.danger-outline:active { background: var(--bad-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 44px; padding: 4px 16px; font-size: 15px; border-radius: 10px; }
.btn[disabled], .btn:disabled {
  background: var(--surface-2); color: var(--muted); border-color: var(--line);
  cursor: not-allowed; transform: none; filter: none;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 16px; }
/* Equal widths when they fit; wrap to full-width rows instead of squeezing labels onto two lines. */
.btn-row > .btn { flex: 1 1 0; min-width: max-content; }
/* Play icon on the confirm button (mirrors the list Play buttons). */
.btn[data-action="play-confirm"]::before,
.btn[data-action="queue-clear"]::before { content: ""; flex: none; width: 12px; height: 14px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.btn[data-action="queue-clear"]::before { width: 12px; height: 12px; clip-path: none; border-radius: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 18px; line-height: 1.3; }
.card h3 { margin: 0 0 8px; font-size: 16px; line-height: 1.3; }
.error, .notice, .success { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 15px; border: 1px solid; overflow-wrap: anywhere; }
.error { color: var(--bad); background: var(--bad-soft); border-color: var(--bad); }
.notice { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
.success { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }

/* Login */
.login { max-width: 420px; margin: 8vh auto 0; }
.login .logo { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 16px; display: block; }
.login h1 { text-align: center; margin: 0 0 24px; font-size: 26px; }

/* Zone selector */
.zonebar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.zonebar label { font-size: 15px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.zonebar select { flex: 1; min-width: 0; font-weight: 600; }

/* File list */
.folder { margin: 24px 4px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.file {
  display: flex; align-items: center; gap: 8px; min-height: 72px; padding: 8px 8px 8px 16px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.file .info { flex: 1; min-width: 0; }
/* Names wrap instead of truncating: "Lockdown - drill" vs "Lockdown - real" must stay distinguishable. */
.file .name { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.file .meta { margin-top: 2px; font-size: 14px; color: var(--muted); }
.file .meta .tag { margin-left: 4px; }
.file .play {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 96px; min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-sm); border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 18px;
  transition: background-color 0.12s ease, transform 0.05s ease;
}
.file .play[data-ready="1"]::before { content: ""; flex: none; width: 12px; height: 14px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.file .play:active { background: var(--accent-press); transform: scale(0.97); }
.file .play[disabled], .file.pending .play {
  background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); cursor: not-allowed; transform: none;
}
.file .more {
  flex: none; width: 44px; min-height: var(--tap); border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 24px; line-height: 1;
}
.file .more:active { background: var(--surface-2); }
/* Messages that skip the confirm sheet: one tap pages the building. */
.file.instant { border-left: 4px solid var(--warn); padding-left: 13px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* Bottom nav */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.bottomnav a {
  position: relative; flex: 1 1 0; max-width: 168px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: var(--nav-h); text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 600;
}
.bottomnav a .ic {
  display: flex; align-items: center; justify-content: center; width: 56px; height: 32px; border-radius: 16px;
  font-size: 20px; line-height: 1; font-variant-emoji: text; transition: background-color 0.15s ease;
}
.bottomnav a.active { color: var(--accent); }
.bottomnav a.active .ic { background: var(--accent-soft); }
.bottomnav .badge {
  position: absolute; top: 4px; left: calc(50% + 10px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

/* Sheet (bottom modal) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: var(--backdrop); animation: fade 0.2s ease-out;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 90vh; max-height: 90dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18); animation: up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
/* Double-tap guard: a second tap on a list Play button must not land on the sheet's Play/Delete. */
@keyframes arm { from { pointer-events: none; } to { pointer-events: auto; } }
.sheet .btn.primary, .sheet .btn.danger { animation: arm 0.35s steps(1, end) both; }
.sheet h2 { margin: 0 0 8px; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.sheet p { margin: 0 0 24px; color: var(--muted); }
.sheet p strong { color: var(--text); }
.sheet .big { margin-bottom: 8px; font-size: 22px; font-weight: 700; line-height: 1.25; color: var(--text); overflow-wrap: anywhere; }

/* Toast */
#toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none;
}
.toast {
  max-width: 480px; padding: 12px 16px; border-radius: 12px; text-align: center;
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 600; line-height: 1.35;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); animation: up 0.2s ease-out;
}
.toast.bad { background: var(--bad-fill); color: var(--fill-ink); }
.toast.ok { background: var(--ok-fill); color: var(--fill-ink); }

/* Tables (admin) */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.list-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.list-item .sub { margin-top: 2px; font-size: 14px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.list-item > .btn { flex: none; }
.tag {
  display: inline-block; vertical-align: 1px; padding: 0 8px; border-radius: 999px;
  font-size: 13px; font-weight: 700; line-height: 1.5; background: var(--surface-2); color: var(--muted);
}
.tag.admin { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--accent-soft); color: var(--accent); }
.segmented {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--surface-2); border-radius: var(--radius-sm);
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-padding-inline: 4px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented a {
  flex: 1 0 auto; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; white-space: nowrap;
  scroll-snap-align: start;
}
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow), inset 0 0 0 1px var(--line-strong); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
/* Labels that wrap to two lines push their input down so inputs in a row line up. */
.grid2 > .field > label { flex-grow: 1; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; margin: 0; font-size: 15px; }
.kv dt, .kv dd { padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }

/* Record */
.meter { height: 16px; margin: 16px 0; background: var(--surface-2); border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn) 70%, var(--bad)); transition: width 0.08s; }
.rec-btn {
  width: 128px; height: 128px; margin: 16px auto; border-radius: 50%; border: 8px solid var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: var(--bad-fill); color: var(--fill-ink); font-weight: 700; font-size: 18px;
}
.rec-btn::before { content: ""; width: 20px; height: 20px; border-radius: 50%; background: currentColor; }
.rec-btn.recording { animation: pulse 1.2s ease-out infinite; border-color: var(--bad); background: var(--surface); color: var(--bad); }
.rec-btn.recording::before { border-radius: 4px; }
.rec-btn[disabled] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198, 47, 37, 0.5); } 100% { box-shadow: 0 0 0 18px rgba(198, 47, 37, 0); } }
.timer { margin-top: 8px; text-align: center; font-size: 40px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
audio { display: block; width: 100%; margin: 8px 0 16px; }

/* Pointer devices only: hover feedback */
@media (hover: hover) {
  .btn:not([disabled]):hover { background: var(--surface-2); }
  .btn.primary:not([disabled]):hover { background: var(--accent-press); border-color: var(--accent-press); }
  .btn.danger:not([disabled]):hover { background: var(--bad-fill); filter: brightness(0.92); }
  .btn.danger-outline:not([disabled]):hover { background: var(--bad-soft); }
  .file .play:not([disabled]):hover { background: var(--accent-press); }
  .file .more:hover, .iconbtn:hover { background: var(--surface-2); }
  .topbar .iconbtn:hover { background: var(--surface-2); color: var(--text); }
  .segmented a:not(.active):hover, .bottomnav a:not(.active):hover { color: var(--text); }
}

/* Tablet / desktop */
@media (min-width: 640px) {
  .card { padding: 24px; }
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 16px; border-top: 0; padding: 32px; max-height: calc(100dvh - 48px); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop, .toast { animation: none; }
  .sheet .btn.primary, .sheet .btn.danger { animation: arm 0.35s steps(1, end) both; } /* not motion; keep */
  .rec-btn.recording { animation: none; box-shadow: 0 0 0 6px var(--bad-soft); }
  .statusbar.disconnected .row::before { animation: none; border-right-color: var(--warn); border-style: dotted; }
  .btn, .file .play, .progress > div, .meter > div, .bottomnav a .ic { transition: none; }
  .btn:active, .file .play:active { transform: none; }
}

@media (forced-colors: active) {
  .pill, .tag, .statusbar, .file .play, .bottomnav a.active .ic, .segmented a.active { border: 1px solid CanvasText; }
  .pill::before, .file .play[data-ready="1"]::before, .rec-btn::before, .btn[data-action]::before { forced-color-adjust: none; background: CanvasText; }
}

/* Settings: permissions */
.perm-table td, .perm-table th { padding: 8px 6px; }
.perm-table th:not(:first-child), .perm-cell { text-align: center; width: 64px; }
.perm-yes { color: var(--ok); font-weight: 700; }
.perm-no { color: var(--muted); }
.role-select { width: auto; min-width: 120px; min-height: 44px; padding: 6px 36px 6px 12px; font-size: 15px; }
