:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1c1b19;
  --muted: #615e57;
  --line: #dedbd3;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --live: #c62828;
  --warn-bg: #fff4d6;
  --warn-text: #5c4300;
  --error: #b3261e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --card: #1f1e1c;
    --text: #f0eee9;
    --muted: #a9a59c;
    --line: #3a3833;
    --accent: #7aa7ff;
    --accent-text: #0d1a33;
    --live: #ff6b62;
    --warn-bg: #3d3110;
    --warn-text: #ffe3a3;
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }
/* buttons set their own display, which would otherwise beat the hidden attribute */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 36rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom));
}

header h1 { font-size: 1.5rem; margin: 0.5rem 0 0; }
.sub { margin: 0 0 1rem; color: var(--muted); }
h2 { font-size: 1.1rem; margin: 0 0 0.25rem; }

.status { font-size: 1.15rem; margin: 1rem 0; min-height: 1.6em; }
.status.live::before { content: "● "; color: var(--live); }
.hint, .fine { color: var(--muted); font-size: 0.9rem; }
.fine { margin-top: 2rem; }
.error { color: var(--error); min-height: 1.4em; margin: 0.5rem 0 0; }
.warning {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 0.5rem;
  padding: 0.75rem;
}

button, .button {
  font: inherit;
  font-size: 1.05rem;
  min-height: 3rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.6rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:disabled { opacity: 0.5; cursor: default; }
button.secondary, .button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: var(--live); color: #fff; }
button.on { background: var(--warn-bg); color: var(--warn-text); }
button.linkish {
  background: none; color: var(--accent); min-height: auto; padding: 0; border: 0;
  text-decoration: underline; font-size: inherit;
}
.buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.75rem 0; }

/* listener */
.play {
  width: 100%;
  min-height: 7rem;
  font-size: 1.8rem;
  font-weight: 600;
  gap: 0.75rem;
  border-radius: 1rem;
}
.play-icon { font-size: 2rem; }
.earbuds {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 0.6rem;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  margin: 1rem 0;
}
.controls { display: grid; gap: 0.75rem; margin: 1rem 0; }
.row { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; }
.row input[type="range"] { flex: 1; min-height: 2.75rem; }
.toggle input { width: 1.4rem; height: 1.4rem; }

.captions {
  margin-top: 1rem;
  max-height: 50vh;
  overflow-y: auto;
  font-size: 1.35rem;
  line-height: 1.5;
}
.captions .caption { margin: 0 0 0.75rem; }
.captions .caption:last-child { font-weight: 500; }
.captions.small { font-size: 1rem; max-height: 16rem; }
.captions .original { color: var(--muted); font-style: italic; }
.captions.hide-original .original { display: none; }

/* speaker */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem;
  margin: 0 0 1rem;
}
label { display: block; font-weight: 600; margin: 0.5rem 0 0.25rem; }
.row, .toggle { font-weight: 400; }
input[type="password"], select {
  font: inherit;
  font-size: 1.1rem;
  width: 100%;
  min-height: 3rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
#pin-form button { margin-top: 0.75rem; width: 100%; }
.live-row { display: flex; justify-content: space-between; align-items: center; }
.badge { padding: 0.25rem 0.6rem; border-radius: 1rem; background: var(--line); font-weight: 600; }
.badge.on { background: var(--live); color: #fff; }
.count { color: var(--muted); }
.meter { height: 0.6rem; background: var(--line); border-radius: 0.3rem; overflow: hidden; margin: 0.5rem 0; }
#level, #l-level { height: 100%; width: 0; background: #2e7d32; transition: width 80ms linear; }
.modes { display: flex; gap: 0.5rem; margin: 0 0 1rem; }
.modes .mode { flex: 1; background: transparent; color: var(--text); border-color: var(--line); }
.modes .mode[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
summary { font-weight: 600; cursor: pointer; min-height: 2rem; }
.diag { white-space: pre-wrap; word-break: break-word; font-size: 0.8rem; margin: 0.5rem 0 0; }
#qr { display: block; width: min(100%, 18rem); height: auto; margin: 1rem auto; image-rendering: pixelated; }
.link { word-break: break-all; text-align: center; }
