/* Layout concept: a single phone-width column, like a driver's stand board —
   dark green slab, auto-rickshaw yellow for the one action that matters (the mic). */
:root {
  --bg: #f4f6f1;
  --surface: #ffffff;
  --ink: #15201a;
  --muted: #5b6b61;
  --line: #dde4dc;
  --green: #145233;
  --green-ink: #ffffff;
  --yellow: #f2c230;
  --yellow-ink: #1d1a08;
  --bubble: #ffffff;
  --bubble-mine: #dcefe2;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn-bg: #fff7dc;
  --focus: #1f6feb;
  --font-display: "Bricolage Grotesque", "Hind", system-ui, sans-serif;
  --font-body: "Hind", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1612; --surface: #17211b; --ink: #e8efe9; --muted: #9db0a4; --line: #27352c;
    --green: #2f8a5a; --green-ink: #ffffff; --yellow: #f2c230; --yellow-ink: #1d1a08;
    --bubble: #1c2821; --bubble-mine: #1f3a2a; --danger: #ff8a7a; --danger-bg: #3a1a16; --warn-bg: #2e2810;
    --focus: #6ea8ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1612; --surface: #17211b; --ink: #e8efe9; --muted: #9db0a4; --line: #27352c;
  --green: #2f8a5a; --green-ink: #ffffff; --yellow: #f2c230; --yellow-ink: #1d1a08;
  --bubble: #1c2821; --bubble-mine: #1f3a2a; --danger: #ff8a7a; --danger-bg: #3a1a16; --warn-bg: #2e2810;
  --focus: #6ea8ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100%; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; }
h2 { font-size: 1.6rem; font-weight: 700; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 24px 0; }
.fine { font-size: .85rem; color: var(--muted); }
.err { color: var(--danger); background: var(--danger-bg); padding: 8px 12px; border-radius: 10px; font-size: .92rem; }
.demo { font-size: .85rem; background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; }

.screen {
  max-width: 480px; margin: 0 auto;
  padding-block: 20px 32px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 18px;
}
.screen.center { min-height: 60vh; justify-content: center; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* buttons */
.btn {
  border: 0; border-radius: 12px; padding: 14px 18px; font-weight: 600; font-size: 1.05rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.btn.primary { background: var(--green); color: var(--green-ink); border-color: transparent; }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 14px; font-size: .95rem; margin-top: 8px; background: var(--green); color: var(--green-ink); border: 0; }
.btn.danger { background: var(--danger); color: #fff; border: 0; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.link { background: none; border: 0; padding: 6px 0; color: var(--green); font-weight: 600; text-align: left; }
.link:disabled { color: var(--muted); font-weight: 400; }
.back { align-self: flex-start; }

/* auth */
.auth { padding-top: 40px; }
.hero { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.hero h1 { font-size: 3.4rem; font-weight: 800; letter-spacing: -.02em; color: var(--green); }
.hero .tag { font-size: 1.1rem; color: var(--muted); max-width: 30ch; }
.mark { width: 56px; height: 56px; border-radius: 16px; background: var(--yellow); display: grid; place-items: center; }
.mark span { width: 26px; height: 26px; background: var(--yellow-ink); -webkit-mask: var(--mic-svg) center/contain no-repeat; mask: var(--mic-svg) center/contain no-repeat; }
label, .lbl { font-weight: 600; font-size: .95rem; }
.lbl em { font-weight: 400; font-style: normal; color: var(--muted); }
input, select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-size: 1.1rem;
}
.phone-row { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.phone-row:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.phone-row .cc { padding: 13px 12px; font-weight: 600; border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.phone-row input { border: 0; border-radius: 0; outline: none; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.otp { font-size: 2rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }

/* profile form */
.field { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: .98rem; }
.chip[aria-pressed="true"] { background: var(--green); color: var(--green-ink); border-color: var(--green); }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
@media (max-width: 400px) { .avatars { grid-template-columns: repeat(4, 1fr); } }
.avpick { border: 2px solid transparent; background: none; border-radius: 50%; padding: 2px; display: grid; place-items: center; }
.avpick[aria-checked="true"] { border-color: var(--green); }
.rules { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.rules legend { font-weight: 700; padding: 0 6px; font-family: var(--font-display); }
.rules ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .95rem; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--green); }
.acct { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }

/* avatars */
.av { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-family: var(--font-display); color: #fff; flex: none; font-size: 1.05rem; }
.av.sm { width: 32px; height: 32px; font-size: .9rem; }
.av0 { background: #145233; } .av1 { background: #b7791f; } .av2 { background: #2b6cb0; } .av3 { background: #9b2c2c; }
.av4 { background: #6b46c1; } .av5 { background: #2c7a7b; } .av6 { background: #c05621; } .av7 { background: #4a5568; }

/* lobby list */
.topbar { display: flex; justify-content: space-between; align-items: center; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.me { background: none; border: 0; padding: 0; border-radius: 50%; }
.sec { font-size: 1.05rem; margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sec small { font-family: var(--font-body); font-weight: 400; color: var(--muted); font-size: .85rem; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rows li + li { border-top: 1px solid var(--line); }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: none; border: 0; text-align: left; }
.row:active { background: var(--bg); }
.row-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-txt small { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-go { color: var(--muted); font-size: 1.4rem; }
.row-ic { width: 36px; height: 36px; border-radius: 10px; flex: none; position: relative; }
.row-ic::after { content: ""; position: absolute; inset: 8px; -webkit-mask: var(--ic) center/contain no-repeat; mask: var(--ic) center/contain no-repeat; }
.row-ic.zone { background: var(--yellow); }
.row-ic.zone::after { background: var(--yellow-ink); --ic: var(--pin-svg); }
.row-ic.channel { background: var(--bubble-mine); }
.row-ic.channel::after { background: var(--green); --ic: var(--hash-svg); }

.miccard { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--warn-bg); }
.miccard.denied, .miccard.unsupported { background: var(--danger-bg); }
.miccard p { font-size: .92rem; color: var(--muted); margin-top: 2px; }
.miccard .mic-ic { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--yellow); position: relative; }
.miccard .mic-ic::after { content: ""; position: absolute; inset: 8px; background: var(--yellow-ink); -webkit-mask: var(--mic-svg) center/contain no-repeat; mask: var(--mic-svg) center/contain no-repeat; }

/* lobby */
.screen.lobby { height: 100vh; height: 100dvh; padding-block: 0; gap: 0; }
.lobbybar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.2rem; flex: none; }
.lb-title { min-width: 0; display: flex; flex-direction: column; }
.lb-title b { font-family: var(--font-display); font-size: 1.15rem; }
.lb-title small { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 0; display: flex; flex-direction: column; gap: 12px; }
.empty { margin: auto 0; text-align: center; padding: 24px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.empty b { color: var(--ink); }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--bubble); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 8px 12px; min-width: 0; }
.msg.mine .bubble { background: var(--bubble-mine); border-radius: 16px 16px 4px 16px; border-color: transparent; }
.bubble header { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; white-space: nowrap; font-size: .8rem; font-weight: 700; color: var(--green); }
.msg.mine .bubble header { color: var(--muted); }
.bubble time { font-weight: 400; color: var(--muted); }
.sample { font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; background: var(--warn-bg); color: var(--muted); padding: 1px 6px; border-radius: 6px; }
.more { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 1.1rem; padding: 0 2px; line-height: 1; }
.txt { overflow-wrap: anywhere; white-space: pre-wrap; }
.vn { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 6px 0 2px; min-width: 200px; }
.vn-ic { width: 34px; height: 34px; border-radius: 50%; background: var(--green); position: relative; flex: none; }
.vn-ic::after { content: ""; position: absolute; inset: 10px; background: var(--green-ink); -webkit-mask: var(--play-svg) center/contain no-repeat; mask: var(--play-svg) center/contain no-repeat; }
.vn.playing .vn-ic::after { -webkit-mask-image: var(--pause-svg); mask-image: var(--pause-svg); }
.vn-track { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.vn-fill { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s linear; }
.vn-len { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.composer {
  position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
}
.composer input { font-size: 1rem; padding: 12px 14px; border-radius: 999px; }
.sendbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--green); color: var(--green-ink); font-size: 1rem; }
.micwrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.micbtn {
  width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--yellow); color: var(--yellow-ink);
  display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.micbtn .mic-ic { width: 28px; height: 28px; background: currentColor; -webkit-mask: var(--mic-svg) center/contain no-repeat; mask: var(--mic-svg) center/contain no-repeat; }
.micbtn[data-state="denied"], .micbtn[data-state="unsupported"] { background: var(--line); color: var(--muted); }
.michint { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.rec-ui { display: none; grid-column: 1 / 3; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.composer.recording .rec-ui { display: flex; }
.composer.recording #txt, .composer.recording .sendbtn { display: none; }
.composer.recording .micbtn { transform: scale(1.12); background: var(--danger); color: #fff; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.rec-track { flex: 1; min-width: 60px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.rec-track span { display: block; height: 100%; width: 0; background: var(--danger); }
.rec-help { width: 100%; font-size: .78rem; color: var(--muted); }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } .vn-fill { transition: none; } .composer.recording .micbtn { transform: none; } }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  width: 100%; max-width: 480px; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 12px; max-height: 85vh; overflow-y: auto;
}
#sheetBody { display: flex; flex-direction: column; gap: 10px; }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reason { padding: 11px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); text-align: left; font-size: .92rem; }
.sheet hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* icons (masks so they follow theme colors) */
:root {
  --mic-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='8' y='2' width='8' height='13' rx='4'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M12 18v4' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  --pin-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5 7 13 7 13s7-8 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E");
  --hash-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M9 3 7 21M17 3l-2 18M4 8h17M3 16h17'/%3E%3C/svg%3E");
  --play-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 3l15 9-15 9z'/%3E%3C/svg%3E");
  --pause-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='5' y='3' width='5' height='18'/%3E%3Crect x='14' y='3' width='5' height='18'/%3E%3C/svg%3E");
}

/* live voice room */
.voice { border-bottom: 1px solid var(--line); padding: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.vjoin { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; flex-wrap: wrap; }
.vfaces { display: flex; }
.vfaces .av { border: 2px solid var(--surface); margin-left: -8px; }
.vfaces .av:first-child { margin-left: 0; }
.vjoin-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vjoin-txt small { color: var(--muted); font-size: .85rem; }
.vbtn { padding: 10px 16px; font-size: .98rem; }
.vbtn:disabled { opacity: .55; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tile { background: none; border: 0; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; border-radius: 12px; }
.tile:active { background: var(--surface); }
.ring { position: relative; border-radius: 50%; padding: 3px; box-shadow: 0 0 0 2px transparent; transition: box-shadow .12s; }
.ring .av { width: 48px; height: 48px; font-size: 1.2rem; }
.tile.speaking .ring { box-shadow: 0 0 0 3px var(--yellow); }
.tile.silenced .ring .av { opacity: .45; }
.mutebadge { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); }
.mutebadge::after { content: ""; position: absolute; inset: 3px; background: var(--muted); -webkit-mask: var(--micoff-svg) center/contain no-repeat; mask: var(--micoff-svg) center/contain no-repeat; }
.tname { font-weight: 600; font-size: .85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tstat { font-size: .72rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.silenced .tstat { color: var(--danger); }
.tvotes { font-size: .68rem; font-weight: 700; color: var(--danger); background: var(--danger-bg); border-radius: 6px; padding: 0 5px; }
.vcontrols { display: flex; gap: 8px; }
.vmic { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 999px; padding: 12px 16px; font-weight: 700; font-size: 1rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.vmic .mic-ic { width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--micoff-svg) center/contain no-repeat; mask: var(--micoff-svg) center/contain no-repeat; }
.vmic.on { background: var(--yellow); color: var(--yellow-ink); border-color: transparent; }
.vmic.on .mic-ic { -webkit-mask-image: var(--mic-svg); mask-image: var(--mic-svg); }
.vmic:disabled { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.vleave { padding: 12px 16px; }
.vhint { font-size: .78rem; color: var(--muted); }
:root {
  --micoff-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='8' y='2' width='8' height='13' rx='4'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v4' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M3 3l18 18' stroke='%23000' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: reduce) { .ring { transition: none; } }
