:root {
  --bg: #1a120b;
  --panel: #241a10;
  --panel-2: #2e2114;
  --gold: #f0a94f;
  --gold-hot: #ffb95e;
  --amber: #c98a3b;
  --text: #f4e3c9;
  --dim: #a98d6b;
  --rx: #8fd0a0;   /* agent (RX) bursts */
  --tx: #f0a94f;   /* human (TX) bursts */
  --danger: #e2574c;
  --radius: 16px;
}

/* themes — swap the palette, keep the shape */
html[data-theme="midnight"] {
  --bg: #0d1321;
  --panel: #151d31;
  --panel-2: #1d2740;
  --gold: #7aa2ff;
  --gold-hot: #93b4ff;
  --amber: #5f7ad9;
  --text: #e6ecff;
  --dim: #8b9bc4;
  --rx: #7ee0b0;
  --tx: #7aa2ff;
}
html[data-theme="ember"] {
  --bg: #170b09;
  --panel: #22110c;
  --panel-2: #2d1710;
  --gold: #ff8a5c;
  --gold-hot: #ffa07a;
  --amber: #c95f3b;
  --text: #ffe9df;
  --dim: #b08a78;
  --rx: #8fd0a0;
  --tx: #ff8a5c;
}
html[data-theme="forest"] {
  --bg: #0c1410;
  --panel: #13211a;
  --panel-2: #1a2d22;
  --gold: #8fce9e;
  --gold-hot: #a8dcb4;
  --amber: #5f9e77;
  --text: #e8f5ec;
  --dim: #8fb39b;
  --rx: #8fd0a0;
  --tx: #8fce9e;
}
html[data-theme="ocean"] {
  --bg: #08141a;
  --panel: #0f212b;
  --panel-2: #162e3a;
  --gold: #4fc3c9;
  --gold-hot: #6fd5da;
  --amber: #3b8f9e;
  --text: #e2f4f5;
  --dim: #83aab0;
  --rx: #8fd0a0;
  --tx: #4fc3c9;
}

