/* Mesa — a quiet, dark, four-person room. */

:root {
  --bg-deep:      #16171b;
  --bg-rail:      #1b1c21;
  --bg-side:      #212329;
  --bg-main:      #292b33;
  --bg-raised:    #31343d;
  --bg-input:     #3a3d47;
  --bg-hover:     rgba(255, 255, 255, 0.045);

  --text:         #e6e8ee;
  --text-dim:     #a3a7b3;
  --text-faint:   #6f7480;

  --accent:       #6f7ff2;
  --accent-soft:  #8b96f5;
  --green:        #46b17b;
  --amber:        #d9a441;
  --red:          #dc5b5b;

  --line:         rgba(255, 255, 255, 0.07);
  --shadow:       rgba(0, 0, 0, 0.45);
  --sel-bg:       rgba(255, 255, 255, 0.09);
  --sel-text:     #ffffff;
  --on-bg:        #ffffff;
  --on-text:      #1a1a1a;
  --radius:       10px;
  --rail-w:       76px;
  --side-w:       248px;
  --members-w:    228px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "Cascadia Mono", "Fira Code", Consolas, monospace;
}

/* Midnight: true black, which an OLED panel simply switches off. */
html[data-theme="midnight"] {
  --bg-deep:   #000000;
  --bg-rail:   #060608;
  --bg-side:   #0a0a0d;
  --bg-main:   #0e0f13;
  --bg-raised: #16171c;
  --bg-input:  #1c1e24;
  --bg-hover:  rgba(255, 255, 255, 0.055);

  --text:      #e9ebf0;
  --text-dim:  #9aa0ad;
  --text-faint:#666c78;

  --accent:      #6b7bf0;
  --accent-soft: #8f99f7;

  --line:   rgba(255, 255, 255, 0.075);
  --shadow: rgba(0, 0, 0, 0.8);
  --sel-bg: rgba(255, 255, 255, 0.1);
}

html[data-theme="light"] {
  --bg-deep:   #e7e9ef;
  --bg-rail:   #dcdfe8;
  --bg-side:   #eef0f5;
  --bg-main:   #ffffff;
  --bg-raised: #f4f5f9;
  --bg-input:  #e9ebf1;
  --bg-hover:  rgba(0, 0, 0, 0.04);

  --text:      #1c1e24;
  --text-dim:  #565b66;
  --text-faint:#858b96;

  --accent:      #4b5bd6;
  --accent-soft: #3d4cc4;
  --green:       #2e8f5f;
  --amber:       #a97a19;
  --red:         #c33d3d;

  --line:     rgba(0, 0, 0, 0.1);
  --shadow:   rgba(20, 24, 40, 0.16);
  --sel-bg:   rgba(75, 91, 214, 0.13);
  --sel-text: #1c1e24;
  --on-bg:    #1c1e24;
  --on-text:  #ffffff;
}

