/* Campfire — every visual choice reads from these tokens.
   theme.js overwrites them at runtime from the user's settings. */
:root {
  --font: 'Outfit';
  --fs: 15px;
  --r: 18px;            /* corner roundness */
  --r-sm: max(6px, calc(var(--r) - 8px));
  --blur: 18px;         /* glass blur */
  --op: 78%;            /* panel opacity */
  --av-r: 32%;          /* avatar shape */
  --gap: 12px;
  --mgap: 14px;         /* space between messages */

  --wall: #0f0d0e;
  --panel: #1a1719;
  --surface: #262124;
  --surface-2: #312a2e;
  --bubble: #2a2427;
  --text: #f4ede8;
  --text-dim: #b3a8a2;
  --text-faint: #7d726d;
  --border: rgba(255,255,255,.07);
  --accent: #ff8a3d;
  --on-accent: #141214;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --green: #3ddc84;
  --red: #ff5c6c;
}

* { box-sizing: border-box; margin: 0; padding: 0; scrollbar-width: thin; scrollbar-color: var(--surface-2) transparent; }
html, body { height: 100%; }
body {
  background: var(--wall); background-attachment: fixed;
  color: var(--text); font-family: var(--font), system-ui, sans-serif; font-size: var(--fs);
  display: flex; flex-direction: column; gap: var(--gap); padding: var(--gap);
  overflow: hidden; transition: background .4s;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.glass {
  background: color-mix(in srgb, var(--panel) var(--op), transparent);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3);
  backdrop-filter: blur(var(--blur)) saturate(1.3);
  border: 1px solid var(--border); border-radius: var(--r);
}
.icon-btn { width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--text-dim); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.av {
  position: relative; width: 36px; height: 36px; border-radius: var(--av-r);
  display: grid; place-items: center; font-weight: 700; color: #141214; flex-shrink: 0;
  background: var(--c, var(--accent));
}
.av .dot { position: absolute; bottom: -3px; right: -3px; width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--panel); background: var(--green); }
.av .dot.away { background: #ffc53d; }
.av .dot.off { background: var(--text-faint); }

/* ---------- Top bar ---------- */
.top { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 10px 0 16px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand .flame { width: 26px; height: 26px; fill: var(--accent); stroke: none; filter: drop-shadow(0 0 8px var(--accent-line)); }
.groups { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding-left: 8px; }
.gp {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px;
  color: var(--text-dim); white-space: nowrap; border: 1px solid transparent; position: relative; transition: background .15s;
}
.gp .gi { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-size: 15px; }
.gp:hover { background: var(--surface); color: var(--text); }
.gp.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); font-weight: 600; }
.gp .ping { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.gp.new { color: var(--text-faint); padding: 6px 14px; }
.top-right { display: flex; align-items: center; gap: 4px; }
.customise-btn { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; }
.customise-btn:hover { filter: brightness(1.08); }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-radius: 999px; margin-left: 4px; }
.me-chip:hover { background: var(--surface); }
.me-chip .n { line-height: 1.15; text-align: left; }
.me-chip b { font-size: 14px; display: block; }
.me-chip span { font-size: 12px; color: var(--text-faint); }
.menu-btn { display: none; }

/* ---------- Layout ---------- */
.layout { flex: 1; min-height: 0; display: flex; gap: var(--gap); }
body.side-right .layout { flex-direction: row-reverse; }

