/* AngelChat — "Glass" visual system
   Apple-Messages structure in ATA's black, gold and white.
   A floating frosted-glass sidebar sits over a dark wallpaper; its labels are etched into the glass
   and the selected row is the only thing lit from behind. Your own messages are gold bubbles,
   everyone else's are smoked glass. The gold halo still marks who is online. */

@font-face { font-family: "Marcellus"; src: url("/fonts/marcellus.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  /* wallpaper: black with two slow pools of warm light behind the glass */
  --wall: #000;
  --wall-art:
    radial-gradient(520px 380px at 6% 6%, rgba(var(--ac-rgb), .55), transparent 60%),
    radial-gradient(380px 300px at 30% 55%, rgba(var(--ac2-rgb), .22), transparent 60%),
    radial-gradient(600px 460px at 14% 100%, rgba(var(--ac-rgb), .45), transparent 62%),
    radial-gradient(1100px 800px at 92% 0%, rgba(var(--ac2-rgb), .16), transparent 60%),
    #000;
  --glass: rgba(40, 36, 30, .42);
  --glass-edge: rgba(255, 255, 255, .14);
  --glass-hi: rgba(255, 255, 255, .22);
  --glass-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 1px 0 rgba(255, 255, 255, .08) inset, 0 0 0 .5px rgba(255, 255, 255, .12) inset;
  --pane: #0b0b0c;                     /* the conversation pane is solid so bubble tails and text stay crisp */
  --pane-solid: #0b0b0c;
  --bar: rgba(16, 16, 17, .72);        /* translucent header / composer bars */
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .18);
  --hover: rgba(255, 255, 255, .05);
  --hover-strong: rgba(255, 255, 255, .1);
  --bubble-them: #26262a;
  --bubble-them-text: #f2f2f4;
  /* accent — set by the colour chooser; gold + sky blue by default (the AngelChat logo) */
  --ac: #d4ad57; --ac-hi: #ecd28f; --ac-lo: #a8822e; --ac-on: #1a1305; --ac-tail: #bb9443;
  --ac2: #6fa8ff; --ac2-hi: #9cc3ff; --ac2-on: #061a3a;
  --ac-rgb: 212, 173, 87; --ac2-rgb: 111, 168, 255;
  --bubble-me: linear-gradient(160deg, var(--ac-hi) 0%, var(--ac) 45%, var(--ac-lo) 100%);
  --bubble-me-solid: var(--ac);
  --bubble-me-text: var(--ac-on);
  --gold: var(--ac);
  --gold-hi: var(--ac-hi);
  --gold-grad: linear-gradient(160deg, var(--ac-hi) 0%, var(--ac) 50%, var(--ac-lo) 100%);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --on-gold: var(--ac-on);
  --mention: rgba(212, 173, 87, .16);
  --code-bg: rgba(255, 255, 255, .07);
  --danger: #ff6b5a;
  --scrim: rgba(0, 0, 0, .55);
  --raise: rgba(36, 34, 30, .78);
  --shadow: 0 24px 70px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .14) inset;
  /* etched-into-glass type: the letters are a little lighter than the glass, with a cut shadow above and a catchlight below */
  --etch-color: rgba(255, 255, 255, .56);
  --etch-shadow: 0 -1px 0 rgba(0, 0, 0, .75), 0 1px 0 rgba(255, 255, 255, .28);
  --lit-color: #ffffff;
  --display: "Marcellus", Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="ivory"] {
  --wall-art:
    radial-gradient(900px 620px at 8% 12%, rgba(var(--ac-rgb), .35), transparent 60%),
    radial-gradient(800px 600px at 22% 95%, rgba(var(--ac2-rgb), .3), transparent 62%),
    radial-gradient(1100px 800px at 92% 0%, rgba(255, 255, 255, .9), transparent 60%),
    #efe9dc;
  --glass: rgba(255, 255, 255, .42);
  --glass-edge: rgba(255, 255, 255, .7);
  --glass-hi: rgba(255, 255, 255, .85);
  --glass-shadow: 0 30px 80px rgba(80, 60, 20, .18), 0 1px 0 rgba(255, 255, 255, .9) inset, 0 0 0 .5px rgba(0, 0, 0, .06);
  --pane: #ffffff;
  --pane-solid: #ffffff;
  --bar: rgba(255, 255, 255, .72);
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .16);
  --hover: rgba(0, 0, 0, .04);
  --hover-strong: rgba(0, 0, 0, .07);
  --bubble-them: #e9e9eb;
  --bubble-them-text: #111;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --mention: rgba(212, 173, 87, .2);
  --code-bg: rgba(0, 0, 0, .05);
  --danger: #d6331f;
  --scrim: rgba(40, 30, 10, .25);
  --raise: rgba(255, 255, 255, .82);
  --shadow: 0 24px 70px rgba(60, 40, 10, .18), 0 0 0 .5px rgba(0, 0, 0, .08);
  --etch-color: rgba(60, 46, 20, .55);
  --etch-shadow: 0 1px 0 rgba(255, 255, 255, .85), 0 -1px 0 rgba(0, 0, 0, .12);
  --lit-color: #111;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { font: 400 14.5px/1.42 var(--ui); color: var(--text); background: var(--wall-art); background-attachment: fixed; -webkit-font-smoothing: antialiased; letter-spacing: -.003em; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
