/*
 * Exosys Collaboration Platform — lightweight Discord-like theme.
 * Hand-rolled (no framework) to stay small and fast; palette follows the
 * Exosys dark identity with a light-text-on-dark chat surface.
 */

:root {
  --bg-0: #17191d;          /* deepest: rail */
  --bg-1: #1e2126;          /* stream background */
  --bg-2: #26292f;          /* cards / composer */
  --bg-3: #2e3238;          /* hover */
  --text-0: #e8eaed;
  --text-1: #b3b8bf;
  --text-2: #7d838c;
  --accent: #2f9e77;        /* exosys green */
  --accent-soft: rgba(47, 158, 119, .18);
  --danger: #e5484d;
  --danger-text: #ff9599;
  --border: #2a2e35;
  --border-2: #333842;
  --border-3: #3a4049;
  --bg-4: #383d45;
  --hover-row: rgba(255, 255, 255, .025);
  --link: #6ab8ff;
  --dot-off: #4a5058;
  --dot-away: #d9a441;      /* declared away / custom status */
  --dot-dnd: #e5484d;       /* do not disturb */
  --dot-custom: #9a7bff;    /* custom status */
  --login-glow: #22303c;
  --shadow: rgba(0, 0, 0, .45);
  --radius: 8px;
  --rail-w: 260px;
}

/* ── day mode ─────────────────────────────────────────────────────────────
   Toggled by theme.js (persisted in localStorage); dark stays the default. */
html[data-theme="light"] {
  --bg-0: #eef0f2;          /* rail */
  --bg-1: #ffffff;          /* stream */
  --bg-2: #f6f7f8;          /* cards / composer */
  --bg-3: #e7e9ec;          /* hover */
  --bg-4: #dde0e4;
  --text-0: #1f2328;
  --text-1: #4b5158;
  --text-2: #71787f;
  --accent-soft: rgba(47, 158, 119, .14);
  --danger-text: #c62a30;
  --border: #d9dce0;
  --border-2: #d2d6db;
  --border-3: #c6cbd1;
  --hover-row: rgba(0, 0, 0, .035);
  --link: #0b6bcb;
  --dot-off: #b9bec4;
  --dot-away: #b8860b;
  --dot-dnd: #c62a30;
  --dot-custom: #6d4fd1;
  --login-glow: #dbe6ee;
  --shadow: rgba(30, 40, 50, .18);
}

* { box-sizing: border-box; }
/* every display: rule below would otherwise beat the [hidden] attribute —
   make hiding authoritative once, instead of per-component */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg-1);
  color: var(--text-0);
}

/* ── login ─────────────────────────────────────────────────────────────── */
.login-page {
  display: grid; place-items: center;
  background: radial-gradient(80rem 40rem at 70% -10%, var(--login-glow) 0%, var(--bg-0) 60%);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 2rem 2.2rem 2.2rem;
  box-shadow: 0 1rem 3rem var(--shadow);
}
.brand { font-size: 1.5rem; letter-spacing: .12em; margin: 0 0 .4rem; }
.brand span, .brand-mini span { color: var(--accent); font-weight: 400; }
.login-hint { color: var(--text-1); font-size: .9rem; margin: 0 0 1.2rem; }
.login-card label { display: block; font-size: .8rem; color: var(--text-1);
  margin: .9rem 0 .25rem; text-transform: uppercase; letter-spacing: .05em; }
.login-card input {
  width: 100%; padding: .6rem .75rem; border-radius: var(--radius);
  border: 1px solid var(--border-3); background: var(--bg-0); color: var(--text-0);
  font-size: .95rem;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn-primary {
  margin-top: 1.3rem; width: 100%; padding: .65rem 1rem; border: 0;
  border-radius: var(--radius); background: var(--accent); color: #fff;
  font-weight: 600; font-size: .95rem; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }
.flash { padding: .55rem .8rem; border-radius: var(--radius);
  font-size: .88rem; margin-bottom: .8rem; }
.flash-danger { background: rgba(229, 72, 77, .15); color: var(--danger-text);
  border: 1px solid rgba(229, 72, 77, .4); }
.field-error { color: var(--danger-text); font-size: .8rem; margin-top: .2rem; }

/* ── chat layout ───────────────────────────────────────────────────────── */
.chat-page { display: flex; flex-direction: column; height: 100vh;
  overflow: hidden; }
.chat-shell { display: flex; flex: 1; min-height: 0; }

/* thin app footer: copyright + version (same format as the other apps) */
.app-footer { display: flex; align-items: center; gap: 1rem;
  padding: .28rem 1rem; background: var(--bg-0);
  border-top: 1px solid var(--border); font-size: .72rem; color: var(--text-2); }
.app-footer a { color: var(--text-2); text-decoration: none; }
.app-footer a:hover { color: var(--text-1); text-decoration: underline; }
.app-footer .app-version { margin-left: auto; font-variant-numeric: tabular-nums; }
/* login page variant: pinned to the viewport bottom */
.app-footer-floating { position: fixed; left: 0; right: 0; bottom: 0; }

.rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  background: var(--bg-0); display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
}
/* the rail header and the channel header sit side by side, so their bottom
   borders must be one continuous line: fix the height rather than hoping two
   different font sizes happen to add up the same */