/* ---------- Channel panel ---------- */
.chan { width: 272px; display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.banner {
  margin: 8px; height: 104px; border-radius: var(--r-sm); padding: 14px; position: relative; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; color: #fff;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.35), transparent 40%),
    linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 35%, #5b21b6));
}
.banner h2 { font-size: 20px; line-height: 1.1; text-shadow: 0 1px 8px rgba(0,0,0,.3); }
.banner small { display: block; font-size: 12px; opacity: .85; font-weight: 500; margin-top: 3px; }
.banner button { background: rgba(0,0,0,.28); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; backdrop-filter: blur(6px); }
.banner button svg { width: 15px; height: 15px; }
.chan-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.sect { display: flex; justify-content: space-between; align-items: center; padding: 14px 10px 6px; font-size: 13px; font-weight: 600; color: var(--text-faint); }
.sect button { color: var(--text-faint); display: grid; }
.sect button svg { width: 16px; height: 16px; }
.ch { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); color: var(--text-dim); text-align: left; transition: background .15s; }
.ch .emo { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--surface); display: grid; place-items: center; font-size: 15px; }
.ch:hover { background: var(--surface); color: var(--text); }
.ch.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.ch.active .emo { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.ch.unread { color: var(--text); font-weight: 600; }
.ch .count { margin-left: auto; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }

.room { width: 100%; text-align: left; display: block; margin: 4px 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid transparent; transition: border-color .15s; }
.room:hover { border-color: var(--border); }
.room.live { border-color: var(--accent-line); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.room.active { box-shadow: 0 0 0 2px var(--accent); }
.room-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.room-head small { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-faint); }
.room.live .room-head small { color: var(--accent); }
.av-stack { display: flex; margin-top: 8px; padding-left: 6px; }
.av-stack .av { width: 26px; height: 26px; font-size: 11px; margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.av-stack .av.speaking { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--green); z-index: 1; margin-right: 4px; }
.room .empty { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

.dock { margin: 8px; padding: 12px; border-radius: var(--r-sm); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.dock-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dock-top .live { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 var(--green); animation: pulse 2s infinite; }
.dock-top b { font-weight: 600; }
.dock-top span { color: var(--text-faint); margin-left: auto; font-size: 12px; }
.dock-btns { display: flex; gap: 6px; margin-top: 10px; }
.dbtn { flex: 1; height: 36px; border-radius: 999px; background: var(--surface); display: grid; place-items: center; color: var(--text-dim); transition: background .15s; }
.dbtn:hover { color: var(--text); background: var(--surface-2); }
.dbtn.off { color: var(--red); }
.dbtn.on { background: var(--accent); color: var(--on-accent); }
.dbtn.leave { background: var(--red); color: #fff; }
.dbtn svg { width: 18px; height: 18px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.head { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--border); }
.head .emo { font-size: 22px; }
.head .t { min-width: 0; line-height: 1.2; }
.head h1 { font-size: 17px; font-weight: 700; }
.head p { font-size: 13px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .actions { margin-left: auto; display: flex; gap: 2px; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: var(--mgap); }
.day { align-self: center; font-size: 12px; font-weight: 600; color: var(--text-faint); background: var(--surface); padding: 4px 12px; border-radius: 999px; }
.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg .stack { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; max-width: min(560px, 78%); min-width: 0; }
.msg .meta { font-size: 12px; color: var(--text-faint); padding: 0 4px 2px; display: flex; gap: 8px; }
.msg .meta b { color: var(--c); font-weight: 600; }
.bubble { background: var(--bubble); padding: 9px 14px; border-radius: var(--r); line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg:not(.me) .item:last-child .bubble { border-bottom-left-radius: 6px; }
.msg.me { flex-direction: row-reverse; }
.msg.me .stack { align-items: flex-end; }
.msg.me .bubble { background: var(--accent); color: var(--on-accent); }
.msg.me .item:last-child .bubble { border-bottom-right-radius: 6px; }
.msg.me .meta b { display: none; }
.mention { background: var(--accent-soft); color: var(--accent); padding: 0 4px; border-radius: 5px; font-weight: 600; }
.msg.me .mention { background: rgba(0,0,0,.15); color: inherit; }
.quote { font-size: 13px; padding: 4px 10px; margin-bottom: 6px; border-left: 3px solid currentColor; border-radius: 4px; background: rgba(0,0,0,.12); opacity: .85; }
.reacts { display: flex; gap: 6px; margin-top: 2px; }
.react { display: flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid transparent; font-size: 13px; }
.react.mine { background: var(--accent-soft); border-color: var(--accent-line); }
.typing { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-faint); padding: 0 22px; height: 18px; }
.typing i { display: inline-flex; gap: 3px; }
.typing i::before, .typing i::after, .typing i > span { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint); animation: blink 1.2s infinite; }
.typing i > span { animation-delay: .2s; }
.typing i::after { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

.composer { margin: 8px 16px 16px; display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: calc(var(--r) + 6px); background: var(--surface); border: 1px solid var(--border); }
.composer:focus-within { border-color: var(--accent-line); }
.composer textarea { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 8px 6px; resize: none; font: inherit; color: inherit; line-height: 1.4; max-height: 160px; }
.composer textarea::placeholder { color: var(--text-faint); }
.send { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.send svg { width: 18px; height: 18px; }

/* Flat message style */
body.flat .msg, body.flat .msg.me { flex-direction: row; align-items: flex-start; }
body.flat .msg .stack, body.flat .msg.me .stack { align-items: flex-start; max-width: none; gap: 2px; }
body.flat .bubble, body.flat .msg.me .bubble { background: none; color: inherit; padding: 0 4px; border-radius: 0; }
body.flat .msg.me .meta b { display: inline; }
body.flat .msg.me .mention { background: var(--accent-soft); color: var(--accent); }

/* Compact density */
body.compact { --mgap: 6px; }
body.compact .bubble { padding: 6px 11px; }
body.compact .msg .av { width: 28px; height: 28px; font-size: 12px; }
body.compact .ch { padding: 3px 8px; }
body.compact .ch .emo { width: 24px; height: 24px; font-size: 13px; }

/* ---------- Voice: around the campfire ---------- */
.stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 20px; overflow: hidden; }
.ring { position: relative; width: min(440px, 100%, 62vh); aspect-ratio: 1; }
.fire {
  position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, #fff6dc 0%, color-mix(in srgb, var(--accent) 60%, #fff6dc) 14%, var(--accent) 32%, color-mix(in srgb, var(--accent) 35%, transparent) 55%, transparent 70%);
  animation: flicker 3s ease-in-out infinite;
}
.fire::after { content: ""; position: absolute; inset: -60%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 65%); }
@keyframes flicker { 0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .95; } 40% { transform: translate(-50%, -52%) scale(1.07); opacity: 1; } 70% { transform: translate(-50%, -49%) scale(.96); opacity: .85; } }
.seat { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: 120px; text-align: center; }
.seat .av { width: 76px; height: 76px; font-size: 28px; box-shadow: 0 0 0 4px var(--panel); transition: box-shadow .2s; }
.seat.speaking .av { box-shadow: 0 0 0 4px var(--panel), 0 0 0 7px var(--green), 0 0 30px color-mix(in srgb, var(--green) 50%, transparent); }
.seat .name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.seat .name svg { width: 14px; height: 14px; color: var(--red); }
.seat .tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; gap: 4px; }
.seat .tag svg { width: 12px; height: 12px; }
.seat.empty .av { background: transparent; border: 2px dashed var(--text-faint); color: var(--text-faint); box-shadow: none; }
.seat.empty .name { color: var(--text-faint); font-weight: 500; }
.controls { align-self: center; display: flex; gap: 8px; padding: 8px; margin-bottom: 18px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.ctrl { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); }
.ctrl.off { background: var(--red); color: #fff; }
.ctrl.on { background: var(--accent); color: var(--on-accent); }
.ctrl.leave { background: var(--red); color: #fff; width: 64px; border-radius: 999px; }

/* ---------- People ---------- */
.people { width: 244px; padding: 14px 8px; overflow-y: auto; flex-shrink: 0; }
body.no-people .people { display: none; }
.people h3.mt { margin-top: 10px; }
.people h3 { font-size: 13px; font-weight: 600; color: var(--text-faint); padding: 6px 10px; }
.person { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); }
.person:hover { background: var(--surface); }
.person .n { min-width: 0; line-height: 1.25; }
.person b { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 5px; }
.person span { font-size: 12px; color: var(--text-faint); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person.away { opacity: .5; }
.crown { font-size: 11px; }

/* ---------- Customise drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.drawer {
  position: fixed; top: var(--gap); right: var(--gap); bottom: var(--gap); width: min(380px, calc(100vw - 2 * var(--gap)));
  z-index: 21; display: flex; flex-direction: column; transform: translateX(calc(100% + 40px)); transition: transform .25s ease;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 18px; }
.drawer-head p { font-size: 12px; color: var(--text-faint); }
.drawer-body { flex: 1; overflow-y: auto; padding: 6px 20px 20px; }
.opt { margin-top: 18px; }
.opt > label, .opt > .lbl { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; }
.opt .val { color: var(--text-faint); font-weight: 500; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset { height: 64px; border-radius: var(--r-sm); border: 2px solid transparent; padding: 8px 10px; display: flex; align-items: flex-end; justify-content: space-between; font-weight: 600; font-size: 13px; text-align: left; background-size: cover !important; }
.preset .sw { width: 16px; height: 16px; border-radius: 50%; }
.preset.sel { border-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; box-shadow: inset 0 0 0 2px rgba(0,0,0,.15); }
.swatch.sel { border-color: var(--text); }
.swatch.theme { background: conic-gradient(#ff8a3d, #5ee6a8, #7c9cff, #ff4fd8, #ff8a3d); }
.custom-color { position: relative; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--text-dim); }
.custom-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.custom-color svg { width: 16px; height: 16px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile-opt { aspect-ratio: 1; border-radius: var(--r-sm); border: 2px solid var(--border); font-size: 11px; font-weight: 600; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.tile-opt.sel { border-color: var(--accent); }
.fonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.font-opt { padding: 10px 6px; border-radius: var(--r-sm); background: var(--surface); border: 2px solid transparent; font-size: 11px; color: var(--text-dim); }
.font-opt b { display: block; font-size: 22px; color: var(--text); font-weight: 600; }
.font-opt.sel { border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.seg { display: flex; background: var(--surface); border-radius: 999px; padding: 3px; }
.seg button { flex: 1; padding: 7px 6px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-dim); }
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-foot p { font-size: 12px; color: var(--text-faint); flex: 1; }
.drawer-foot button { padding: 8px 14px; border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 22px 0 4px; }
.group-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) { .people { display: none; } }
@media (max-width: 760px) {
  body { --gap: 8px; }
  .top .brand span, .me-chip .n, .customise-btn span { display: none; }
  .menu-btn { display: grid; }
  .chan { position: fixed; top: calc(60px + 2 * var(--gap)); bottom: var(--gap); left: var(--gap); z-index: 15; transform: translateX(calc(-100% - 20px)); transition: transform .2s; background: color-mix(in srgb, var(--panel) 96%, transparent); }
  body.nav-open .chan { transform: none; }
  .msg .stack { max-width: 85%; }
}

/* =========================================================
   Real app additions
   ========================================================= */
[hidden] { display: none !important; }
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.customise-btn svg { width: 17px; height: 17px; }
.gp.new svg { width: 16px; height: 16px; }
.me-chip .av { width: 34px; height: 34px; }
a { color: inherit; }

/* Screens: setup / auth / welcome */
.screen { flex: 1; min-height: 0; overflow-y: auto; display: grid; place-items: center; padding: 12px 0; }
.card { width: min(420px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.card h2 { font-size: 22px; }
.brand.big { font-size: 26px; gap: 10px; }
.brand.big .flame { width: 36px; height: 36px; }
.setup ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
code { font-family: 'JetBrains Mono', monospace; font-size: .88em; background: var(--surface); padding: 1px 6px; border-radius: 6px; }
.only-signup { display: none !important; }
#auth-form.signup .only-signup { display: flex !important; }
.stack-fields { display: flex; flex-direction: column; gap: 14px; }

/* Form bits */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.field em { font-weight: 400; font-style: normal; color: var(--text-faint); }
.field input, .copy-row input {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; color: var(--text); font-size: 15px; font-weight: 400; outline: none; width: 100%;
}
.field input:focus { border-color: var(--accent-line); }
.btn { padding: 10px 18px; border-radius: 999px; font-weight: 600; background: var(--surface); transition: filter .15s; }
.btn:hover { filter: brightness(1.1); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.btn.ghost { background: none; color: var(--text-faint); }
.btn:disabled { opacity: .6; cursor: progress; }
.link-btn { color: var(--text-faint); font-size: 13px; text-decoration: underline; align-self: flex-start; }
.form-error { color: var(--red); font-size: 13px; }
.form-error:empty { display: none; }
.form-error.ok { color: var(--green); }
.form-note { color: var(--text-faint); font-size: 14px; line-height: 1.45; }
.emoji-field, .color-field { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.emoji-field input { width: 64px !important; text-align: center; font-size: 18px !important; margin-right: 4px; }
.emoji-field button { width: 32px; height: 32px; border-radius: 8px; font-size: 17px; }
.emoji-field button:hover { background: var(--surface); }
.color-field .swatch { width: 28px; height: 28px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-size: 13px; }
.profile-preview { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-sm); background: var(--surface); }
.profile-preview .av { width: 48px; height: 48px; font-size: 20px; }
.profile-preview b { display: block; }
.profile-preview span { font-size: 13px; color: var(--text-faint); }

/* Modal */
.modal-bg { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(440px, 100%); max-height: 90vh; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; background: color-mix(in srgb, var(--panel) 96%, transparent); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 18px; }
.modal-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.modal-foot .primary { margin-left: auto; }
@keyframes fade { from { opacity: 0; } }

/* Toasts */
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 18px; border-radius: 999px !important; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); background: color-mix(in srgb, var(--panel) 95%, transparent) !important; animation: fade .2s; transition: opacity .3s, transform .3s; text-align: center; }
.toast.error { border-color: color-mix(in srgb, var(--red) 60%, transparent) !important; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* Channel panel */
.banner-text { min-width: 0; width: 100%; }
.banner h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-btns { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.banner button.round { padding: 6px; }
.ch-row { position: relative; }
.ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-del { position: absolute; right: 6px; top: 8px; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--text-faint); opacity: 0; transition: opacity .15s; background: var(--surface-2); }
.ch-del svg { width: 14px; height: 14px; }
.ch-row:hover .ch-del { opacity: 1; }
.ch-del:hover { color: var(--red); }
.room { cursor: pointer; }
.dock-top { width: 100%; text-align: left; }

/* Messages */
.loading { text-align: center; color: var(--text-faint); font-size: 13px; padding: 8px; }
.chan-start { padding: 12px 4px 4px; }
.chan-start .big { font-size: 40px; line-height: 1.2; }
.chan-start h3 { font-size: 20px; margin-top: 6px; }
.chan-start p { color: var(--text-faint); font-size: 14px; }
.item { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; max-width: 100%; }
.msg.me .item { align-items: flex-end; }
body.flat .msg.me .item { align-items: flex-start; }
.photo { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: var(--r); object-fit: cover; background: var(--surface); }
.bubble a { text-decoration: underline; text-underline-offset: 2px; }
.edited { opacity: .6; font-size: 11px; margin-left: 6px; }
.msg-actions {
  position: absolute; top: -18px; left: -6px; z-index: 2; display: none; gap: 2px; padding: 3px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.msg.me .msg-actions { left: auto; right: -6px; }
body.flat .msg.me .msg-actions { right: auto; left: -6px; }
.msg-actions button { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; color: var(--text-dim); }
.msg-actions button:hover { background: var(--surface); }
.msg-actions svg { width: 15px; height: 15px; }
@media (hover: hover) { .item:hover .msg-actions { display: flex; } }
.item.picked .msg-actions { display: flex; }
.typing.idle { visibility: hidden; }
#text-view { position: relative; }
#text-view.dropping::after { content: "Drop to share"; position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: var(--r); display: grid; place-items: center; background: var(--accent-soft); font-weight: 700; font-size: 18px; }
.emoji-pop { position: absolute; right: 16px; bottom: 76px; z-index: 5; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; background: color-mix(in srgb, var(--panel) 96%, transparent); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.emoji-pop button { width: 36px; height: 36px; border-radius: 8px; font-size: 20px; }
.emoji-pop button:hover { background: var(--surface); }

/* Hangouts */
.join-btn { display: flex; align-items: center; gap: 10px; padding: 12px 26px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 16px; box-shadow: 0 0 30px var(--accent-line); }
.join-btn svg { fill: currentColor; stroke: none; }
.controls:has(.join-btn) { background: none; border-color: transparent; }
.ring.many .seat .av { width: 56px; height: 56px; font-size: 22px; }
.seat.empty { cursor: pointer; }
.seat.empty:hover .av { border-color: var(--accent); color: var(--accent); }