a { color: var(--gold-hi); text-underline-offset: 2px; }
:root[data-theme="ivory"] a { color: var(--ac-lo); }
::selection { background: rgba(212, 173, 87, .4); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
* { scrollbar-width: thin; scrollbar-color: rgba(127,127,127,.35) transparent; }

/* ---------- logo ---------- */
.mark { display: block; flex: none; }
.logo-img { display: block; height: 34px; width: auto; }
.logo-img.lg { height: 64px; }
.mark .ring { fill: none; stroke: url(#halo-grad); stroke-width: 1.6; }
.mark .glyph { fill: var(--text); font-family: var(--display); }
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: #000; z-index: 100; transition: opacity .5s ease; }
.splash.out { opacity: 0; pointer-events: none; }
.splash .ring { stroke-dasharray: 120; stroke-dashoffset: 120; animation: draw 1.1s cubic-bezier(.6,0,.2,1) forwards; }
.splash .glyph { opacity: 0; animation: rise .7s .55s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- glass primitive ---------- */
.glass { background: var(--glass); -webkit-backdrop-filter: blur(40px) saturate(170%); backdrop-filter: blur(40px) saturate(170%);
  box-shadow: var(--glass-shadow); border: .5px solid var(--glass-edge); }
.etched { color: var(--etch-color); text-shadow: var(--etch-shadow); }

/* ---------- buttons + fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 15px; border-radius: 999px;
  border: 0; background: var(--hover-strong); font-weight: 500; font-size: 13.5px; color: var(--text); white-space: nowrap; }
.btn:hover { background: color-mix(in srgb, var(--text) 16%, transparent); }
.btn-gold { background: var(--gold-grad); color: var(--on-gold); font-weight: 600; }
.btn-gold:hover { background: var(--gold-grad); filter: brightness(1.06); }
.btn-quiet { background: transparent; color: var(--gold-hi); }
.btn-quiet:hover { background: var(--hover); }
:root[data-theme="ivory"] .btn-quiet { color: var(--ac-lo); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; border-radius: 12px; }
.btn[disabled] { opacity: .45; cursor: default; filter: none; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .input {
  width: 100%; padding: 10px 13px; border: .5px solid var(--line-strong); border-radius: 10px; background: var(--hover); outline: none; transition: box-shadow .15s, border-color .15s;
}
select option { background: var(--pane-solid); color: var(--text); }
.field input:not([type="checkbox"]):focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--gold); box-shadow: 0 0 0 3.5px rgba(var(--ac-rgb),.28); }
.field small { color: var(--text-3); font-size: 12px; font-weight: 400; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 10px; }

/* ---------- auth ---------- */
.auth { min-height: 100%; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; border-radius: 28px; padding: 36px 32px 30px; }
.auth-card .wordmark { justify-content: center; flex-direction: column; text-align: center; gap: 10px; margin-bottom: 26px; }
.auth-card h1 { font-weight: 600; font-size: 24px; letter-spacing: -.02em; margin: 0 0 6px; text-align: center; }
.auth-card .lede { margin: 0 0 24px; color: var(--text-2); text-align: center; }
.auth-card .fine { margin: 18px 0 0; font-size: 12.5px; color: var(--text-3); text-align: center; }
.auth-art { display: none; }
.wordmark { display: flex; align-items: center; gap: 11px; }
.wordmark b { font-family: var(--ui); font-weight: 600; font-size: 19px; letter-spacing: -.02em; display: block; line-height: 1.1; }
.wordmark b i { font-style: normal; color: var(--ac); }
.wordmark small { display: block; font-size: 11.5px; letter-spacing: .01em; opacity: .85; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: 100%; height: 100dvh; padding: 10px; gap: 10px; }
.shell.thread-open { grid-template-columns: 300px minmax(0, 1fr) 380px; }

/* The sidebar is a floating pane of frosted glass. Everything on it is etched; only the selection is lit. */
.sidebar { position: relative; display: flex; flex-direction: column; min-height: 0; border-radius: 22px; overflow: hidden; }
.sidebar::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.07), transparent 22%, transparent 78%, rgba(255,255,255,.03)); }
:root[data-theme="ivory"] .sidebar::before { background: linear-gradient(180deg, rgba(255,255,255,.6), transparent 30%); }
.side-head { padding: 18px 18px 10px; position: relative; }
.side-head .wordmark b, .side-head .wordmark small { color: var(--etch-color); text-shadow: var(--etch-shadow); }
.side-head .wordmark b i { color: var(--ac); text-shadow: none; opacity: .9; }
.side-head .mark .glyph { fill: var(--etch-color); }
.side-search { margin: 4px 12px 8px; position: relative; }
.side-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--etch-color); pointer-events: none; }
.side-search input { width: 100%; padding: 7px 12px 7px 32px; border-radius: 10px; border: 0; outline: none; font-size: 13.5px;
  background: rgba(0,0,0,.28); color: var(--text); box-shadow: inset 0 1px 2px rgba(0,0,0,.35), 0 .5px 0 rgba(255,255,255,.1); }
:root[data-theme="ivory"] .side-search input { background: rgba(0,0,0,.06); box-shadow: inset 0 1px 2px rgba(0,0,0,.08), 0 .5px 0 rgba(255,255,255,.9); }
.side-search input::placeholder { color: var(--etch-color); }
.side-search input:focus { box-shadow: 0 0 0 3px rgba(var(--ac-rgb),.35); }
.side-nav { padding: 2px 10px 0; }
.side-scroll { flex: 1; overflow-y: auto; padding: 2px 0 14px; position: relative; }
.side-section { margin-top: 14px; }
.side-label { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 4px 20px; font-size: 11.5px; font-weight: 600;
  color: var(--etch-color); text-shadow: var(--etch-shadow); letter-spacing: .01em; }
.icon-btn { background: none; border: 0; padding: 5px; border-radius: 8px; color: var(--etch-color); line-height: 0; display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--lit-color); background: var(--hover-strong); }
.side-item { position: relative; display: flex; align-items: center; gap: 10px; width: calc(100% - 20px); margin: 1px 10px; padding: 7px 10px; border: 0;
  background: none; text-align: left; border-radius: 10px; font-size: 14.5px; font-weight: 600; letter-spacing: .01em;
  color: var(--etch-color); text-shadow: var(--etch-shadow); transition: background .12s, color .12s; }
.side-item:hover { background: rgba(255,255,255,.06); }
:root[data-theme="ivory"] .side-item:hover { background: rgba(255,255,255,.45); }
.side-item.unread { color: color-mix(in srgb, var(--lit-color) 88%, transparent); font-weight: 650; }
/* selection: lit from behind — a brighter slab of glass, letters go clear and bright */
.side-item.active { color: var(--lit-color); text-shadow: none; background: rgba(255,255,255,.16);
  box-shadow: inset 0 .5px 0 rgba(255,255,255,.28), 0 1px 3px rgba(0,0,0,.25); }