.rail-head { display: flex; align-items: center; height: 52px;
  padding: 0 1rem; border-bottom: 1px solid var(--border); }
.brand-mini { font-weight: 700; letter-spacing: .1em; font-size: .95rem; }
.server-name { padding: .8rem 1rem .3rem; font-weight: 700; }
.channel-list { flex: 1; overflow-y: auto; padding: .35rem .5rem; }
.channel-item {
  display: flex; align-items: center; gap: .45rem; width: 100%;
  padding: .42rem .6rem; margin: .1rem 0; border: 0; border-radius: 6px;
  background: none; color: var(--text-1); font-size: .95rem; cursor: pointer;
  text-align: left;
}
.channel-item .hash { color: var(--text-2); }
.channel-item:hover { background: var(--bg-3); color: var(--text-0); }
.channel-item.active { background: var(--accent-soft); color: var(--text-0); }
.channel-item .unread {
  margin-left: auto; min-width: 1.25rem; text-align: center;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: .7rem; padding: .05rem .3rem;
}
/* who you are on one row, the controls on another, separated by a rule —
   the single row was too crowded to read a name in */
.rail-foot { display: flex; flex-direction: column; gap: .5rem;
  padding: .6rem .75rem .7rem; border-top: 1px solid var(--border); }
.me-row { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-name { font-size: .85rem; color: var(--text-0); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.me-status { font-size: .72rem; color: var(--text-2); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.me-status.away { color: var(--dot-away); }
.me-status.dnd { color: var(--dot-dnd); }
.me-status.custom { color: var(--dot-custom); }
#statusBtn.away { color: var(--dot-away); border-color: var(--dot-away); }
#statusBtn.dnd { color: var(--dot-dnd); border-color: var(--dot-dnd); }
#statusBtn.custom { color: var(--dot-custom); border-color: var(--dot-custom); }
.rail-actions { display: flex; align-items: center; gap: .4rem;
  padding-top: .5rem; border-top: 1px solid var(--border); }
.avatar-sm { width: 30px; height: 30px; flex: 0 0 30px; font-size: .72rem; }
.logout-form { margin: 0; }
.btn-ghost { background: none; border: 1px solid var(--border-3); color: var(--text-1);
  border-radius: 6px; padding: .3rem .6rem; font-size: .8rem; cursor: pointer; }
.btn-ghost:hover { color: var(--text-0); border-color: var(--text-2); }

/* ── stream ────────────────────────────────────────────────────────────── */
.stream-pane { flex: 1; display: flex; flex-direction: column; min-width: 0;
  position: relative; }
.channel-head { display: flex; align-items: center; gap: .4rem;
  height: 52px; padding: 0 1.2rem; border-bottom: 1px solid var(--border);
  font-weight: 700; flex: 0 0 auto; }
.channel-head .hash { color: var(--text-2); font-weight: 400; }
.channel-topic { margin-left: .8rem; font-weight: 400; font-size: .85rem;
  color: var(--text-2); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
/* the connection lamp: the ring is the housing, the core is the light. It
   lifts slightly under the pointer so it reads as something to hover. */
.conn { margin-left: auto; display: inline-flex; align-items: center;
  color: var(--danger); opacity: .8; transition: opacity .12s ease; }
.conn svg circle:last-child { fill: currentColor; }
.conn svg circle:first-child { opacity: .45; }
.conn:hover, .conn:focus-visible { opacity: 1; outline: none; }
.conn:hover svg circle:first-child { opacity: .9; }
.conn.on { color: var(--accent); }

.stream { flex: 1; overflow-y: auto; padding: .8rem 1.2rem; }
.backfill { text-align: center; padding: .4rem 0; }
.messages { list-style: none; margin: 0; padding: 0; }
.msg { display: flex; gap: .75rem; padding: .28rem .4rem; border-radius: 6px; }
.msg:hover { background: var(--hover-row); }
.msg.first-of-group { margin-top: .65rem; }
.avatar {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
  color: #fff; user-select: none;
}
.avatar.staff { background: var(--accent); }
.avatar.customer { background: #4f6df5; }
.avatar.spacer { visibility: hidden; height: 0; }
.msg-body { min-width: 0; flex: 1; }
.msg-meta { display: flex; align-items: baseline; gap: .5rem; }
.msg-author { font-weight: 600; font-size: .95rem; }
.msg-author.staff { color: var(--accent); }
.msg-time { font-size: .72rem; color: var(--text-2); }
.staff-badge { font-size: .62rem; background: var(--accent); color: #fff;
  padding: .05rem .3rem; border-radius: 4px; letter-spacing: .04em; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--text-0); }
.msg-text a { color: var(--link); }
.msg.pending { opacity: .55; }

/* attachments */
.attachment-image { display: block; max-width: min(420px, 90%);
  max-height: 320px; border-radius: 8px; margin-top: .35rem; }
.attachment-card { display: inline-flex; align-items: center; gap: .6rem;
  margin-top: .35rem; padding: .5rem .8rem; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 8px; color: var(--text-0);
  text-decoration: none; font-size: .9rem; max-width: 90%; }
.attachment-card:hover { border-color: var(--accent); }
.attachment-card .icon { font-size: 1.25rem; }
.attachment-card .meta { min-width: 0; }
.attachment-card .name { display: block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.attachment-card .size { color: var(--text-2); font-size: .75rem; }

/* typing + composer */
.typing { min-height: 1.3rem; padding: 0 1.2rem; font-size: .78rem;
  color: var(--text-2); font-style: italic; }
.composer { padding: 0 1.2rem 1rem; }
.pending-uploads { display: flex; flex-wrap: wrap; gap: .5rem; }
.pending-chip { display: inline-flex; align-items: center; gap: .45rem;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 8px;
  padding: .35rem .6rem; font-size: .8rem; margin-bottom: .45rem; }
.pending-chip progress { width: 90px; height: 6px; }
.pending-chip .remove { cursor: pointer; color: var(--text-2); border: 0;
  background: none; font-size: .9rem; }
.composer-row { display: flex; align-items: flex-end; gap: .6rem;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 10px; padding: .45rem .6rem; }
.attach-btn { display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--bg-3); color: var(--text-1);
  font-size: 1.15rem; cursor: pointer; user-select: none; }
.attach-btn:hover { color: var(--text-0); background: var(--bg-4); }
#composerInput { flex: 1; resize: none; border: 0; background: none;
  color: var(--text-0); font: inherit; outline: none; max-height: 10rem; }
.composer .btn-primary { margin: 0; width: auto; padding: .45rem 1rem; }

/* drop overlay */
.drop-overlay { position: absolute; inset: 0; z-index: 30;
  background: rgba(23, 25, 29, .82); display: grid; place-items: center; }
.drop-overlay-inner { border: 3px dashed var(--accent); border-radius: 16px;
  padding: 3rem 5rem; font-size: 1.3rem; color: var(--accent); }

/* member rail */
.member-rail { width: 248px; flex: 0 0 248px; background: var(--bg-0);
  border-left: 1px solid var(--border); overflow-y: auto; }
.member-rail-head { padding: .85rem 1rem .4rem; font-size: .72rem;
  color: var(--text-2); text-transform: uppercase; letter-spacing: .08em; }
.member { display: flex; align-items: center; gap: .55rem;
  padding: .35rem 1rem; color: var(--text-1); font-size: .9rem; }
.member .dot { width: 9px; height: 9px; border-radius: 50%;
  background: var(--dot-off); flex: 0 0 9px; }
.member.online { color: var(--text-0); }
.member.online .dot { background: var(--accent); }
/* a declared away/custom state tints the dot amber — presence still decides
   whether it is lit at all */
.member.online.away .dot { background: var(--dot-away); }
.member.online.dnd .dot { background: var(--dot-dnd); }
.member.online.custom .dot { background: var(--dot-custom); }
/* the badge never shrinks and never wraps: it is the name that gives way,
   with the full one kept in the row's tooltip */
.member .tag { margin-left: auto; flex: 0 0 auto; font-size: .6rem;
  color: var(--accent); border: 1px solid var(--accent-soft);
  background: var(--accent-soft); border-radius: 4px; padding: .02rem .28rem;
  white-space: nowrap; }
.member { cursor: default; }
.member .member-name { flex: 0 1 auto; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
/* the declared state is the dot's colour and its tooltip — the roster stays
   one line per member (design memo §2.3) */
.member .dot { cursor: default; }
.member:hover { background: var(--bg-2); }
@media (max-width: 980px) { .member-rail { display: none; } }

/* ── public profile modal ─────────────────────────────────────────────── */
.profile-box { width: min(420px, 94vw); }
.profile-body { display: flex; gap: 1rem; padding: 1.1rem; align-items: start; }
.profile-text { min-width: 0; }
.profile-status { margin: 0 0 .2rem; color: var(--text-0); font-size: .95rem; }
.profile-presence { margin: 0 0 .6rem; font-size: .75rem; color: var(--text-2); }
.profile-bio { margin: 0; color: var(--text-1); font-size: .88rem;
  white-space: pre-wrap; word-break: break-word; }

/* labelled text fields in the settings modal */
.field { display: block; margin-bottom: .7rem; }
.field > span { display: block; font-size: .78rem; color: var(--text-2);
  margin-bottom: .25rem; }
.field input, .field textarea { width: 100%; background: var(--bg-1);
  border: 1px solid var(--border-2); border-radius: 8px; color: var(--text-0);
  padding: .45rem .6rem; font: inherit; font-size: .88rem; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none;
  border-color: var(--accent); }

/* link preview card */
.link-preview { display: flex; gap: .7rem; margin-top: .4rem;
  max-width: min(480px, 92%); background: var(--bg-2);
  border-left: 3px solid var(--accent); border-radius: 6px;
  padding: .55rem .75rem; }
.link-preview .lp-text { min-width: 0; }
.link-preview .lp-title { display: block; font-weight: 600; font-size: .9rem;
  color: var(--link); text-decoration: none; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.link-preview .lp-title:hover { text-decoration: underline; }
.link-preview .lp-desc { margin: .15rem 0 0; font-size: .8rem;
  color: var(--text-1); display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.link-preview .lp-img { width: 70px; height: 70px; object-fit: cover;
  border-radius: 6px; flex: 0 0 70px; margin-left: auto; }

/* inline video */
.attachment-video { display: block; max-width: min(480px, 92%);
  max-height: 340px; border-radius: 8px; margin-top: .35rem;
  background: #000; }

/* day separators */
.day-sep { display: flex; align-items: center; gap: .8rem;
  color: var(--text-2); font-size: .72rem; margin: .9rem 0 .3rem; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px;
  background: var(--border); }

@media (max-width: 720px) {
  :root { --rail-w: 200px; }
  .attachment-image { max-width: 100%; }
}

/* AV-blocked attachment */
.attachment-blocked { border-color: var(--danger) !important;
  color: var(--danger-text) !important; cursor: not-allowed; }

/* theme toggle placement on the login page */
.theme-corner { position: fixed; top: 1rem; right: 1rem; }

/* message actions (edit / delete) — revealed on hover */
.msg-actions { margin-left: auto; display: flex; gap: .4rem; opacity: 0;
  transition: opacity .12s ease; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-action { background: none; border: 0; padding: 0; cursor: pointer;
  font-size: .7rem; color: var(--text-2); text-transform: uppercase;
  letter-spacing: .04em; }
.msg-action:hover { color: var(--text-0); text-decoration: underline; }
.msg-removed { color: var(--text-2); font-style: italic; }

/* ── settings modal ───────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .55); display: flex; align-items: center;
  justify-content: center; padding: 1rem; }
.modal-box { width: min(460px, 96vw); background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 12px;
  box-shadow: 0 1rem 3rem var(--shadow); max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-section { padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); }
.modal-section h3 { margin: 0 0 .7rem; font-size: .74rem; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .07em; }
.modal-foot { display: flex; align-items: center; gap: .8rem;
  padding: .9rem 1.1rem; }
.modal-foot .btn-primary { margin: 0; width: auto; padding: .45rem 1.1rem;
  margin-left: auto; }
.avatar-row { display: flex; align-items: center; gap: 1rem; }
.avatar-lg { width: 64px; height: 64px; flex: 0 0 64px; font-size: 1.3rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover;
  border-radius: 50%; }
.hint { margin: .35rem 0 0; font-size: .75rem; color: var(--text-2); }
.switch-row { display: flex; align-items: center; gap: .55rem;
  padding: .3rem 0; font-size: .9rem; cursor: pointer; }
.switch-row input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── emoji picker ─────────────────────────────────────────────────────── */
.emoji-btn { width: 30px; height: 30px; flex: 0 0 30px; border: 0;
  border-radius: 50%; background: var(--bg-3); color: var(--text-1);
  font-size: 1.05rem; cursor: pointer; line-height: 1; }
.emoji-btn:hover { color: var(--text-0); background: var(--bg-4); }
.composer { position: relative; }
.emoji-panel { position: absolute; bottom: 100%; right: 1.2rem;
  width: min(340px, calc(100vw - 2rem)); margin-bottom: .5rem; z-index: 40;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 10px; box-shadow: 0 .75rem 2rem var(--shadow);
  padding: .5rem; }
.emoji-tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border);
  padding-bottom: .4rem; margin-bottom: .4rem; }
.emoji-tab { flex: 1; border: 0; background: none; cursor: pointer;
  font-size: 1.05rem; padding: .25rem 0; border-radius: 6px; line-height: 1; }
.emoji-tab:hover { background: var(--bg-3); }
.emoji-tab.active { background: var(--accent-soft); }
.emoji-search { width: 100%; padding: .35rem .55rem; margin-bottom: .4rem;
  border: 1px solid var(--border-3); border-radius: 6px;
  background: var(--bg-0); color: var(--text-0); font-size: .85rem; }
.emoji-search:focus { outline: 2px solid var(--accent); border-color: transparent; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr);
  gap: .1rem; max-height: 240px; overflow-y: auto; }
.emoji-item { border: 0; background: none; cursor: pointer; line-height: 1;
  font-size: 1.25rem; padding: .25rem 0; border-radius: 6px; }
.emoji-item:hover { background: var(--bg-3); transform: scale(1.15); }
.emoji-empty { grid-column: 1 / -1; margin: .6rem 0; text-align: center;
  color: var(--text-2); font-size: .8rem; }

/* ── left-rail workspace nav (Slack-style) ────────────────────────────── */
.rail-nav { padding: .25rem .5rem .5rem; border-bottom: 1px solid var(--border);
  margin-bottom: .35rem; }
.rail-nav-item { display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .4rem .6rem; border: 0; border-radius: 6px; background: none;
  color: var(--text-1); font-size: .9rem; cursor: pointer; text-align: left; }
.rail-nav-item:hover { background: var(--bg-3); color: var(--text-0); }
.rail-nav-icon { font-size: .95rem; }
.rail-nav-count { margin-left: auto; font-size: .7rem; color: var(--text-2); }

/* ── item context menu ────────────────────────────────────────────────── */
.item-menu { position: fixed; z-index: 60; min-width: 170px; padding: .3rem;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 8px; box-shadow: 0 .6rem 1.6rem var(--shadow); }
.item-menu button { display: flex; align-items: center; gap: .55rem;
  width: 100%; padding: .4rem .6rem; border: 0; border-radius: 6px;
  background: none; color: var(--text-0); font-size: .85rem; cursor: pointer;
  text-align: left; }
.item-menu button:hover { background: var(--bg-3); }
.item-menu button.danger { color: var(--danger-text); }
.item-menu .menu-sep { height: 1px; margin: .25rem .2rem;
  background: var(--border); }

/* ── saved items / files list ─────────────────────────────────────────── */
.list-body { padding: .5rem .6rem 1rem; max-height: 60vh; overflow-y: auto; }
.list-item { display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .5rem .6rem; border: 0; border-radius: 8px; background: none;
  color: var(--text-0); text-align: left; cursor: pointer; }
.list-item:hover { background: var(--bg-3); }
.list-item .li-icon { font-size: 1.1rem; }
.list-item .li-main { min-width: 0; flex: 1; }
.list-item .li-preview { display: block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.list-item .li-meta { font-size: .72rem; color: var(--text-2); }
.list-empty { padding: 1.5rem .6rem; text-align: center; color: var(--text-2);
  font-size: .85rem; }
.msg.bookmarked .msg-body { border-left: 2px solid var(--accent);
  padding-left: .5rem; margin-left: -.5rem; }

/* ── icons ────────────────────────────────────────────────────────────── */
.icon { display: block; flex: 0 0 auto; }
.btn-ghost, .rail-nav-item, .item-menu button, .attach-btn, .emoji-btn,
.drive-toolbar > * { display: inline-flex; align-items: center; gap: .4rem; }
.attach-btn, .emoji-btn { justify-content: center; }

/* ── #files workspace ─────────────────────────────────────────────────── */
.drive-pane { flex: 1; display: flex; flex-direction: column; min-width: 0;
  position: relative; }
.breadcrumb { display: flex; align-items: center; gap: .3rem; flex: 1;
  font-weight: 400; font-size: .9rem; overflow: hidden; }
.breadcrumb button { border: 0; background: none; color: var(--text-1);
  cursor: pointer; font-size: .9rem; padding: .1rem .2rem; border-radius: 4px; }
.breadcrumb button:hover { color: var(--text-0); background: var(--bg-3); }
.breadcrumb .sep { color: var(--text-2); }
.breadcrumb .current { color: var(--text-0); font-weight: 600; }
.drive-quota { font-size: .72rem; color: var(--text-2); white-space: nowrap; }

.drive-toolbar { display: flex; gap: .5rem; padding: .6rem 1.2rem;
  border-bottom: 1px solid var(--border); }
.drive-body { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; }
.drive-grid { display: grid; gap: .6rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.drive-card { display: flex; flex-direction: column; align-items: center;
  gap: .5rem; padding: .9rem .6rem; border: 1px solid var(--border-2);
  border-radius: 10px; background: var(--bg-2); cursor: pointer;
  text-align: center; color: var(--text-0); position: relative; }
.drive-card:hover { border-color: var(--accent); }
.drive-card .card-icon { color: var(--text-1); }
.drive-card.folder .card-icon { color: var(--accent); }
/* a saved item is marked in the grid itself, not only in the menu */
.drive-card .card-icon.saved { color: var(--accent); }
.drive-card.is-saved { border-color: var(--accent-soft); }
.drive-card .card-name { font-size: .85rem; width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.drive-card .card-meta { font-size: .7rem; color: var(--text-2); }
.drive-card .card-thumb { width: 100%; height: 76px; object-fit: cover;
  border-radius: 6px; }
.drive-card .card-del { position: absolute; top: .25rem; right: .25rem;
  border: 0; background: none; color: var(--text-2); cursor: pointer;
  opacity: 0; padding: .15rem; border-radius: 4px; }
.drive-card:hover .card-del { opacity: 1; }
.drive-card .card-del:hover { color: var(--danger-text); background: var(--bg-3); }
/* the date column only exists in list view */
.drive-card .card-when { font-size: .7rem; color: var(--text-2); display: none; }

/* thumbnail size — three steps, one variable. A slider would imply
   arbitrary sizes and per-request resizing; the stored thumbnail is one size
   and these only decide how much of the grid it fills. */
.drive-grid.thumb-s { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.drive-grid.thumb-s .card-thumb { height: 58px; }
.drive-grid.thumb-m { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.drive-grid.thumb-l { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.drive-grid.thumb-l .card-thumb { height: 128px; }

/* ── list view: the same cards, laid out as rows ──────────────────────── */
/* one column template shared by the header and every row, so they line up.
   Deliberately not `subgrid` — it is too new to rely on here. */
.drive-head, .drive-grid.list .drive-card {
  display: grid; grid-template-columns: 26px 1fr 7rem 8rem;
  align-items: center; gap: .5rem; }
.drive-head { padding: 0 .6rem .35rem;
  border-bottom: 1px solid var(--border); margin-bottom: .35rem; }
.drive-head .col-head { border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .72rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-2); text-align: left;
  display: inline-flex; align-items: center; gap: .25rem; padding: .2rem 0; }
.drive-head .col-head.active { color: var(--text-0); }
.drive-head .col-head[aria-sort="descending"] svg { transform: scaleY(-1); }
.drive-grid.list { display: flex; flex-direction: column; gap: 0; }
.drive-grid.list .drive-card { text-align: left; padding: .4rem .6rem;
  border: 0; border-bottom: 1px solid var(--border-2); border-radius: 6px;
  background: none; }
.drive-grid.list .drive-card:hover { background: var(--bg-2); }
.drive-grid.list .card-icon { display: inline-flex; }
.drive-grid.list .card-icon svg { width: 20px; height: 20px; }
.drive-grid.list .card-thumb { width: 26px; height: 26px; object-fit: cover; }
.drive-grid.list .card-name { padding: 0; }
.drive-grid.list .card-when { display: block; }
.drive-grid.list .card-del { top: 50%; transform: translateY(-50%); }
.drive-grid.list .drive-empty { padding: 2rem 1rem; }

/* segmented control (thumbnail size) */
.drive-tools { margin-left: auto; display: inline-flex; gap: .4rem;
  align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border-2);
  border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; color: var(--text-2);
  cursor: pointer; font: inherit; font-size: .72rem; padding: .25rem .5rem; }
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button.active { background: var(--bg-3); color: var(--text-0); }

.drive-empty { padding: 3rem 1rem; text-align: center; color: var(--text-2); }
.drive-uploads { display: flex; flex-direction: column; gap: .35rem;
  margin-bottom: .8rem; }

/* ── file viewer ──────────────────────────────────────────────────────── */
.viewer-box { width: min(900px, 96vw); max-height: 92vh; display: flex;
  flex-direction: column; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 12px;
  box-shadow: 0 1rem 3rem var(--shadow); }
.viewer-actions { display: flex; align-items: center; gap: .4rem; }
.viewer-body { padding: 1rem; overflow: auto; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 70vh;
  display: block; margin: 0 auto; border-radius: 8px; }
.viewer-body pre { margin: 0; padding: .8rem; background: var(--bg-0);
  border-radius: 8px; font-size: .82rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-0); }
.viewer-note { color: var(--text-2); font-size: .85rem; text-align: center;
  padding: 1.5rem; }

/* left-click selection (the actions live on the right button) */
.msg.selected { background: var(--accent-soft); }
.drive-card.selected { border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset; }

/* breadcrumb items stay on one line, icon beside the label */
.breadcrumb button, .breadcrumb .current, .breadcrumb .sep {
  display: inline-flex; align-items: center; gap: .35rem;
  white-space: nowrap; }

/* ── saved items pane ─────────────────────────────────────────────────── */
.saved-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pane-title { display: inline-flex; align-items: center; gap: .45rem;
  flex: 1; font-weight: 700; }
.pane-search { flex: 1; min-width: 8rem; padding: .35rem .6rem;
  border: 1px solid var(--border-3); border-radius: 6px;
  background: var(--bg-0); color: var(--text-0); font-size: .85rem; }
.pane-search:focus { outline: 2px solid var(--accent);
  border-color: transparent; }
.filter-btn.active { color: var(--text-0); border-color: var(--accent);
  background: var(--accent-soft); }
.saved-more { text-align: center; padding: .8rem 0; }
.list-item .li-chan { font-size: .72rem; color: var(--accent); }
.list-item .li-remove { margin-left: auto; border: 0; background: none;
  color: var(--text-2); cursor: pointer; padding: .2rem; border-radius: 4px;
  opacity: 0; }
.list-item:hover .li-remove { opacity: 1; }
.list-item .li-remove:hover { color: var(--danger-text);
  background: var(--bg-3); }

/* the rail entry matching the visible pane */
.rail-nav-item.active { background: var(--accent-soft); color: var(--text-0); }

/* ── activity entries (posted by the workspace, not typed) ────────────── */
.msg.system { padding: .15rem .4rem; margin-top: .1rem; }
.msg.system .avatar { width: 22px; height: 22px; flex-basis: 22px;
  background: none; color: var(--text-2); }
.msg.system .msg-body { display: flex; align-items: baseline; gap: .5rem;
  flex-wrap: wrap; }
.msg.system .msg-meta { gap: .4rem; }
.msg.system .msg-author { font-weight: 600; font-size: .82rem;
  color: var(--text-1); }
.msg.system .msg-text { font-size: .82rem; color: var(--text-2); }
.msg.system .staff-badge { display: none; }

/* ── resizable sidebar (wider only, never below the default) ──────────── */
.rail { position: relative; }
.rail-resizer { position: absolute; top: 0; right: -3px; width: 6px;
  height: 100%; cursor: col-resize; z-index: 5; }
.rail-resizer:hover, .rail-resizer.dragging {
  background: var(--accent); opacity: .5; }
/* the grip: three dots at mid-height. Nothing says "drag me" like a handle,
   and a 6 px invisible strip says nothing at all. */
.rail-resizer::before { content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 3px; height: 3px;
  border-radius: 50%; background: var(--text-2);
  box-shadow: 0 -6px 0 var(--text-2), 0 6px 0 var(--text-2); opacity: .55; }
.rail-resizer:hover::before, .rail-resizer.dragging::before {
  background: var(--text-0); box-shadow: 0 -6px 0 var(--text-0),
    0 6px 0 var(--text-0); opacity: 1; }
body.resizing { user-select: none; cursor: col-resize; }

/* ── collapsible member rail ──────────────────────────────────────────── */
.members-toggle { margin-left: .4rem; }
.members-toggle.off { color: var(--text-2); }

/* activity entries: the target is a link, the row opens it on double-click */
.msg.activity { cursor: default; }
.activity-link { border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--link); text-decoration: underline;
  text-underline-offset: 2px; }
.activity-link:hover { color: var(--text-0); }

/* the brand doubles as "go to #general" */
button.brand-mini { border: 0; background: none; color: inherit;
  cursor: pointer; padding: 0; font: inherit; font-weight: 700;
  letter-spacing: .1em; }


/* ── direct messages in the rail (design memo §2.2) ───────────────────── */
.rail-group { padding: .8rem .9rem .25rem; font-size: .68rem;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }
.channel-item.dm .dm-dot { width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-2); flex: 0 0 7px; margin: 0 .3rem 0 .15rem; }

/* channel group header carrying the admin-only "create a channel" button */
.rail-group-action { display: flex; align-items: center;
  justify-content: space-between; gap: .4rem; }
.rail-add { background: none; border: 0; color: var(--text-2); cursor: pointer;
  padding: 0 .1rem; line-height: 1; border-radius: 4px; }
.rail-add:hover { color: var(--text-0); background: var(--hover-row); }
.rail-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── danger zone: self-service erasure (design memo §3) ───────────────── */
.danger-zone h3 { color: var(--danger-text); }
.btn-danger { border: 1px solid var(--danger-text); background: none;
  color: var(--danger-text); border-radius: 8px; padding: .4rem .8rem;
  font: inherit; font-size: .85rem; cursor: pointer; }
.btn-danger:hover { background: var(--danger-text); color: var(--bg-0); }
.danger-zone .field { margin-top: .8rem; }
/* the button sits right under the explanation, whose own margin-bottom is 0
   — 3px was there but read as nothing. Give it a real gap. */
.danger-zone #eraseStart { margin-top: .75rem; }

/* close control on a direct conversation (hides it; deletes nothing).
   Big enough to aim at: a 13px glyph in a 22px target. */
.channel-item.dm .dm-close { margin-left: auto; display: inline-flex;
  align-items: center; justify-content: center; width: 22px; height: 22px;
  color: var(--text-2); opacity: .45; border-radius: 5px; }
.channel-item.dm .dm-close svg { width: 15px; height: 15px;
  stroke-width: 2; }
.channel-item.dm:hover .dm-close { opacity: .9; }
.channel-item.dm .dm-close:hover { opacity: 1; color: var(--text-0);
  background: var(--bg-4); }
.channel-item.dm .unread + .dm-close { margin-left: .3rem; }

/* properties dialog */
.props { display: grid; grid-template-columns: 9rem 1fr; gap: .35rem .8rem;
  margin: 0; padding: 1.1rem; font-size: .88rem; }
.props dt { color: var(--text-2); }
.props dd { margin: 0; color: var(--text-0); word-break: break-word; }


/* the status menu's dots carry the meaning, so they are coloured */
.icon-dot-green { color: var(--accent); }
.icon-dot-amber { color: var(--dot-away); }
.icon-dot-red { color: var(--dot-dnd); }
/* the dnd glyph's minus stays readable on the filled disc */
.icon-dot-red path { stroke: var(--bg-1); stroke-width: 2.4; }
.icon-dot-purple { color: var(--dot-custom); }
.status-box { width: min(420px, 94vw); }

/* a caption above a group of menu entries (e.g. the status states) */
.menu-head { padding: .35rem .7rem .2rem; font-size: .66rem;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }

/* ── 1:1 calls (memo §8 / §11e): a centered, Signal-style surface ─────── */
.ring-banner { position: fixed; top: 14px; left: 50%;
  transform: translateX(-50%); z-index: 80; display: flex;
  align-items: center; gap: .7rem; padding: .55rem .9rem;
  background: var(--bg-2); border: 1px solid var(--accent);
  border-radius: 12px; box-shadow: 0 .6rem 2rem var(--shadow); }
.ring-banner .btn-primary { margin-top: 0; width: auto;
  padding: .35rem .8rem; }
.call-overlay { position: fixed; inset: 0; z-index: 70; display: flex;
  align-items: center; justify-content: center;
  background: rgba(10, 12, 15, .6); }
.call-stage { position: relative; width: min(760px, 94vw);
  aspect-ratio: 4 / 3; max-height: 88vh; background: #14161a;
  border: 1px solid var(--border-2); border-radius: 16px; overflow: hidden;
  box-shadow: 0 1.2rem 3.5rem var(--shadow); }
#callRemote { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; }
.call-stage.has-video #callRemote { opacity: 1; }
/* the peer's face until — and unless — video flows */
.call-identity { position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  gap: .8rem; color: #e8eaed; }
.call-stage.has-video .call-identity { display: none; }
.avatar-xl { width: 96px; height: 96px; flex: 0 0 96px; font-size: 2rem; }
.call-peer-name { font-size: 1.15rem; font-weight: 600; }
#callLocal { position: absolute; right: 12px; top: 12px; width: 120px;
  border-radius: 8px; border: 1px solid var(--border-3); background: #000;
  z-index: 2; }
.call-foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .8rem 1rem 1rem;
  background: linear-gradient(transparent, rgba(8, 10, 12, .82)); }
.call-status { font-size: .85rem; color: #d5d9de; }
.call-sas { font-size: .8rem; color: #9aa1a9; }
.call-sas strong { color: #fff; letter-spacing: .12em;
  font-variant-numeric: tabular-nums; }
.call-controls { display: flex; gap: .5rem; margin-top: .3rem; }
.call-controls .btn-ghost { color: #d5d9de; border-color: #4a5058; }
.call-controls .btn-ghost:hover { color: #fff; }

/* minimise the call to a corner card; the chat stays fully usable */
.call-shrink { position: absolute; top: 10px; left: 10px; z-index: 3;
  border: 0; border-radius: 8px; background: rgba(10, 12, 15, .55);
  color: #d5d9de; padding: .3rem; cursor: pointer; display: inline-flex; }
.call-shrink:hover { color: #fff; background: rgba(10, 12, 15, .8); }
.call-shrink-2 { left: 44px; }
.call-overlay.mini .call-shrink-2 { display: none; }
.call-overlay.mini { inset: auto; right: 16px; bottom: 52px;
  background: none; pointer-events: none; }
.call-overlay.mini .call-stage { width: 260px; pointer-events: auto;
  border-radius: 12px; }
.call-overlay.mini #callLocal { width: 64px; right: 8px; top: 8px; }
.call-overlay.mini .call-sas,
.call-overlay.mini #callMute,
.call-overlay.mini #callCamera { display: none; }
.call-overlay.mini .call-foot { padding: .4rem .6rem .55rem; }
.call-overlay.mini .avatar-xl { width: 56px; height: 56px; flex: 0 0 56px;
  font-size: 1.2rem; }
.call-overlay.mini .call-peer-name { font-size: .85rem; }

/* ── slash-command palette: sits on the composer, filters as you type ──── */
.cmd-palette { position: absolute; bottom: 100%; left: 0; right: 0;
  margin-bottom: .45rem; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 10px;
  box-shadow: 0 -.4rem 1.6rem var(--shadow); overflow: hidden;
  max-height: 260px; overflow-y: auto; z-index: 40; }
.cmd-item { display: flex; align-items: baseline; gap: .7rem; width: 100%;
  padding: .45rem .8rem; border: 0; background: none; cursor: pointer;
  text-align: left; color: var(--text-0); font: inherit; }
.cmd-item:hover { background: var(--bg-3); }
.cmd-name { font-family: ui-monospace, monospace; font-size: .85rem;
  white-space: nowrap; }
.cmd-desc { font-size: .78rem; color: var(--text-2); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* IRC-style /me action lines */
.msg-action-text { font-style: italic; color: var(--text-1); }

/* the enable-alerts bell: carries a dot until the user has clicked it */
.alerts-bell { position: relative; }
.alerts-bell::after { content: ''; position: absolute; top: 3px; right: 3px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }

/* ── device check (pre-call preview, settings test, in-call switch) ────── */
.device-box { width: min(460px, 94vw); }
.dev-preview-box { position: relative; background: #000; border-radius: 10px;
  overflow: hidden; aspect-ratio: 4 / 3; margin-bottom: .7rem; }
#devPreview { width: 100%; height: 100%; object-fit: cover; }
.dev-no-cam { position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; color: #d5d9de;
  font-size: .85rem; padding: 1rem; text-align: center; }
.dev-mic-row { display: flex; align-items: center; gap: .6rem;
  font-size: .78rem; color: var(--text-2); margin-bottom: .7rem; }
.dev-mic-track { flex: 1; height: 6px; border-radius: 3px;
  background: var(--bg-3); overflow: hidden; }
#devMicLevel { height: 100%; width: 0; background: var(--accent);
  transition: width .1s linear; }
.field select { width: 100%; background: var(--bg-1);
  border: 1px solid var(--border-2); border-radius: 8px;
  color: var(--text-0); padding: .4rem .5rem; font: inherit;
  font-size: .85rem; }
.call-shrink-3 { left: 78px; }
.call-overlay.mini .call-shrink-3 { display: none; }
.modal-foot .btn-ghost { margin-right: .4rem; }

/* a file carrying location data says so in Properties, in the danger colour */
.meta-warn { color: var(--danger-text); font-weight: 600; }
