:root {
  --ink: #0E1116;
  --ink-2: #3A4250;
  --ground: #EEF1F4;
  --surface: #FFFFFF;
  --line: #D5DBE3;
  --off: #C3CAD3;
  --blue: #2448F0;
  --blue-dark: #1530B8;
  --talk: #10A35A;
  --red: #D92D20;
  --green-soft: #D5F5DC;
  --yellow: #FFE58A;
  --wood: #6B4630;
  --av: 88px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; }
h1 { font-size: 40px; line-height: 1.05; }
h2 { font-size: 22px; }
p { margin: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.center { text-align: center; }
.strong { font-weight: 700; }
.mono { font-family: var(--mono); }
.self-start { align-self: flex-start; }
.stack-4 { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.stack-10 { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row-between.wrap { flex-wrap: wrap; align-items: center; }

.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.icon-sm { width: 18px; height: 18px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; }
.wordmark { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -0.02em; line-height: 1; }
.wordmark-lg { font-size: 30px; }

/* controls */
.card { background: var(--surface); border: 2px solid var(--ink); border-radius: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 18px;
  border: 1.5px solid var(--ink); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  font-size: 16px; font-weight: 700; white-space: nowrap;
}
.btn:hover { background: var(--ground); }
.btn[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.btn-sm { height: 44px; padding: 0 16px; }
.btn-big { height: 56px; font-size: 18px; border-width: 2px; }
.btn-primary { background: var(--blue); color: #FFFFFF; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: var(--ink-2); cursor: wait; }
.btn-danger { background: var(--red); color: #FFFFFF; }
.btn-danger:hover { background: #B42318; }
.link-btn {
  margin-left: auto; height: 44px; padding: 0 12px; border: 0; background: transparent;
  color: var(--blue); font-size: 15px; font-weight: 700; text-decoration: underline;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1.5px solid var(--ink); border-radius: 999px;
  background: var(--surface); font-size: 15px; font-weight: 700; white-space: nowrap;
}
.chip-btn.on { background: var(--green-soft); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--talk); }
.chip .dot.slow { background: #F59E0B; }
.chip .dot.bad { background: var(--red); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 15px; font-weight: 700; }
input[type="text"], input[type="password"] {
  width: 100%; height: 52px; padding: 0 16px;
  border: 1.5px solid var(--ink); border-radius: 14px; background: var(--surface); font-size: 17px;
}
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 16px; top: 16px; pointer-events: none; }
.input-icon input { padding-left: 48px; }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; -webkit-appearance: none; width: 100%; height: 52px; padding: 0 44px 0 16px;
  border: 1.5px solid var(--ink); border-radius: 14px; background: var(--surface); font-size: 16px;
  text-overflow: ellipsis;
}
.select-wrap .chevron { position: absolute; right: 16px; top: 16px; pointer-events: none; }
.select-sm select { height: 40px; font-size: 15px; font-weight: 700; padding-left: 10px; }
.select-sm .chevron { top: 10px; right: 10px; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--blue); height: 28px; }
.error { color: #B42318; font-weight: 700; font-size: 15px; }

/* meters: bars are drawn by JS */
.meter { display: flex; align-items: center; gap: 3px; height: 12px; }
.meter i { display: block; width: 6px; height: 100%; border-radius: 2px; background: var(--off); }
.meter i.on { background: var(--talk); }
.meter-dock { height: 18px; }
.meter-wide { position: relative; height: 20px; }
.meter-wide i { flex: 1 1 0; width: auto; }
.meter-wide .threshold {
  position: absolute; top: -5px; width: 3px; height: 30px; border-radius: 2px; background: var(--ink);
  transform: translateX(-50%);
}

/* join */
.join { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.join-card { width: 100%; max-width: 440px; border-radius: 24px; padding: 36px; display: flex; flex-direction: column; gap: 24px; }
.join-head { display: flex; flex-direction: column; gap: 8px; }
.join-head p { font-size: 17px; }
.mic-check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--ground); }
.mic-check-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 auto; }
.mic-check-body .strong { font-size: 15px; }

/* top bar */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 32px; }
.topbar-left, .topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.banner {
  margin: 0 auto; padding: 10px 16px; border: 1.5px solid var(--ink); border-radius: 12px;
  background: var(--yellow); font-weight: 700; max-width: calc(100% - 32px);
}

/* room */
.room { min-height: 100vh; display: flex; flex-direction: column; }
.stage { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 8px 32px 20px; }
.table-wrap {
  width: min(940px, 100%);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto auto;
  align-items: center;
}
.seats { position: relative; z-index: 1; display: flex; }
.seats-top { grid-column: 2; grid-row: 1; justify-content: space-evenly; margin-bottom: calc(var(--av) * -0.36); }
.seats-bottom { grid-column: 2; grid-row: 3; justify-content: space-evenly; margin-top: calc(var(--av) * -0.36); padding-bottom: 14px; }
.seats-left { grid-column: 1; grid-row: 2; margin-right: calc(var(--av) * -0.36); }
.seats-right { grid-column: 3; grid-row: 2; margin-left: calc(var(--av) * -0.36); }
.table {
  grid-column: 2; grid-row: 2; position: relative;
  height: clamp(220px, 32vw, 320px);
  border: 3px solid var(--ink); border-radius: 8px; overflow: hidden;
  background: var(--wood) url("wood.svg") center / cover no-repeat;
}
.table-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  max-width: calc(100% - 32px);
  padding: 16px 32px; background: var(--surface); border: 2px solid var(--ink); border-radius: 16px; text-align: center;
}
.eyebrow { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.talk-name {
  font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1.05;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.table-card .muted { font-size: 15px; }
.wave { display: flex; align-items: center; gap: 4px; height: 26px; }
.wave span { width: 5px; height: 26px; border-radius: 3px; background: var(--talk); transform: scaleY(0.25); transform-origin: center; }
.wave:not(.on) { visibility: hidden; }
.wave.on span { animation: wave 0.9s ease-in-out infinite; }
.wave.on span:nth-child(2) { animation-delay: -0.7s; }
.wave.on span:nth-child(3) { animation-delay: -0.2s; }
.wave.on span:nth-child(4) { animation-delay: -0.5s; }
.wave.on span:nth-child(5) { animation-delay: -0.1s; }
.wave.on span:nth-child(6) { animation-delay: -0.6s; }
.wave.on span:nth-child(7) { animation-delay: -0.3s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }

.seat { position: relative; width: var(--av); height: var(--av); flex: 0 0 auto; }
.avatar {
  width: 100%; height: 100%; border-radius: 50%; border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: calc(var(--av) * 0.36);
  transition: outline-color 0.12s;
  outline: 5px solid transparent; outline-offset: 3px;
}
.seat.talking .avatar { outline-color: var(--talk); }
.seat.connecting .avatar { border-style: dashed; }
.seat.free .avatar {
  background: var(--ground); border-style: dashed;
  font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.nametag {
  position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
  background: var(--ink); color: #FFFFFF; font-size: 14px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.seat.you .nametag { background: var(--blue); }
.badge {
  position: absolute; right: -6px; top: -6px; width: 32px; height: 32px;
  border-radius: 50%; background: var(--ink); color: #FFFFFF; border: 2px solid #FFFFFF;
  display: flex; align-items: center; justify-content: center;
}
.badge .icon { width: 16px; height: 16px; }

/* dock */
.dock-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 4px 16px 28px; }
.dock {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px;
  padding: 10px; background: var(--surface); border: 2px solid var(--ink); border-radius: 22px;
}
.mode { display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px; border-radius: 14px; background: var(--ground); font-size: 15px; }

/* settings */
.settings { min-height: 100vh; }
.settings .topbar { justify-content: space-between; }
.settings-main { width: 100%; max-width: 1060px; margin: 0 auto; padding: 4px 32px 36px; }
.settings-main h1 { margin-bottom: 20px; }
.settings-cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.settings-col { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.panel { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.segmented { display: flex; gap: 4px; padding: 4px; border: 1.5px solid var(--ink); border-radius: 14px; }
.seg {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; border: 0; border-radius: 10px; background: var(--surface); font-size: 16px; font-weight: 700;
}
.seg-on { background: var(--ink); color: #FFFFFF; }
.seg[aria-disabled="true"] { cursor: not-allowed; }
.soon {
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--yellow); color: var(--ink); padding: 3px 7px; border: 1px solid var(--ink); border-radius: 6px;
}
.ptt-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1.5px dashed var(--ink); border-radius: 14px;
}
.keycap {
  flex: 0 0 auto; font-family: var(--mono); font-size: 14px; font-weight: 700;
  padding: 8px 12px; border: 1.5px solid var(--ink); border-bottom-width: 4px; border-radius: 8px; background: var(--surface);
}
.tag { font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 4px 8px; border: 1px solid var(--ink); border-radius: 6px; background: var(--green-soft); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; border-top: 1.5px solid var(--line); }
.switch-row:first-of-type { border-top: 0; padding-top: 4px; }
.switch {
  flex: 0 0 auto; position: relative; width: 68px; height: 40px; padding: 0;
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--surface);
}
.switch span {
  position: absolute; top: 3.5px; left: 3.5px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--ink); transition: left 0.12s;
}
.switch[aria-pressed="true"] { background: var(--talk); }
.switch[aria-pressed="true"] span { left: 31px; background: #FFFFFF; border: 1.5px solid var(--ink); }
.switch:disabled { cursor: not-allowed; background: var(--line); }

@media (max-width: 720px) {
  :root { --av: 60px; }
  .topbar { padding: 14px 16px; }
  .stage { padding: 8px 12px 16px; }
  .wordmark { font-size: 24px; }
  .talk-name { font-size: 28px; }
  .table { height: 290px; }
  .table-card { padding: 10px 14px; gap: 6px; }
  .table-card .muted { font-size: 13px; }
  .wave { height: 18px; }
  .wave span { height: 18px; }
  .nametag { font-size: 12px; padding: 2px 8px; max-width: 90px; }
  .badge { width: 26px; height: 26px; }
  .join-card { padding: 24px; }
  .settings-main { padding: 4px 16px 28px; }
  .dock .btn span { display: none; }
  .dock .btn { padding: 0 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .wave.on span { animation: none; transform: scaleY(0.8); }
}

/* per-person menu (click a friend's seat) */
button.avatar { padding: 0; color: var(--ink); cursor: pointer; }
button.avatar:hover { border-width: 3px; }
.badge-left { right: auto; left: -6px; }
.badge-mine { background: var(--surface); color: var(--ink); border: 2px solid var(--ink); }
.badge-text { width: auto; min-width: 32px; padding: 0 6px; border-radius: 999px; font-family: var(--mono); font-size: 11px; font-weight: 700; }
.peer-menu {
  position: fixed; z-index: 20; width: 280px; max-width: calc(100vw - 16px);
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.peer-menu-head { align-items: center; }
.peer-menu-name { font-family: var(--display); font-size: 22px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-menu .btn { align-self: flex-start; }
.icon-btn {
  flex: 0 0 auto; width: 44px; height: 44px; margin: -8px -8px -8px 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--ground); }