:root[data-theme="ivory"] .side-item.active { background: rgba(255,255,255,.85); box-shadow: 0 1px 3px rgba(80,60,20,.12), inset 0 .5px 0 #fff; }
.side-item .glyph { width: 18px; flex: none; text-align: center; font-size: 14px; line-height: 0; opacity: .9; }
.side-item.active .glyph { color: var(--gold); opacity: 1; }
.side-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .count { font-size: 11.5px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center;
  background: var(--gold-grad); color: var(--on-gold); text-shadow: none; }
.side-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ac2); box-shadow: 0 0 6px rgba(var(--ac-rgb),.6); }
.side-foot { position: relative; border-top: .5px solid var(--glass-edge); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.side-foot .who { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 5px 6px; border-radius: 10px; }
.side-foot .who:hover { background: rgba(255,255,255,.06); }
.side-foot .who b { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--etch-color); text-shadow: var(--etch-shadow); }
.side-foot .who small { font-size: 11.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--etch-color); text-shadow: var(--etch-shadow); opacity: .8; }

/* ---------- avatars + halo ---------- */
.av { position: relative; width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; user-select: none;
  font-size: 13px; font-weight: 600; letter-spacing: .02em; color: #fff;
  background: linear-gradient(180deg, #8e8e93, #5a5a5f); }
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.av.sm { width: 28px; height: 28px; font-size: 11px; }
.av.xs { width: 22px; height: 22px; font-size: 9px; }
.av.xl { width: 92px; height: 92px; font-size: 34px; font-weight: 500; }
.av.bot { border-radius: 9px; background: var(--gold-grad); color: var(--on-gold); }
.av.on::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--gold);
  box-shadow: 0 0 9px rgba(var(--ac-rgb),.45); pointer-events: none; }
.av.xs.on::after { inset: -3px; border-width: 1.2px; }
.av.xl.on::after { inset: -7px; border-width: 2px; }

/* ---------- conversation pane ---------- */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--pane);
  border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.45), 0 0 0 .5px var(--line-strong); }