/* The plain background must not win over the active and ghost states. */
html[data-theme="light"] .rail-btn:not(.active):not(.ghost-btn) { background: var(--bg-main); }
html[data-theme="light"] .msg:hover { background: rgba(0, 0, 0, 0.028); }
html[data-theme="light"] .tile { background: var(--bg-raised); }
html[data-theme="light"] .me-bar { background: rgba(0, 0, 0, 0.05); }
html[data-theme="light"] .toast,
html[data-theme="light"] .modal { box-shadow: 0 18px 44px var(--shadow); }
html[data-theme="light"] .signin-wrap {
  background:
    radial-gradient(900px 600px at 20% -10%, rgba(75, 91, 214, .12), transparent 60%),
    radial-gradient(700px 500px at 90% 110%, rgba(46, 143, 95, .09), transparent 60%),
    var(--bg-deep);
}
html[data-theme="light"] .nameplate { background: rgba(0, 0, 0, .6); color: #fff; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  transition: background-color .16s ease, color .16s ease;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); }

.muted  { color: var(--text-dim); }
.faint  { color: var(--text-faint); }
.row    { display: flex; align-items: center; }
.col    { display: flex; flex-direction: column; }
.gap    { gap: 10px; }
.gap-sm { gap: 6px; }
.end    { justify-content: flex-end; }
.between{ justify-content: space-between; }
.grow   { flex: 1; min-width: 0; }
.center { align-items: center; justify-content: center; }
.mono   { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------- buttons ---------- */

.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 550;
  cursor: pointer;
  transition: background .13s, transform .06s, opacity .13s;
}
.btn:hover  { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost  { background: transparent; color: var(--text-dim); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #e97070; }
.btn.wide   { width: 100%; }
.btn.small  { padding: 6px 12px; font-size: 13.5px; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 7px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  transition: background .12s, color .12s;
  font-size: 15px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.on    { color: var(--accent-soft); }
.icon-btn.danger-on { background: var(--red); color: #fff; }

/* ---------- inputs ---------- */

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 7px;
  font-weight: 650;
}
.input, textarea.input, select.input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .13s;
}
.input:focus { border-color: var(--accent); }
.input.mono { letter-spacing: .06em; }

/* ---------- sign in ---------- */

.signin-wrap {
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 600px at 20% -10%, rgba(111,127,242,.16), transparent 60%),
    radial-gradient(700px 500px at 90% 110%, rgba(70,177,123,.10), transparent 60%),
    var(--bg-deep);
  padding: 24px;
}
.signin {
  width: 100%;
  max-width: 420px;
  background: var(--bg-main);
  border-radius: 16px;
  padding: 34px 32px 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.signin h1 { margin: 0 0 4px; font-size: 25px; letter-spacing: -.02em; }
.signin .sub { margin: 0 0 26px; color: var(--text-dim); font-size: 14px; }
.signin .err {
  background: rgba(220,91,91,.12);
  border: 1px solid rgba(220,91,91,.35);
  color: #f0a5a5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13.5px;
}
.signin .note { margin-top: 18px; font-size: 12.5px; color: var(--text-faint); text-align: center; }

/* ---------- app frame ---------- */

.app { display: flex; height: 100%; min-height: 0; }
#root { height: 100%; }

.rail {
  width: var(--rail-w);
  background: var(--bg-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  flex-shrink: 0;
}
.rail-btn {
  width: 46px; height: 46px;
  border-radius: 15px;
  background: var(--bg-main);
  border: 0;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 18px;
  color: var(--text-dim);
  transition: border-radius .16s, background .16s, color .16s;
  position: relative;
}
.rail-btn:hover { border-radius: 12px; background: var(--accent); color: #fff; }
.rail-btn.active { border-radius: 12px; background: var(--accent); color: #fff; }
.rail-btn.active svg, .rail-btn:hover svg { color: #fff; }
.rail-sep { width: 32px; height: 1px; background: var(--line); margin: 4px 0; }

.side {
  width: var(--side-w);
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.side-head {
  height: 50px;
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  letter-spacing: -.01em;
  flex-shrink: 0;
}
.side-scroll { flex: 1; overflow-y: auto; padding: 12px 8px; }

.group-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700;
  padding: 14px 8px 5px;
}
.group-label > .icon-btn { opacity: 0; transition: opacity .12s; }
.group-label:hover > .icon-btn { opacity: 1; }
.group-toggle {
  display: flex; align-items: center; gap: 5px;
  background: none; border: 0; cursor: pointer; padding: 0;
  color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.group-toggle:hover { color: var(--text-dim); }
.group-toggle .caret { font-size: 9px; transition: transform .13s; display: inline-block; }
.group-toggle .caret.closed { transform: rotate(-90deg); }
.group-label .badge {
  background: var(--red); color: #fff; border-radius: 9px;
  font-size: 10px; padding: 0 5px; margin-left: 4px;
}

.chan {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14.5px;
  border: 0; background: transparent; width: 100%; text-align: left;
  position: relative;
}
.chan:hover { background: var(--bg-hover); color: var(--text); }
.chan.active { background: var(--sel-bg); color: var(--sel-text); }
.chan .sigil { color: var(--text-faint); font-size: 17px; width: 18px; text-align: center; flex-shrink: 0; }
.chan .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chan .badge {
  background: var(--red); color: #fff;
  border-radius: 10px; font-size: 11px; font-weight: 700;
  padding: 1px 6px; min-width: 18px; text-align: center;
}
.chan.unread { color: var(--sel-text); font-weight: 600; }

.voice-roster { padding: 2px 0 6px 30px; display: flex; flex-direction: column; gap: 3px; }
.voice-roster .who {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-dim);
  padding: 2px 6px; border-radius: 5px;
}
.voice-roster .who.speaking { color: var(--green); }
.voice-roster .who .mini-av { width: 20px; height: 20px; font-size: 9px; }

.me-bar {
  height: 56px;
  background: rgba(0,0,0,.22);
  display: flex; align-items: center; gap: 9px;
  padding: 0 10px;
  flex-shrink: 0;
}

/* ---------- avatars ---------- */

.av {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  user-select: none;
}
.av.lg { width: 42px; height: 42px; font-size: 15px; }
.av.mini-av { width: 24px; height: 24px; font-size: 10px; }
.av .dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 3px var(--bg-side);
}
.av .dot.on { background: var(--green); }
.av.ring { box-shadow: 0 0 0 2px var(--green); }

/* ---------- main ---------- */

.main { flex: 1; display: flex; flex-direction: column; background: var(--bg-main); min-width: 0; }

.topbar {
  height: 50px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  flex-shrink: 0;
}
.topbar .title { font-weight: 650; }
.topbar .topic {
  color: var(--text-dim); font-size: 13px;
  border-left: 1px solid var(--line); padding-left: 12px; margin-left: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.body-split { flex: 1; display: flex; min-height: 0; }

.stream {
  flex: 1;
  overflow-y: auto;
  padding: 18px 0 8px;
  display: flex; flex-direction: column;
  min-width: 0;
}
.stream-top { padding: 24px 20px 14px; }
.stream-top h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }

.day {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 20px 8px;
  color: var(--text-faint); font-size: 11.5px; font-weight: 650;
  letter-spacing: .04em; text-transform: uppercase;
}
.day::before, .day::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.msg {
  display: flex; gap: 13px;
  padding: 3px 20px;
  position: relative;
}
.msg:hover { background: rgba(0,0,0,.13); }
.msg.first { margin-top: 14px; }
.msg .gutter { width: 40px; flex-shrink: 0; display: flex; justify-content: center; }
.msg .stamp-hover {
  font-size: 10.5px; color: var(--text-faint);
  opacity: 0; align-self: flex-start; padding-top: 4px;
}
.msg:hover .stamp-hover { opacity: 1; }
.msg .content { flex: 1; min-width: 0; }
.msg .who { display: flex; align-items: baseline; gap: 9px; margin-bottom: 1px; }
.msg .who .name { font-weight: 650; }
.msg .who .when { font-size: 11.5px; color: var(--text-faint); }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .text .edited { font-size: 10.5px; color: var(--text-faint); margin-left: 5px; }
.msg.pending { opacity: .55; }
.msg.failed .text { color: var(--red); }
.msg.locked .text { color: var(--amber); font-style: italic; font-size: 13.5px; }

.msg-tools {
  position: absolute; top: -14px; right: 22px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  overflow: hidden;
}
.msg:hover .msg-tools { display: flex; }
.msg-tools .icon-btn { width: 30px; height: 28px; border-radius: 0; font-size: 13px; }

.reply-strip {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-dim);
  margin-bottom: 3px; padding-left: 2px;
}
.reply-strip .bar { width: 2px; height: 13px; background: var(--line); border-radius: 2px; }
.reply-strip .snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }

.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.reaction {
  background: var(--bg-raised); border: 1px solid transparent;
  border-radius: 8px; padding: 2px 8px; font-size: 13px;
  cursor: pointer; display: flex; gap: 5px; align-items: center;
}
.reaction:hover { border-color: var(--line); }
.reaction.mine { background: rgba(111,127,242,.2); border-color: var(--accent); }
.reaction .n { font-size: 11.5px; color: var(--text-dim); font-weight: 650; }

/* ---------- attachments ---------- */

.attachments { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 7px; }
.att-image {
  max-width: min(460px, 100%);
  border-radius: 9px;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--bg-deep);
  display: block;
}
.att-image img, .att-image video { display: block; max-width: 100%; height: auto; border-radius: 9px; }
.att-video { max-width: min(520px, 100%); border-radius: 9px; }
.att-video video { width: 100%; border-radius: 9px; background: #000; }

.att-card {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  min-width: 260px; max-width: 420px;
}
.att-card .glyph {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--bg-deep); display: grid; place-items: center; font-size: 16px;
  flex-shrink: 0;
}
.att-card .fname { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-card .fmeta { font-size: 11.5px; color: var(--text-faint); }

.progress { height: 3px; background: var(--bg-deep); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .18s; }

/* ---------- composer ---------- */

.composer-wrap { padding: 0 20px 22px; flex-shrink: 0; }
.composer {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 4px 6px 4px 8px;
  display: flex; align-items: flex-end; gap: 4px;
}
.composer textarea {
  flex: 1;
  background: transparent; border: 0; outline: none;
  resize: none;
  padding: 11px 6px;
  max-height: 45vh;
  line-height: 1.45;
}
.composer textarea::placeholder { color: var(--text-faint); }

.reply-banner, .upload-tray {
  background: var(--bg-raised);
  border-radius: 9px 9px 0 0;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid var(--bg-deep);
}
.upload-tray { flex-wrap: wrap; gap: 8px; }
.tray-chip {
  background: var(--bg-input); border-radius: 7px;
  padding: 5px 9px; font-size: 12.5px;
  display: flex; align-items: center; gap: 7px;
}

.typing-line { height: 18px; font-size: 12.5px; color: var(--text-dim); padding: 2px 4px 0; }

/* ---------- members ---------- */

.members {
  width: var(--members-w);
  transition: width .14s;
  background: var(--bg-side);
  padding: 16px 10px;
  overflow-y: auto;
  flex-shrink: 0;
}
.member {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 7px;
  cursor: pointer;
}
.member:hover { background: var(--bg-hover); }
.member .nm { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member.offline { opacity: .42; }
.members:empty { width: 0; padding: 0; overflow: hidden; }

/* ---------- voice stage ---------- */

.voice-stage {
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  flex-shrink: 0;
  max-height: 48vh;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 300px));
  justify-content: center;
  gap: 11px;
  overflow-y: auto;
  align-content: start;
}
.tile {
  background: var(--bg-side);
  border-radius: 11px;
  aspect-ratio: 16 / 10;
  position: relative;
  overflow: hidden;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px transparent;
  transition: box-shadow .1s;
}
.tile.speaking { box-shadow: inset 0 0 0 2px var(--green); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile .nameplate {
  position: absolute; left: 9px; bottom: 8px;
  background: rgba(0,0,0,.62);
  border-radius: 6px; padding: 3px 8px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 6px;
}
.tile.screen-tile { grid-column: 1 / -1; aspect-ratio: 16 / 9; max-width: 100%; }
.tiles:has(.screen-tile) { grid-template-columns: repeat(auto-fit, minmax(160px, 220px)); }
.tile .status-icons { position: absolute; right: 9px; top: 8px; display: flex; gap: 5px; }
.tile .status-icons span {
  background: rgba(0,0,0,.6); border-radius: 5px; padding: 2px 6px; font-size: 11px;
}

.voice-controls { display: flex; align-items: center; justify-content: center; gap: 9px; }
.vc-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--bg-raised); color: var(--text);
  display: grid; place-items: center; font-size: 16px;
  transition: background .12s, color .12s;
}
.vc-btn:hover { background: var(--bg-input); }
.vc-btn.on { background: var(--on-bg); color: var(--on-text); }
.vc-btn.hangup { background: var(--red); color: #fff; }
.vc-btn.hangup:hover { background: #e97070; }

.voice-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-dim);
}
.voice-status .lamp { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.voice-status .lamp.warn { background: var(--amber); }
.voice-status .lamp.bad { background: var(--red); }

/* ---------- drive ---------- */

.pane { flex: 1; overflow-y: auto; padding: 26px 30px; }
.pane h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.pane .lede { color: var(--text-dim); margin: 0 0 22px; font-size: 14px; }

.meter { background: var(--bg-deep); border-radius: 8px; height: 9px; overflow: hidden; margin: 10px 0 6px; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); }
.meter.high > i { background: linear-gradient(90deg, var(--amber), var(--red)); }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 13px; margin-top: 18px; }
.file-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.file-card .thumb {
  height: 118px; background: var(--bg-deep);
  display: grid; place-items: center; font-size: 30px; color: var(--text-faint);
  overflow: hidden;
}
.file-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-card .info { padding: 10px 11px; }
.file-card .nm { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .sz { font-size: 11.5px; color: var(--text-faint); }
.file-card .acts { display: flex; border-top: 1px solid var(--line); }
.file-card .acts button {
  flex: 1; border: 0; background: transparent; color: var(--text-dim);
  padding: 8px; cursor: pointer; font-size: 12.5px;
}
.file-card .acts button:hover { background: var(--bg-hover); color: var(--text); }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 34px;
  text-align: center;
  color: var(--text-dim);
  transition: border-color .13s, background .13s;
}
.dropzone.hot { border-color: var(--accent); background: rgba(111,127,242,.08); }

/* ---------- modal ---------- */

.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.62);
  display: grid; place-items: center;
  z-index: 60;
  padding: 24px;
  animation: fade .13s ease;
}
.modal {
  background: var(--bg-main);
  border-radius: 14px;
  width: 100%; max-width: 480px;
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  animation: pop .15s ease;
}
.modal-wide { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 12px;
}
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-body { padding: 4px 22px 22px; overflow-y: auto; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9);
  display: grid; place-items: center; z-index: 70; padding: 40px;
}
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox .close { position: absolute; top: 18px; right: 22px; font-size: 26px; }