.theme-row { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-btn {
  flex: 1 1 40%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--amber);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.theme-btn.selected { background: var(--gold); color: var(--bg); border-color: var(--gold); font-weight: 700; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 600px at 50% -10%, #3a2a16 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  user-select: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 1.05rem; letter-spacing: 0.08em; }
.dim { color: var(--dim); font-weight: 400; }
.chan { font-size: 0.75rem; color: var(--dim); }
.chan b { color: var(--gold); font-weight: 600; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

main { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 6px 14px 12px; max-width: 640px; width: 100%; margin: 0 auto; }

.log-panel, .voice-panel { background: var(--panel); border: 1px solid #3a2c1a; border-radius: var(--radius); overflow: hidden; }

.log-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid #3a2c1a; background: var(--panel-2);
}
.log-head span:first-child { color: var(--gold); font-weight: 700; }

.log-actions { display: flex; align-items: center; gap: 10px; }
.live-badge { color: var(--rx); text-transform: none; letter-spacing: 0; }
.ghost-btn {
  background: none; border: 1px solid #4a3820; color: var(--text);
  border-radius: 999px; padding: 4px 12px; font-size: 0.72rem; cursor: pointer;
}
.ghost-btn:active { background: #3a2c1a; }

.log { height: 38dvh; min-height: 200px; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--dim); font-size: 0.85rem; text-align: center; margin-top: 30px; }

.burst {
  padding: 8px 12px; border-radius: 12px; font-size: 0.88rem;
  max-width: 92%; animation: rise 0.25s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.burst .meta { display: flex; gap: 8px; align-items: baseline; font-size: 0.7rem; opacity: 0.85; margin-bottom: 3px; }
.burst .who { font-weight: 700; }
.burst .time { margin-left: auto; font-variant-numeric: tabular-nums; }
.burst .dur { font-variant-numeric: tabular-nums; }

.burst.tx { align-self: flex-end; background: linear-gradient(135deg, #3d2b15, #33230f); border: 1px solid #4d3a1d; background: linear-gradient(135deg, color-mix(in srgb, var(--tx) 24%, var(--bg)), color-mix(in srgb, var(--tx) 14%, var(--bg))); border: 1px solid color-mix(in srgb, var(--tx) 45%, transparent); }
.burst.tx .who { color: var(--tx); }
.burst.rx { align-self: flex-start; background: linear-gradient(135deg, #14301f, #10261a); border: 1px solid #1f4529; background: linear-gradient(135deg, color-mix(in srgb, var(--rx) 24%, var(--bg)), color-mix(in srgb, var(--rx) 14%, var(--bg))); border: 1px solid color-mix(in srgb, var(--rx) 45%, transparent); }
.burst.rx .who { color: var(--rx); }

.play-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.play-btn {
  background: var(--gold); color: #1a120b; border: none; border-radius: 999px;
  padding: 3px 12px; font-size: 0.75rem; font-weight: 700; cursor: pointer;
}
.play-btn.playing { background: var(--danger); }
.note { font-size: 0.78rem; color: var(--dim); margin-top: 4px; font-style: italic; }

.voice-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.voice-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; border: 1px solid #3a2c1a; cursor: pointer;
}
.voice-item.selected { border-color: var(--gold); background: #2e2114; }
.voice-item .vname { font-size: 0.9rem; font-weight: 600; flex: 1; }
.voice-item .vdesc { font-size: 0.72rem; color: var(--dim); }
.voice-item .radio { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--dim); }
.voice-item.selected .radio { border-color: var(--gold); background: var(--gold); box-shadow: 0 0 8px var(--gold); }

.ptt-wrap { text-align: center; padding: 6px 0 10px; position: relative; }
.ptt-tools { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
.dice-tray[hidden] { display: none; }
.dice-tray {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  width: min(360px, 94vw); z-index: 30; text-align: left;
  background: var(--panel-2); border: 1px solid #4a3a6a; border-radius: 14px;
  padding: 10px 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.dice-head { font-weight: 700; margin-bottom: 8px; color: var(--gold); font-size: 0.9rem; }
.dice-close { float: right; background: none; border: none; color: var(--dim); font-size: 1rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.dice-close:hover { color: var(--text); }
.dice-dies, .dice-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.dice-row:last-of-type { margin-bottom: 0; }
.die-btn {
  background: var(--panel); border: 1px solid #4a3a6a; color: var(--text);
  border-radius: 9px; padding: 7px 11px; font-size: 0.85rem; cursor: pointer;
}
.die-btn.sel { background: #4a3a6a; border-color: #b07cf5; color: #fff; }
.die-btn.cursed { border-color: #6a4a3a; background: #3a2a1a; }
.dice-count { min-width: 2ch; text-align: center; font-weight: 700; color: var(--gold); }
.dice-err { color: var(--danger); font-size: 0.75rem; margin-top: 6px; min-height: 1em; }
.burst.roll { border-left: 3px solid #b07cf5; }
.burst.roll .note { font-weight: 600; }
.ptt {
  width: 100%; max-width: 380px; padding: 22px 16px;
  border-radius: 28px; border: 2px solid #4d3a1d;
  background: linear-gradient(160deg, #3d2b15, #2a1d0d);
  color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  touch-action: none;
}
.ptt:disabled { opacity: 0.55; }
.ptt.live { border-color: var(--danger); background: linear-gradient(160deg, #4a1c16, #33120e); animation: pulse 1.2s ease-in-out infinite; }
.ptt-icon { font-size: 1.7rem; }
.ptt-label { font-size: 0.95rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; }
.ptt-timer { font-size: 0.8rem; font-variant-numeric: tabular-nums; color: var(--gold); min-height: 1em; }
.hint { color: var(--dim); font-size: 0.72rem; margin-top: 8px; }

/* ---------- roster ---------- */
.roster { background: var(--panel); border: 1px solid #3a2c1a; border-radius: var(--radius); overflow: hidden; }
.roster-list { padding: 8px 14px; display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; }
.roster-empty { font-size: 0.8rem; padding: 6px 0; }
.roster-item {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid #3a2c1a;
  border-radius: 999px; padding: 5px 12px 5px 8px; font-size: 0.82rem;
}
.roster-icon { font-size: 0.95rem; }
.roster-name { font-weight: 600; }
.roster-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rx); box-shadow: 0 0 6px var(--rx); }
.roster-dot.stale { background: var(--dim); box-shadow: none; }

/* ---------- login overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 6, 2, 0.88); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.login-card {
  background: var(--panel); border: 1px solid #4d3a1d; border-radius: 20px;
  padding: 26px 22px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-brand h2 { font-size: 1.15rem; letter-spacing: 0.08em; }
.login-sub { color: var(--dim); font-size: 0.85rem; margin-bottom: 18px; line-height: 1.45; }
.login-input {
  width: 100%; background: #1a120b; border: 2px solid #4d3a1d; border-radius: 12px;
  color: var(--text); font-size: 1.05rem; padding: 13px 14px; text-transform: uppercase;
  letter-spacing: 0.06em; outline: none; margin-bottom: 12px;
}
.login-input:focus { border-color: var(--gold); }
.kind-row { display: flex; gap: 10px; margin-bottom: 16px; }
.kind-btn {
  flex: 1; background: var(--panel-2); border: 1px solid #3a2c1a; color: var(--dim);
  border-radius: 12px; padding: 11px 8px; font-size: 0.9rem; cursor: pointer;
}
.kind-btn.selected { border-color: var(--gold); color: var(--text); background: #2e2114; }
.join-btn {
  width: 100%; background: var(--gold); color: #1a120b; border: none;
  border-radius: 14px; padding: 14px; font-size: 0.95rem; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
}
.join-btn:active { background: var(--gold-hot); }
.login-err { text-align: center; margin-top: 10px; min-height: 1.2em; font-size: 0.8rem; color: var(--danger); }

/* ---------- header ---------- */
.me { color: var(--gold); font-weight: 700; margin-right: 8px; }
.chan { display: flex; align-items: center; gap: 6px; }

/* ---------- mic status + level meter ---------- */
.mic-status {
  font-size: 0.72rem; color: var(--dim); margin-top: 8px;
  letter-spacing: 0.04em;
}
.mic-status.ok { color: var(--rx); }
.mic-status.bad { color: var(--danger); }
.mic-status.busy { color: var(--gold); }
.mic-check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.72rem; color: var(--dim); letter-spacing: 0.04em;
  margin-top: 10px; cursor: pointer; user-select: none;
}
.mic-check input {
  width: 15px; height: 15px; margin: 0;
  accent-color: var(--gold); cursor: pointer;
}
.mic-check.ok { color: var(--rx); }
.level-track {
  width: 100%; max-width: 380px; height: 5px; margin: 10px auto 0;
  background: #33230f; border-radius: 999px; overflow: hidden;
}
.level-bar {
  width: 0%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-hot));
  box-shadow: 0 0 8px var(--gold-hot);
  transition: width 80ms linear;
}

.ptt, .ptt-label, .ptt-icon, .ptt-timer {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* ================= v2: rooms sidebar, pins, impressions, avatars ================= */

/* ---------- header buttons ---------- */
.icon-btn {
  background: none; border: 1px solid #4a3820; color: var(--text);
  border-radius: 10px; width: 34px; height: 34px; font-size: 1rem;
  cursor: pointer; line-height: 1; flex-shrink: 0;
}
.icon-btn:active { background: #3a2c1a; }
.gold { color: var(--gold); }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 88vw);
  background: var(--panel); border-right: 1px solid #4d3a1d; z-index: 60;
  display: flex; flex-direction: column;
  transform: translateX(-102%); transition: transform 0.22s ease;
  box-shadow: 20px 0 60px rgba(0, 0, 0, 0.45);
}
.sidebar.open { transform: translateX(0); }
.scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(10, 6, 2, 0.55); backdrop-filter: blur(2px);
}
.side-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid #3a2c1a; background: var(--panel-2);
}
.side-tab {
  flex: 1; background: none; border: 1px solid #4a3820; color: var(--dim);
  border-radius: 999px; padding: 7px 10px; font-size: 0.78rem;
  letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
}
.side-tab.active { border-color: var(--gold); color: var(--gold); font-weight: 700; }
.side-body { flex: 1; overflow-y: auto; padding: 12px 14px 24px; display: flex; flex-direction: column; gap: 16px; }
.side-sec { display: flex; flex-direction: column; gap: 8px; }
.side-title {
  font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold); font-weight: 700;
}
.side-note { font-size: 0.74rem; line-height: 1.45; }
.small { font-size: 0.82rem; }
.tiny { font-size: 0.68rem; }
.login-input.small { padding: 10px 12px; font-size: 0.9rem; margin-bottom: 8px; }
.join-btn.small { padding: 11px; font-size: 0.85rem; }
.join-btn.alt { background: none; border: 2px solid var(--gold); color: var(--gold); }
.ghost-btn.tiny { padding: 2px 10px; font-size: 0.68rem; }
.ghost-btn.full { width: 100%; margin-top: 10px; padding: 9px; }
.kind-row.mini { margin-bottom: 8px; }
.kind-btn { font-size: 0.8rem; padding: 9px 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--dim); margin-bottom: 8px; }
.check input { accent-color: var(--gold); width: 15px; height: 15px; }
.code-row { display: flex; gap: 8px; align-items: center; }
.code-input { text-transform: uppercase; letter-spacing: 0.25em; margin-bottom: 0; flex: 1; }
.room-list { display: flex; flex-direction: column; gap: 6px; }
.room-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid #3a2c1a; border-radius: 10px;
  padding: 9px 11px; cursor: pointer; font-size: 0.85rem;
}
.room-item.now { border-color: var(--gold); background: #2e2114; }
.room-item .room-name { flex: 1; font-weight: 600; }
.room-item .ghost-btn { flex-shrink: 0; }

/* steering sliders */
.slider-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: var(--dim); margin-top: 4px;
}
input[type="range"] {
  width: 100%; accent-color: var(--gold); height: 26px; cursor: pointer;
}

/* ---------- doors ---------- */
.doors { display: flex; justify-content: center; padding: 20px 0 4px; }
.doors[hidden] { display: none; }
.door-card {
  background: var(--panel); border: 1px solid #3a2c1a; border-radius: 20px;
  padding: 26px 22px; width: 100%; max-width: 380px; text-align: center;
}
.door-icon { font-size: 2rem; margin-bottom: 8px; }
.door-title { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.06em; margin-bottom: 6px; }
.door-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---------- pins ---------- */
.pins-panel { background: var(--panel); border: 1px solid #3a2c1a; border-radius: var(--radius); overflow: hidden; }
.pins-list {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px;
  scrollbar-width: thin;
}
.pin-chip {
  display: flex; align-items: center; gap: 7px; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid #4a3820; border-radius: 12px;
  padding: 7px 12px; max-width: 240px;
}
.pin-who { font-weight: 700; font-size: 0.75rem; color: var(--gold); }
.pin-note {
  font-size: 0.75rem; color: var(--dim); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- message menu ---------- */
.msg-menu {
  position: fixed; z-index: 80; min-width: 190px;
  background: var(--panel-2); border: 1px solid #4d3a1d; border-radius: 14px;
  padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-item {
  background: none; border: none; color: var(--text); text-align: left;
  padding: 10px 12px; border-radius: 9px; font-size: 0.85rem; cursor: pointer;
}
.menu-item:active { background: #3a2c1a; }
.menu-btn {
  background: none; border: none; color: var(--dim); font-size: 1rem;
  line-height: 1; cursor: pointer; padding: 0 2px; margin-left: auto;
}
.burst .meta { gap: 8px; }
.pin-tag { font-size: 0.75rem; }

/* ---------- impressions ---------- */
.imp-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.imp-btn {
  background: var(--panel-2); border: 1px solid #3a2c1a; color: var(--dim);
  border-radius: 999px; padding: 3px 9px; font-size: 0.75rem; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.imp-btn.has { color: var(--text); }
.imp-btn.mine { border-color: var(--gold); background: #2e2114; box-shadow: 0 0 6px rgba(240, 169, 79, 0.35); }

/* ---------- pics & avatars ---------- */
.avatar-list, .roster-list { padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 10px; }
.avatar-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-2); border: 1px solid #3a2c1a; border-radius: 14px;
  padding: 8px 12px 8px 8px; min-width: 130px;
}
.avatar-item.live { border-color: #1f4529; }
.avatar-img {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 2px solid #4d3a1d;
}
.avatar-item.live .avatar-img { border-color: var(--rx); box-shadow: 0 0 8px rgba(143, 208, 160, 0.4); }
.ping-btn {
  background: none; border: 1px solid #4a3820; color: var(--gold);
  border-radius: 999px; padding: 3px 9px; font-size: 0.68rem; cursor: pointer;
  font-weight: 700; flex-shrink: 0; transition: all .15s ease;
}
.ping-btn:active { background: #2e2114; }
.ping-btn:disabled { opacity: .55; cursor: default; }
.ping-btn.pinged { border-color: var(--gold); background: #2e2114; color: var(--text); }
.avatar-fallback {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #4d3a1d, #2e2114); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; border: 2px solid #4d3a1d;
}
.avatar-info { display: flex; flex-direction: column; min-width: 0; }
.avatar-name { font-size: 0.85rem; font-weight: 700; }
.roster-empty { font-size: 0.8rem; padding: 6px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90; max-width: 86vw;
  background: var(--panel-2); border: 1px solid var(--gold); color: var(--text);
  border-radius: 999px; padding: 11px 20px; font-size: 0.85rem;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  animation: rise 0.25s ease-out;
  text-align: center;
}

/* ---------- select ---------- */
.login-input.select {
  text-transform: none; letter-spacing: 0;
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23f0a94f' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}

/* ---------- voice (agent-owned, settings) ---------- */
.voice-item.small { padding: 8px 11px; }
.dob-input { margin-bottom: 12px; }

/* ---------- hidden must actually hide (flex rules override the UA default) ---------- */
[hidden] { display: none !important; }

/* ---------- mod console ---------- */
.mod-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 4px 0; border-top: 1px dashed #3a2c1a; font-size: 0.75rem; }
.mod-row span { flex: 1 1 100%; }
.mod-row .ghost-btn { font-size: 0.7rem; padding: 2px 8px; }