.chan-head { position: absolute; top: 0; left: 0; right: 0; z-index: 5; min-height: 60px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 14px; background: var(--bar); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  border-bottom: .5px solid var(--line); }
.chan-head .head-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.chan-title { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; max-width: 46vw; border: 0; background: none; padding: 4px 10px; border-radius: 10px; }
button.chan-title:hover { background: var(--hover); }
.chan-title .row1 { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14.5px; max-width: 100%; }
.chan-title .row1 span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-title .glyph { color: var(--gold); font-weight: 400; line-height: 0; }
.chan-title .sub { font-size: 11.5px; color: var(--text-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-title .avs { margin-bottom: 2px; }
.star { border: 0; background: none; padding: 2px; color: var(--text-3); line-height: 0; }
.star.on, .star:hover { color: var(--gold); }
.head-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.head-btn { border: 0; background: transparent; border-radius: 999px; padding: 6px 10px; font-size: 12.5px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; }
.head-btn:hover { background: var(--hover-strong); color: var(--text); }
.facepile { display: flex; }
.facepile .av { margin-left: -6px; box-shadow: 0 0 0 1.5px var(--pane-solid); }
.facepile .av:first-child { margin-left: 0; }
.menu-toggle { display: none; color: var(--gold); }
.menu-toggle:hover { color: var(--gold-hi); }
.conn-banner { position: absolute; top: 60px; left: 0; right: 0; z-index: 4; background: rgba(var(--ac-rgb),.16); color: var(--gold-hi); font-size: 12px; text-align: center; padding: 5px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }

.messages { flex: 1; overflow-y: auto; padding: 72px 0 14px; min-height: 0; overscroll-behavior: contain; }
.stamp { text-align: center; margin: 18px 0 6px; font-size: 11px; color: var(--text-3); font-weight: 500; }
.stamp b { font-weight: 600; color: var(--text-2); }
.new-line { display: flex; align-items: center; gap: 10px; margin: 10px 20px; color: var(--gold); font-size: 11px; font-weight: 600; }
.new-line::before, .new-line::after { content: ""; flex: 1; height: .5px; background: var(--gold); opacity: .5; }

.intro { padding: 48px 24px 14px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.intro .av { margin-bottom: 14px; }
.intro .big-hash { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; font-size: 40px; font-weight: 300; color: var(--on-gold); background: var(--gold-grad); margin-bottom: 14px; box-shadow: 0 10px 30px rgba(var(--ac-rgb),.25); }
.intro h2 { font-weight: 600; font-size: 22px; letter-spacing: -.02em; margin: 0 0 6px; }
.intro p { color: var(--text-2); margin: 0 0 14px; max-width: 46ch; font-size: 13.5px; }
.intro .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- bubbles ---------- */
.msg { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; padding: 1px 16px; align-items: end; }
.msg.mine { grid-template-columns: minmax(0, 1fr); }
.msg.mine > .av { display: none; }
.msg.group-start { margin-top: 8px; }
.msg > .av { width: 30px; height: 30px; font-size: 11px; visibility: hidden; margin-bottom: 2px; }
.msg.tail > .av { visibility: visible; }
.stack { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(72%, 620px); }
.msg.mine .stack { align-items: flex-end; margin-left: auto; }
.sender { font-size: 11.5px; color: var(--text-2); margin: 0 0 2px 13px; display: flex; gap: 6px; align-items: center; }
.sender .who { border: 0; background: none; padding: 0; color: inherit; font: inherit; }
.sender .who:hover { color: var(--text); }
.sender .tag { font-size: 10px; font-weight: 600; color: var(--on-gold); background: var(--gold-grad); border-radius: 4px; padding: 0 5px; line-height: 15px; }
.bubble { position: relative; padding: 7px 12px 8px; border-radius: 18px; background: var(--bubble-them); color: var(--bubble-them-text);
  max-width: 100%; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.38; }
.msg.mine .bubble { background: var(--bubble-me); color: var(--bubble-me-text); }
/* the iMessage tail on the last bubble of a run */
.msg.tail .bubble::before, .msg.tail .bubble::after { content: ""; position: absolute; bottom: 0; height: 18px; }
.msg.tail:not(.mine) .bubble::before { left: -6px; width: 18px; background: var(--bubble-them); border-bottom-right-radius: 14px 12px; }
.msg.tail:not(.mine) .bubble::after { left: -10px; width: 10px; background: var(--pane-solid); border-bottom-right-radius: 10px; }
.msg.tail.mine .bubble::before { right: -6px; width: 18px; background: var(--ac-tail); border-bottom-left-radius: 14px 12px; }
.msg.tail.mine .bubble::after { right: -10px; width: 10px; background: var(--pane-solid); border-bottom-left-radius: 10px; }
.bubble.deleted { background: transparent !important; color: var(--text-3) !important; font-style: italic; border: .5px dashed var(--line-strong); }
.msg .bubble.deleted::before, .msg .bubble.deleted::after { display: none; }
.bubble.jumbo { background: none !important; padding: 4px 2px 2px; font-size: 44px; line-height: 1.2; }
.msg .bubble.jumbo::before, .msg .bubble.jumbo::after { display: none; }
.bubble.bot { background: var(--bubble-them); border: .5px solid rgba(var(--ac-rgb),.45); }
.msg.mention:not(.mine) .bubble { box-shadow: 0 0 0 1.5px var(--gold); }
.msg.flash .bubble { animation: flash 1.6s ease; }
@keyframes flash { 0%, 35% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: 0 0 0 0 transparent; } }
.bubble code { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); border-radius: 5px; padding: 1px 5px; }
.msg.mine .bubble code { background: rgba(0,0,0,.12); }
.bubble pre { font-family: var(--mono); font-size: 12.5px; background: rgba(0,0,0,.28); border-radius: 10px; padding: 10px 12px; margin: 4px 0; overflow-x: auto; white-space: pre; }
:root[data-theme="ivory"] .bubble pre { background: rgba(0,0,0,.06); }
.msg.mine .bubble pre { background: rgba(0,0,0,.12); }
.bubble blockquote { margin: 2px 0; padding-left: 10px; border-left: 2px solid currentColor; opacity: .8; }
.bubble a { color: inherit; text-decoration: underline; }
.mention-chip { font-weight: 600; color: var(--gold-hi); }
:root[data-theme="ivory"] .mention-chip { color: var(--ac-lo); }
.msg.mine .mention-chip { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; }
.edited { font-size: 11px; opacity: .6; }
.meta-under { display: flex; gap: 10px; align-items: center; font-size: 11px; color: var(--text-3); margin: 3px 12px 0; }
.meta-under .pin-flag { color: var(--gold); display: inline-flex; align-items: center; gap: 3px; }
.hover-time { font-size: 11px; color: var(--text-3); align-self: center; opacity: 0; transition: opacity .15s; white-space: nowrap; }
.msg:hover .hover-time { opacity: 1; }
.bubble-row { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.msg.mine .bubble-row { flex-direction: row-reverse; }

.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0; }
.msg.mine .attachments { justify-content: flex-end; }
.att-img { border: 0; padding: 0; background: none; border-radius: 18px; overflow: hidden; line-height: 0; }
.att-img img { max-width: 320px; max-height: 300px; border-radius: 18px; display: block; }
.att-file { display: inline-flex; align-items: center; gap: 11px; border: 0; border-radius: 16px; padding: 9px 14px 9px 10px;
  text-decoration: none; color: var(--bubble-them-text); background: var(--bubble-them); max-width: 320px; text-align: left; }
.msg.mine .att-file { background: var(--bubble-me); color: var(--bubble-me-text); }
.att-file .ext { width: 34px; height: 40px; flex: none; border-radius: 5px; display: grid; place-items: end center; padding-bottom: 4px;
  font-size: 9px; font-weight: 700; letter-spacing: .03em; background: rgba(255,255,255,.12); }
.msg.mine .att-file .ext { background: rgba(0,0,0,.12); }
.att-file b { display: block; font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.att-file small { font-size: 11.5px; opacity: .7; }

/* tapbacks: reactions perch on the bubble's top corner */
.reactions { display: flex; flex-wrap: wrap; gap: 3px; margin: -8px 4px 0 18px; position: relative; z-index: 1; }
.msg.mine .reactions { margin: -8px 18px 0 4px; justify-content: flex-end; }
.reaction { border: 0; border-radius: 999px; padding: 2px 8px 2px 6px; font-size: 12.5px; display: inline-flex; gap: 4px; align-items: center;
  background: var(--raise); color: var(--text-2); box-shadow: 0 0 0 2px var(--pane-solid), 0 2px 6px rgba(0,0,0,.25);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.reaction { color: var(--ac2-hi); }
.reaction.mine { background: var(--gold-grad); color: var(--on-gold); }
.reaction.mine b { color: var(--on-gold); }
.reaction b { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reaction.add { padding: 2px 6px; color: var(--text-3); }
.reaction.add svg { width: 14px; height: 14px; }
.thread-link { margin: 4px 12px 0; border: 0; background: none; padding: 0; color: var(--ac2-hi); font-size: 12px; font-weight: 600; display: inline-flex; gap: 6px; }
.thread-link span { color: var(--text-3); font-weight: 400; }
.thread-link:hover { color: var(--gold-hi); }

.msg-actions { position: absolute; top: 50%; transform: translateY(-50%); display: none; z-index: 3; gap: 1px; padding: 3px; border-radius: 999px;
  background: var(--raise); -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%); box-shadow: var(--shadow); }
.msg:not(.mine) .msg-actions { right: 18px; }
.msg.mine .msg-actions { left: 18px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions button { border: 0; background: none; border-radius: 999px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--text-2); }
.msg-actions button:hover { background: var(--hover-strong); color: var(--text); }
.load-more { display: flex; margin: 8px auto; }

/* ---------- composer ---------- */
.composer-wrap { flex: none; padding: 8px 14px 10px; background: var(--bar); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  border-top: .5px solid var(--line); }
.composer { display: flex; align-items: flex-end; gap: 8px; position: relative; }
.composer .plus { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--hover-strong); color: var(--text-2); margin-bottom: 1px; }
.composer .plus:hover { color: var(--text); }
.composer .field-wrap { flex: 1; min-width: 0; border-radius: 19px; border: .5px solid var(--line-strong); background: color-mix(in srgb, var(--pane-solid) 60%, transparent);
  display: flex; flex-direction: column; transition: border-color .15s; }
.composer .field-wrap:focus-within { border-color: color-mix(in srgb, var(--gold) 70%, transparent); }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; padding: 8px 4px 8px 14px; background: transparent; max-height: 200px; min-height: 36px; display: block; line-height: 1.4; }
.composer textarea::placeholder { color: var(--text-3); }
.composer .in-row { display: flex; align-items: flex-end; }
.composer .tool { border: 0; background: none; border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; color: var(--text-3); margin: 2px 0; flex: none; }
.composer .tool:hover { color: var(--text); }
.send { flex: none; width: 28px; height: 28px; margin: 4px 4px 4px 0; border: 0; border-radius: 50%; background: var(--gold-grad); color: var(--on-gold); display: grid; place-items: center;
  transition: transform .12s, opacity .15s; }
.send svg { transform: rotate(-90deg); }
.send:hover:not([disabled]) { transform: scale(1.07); }
.send[disabled] { opacity: 0; pointer-events: none; transform: scale(.6); }
.hint { display: none; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0; }
.pending-file { display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 5px 6px 5px 11px; font-size: 12px; background: var(--hover-strong); }
.pending-file small { color: var(--text-3); }
.pending-file button { border: 0; background: rgba(0,0,0,.25); width: 18px; height: 18px; border-radius: 50%; color: var(--text); line-height: 1; font-size: 12px; }
.typing { min-height: 0; font-size: 11.5px; color: var(--text-3); padding: 0 0 0 50px; display: flex; align-items: center; gap: 8px; }
.typing:not(:empty) { padding-top: 6px; }
.typing .dots { display: inline-flex; gap: 3px; padding: 6px 9px; border-radius: 12px; background: var(--bubble-them); }
.typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ac2); animation: blink 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: .2s; }
.typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer.locked { justify-content: center; align-items: center; gap: 12px; padding: 6px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; text-align: center; }