/* ---------- toasts ---------- */

#toasts {
  position: fixed; right: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 9px;
  z-index: 80; max-width: 380px;
}
.toast {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 11px 15px;
  font-size: 13.5px;
  box-shadow: 0 8px 26px rgba(0,0,0,.4);
  animation: slide .18s ease;
}
.toast-error { border-left-color: var(--red); }
.toast-good  { border-left-color: var(--green); }
.toast-warn  { border-left-color: var(--amber); }
.toast.leaving { opacity: 0; transform: translateX(14px); transition: .24s; }
@keyframes slide { from { opacity: 0; transform: translateX(18px); } }

/* ---------- misc ---------- */

.code-inline {
  background: var(--bg-deep); border-radius: 4px;
  padding: 1px 5px; font-family: var(--mono); font-size: 13px;
}
.code-block {
  background: var(--bg-deep); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; margin: 6px 0;
}
.mention {
  background: rgba(111,127,242,.22); color: var(--accent-soft);
  border-radius: 4px; padding: 0 3px; cursor: pointer; font-weight: 550;
}
.mention:hover { background: var(--accent); color: #fff; }
.link { text-decoration: none; }
.link:hover { text-decoration: underline; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-raised); border-radius: 20px;
  padding: 3px 11px; font-size: 12px; color: var(--text-dim);
}