/* ---------- thread pane ---------- */
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; border-radius: 22px; overflow: hidden;
  background: var(--pane); box-shadow: 0 30px 80px rgba(0,0,0,.45), 0 0 0 .5px var(--line-strong); }
.thread-root { padding-bottom: 6px; border-bottom: .5px solid var(--line); margin-bottom: 4px; }
.reply-count { margin: 8px 0 4px; font-size: 11px; color: var(--text-3); text-align: center; }

/* ---------- overlays ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 500px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border-radius: 22px;
  background: var(--raise); -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%); box-shadow: var(--shadow);
  animation: pop .22s cubic-bezier(.2,.9,.3,1.1); }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px 24px; }
.modal-head h2 { margin: 0; font-weight: 600; font-size: 18px; letter-spacing: -.015em; }
.modal-body { padding: 6px 24px 4px; overflow-y: auto; }
.modal-body > p:first-child { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.close-x { border: 0; background: var(--hover-strong); width: 26px; height: 26px; border-radius: 50%; color: var(--text-2); display: grid; place-items: center; font-size: 17px; line-height: 1; }
.close-x:hover { color: var(--text); }
.list { border-radius: 12px; overflow: hidden; background: var(--hover); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: .5px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow b { display: block; font-size: 14px; font-weight: 600; }
.list-row .grow small { color: var(--text-3); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover { background: var(--hover); }
.tabs { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--hover-strong); margin: 0 0 16px; }
.tab { flex: 1; border: 0; background: none; padding: 6px 12px; font-weight: 500; font-size: 13px; color: var(--text-2); border-radius: 8px; }
.tab.active { background: var(--pane-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.pill { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 9px; background: var(--hover-strong); color: var(--text-2); text-transform: capitalize; white-space: nowrap; }
.pill.admin { background: rgba(var(--ac-rgb),.2); color: var(--gold-hi); }
:root[data-theme="ivory"] .pill.admin { color: var(--ac-lo); }
.pill.off { background: rgba(255,107,90,.16); color: var(--danger); }
.copy-box { display: flex; gap: 8px; margin: 8px 0 16px; }
.copy-box input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; padding: 8px 12px; border: 0; border-radius: 10px; background: var(--hover-strong); }
.check-list { max-height: 280px; overflow-y: auto; margin: 0 -6px; }
.check-list label { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 10px; cursor: pointer; }
.check-list label:hover { background: var(--hover); }
.check-list input[type=checkbox] { accent-color: var(--gold); width: 17px; height: 17px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
pre.snippet { font-family: var(--mono); font-size: 12px; background: var(--hover-strong); border-radius: 10px; padding: 12px; overflow-x: auto; color: var(--text-2); }
.seg { display: inline-flex; border-radius: 9px; padding: 2px; gap: 2px; background: var(--hover-strong); }
.seg button { border: 0; background: none; border-radius: 7px; padding: 5px 14px; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--pane-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); font-weight: 500; }
.section-h { font-weight: 600; font-size: 14px; margin: 22px 0 8px; }

.popover { position: fixed; z-index: 70; border-radius: 18px; background: var(--raise); -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  box-shadow: var(--shadow); animation: pop .16s ease; }
.profile-card { width: 290px; padding: 24px 22px 18px; text-align: center; }
.profile-card .av { margin: 6px auto 16px; }
.profile-card h3 { font-weight: 600; font-size: 20px; letter-spacing: -.02em; margin: 0 0 2px; }
.profile-card .title { color: var(--text-2); font-size: 13px; }
.profile-card .status { color: var(--text-3); font-size: 12px; margin: 10px 0 16px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.profile-card .status .ind { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.profile-card .status.on { color: var(--gold); }
.profile-card .status.on .ind { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.profile-card .btn { width: 100%; padding: 9px; border-radius: 12px; }

.emoji-panel { width: 340px; padding: 12px; }
.emoji-panel input { width: 100%; padding: 7px 12px; border: 0; border-radius: 10px; background: var(--hover-strong); outline: none; font-size: 13px; margin-bottom: 8px; }
.emoji-cats { display: flex; gap: 2px; margin-bottom: 6px; }
.emoji-cats button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 5px 0; font-size: 16px; opacity: .55; }
.emoji-cats button.on, .emoji-cats button:hover { opacity: 1; background: var(--hover-strong); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; height: 228px; overflow-y: auto; align-content: start; }
.emoji-grid button { border: 0; background: none; font-size: 22px; border-radius: 8px; aspect-ratio: 1; display: grid; place-items: center; line-height: 1; }
.emoji-grid button:hover { background: var(--hover-strong); }
.emoji-grid .cat-h { grid-column: 1 / -1; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 8px 4px 2px; }
.emoji-empty { grid-column: 1 / -1; color: var(--text-3); font-size: 13px; padding: 20px 4px; text-align: center; }

.mention-pop { position: absolute; bottom: calc(100% + 8px); left: 42px; width: 280px; padding: 6px; }
.mention-pop .opt { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; cursor: pointer; font-size: 13.5px; }
.mention-pop .opt.on { background: var(--gold-grad); color: var(--on-gold); }
.mention-pop .opt small { color: var(--text-3); margin-left: auto; font-size: 11.5px; }
.mention-pop .opt.on small { color: var(--on-gold); opacity: .7; }

.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  display: flex; flex-direction: column; animation: fade .18s; color: #f5f5f7; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.lightbox-bar .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 500; }
.lightbox-bar .name small { color: #8e8e93; margin-left: 10px; font-weight: 400; }
.lightbox-stage { flex: 1; display: grid; place-items: center; padding: 10px 20px 24px; min-height: 0; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; }
.lightbox-stage iframe { width: min(960px, 100%); height: 100%; border: 0; border-radius: 12px; background: #fff; }
.lightbox .btn, .lightbox .close-x { color: #f5f5f7; background: rgba(255,255,255,.12); }

.panel-list > div { cursor: pointer; padding: 4px 0 8px; }
.panel-list > div:hover { background: var(--hover); }
.panel-list .where { font-size: 11.5px; color: var(--text-3); padding: 8px 18px 4px; }
.panel-list .where b { color: var(--gold); font-weight: 600; }
.empty { color: var(--text-3); padding: 28px 4px; text-align: center; font-size: 13.5px; }

#toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(16px); color: var(--text); padding: 10px 18px; border-radius: 999px; font-size: 13px;
  background: var(--raise); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .22s; z-index: 90; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- mobile (iOS) ---------- */
.tabbar { display: none; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: var(--scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .15s; }
.sheet { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 61; border-radius: 22px; padding: 10px 8px 8px;
  background: var(--raise); -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%); box-shadow: var(--shadow);
  animation: up .26s cubic-bezier(.2,.9,.3,1); }
@keyframes up { from { transform: translateY(110%); } }
.sheet .quick { display: flex; justify-content: space-between; padding: 2px 6px 10px; border-bottom: .5px solid var(--line); margin-bottom: 4px; }
.sheet .quick button { border: 0; background: var(--hover-strong); width: 44px; height: 44px; border-radius: 50%; font-size: 22px; }
.sheet .item { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 13px 12px; border-radius: 12px; font-size: 16px; text-align: left; }
.sheet .item:active { background: var(--hover-strong); }
.sheet .item.danger { color: var(--danger); }

@media (max-width: 860px) {
  body { font-size: 16px; }
  .shell, .shell.thread-open { grid-template-columns: 1fr; grid-template-rows: 1fr; padding: 0; gap: 0; }
  .sidebar { position: fixed; inset: 0; z-index: 20; border-radius: 0; border: 0; transform: translateX(-100%); transition: transform .3s cubic-bezier(.2,.9,.3,1);
    padding-top: env(safe-area-inset-top); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .shell.nav-open .sidebar { transform: none; }
  .side-head { padding: 14px 18px 4px; }
  .side-head .wordmark b { font-size: 26px; font-weight: 700; }
  .side-head .wordmark small { display: none; }
  .side-head .mark { width: 30px; height: 30px; }
  .side-foot { display: none; }
  .side-item { padding: 11px 12px; font-size: 16.5px; }
  .main { border-radius: 0; box-shadow: none; }
  .main, .thread { padding-bottom: calc(0px + env(safe-area-inset-bottom)); }
  .menu-toggle { display: inline-grid; }
  .thread { position: fixed; inset: 0; z-index: 40; border-radius: 0; }
  .chan-head { padding-top: env(safe-area-inset-top); min-height: calc(56px + env(safe-area-inset-top)); }
  .chan-title { max-width: 52vw; }
  .chan-head { grid-template-columns: 44px 1fr auto; }
  .chan-head .chan-title { justify-self: center; }
  .head-btn .lbl, .facepile { display: none; }
  .messages { padding-top: calc(80px + env(safe-area-inset-top)); }
  .stack { max-width: 78%; }
  .msg { padding: 1px 10px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .bubble { -webkit-user-select: text; user-select: text; font-size: 16px; }
  .msg:hover .msg-actions, .hover-time { display: none !important; }
  .composer-wrap { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .shell.nav-open ~ * .composer-wrap { display: none; }
  .att-img img { max-width: 100%; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding-bottom: env(safe-area-inset-bottom); background: var(--bar); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
    border-top: .5px solid var(--line); }
  .shell:not(.nav-open) .tabbar { display: none; }
  .shell.tabs-on .tabbar { display: grid; }
  .tabbar button { position: relative; border: 0; background: none; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 6px; font-size: 10.5px; font-weight: 500; }
  .tabbar button.on { color: var(--gold); }
  .tabbar .badge-dot { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
    background: #ff3b30; color: #fff; font-size: 10.5px; font-weight: 600; display: grid; place-items: center; }
  .page .messages { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { max-width: none !important; border-radius: 22px 22px 0 0; max-height: 92dvh; animation: up .28s cubic-bezier(.2,.9,.3,1); padding-bottom: env(safe-area-inset-bottom); }
  .emoji-panel { width: auto; left: 8px !important; right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .splash .ring { stroke-dashoffset: 0; }
  .splash .glyph { opacity: 1; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(28, 26, 22, .92); --raise: rgba(36, 34, 30, .98); }
  :root[data-theme="ivory"] { --glass: rgba(255, 255, 255, .92); --raise: #fff; }
}

/* ---------- colour chooser ---------- */
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 4px 0 12px; }
.swatch { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.swatch .chip { width: 52px; height: 52px; border-radius: 50%; position: relative; box-shadow: 0 0 0 2px transparent, 0 4px 14px rgba(0,0,0,.25); transition: transform .12s, box-shadow .12s;
  background: linear-gradient(135deg, var(--c-hi), var(--c) 55%, var(--c-lo)); }
.swatch .chip::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--c2); box-shadow: 0 0 0 2.5px var(--raise); }
.swatch:hover .chip { transform: scale(1.06); }
.swatch.on .chip { box-shadow: 0 0 0 2.5px var(--raise), 0 0 0 4.5px var(--c), 0 4px 14px rgba(0,0,0,.25); }
.swatch.on { color: var(--text); font-weight: 600; }
.picker-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--hover); }
.picker-row input[type=color] { width: 44px; height: 44px; border: 0; padding: 0; border-radius: 50%; background: none; cursor: pointer; }
.picker-row input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.picker-row input[type=color]::-webkit-color-swatch { border: 2.5px solid var(--raise); border-radius: 50%; }
.picker-row input[type=color]::-moz-color-swatch { border: 2.5px solid var(--raise); border-radius: 50%; }
.picker-row .grow b { display: block; font-size: 13.5px; }
.picker-row .grow small { color: var(--text-3); font-size: 12px; }
.picker-row .comp { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--raise); }

/* ---------- v0.5: replies, voice, previews, palette, status ---------- */

/* custom emoji */
.cemoji { width: 1.35em; height: 1.35em; vertical-align: -.3em; object-fit: contain; }
.bubble.jumbo .cemoji { width: 1em; height: 1em; vertical-align: -.1em; }
.emoji-grid .cemoji { width: 24px; height: 24px; }

/* code */
.bubble pre { position: relative; }
.bubble pre[data-lang]::before { content: attr(data-lang); position: absolute; top: 4px; right: 8px; font-size: 10px;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.hl-k { color: #c3a0ff; font-weight: 600; }
.hl-s { color: #8fd98f; }
.hl-c { color: var(--text-3); font-style: italic; }
.hl-n { color: #f0b36b; }
.hl-a { color: #7fc8e8; }
:root[data-theme="ivory"] .hl-k { color: #7a3fc4; }
:root[data-theme="ivory"] .hl-s { color: #1d7a3c; }
:root[data-theme="ivory"] .hl-n { color: #a35a0c; }
:root[data-theme="ivory"] .hl-a { color: #16688c; }
.msg.mine .bubble .hl-k, .msg.mine .bubble .hl-s, .msg.mine .bubble .hl-c,
.msg.mine .bubble .hl-n, .msg.mine .bubble .hl-a { color: inherit; opacity: .85; font-style: normal; }

/* quoted reply inside a bubble */
.quote { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; max-width: 100%; border: 0; text-align: left;
  background: var(--hover-strong); border-left: 2.5px solid var(--ac); border-radius: 8px; padding: 5px 10px; margin-bottom: 3px; }
.msg.mine .quote { align-self: flex-end; }
.quote:hover { background: color-mix(in srgb, var(--ac) 18%, transparent); }
.quote .qname { font-size: 11.5px; font-weight: 600; color: var(--ac); }
.quote .qbody { font-size: 12.5px; color: var(--text-2); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* link previews */
.previews { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; max-width: 100%; }
.msg.mine .previews { align-items: flex-end; }
.preview { display: flex; gap: 0; text-decoration: none; color: inherit; border-radius: 14px; overflow: hidden;
  background: var(--bubble-them); max-width: 360px; border-left: 3px solid var(--ac2); }
.preview:hover { filter: brightness(1.12); }
.preview img { width: 76px; height: 76px; object-fit: cover; flex: none; }
.preview .pv-body { padding: 8px 12px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.preview b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.preview small { font-size: 12px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.preview em { font-size: 11px; font-style: normal; color: var(--text-3); }

/* voice messages */
.voice { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border-radius: 18px;
  background: var(--bubble-them); color: var(--bubble-them-text); min-width: 210px; }
.msg.mine .voice { background: var(--bubble-me); color: var(--bubble-me-text); }
.vplay { border: 0; width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--ac); color: var(--ac-on); }
.msg.mine .vplay { background: rgba(0,0,0,.18); color: inherit; }
.wave { position: relative; flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; overflow: hidden; }
.wave i { width: 2.5px; border-radius: 2px; background: currentColor; opacity: .38; flex: none; }
.wave-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: currentColor; opacity: .3; border-radius: 3px; pointer-events: none; transition: width .15s linear; }
.vtime { font-size: 11.5px; opacity: .75; flex: none; }

/* reply bar + recorder above the composer */
.replybar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; margin: 0 0 6px 42px; border-radius: 12px;
  background: var(--hover-strong); border-left: 2.5px solid var(--ac); }
.replybar .rb-icon { color: var(--ac); line-height: 0; flex: none; }
.replybar .rb-text { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replybar .rb-text b { color: var(--text); margin-right: 8px; }
.replybar .rb-x { border: 0; background: none; color: var(--text-3); font-size: 17px; line-height: 1; padding: 0 4px; }
.recorder { display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin: 0 0 6px 42px; border-radius: 14px;
  background: var(--bubble-them); }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff3b30; animation: pulse 1.1s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .25; } }
.rec-time { font-size: 12.5px; font-weight: 600; flex: none; }
.rec-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; overflow: hidden; }
.rec-wave i { width: 2.5px; border-radius: 2px; background: var(--ac); flex: none; }
.rec-cancel, .rec-stop { border: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.rec-cancel { background: var(--hover-strong); color: var(--text-2); }
.rec-stop { background: var(--ac); color: var(--ac-on); }
.composer .tool.mic.hidden, .composer .tool.later.hidden { display: none; }

/* private command replies */
.sysnote { display: flex; gap: 10px; align-items: flex-start; margin: 8px 16px; padding: 10px 14px; border-radius: 14px;
  background: var(--hover); border: .5px dashed var(--line-strong); font-size: 13.5px; color: var(--text-2); }
.sysnote span { flex: 1; min-width: 0; white-space: pre-wrap; }
.sysnote button { border: 0; background: none; color: var(--text-3); font-size: 16px; line-height: 1; }

/* popover menus */
.menu-pop { width: 260px; padding: 6px; }
.menu-h { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 8px 10px 4px; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; border: 0; background: none;
  padding: 8px 10px; border-radius: 10px; font-size: 13.5px; text-align: left; color: var(--text); }
.menu-item:hover { background: var(--hover-strong); }
.menu-item.on { color: var(--ac); font-weight: 600; }
.menu-item small { color: var(--text-3); font-size: 11.5px; }
.menu-custom { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; font-size: 13px; color: var(--text-2); }
.menu-custom input { border: 0; background: var(--hover-strong); border-radius: 8px; padding: 5px 8px; color: var(--text); font-size: 12.5px; }

/* command palette */
.palette-backdrop { position: fixed; inset: 0; z-index: 75; background: var(--scrim); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; animation: fade .15s; }
.palette { width: 100%; max-width: 560px; border-radius: 18px; background: var(--raise); box-shadow: var(--shadow); overflow: hidden;
  -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%); animation: pop .18s cubic-bezier(.2,.9,.3,1.1); }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: .5px solid var(--line); color: var(--text-3); }
.pal-input input { flex: 1; border: 0; background: none; outline: none; font-size: 16px; color: var(--text); }
.pal-list { max-height: 48vh; overflow-y: auto; padding: 6px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 9px 12px; border-radius: 12px; text-align: left; }
.pal-item.on { background: var(--hover-strong); }
.pal-ico { width: 28px; text-align: center; color: var(--ac); line-height: 0; display: inline-grid; place-items: center; font-size: 15px; }
.pal-label { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-label small { display: block; font-size: 11.5px; color: var(--text-3); }
.pal-kind { font-size: 11px; color: var(--text-3); flex: none; }
.pal-foot { display: flex; gap: 16px; padding: 9px 18px; border-top: .5px solid var(--line); font-size: 11px; color: var(--text-3); }
kbd { font-family: var(--ui); font-size: 11px; padding: 2px 6px; border-radius: 5px; background: var(--hover-strong); color: var(--text-2);
  border-bottom: 1.5px solid var(--line-strong); margin-right: 2px; white-space: nowrap; }
.list-row kbd { font-size: 12px; }

/* status + quiet hours */
.status-row { display: flex; align-items: center; gap: 8px; }
.status-row .input { flex: 1; min-width: 0; }
.status-emo { width: 42px; height: 42px; border-radius: 50%; padding: 0; font-size: 20px; flex: none; }
.status-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-btn { border: 0; background: var(--hover-strong); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--text-2); }
.chip-btn:hover { color: var(--text); }
.statusline { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.localtime { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 11.5px; color: var(--text-3); margin-bottom: 14px; }
.side-item.muted .name { opacity: .6; }
.muted-ico { color: var(--text-3); line-height: 0; opacity: .7; }
.head-btn.muted { color: var(--text-3); }
.saved-flag { color: var(--ac2); display: inline-flex; align-items: center; gap: 3px; }

/* jump to unread */
.jump-unread { position: absolute; left: 50%; transform: translateX(-50%); bottom: 86px; z-index: 4; border: 0;
  background: var(--gold-grad); color: var(--on-gold); font-size: 12.5px; font-weight: 600; padding: 7px 16px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.35); animation: pop .2s ease; }

/* admin emoji grid */
.emoji-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ea-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--hover); }
.ea-item img { width: 24px; height: 24px; object-fit: contain; }
.ea-item code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.ea-item button { padding: 2px 9px; font-size: 15px; line-height: 1; }

@media (max-width: 860px) {
  .replybar, .recorder { margin-left: 0; }
  .typing { padding-left: 12px; }
  .palette-backdrop { padding-top: 6vh; }
  .jump-unread { bottom: 96px; }
  .preview { max-width: 100%; }
}

.list-row input[type="checkbox"] { accent-color: var(--ac); width: 18px; height: 18px; flex: none; margin: 0; }
.list-row .grow b { white-space: normal; }
.list-row .chev { color: var(--text-3); font-size: 18px; line-height: 1; }

/* Admin and other dense modals on a phone: stack the columns, scroll the tab strip */
@media (max-width: 860px) {
  /* a long URL or a wide <select> must never stretch the sheet past the screen */
  .modal { max-width: 100vw !important; overflow-x: hidden; }
  .modal-body { padding-left: 18px; padding-right: 18px; overflow-x: hidden; }
  .modal input, .modal select, .modal textarea { min-width: 0; max-width: 100%; }
  .row { flex-direction: column; gap: 0; }
  .row > * { flex: none; width: 100%; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; }
  .copy-box { flex-wrap: wrap; }
  .copy-box input { flex: 1 1 100%; }
  .list-row { flex-wrap: wrap; }
  .list-row .grow { flex: 1 1 60%; }
  .emoji-admin { grid-template-columns: 1fr 1fr; }
}

/* ---------- embedded mode (AngelChat inside AngelBoard or another ATA system) ---------- */
.shell.embed { grid-template-columns: 1fr; padding: 0; gap: 0; height: 100vh; height: 100dvh; }
.shell.embed .main { border-radius: 0; box-shadow: none; background: var(--pane); }
.shell.embed .messages { padding-top: 62px; }
.embed-head { min-height: 54px; grid-template-columns: 1fr auto; padding: 0 12px; }
.embed-head .chan-title { padding-left: 2px; }
.embed-head .chan-title .row1 { font-size: 14px; }
.embed-head .head-btn { font-size: 12px; padding: 5px 10px; border: .5px solid var(--line-strong); }
.shell.embed .stack { max-width: 84%; }
.shell.embed .msg { padding-left: 12px; padding-right: 16px; }
.shell.embed .composer-wrap { padding: 6px 10px 8px; }
.shell.embed .intro { padding: 32px 20px 14px; }
.shell.embed .intro .big-hash { width: 64px; height: 64px; font-size: 30px; }
.shell.embed .intro h2 { font-size: 19px; }
.embed-login { max-width: 320px; margin: auto; padding: 32px 20px; width: 100%; }
.embed-login .wordmark { justify-content: center; margin-bottom: 16px; }
.embed-login .lede { text-align: center; color: var(--text-2); font-size: 13.5px; margin: 0 0 20px; }