.fingerprint {
  font-family: var(--mono); font-size: 17px; letter-spacing: .1em;
  background: var(--bg-deep); border-radius: 8px; padding: 13px 15px;
  text-align: center; margin: 10px 0;
}

.callout {
  background: rgba(217,164,65,.1);
  border: 1px solid rgba(217,164,65,.3);
  border-radius: 9px; padding: 12px 14px;
  font-size: 13.5px; color: #e6c894;
  margin: 12px 0;
}
.callout.good { background: rgba(70,177,123,.1); border-color: rgba(70,177,123,.3); color: #9cd9ba; }

.empty { text-align: center; color: var(--text-faint); padding: 50px 20px; }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.conn-banner {
  background: var(--amber); color: #241c06;
  text-align: center; padding: 5px; font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}

/* ---------- narrow screens ---------- */

@media (max-width: 900px) {
  .members { display: none; }
}
@media (max-width: 680px) {
  :root { --rail-w: 60px; --side-w: 200px; }
  .side.mobile-hidden { display: none; }
  .msg { padding-left: 12px; padding-right: 12px; }
  .composer-wrap { padding: 0 12px 14px; }
}

/* ---------- svg icons ---------- */

svg { display: block; }
.btn svg, .chan svg, .icon-btn svg, .vc-btn svg, .rail-btn svg { pointer-events: none; }
.btn.row svg { margin-right: 2px; }
.chan .sigil svg { opacity: .75; }
.chan.active .sigil svg, .chan:hover .sigil svg { opacity: 1; }
.att-card .glyph svg, .file-card .thumb svg { color: var(--text-faint); }
.nameplate svg { opacity: .85; }
.voice-roster .who svg { opacity: .7; }

/* ---------- space rail ---------- */

.rail-btn.ghost-btn {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text-faint);
}
.rail-btn.ghost-btn:hover { background: var(--accent); color: #fff; box-shadow: none; }
.rail-badge {
  position: absolute; right: -3px; bottom: -3px;
  background: var(--red); color: #fff;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  padding: 1px 5px; min-width: 17px; text-align: center;
  box-shadow: 0 0 0 3px var(--bg-rail);
}
.space-badge.active { box-shadow: 0 0 0 2px var(--text); }

.space-title {
  display: flex; align-items: center; gap: 7px;
  background: none; border: 0; cursor: pointer; padding: 4px 6px;
  margin-left: -6px; border-radius: 7px;
  color: inherit; font: inherit; font-weight: 650;
  max-width: 165px; overflow: hidden;
}
.space-title:hover { background: var(--bg-hover); }
.space-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- translation ---------- */

.translated {
  margin-top: 3px;
  padding-left: 9px;
  border-left: 2px solid var(--accent);
  color: var(--text);
}
.translated .tag {
  font-size: 10.5px; color: var(--text-faint);
  letter-spacing: .04em; text-transform: uppercase;
  display: block; margin-bottom: 1px;
}
.original-hidden { display: none; }
.msg .show-original {
  font-size: 11px; color: var(--text-faint);
  background: none; border: 0; cursor: pointer; padding: 2px 0;
}
.msg .show-original:hover { color: var(--text-dim); text-decoration: underline; }

/* ---------- video quality ---------- */

.tile.hd video { object-fit: contain; background: #000; }
.quality-pill {
  position: absolute; left: 9px; top: 8px;
  background: rgba(0,0,0,.6); border-radius: 5px;
  padding: 1px 6px; font-size: 10.5px; letter-spacing: .04em;
}

/* Light theme needs a little more separation than dark does. */
html[data-theme="light"] .side,
html[data-theme="light"] .members { border-right: 1px solid var(--line); }
html[data-theme="light"] .members { border-right: 0; border-left: 1px solid var(--line); }
html[data-theme="light"] .rail { border-right: 1px solid var(--line); }
html[data-theme="light"] .composer { box-shadow: inset 0 0 0 1px var(--line); }
html[data-theme="light"] .code-block,
html[data-theme="light"] .code-inline { background: rgba(0, 0, 0, .05); }
html[data-theme="light"] .fingerprint { background: rgba(0, 0, 0, .05); }
html[data-theme="light"] .msg-tools { box-shadow: 0 3px 12px var(--shadow); }
html[data-theme="light"] .av .dot { box-shadow: 0 0 0 3px var(--bg-side); }

/* ---------- denied features ---------- */

.vc-btn.denied,
.chan.denied {
  opacity: .38;
  cursor: not-allowed;
}
.vc-btn.denied:hover { background: var(--bg-raised); }
.chan.denied:hover { background: transparent; color: var(--text-dim); }

.perm-grid {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 6px 14px;
  align-items: center;
  font-size: 13.5px;
}
.perm-grid .head {
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; text-align: center;
}
.perm-grid select {
  background: var(--bg-deep); border: 1px solid transparent;
  border-radius: 6px; padding: 3px 6px; font-size: 12px; color: inherit;
}
.perm-note {
  font-size: 11.5px; color: var(--text-faint);
  margin-top: 10px; line-height: 1.45;
}

/* ---------- writing rooms ---------- */

.writing-pane { max-width: 1100px; }

.piece-list { display: flex; flex-direction: column; gap: 10px; }

.piece-card {
  display: block; width: 100%; text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 15px 17px;
  cursor: pointer;
  color: inherit; font: inherit;
  transition: border-color .12s, transform .06s;
}
.piece-card:hover { border-color: var(--accent); }
.piece-card:active { transform: translateY(1px); }
.piece-card.draft { border-style: dashed; }
.piece-title { font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; margin-bottom: 3px; }
.piece-excerpt {
  color: var(--text-dim); font-size: 13.5px; line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.piece-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12px; }

.piece-title-input {
  width: 100%; background: transparent; border: 0; outline: none;
  font-size: 27px; font-weight: 700; letter-spacing: -.02em;
  padding: 6px 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.piece-title-input::placeholder { color: var(--text-faint); }

.piece-body-input {
  width: 100%; min-height: 58vh;
  background: transparent; border: 0; outline: none; resize: vertical;
  font-size: 16.5px; line-height: 1.75;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  padding: 10px 0;
}
.piece-body-input::placeholder { color: var(--text-faint); font-family: var(--font); font-size: 15px; }

.piece-read { max-width: 68ch; }
.piece-read h1 { font-size: 30px; letter-spacing: -.025em; margin: 0 0 10px; line-height: 1.2; }
.piece-byline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-dim);
  padding-bottom: 16px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.piece-para {
  position: relative;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 17px; line-height: 1.78;
  margin: 0 0 1.15em;
  padding: 2px 34px 2px 0;
  border-radius: 5px;
}
.piece-para:hover { background: var(--bg-hover); }
.piece-para.flash { background: rgba(111,127,242,.18); transition: background .5s; }
.para-note {
  position: absolute; right: 2px; top: 4px;
  opacity: 0; transition: opacity .12s;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 6px; width: 24px; height: 24px;
  display: grid; place-items: center;
  cursor: pointer; color: var(--text-dim);
}
.piece-para:hover .para-note { opacity: 1; }
.para-note:hover { color: var(--text); border-color: var(--accent); }

.critique { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.note {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
}
.note.resolved { opacity: .55; }
.note.resolved .note-body { text-decoration: line-through; text-decoration-color: var(--text-faint); }
.note-body { font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
