:root {
  --side-bg: #173532;
  --side-fg: #BFD3CE;
  --side-fg-strong: #FFFFFF;
  --side-hover: rgba(255, 255, 255, 0.08);
  --marigold: #F0B43C;
  --marigold-ink: #2A1E04;

  --bg: #FFFFFF;
  --surface: #F3F6F5;
  --fg: #19231F;
  --muted: #5B6A66;
  --border: #DDE5E2;
  --link: #1C6A85;
  --focus: #1C6A85;
  --mention-bg: #FCEFD0;
  --mention-fg: #6E4A00;
  --bot-bg: #FFF8E9;
  --code-bg: #ECF1EF;
  --danger: #B3232E;
  --hover: #F6F8F7;
  --pin: #8A5A00;
  --pin-bg: #FFF4D6;

  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --side-bg: #0D1F1D;
    --side-fg: #A9C0BA;
    --side-hover: rgba(255, 255, 255, 0.06);
    --bg: #121918;
    --surface: #19221F;
    --fg: #E2EBE8;
    --muted: #94A6A1;
    --border: #273330;
    --link: #7EC3DB;
    --focus: #7EC3DB;
    --mention-bg: #3A2D10;
    --mention-fg: #F3CC78;
    --bot-bg: #1D1C13;
    --code-bg: #1E2926;
    --danger: #F07C85;
    --hover: #161F1D;
    --pin: #F3CC78;
    --pin-bg: #2A2410;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: var(--link); }

/* ---------- Shared bits ---------- */

.wordmark {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 26px; letter-spacing: -0.01em;
}
.wordmark.small { font-size: 18px; color: var(--side-fg-strong); }
.mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--marigold); position: relative; flex: none;
}
.mark::after {
  content: ""; position: absolute; left: 5px; bottom: -4px;
  border: 5px solid transparent; border-top-color: var(--marigold); border-left-color: var(--marigold);
}
.wordmark.small .mark { width: 18px; height: 18px; border-radius: 5px; }
.wordmark.small .mark::after { left: 4px; bottom: -3px; border-width: 4px; }

.btn {
  border: 1px solid transparent; border-radius: var(--radius); padding: 7px 14px;
  background: none; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.btn.primary { background: var(--side-bg); color: #fff; }
.btn.primary:hover { filter: brightness(1.15); }
.btn.ghost { border-color: var(--border); color: var(--fg); }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { color: var(--danger); border-color: var(--border); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.wide { width: 100%; padding: 11px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: var(--radius); background: none; color: var(--muted);
}
.icon-btn:hover { background: var(--surface); color: var(--fg); }

.link-btn { border: 0; background: none; color: var(--link); padding: 6px; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

.form-error { color: var(--danger); font-size: 14px; margin: 0; min-height: 1em; }
.form-error:empty { display: none; }

label { display: grid; gap: 5px; font-size: 14px; font-weight: 700; }
input[type="text"], input:not([type]), input[type="password"], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); font-weight: 400;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }

.loading { color: var(--muted); padding: 16px 20px; margin: 0; }

/* ---------- Sign in ---------- */

.auth {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: var(--side-bg);
}
.auth-card {
  width: min(380px, 100%); background: var(--bg); border-radius: 14px; padding: 32px 28px 22px;
  display: grid; gap: 14px;
}
.auth-sub { margin: -6px 0 6px; color: var(--muted); }
.field-group { display: grid; gap: 14px; }

/* ---------- Layout ---------- */

.app {
  flex: 1; min-height: 0; height: auto;
  display: grid; grid-template-columns: 260px minmax(0, 1fr);
}
body.thread-open .app { grid-template-columns: 260px minmax(0, 1fr) minmax(320px, 400px); }

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--side-bg); color: var(--side-fg);
  display: flex; flex-direction: column; min-height: 0;
  padding-top: env(safe-area-inset-top, 0px);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 12px 18px; }
.me-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--marigold); color: var(--marigold-ink); font-weight: 700; font-size: 13px;
}
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.side-group + .side-group { margin-top: 18px; }
.side-title { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 8px; }
.side-title h2 { margin: 0; font-size: 13px; font-weight: 700; color: var(--side-fg); }
.side-add {
  width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--side-fg);
  font-size: 18px; line-height: 1;
}
.side-add:hover { background: var(--side-hover); color: var(--side-fg-strong); }
.side-list { list-style: none; margin: 2px 0 0; padding: 0; }
.side-item {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border: 0; border-radius: 7px; background: none; color: var(--side-fg);
  text-align: left; font-size: 15px;
}
.side-item:hover { background: var(--side-hover); }
.side-item.unread { color: var(--side-fg-strong); font-weight: 700; }
.side-item.active { background: rgba(240, 180, 60, 0.16); color: var(--side-fg-strong); box-shadow: inset 3px 0 0 var(--marigold); }
.side-item .glyph { width: 18px; flex: none; display: grid; place-items: center; opacity: 0.8; font-size: 15px; }
.side-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .badge {
  background: var(--marigold); color: var(--marigold-ink); border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 1px 7px; min-width: 22px; text-align: center;
}
.side-item .badge.mention { background: #fff; color: #7A1F28; box-shadow: 0 0 0 2px var(--marigold); }
.side-item.archived { opacity: 0.7; font-style: italic; }

.side-search { padding: 0 12px 6px; }
.side-search input {
  width: 100%; padding: 7px 10px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07); color: var(--side-fg-strong); font-size: 14px;
}
.side-search input::placeholder { color: var(--side-fg); opacity: 0.8; }
.side-search input:focus { outline: 2px solid var(--marigold); outline-offset: -1px; border-color: transparent; }
.side-link {
  border: 0; background: none; color: var(--side-fg); font-size: 14px; padding: 6px 8px 6px 35px; opacity: 0.85;
}
.side-link:hover { color: var(--side-fg-strong); text-decoration: underline; }
.mini-avatar {
  width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff; background: hsl(var(--h, 180) 35% 42%);
}
.mini-avatar.bot { background: var(--marigold); color: var(--marigold-ink); }
.offline {
  margin: 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--marigold); color: var(--marigold-ink); font-size: 13px; font-weight: 700;
}

/* ---------- Main column ---------- */

.main, .thread { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.thread { border-left: 1px solid var(--border); }

.chan-head, .thread-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border); min-height: 60px;
}
.chan-title { flex: 1; min-width: 0; }
.chan-title h1 { margin: 0; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-title p { margin: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-title p:empty { display: none; }
.chan-actions { display: flex; gap: 8px; }
.menu-btn { display: none; }
.thread-head h2 { flex: 1; margin: 0; font-size: 17px; }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 0 8px; overscroll-behavior: contain; }

.empty-state { max-width: 460px; margin: 18vh auto 0; padding: 0 24px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--fg); margin: 0 0 6px; font-size: 18px; }

.load-more { display: block; margin: 4px auto 12px; }

.day {
  display: flex; align-items: center; gap: 12px; margin: 14px 20px 6px;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Messages ---------- */

.msg {
  position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 0 12px;
  padding: 6px 20px 6px 18px;
}
.msg:hover { background: var(--hover); }
.msg.compact { padding-top: 1px; padding-bottom: 2px; }
.avatar {
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff; background: hsl(var(--h, 180) 35% 40%);
  margin-top: 2px;
}
.avatar.bot { background: var(--marigold); color: var(--marigold-ink); }
.gutter-time {
  font-size: 11px; color: var(--muted); text-align: right; padding-top: 4px; opacity: 0; white-space: nowrap;
}
.msg:hover .gutter-time { opacity: 1; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.author { font-weight: 700; }
.author .you { font-weight: 400; color: var(--muted); font-size: 12px; }
.ai-chip {
  font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 4px;
  background: var(--mention-bg); color: var(--mention-fg);
}
.msg-meta time { font-size: 12px; color: var(--muted); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.deleted .msg-body { color: var(--muted); font-style: italic; }

/* Claude's messages get a marigold rule so they're easy to spot. */
.msg.bot { background: var(--bot-bg); box-shadow: inset 3px 0 0 var(--marigold); }
.msg.bot:hover { background: var(--bot-bg); }

.thinking { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.thinking i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--marigold);
  animation: pulse 1.2s ease-in-out infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .thinking i { animation: none; opacity: 0.7; } }

.msg-body code {
  font-family: var(--mono); font-size: 0.88em; background: var(--code-bg);
  padding: 1px 5px; border-radius: 4px;
}
.msg-body pre {
  white-space: pre; overflow-x: auto; background: var(--code-bg);
  padding: 10px 12px; border-radius: var(--radius); margin: 6px 0; font-size: 13px;
}
.msg-body pre code { background: none; padding: 0; }
.mention { background: var(--mention-bg); color: var(--mention-fg); border-radius: 4px; padding: 0 3px; font-weight: 700; }

.file-image { display: inline-block; margin-top: 6px; }
.file-image img {
  display: block; max-width: min(360px, 100%); max-height: 280px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
}
.file-chip {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--fg);
  max-width: 100%;
}
.file-chip:hover { background: var(--surface); }
.file-chip .ext {
  flex: none; font-size: 11px; font-weight: 700; background: var(--side-bg); color: #fff;
  border-radius: 4px; padding: 3px 5px; text-transform: lowercase;
}
.file-chip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.file-chip .fsize { color: var(--muted); font-size: 13px; white-space: nowrap; }

.replies {
  display: inline-flex; gap: 8px; align-items: baseline; margin-top: 4px; padding: 3px 8px 3px 0;
  border: 0; background: none; color: var(--link); font-weight: 700; font-size: 13px;
}
.replies span { color: var(--muted); font-weight: 400; }
.replies:hover { text-decoration: underline; }

.msg-actions {
  position: absolute; top: -12px; right: 16px; display: none; gap: 2px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px;
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-actions button {
  border: 0; background: none; border-radius: 6px; padding: 4px 8px; font-size: 13px; color: var(--muted);
}
.msg-actions button:hover { background: var(--surface); color: var(--fg); }
.msg-actions .del:hover { color: var(--danger); }

.thread-divider { margin: 8px 20px; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.thread-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Edits, reactions, pins ---------- */

.msg:focus { outline: none; }
.msg.flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 40% { background: var(--mention-bg); } 100% { background: transparent; } }
.edited { margin-left: 6px; font-size: 12px; color: var(--muted); font-style: normal; }
.pin-flag { font-size: 12px; font-weight: 700; color: var(--pin); margin-bottom: 1px; }
.mention.me { background: var(--marigold); color: var(--marigold-ink); }

.edit-wrap { display: grid; gap: 6px; margin-top: 2px; }
.edit-box { min-height: 38px; max-height: 240px; resize: none; line-height: 1.4; }
.edit-actions { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.edit-actions .btn { padding: 4px 12px; font-size: 13px; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px; line-height: 1.6;
}
.reaction:hover { border-color: var(--muted); }
.reaction.mine { background: var(--mention-bg); border-color: var(--marigold); color: var(--mention-fg); font-weight: 700; }
.reaction:disabled { cursor: default; }

.react-pop {
  position: fixed; z-index: 60; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(10, 20, 18, 0.2);
}
.react-pop button { border: 0; background: none; font-size: 20px; width: 38px; height: 36px; border-radius: 6px; }
.react-pop button:hover, .react-pop button:focus-visible { background: var(--surface); }

/* ---------- Files ---------- */

.file-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.file-grid .file-image { margin-top: 0; }
.file-grid.many .file-image img { width: 160px; height: 120px; object-fit: cover; }
.file-image { cursor: zoom-in; }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; }
.file-list .file-chip { margin-top: 6px; }

.lightbox {
  width: fit-content; min-width: 260px; max-width: min(96vw, 1100px); max-height: 94vh; padding: 14px; background: #0D1F1D; color: #fff;
  overflow: hidden;
}
.lightbox[open] { display: grid; gap: 8px; justify-items: center; }
.lightbox img { max-width: 100%; max-height: calc(94vh - 90px); object-fit: contain; border-radius: 6px; }
.lightbox .lb-foot { margin: 0; font-size: 13px; display: flex; gap: 14px; align-items: center; }
.lightbox a { color: var(--marigold); }
.lb-close {
  position: absolute; top: 6px; right: 10px; border: 0; background: none; color: #fff; font-size: 26px; line-height: 1;
}

.drop-hint {
  position: absolute; inset: 8px; z-index: 40; display: grid; place-items: center; text-align: center;
  border: 2px dashed var(--focus); border-radius: 12px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  font-weight: 700; font-size: 17px; color: var(--link); pointer-events: none;
}

.attach-slot { display: flex; flex-wrap: wrap; gap: 6px; }
.attach-slot:not(:empty) { margin-bottom: 6px; }
.attach-tile {
  position: relative; display: flex; align-items: center; gap: 8px; max-width: 220px; padding: 4px 26px 4px 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px;
}
.attach-tile img, .attach-tile .ext-tile {
  width: 40px; height: 40px; flex: none; border-radius: 6px; object-fit: cover; background: var(--code-bg);
}
.attach-tile .ext-tile { display: grid; place-items: center; font-weight: 700; text-transform: lowercase; color: var(--muted); }
.attach-tile .tname { display: grid; min-width: 0; line-height: 1.25; }
.attach-tile .tname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-tile .tname small { color: var(--muted); }
.attach-tile button {
  position: absolute; top: 1px; right: 2px; border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 5px;
}

/* ---------- @mention suggestions, banners, toasts ---------- */

.composer { position: relative; }
.mention-pop {
  position: absolute; left: 16px; bottom: calc(100% - 4px); z-index: 50; width: min(340px, calc(100% - 32px));
  margin: 0; padding: 4px; list-style: none; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(10, 20, 18, 0.2); max-height: 260px; overflow-y: auto;
}
.mention-pop li { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.mention-pop li[aria-selected="true"], .mention-pop li:hover { background: var(--surface); }
.mention-pop .who { min-width: 0; display: flex; gap: 6px; align-items: baseline; }
.mention-pop .who small { color: var(--muted); }

.archived-banner {
  margin: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 12px;
  align-items: center; justify-content: space-between; background: var(--surface); border-top: 1px solid var(--border);
  color: var(--muted); font-size: 14px;
}

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; width: min(340px, calc(100% - 32px));
}
.toast {
  text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); box-shadow: 0 8px 24px rgba(10, 20, 18, 0.22), inset 3px 0 0 var(--marigold);
  display: grid; gap: 2px; font-size: 14px;
}
.toast strong { font-size: 14px; }
.toast span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Search results and pins (inside the dialog) ---------- */

dialog.wide { width: min(620px, calc(100% - 32px)); }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 60vh; overflow-y: auto; }
.result-list li { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--radius); }
.result-list li.clickable { cursor: pointer; }
.result-list li:hover { background: var(--surface); }
.result-meta { font-size: 12px; color: var(--muted); }
.result-meta strong { color: var(--fg); }
.result-text { overflow-wrap: anywhere; white-space: pre-wrap; max-height: 5.5em; overflow: hidden; }
.result-text mark { background: var(--mention-bg); color: var(--mention-fg); border-radius: 3px; padding: 0 1px; }
.result-actions { display: flex; gap: 8px; margin-top: 4px; }
.result-actions .btn { padding: 3px 10px; font-size: 13px; }

/* ---------- Summary panel ---------- */

.summary {
  margin: 12px 16px 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--bot-bg); box-shadow: inset 3px 0 0 var(--marigold);
  max-height: 40vh; overflow-y: auto;
}
.summary-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.summary-head strong { font-size: 14px; }
.summary .msg-body { font-size: 14px; }
.summary .loading { padding: 0; }

/* ---------- Composer ---------- */

.composer { padding: 6px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.composer-box {
  display: flex; align-items: flex-end; gap: 6px; padding: 6px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.composer-box:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.composer textarea {
  flex: 1; border: 0; resize: none; padding: 7px 4px; max-height: 200px; background: none; line-height: 1.4;
}
.composer textarea:focus { outline: none; }
.attach { cursor: pointer; }
.send {
  border: 0; border-radius: 7px; padding: 7px 14px; font-weight: 700;
  background: var(--side-bg); color: #fff;
}
.send:disabled { opacity: 0.5; }
.composer-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; font-size: 12px; color: var(--muted); }
.composer-status.error { color: var(--danger); }

/* ---------- Dialogs ---------- */

dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100% - 32px));
  background: var(--bg); color: var(--fg);
}
dialog::backdrop { background: rgba(10, 20, 18, 0.5); }
#dialog-form { padding: 22px; display: grid; gap: 14px; }
#dialog-form h3 { margin: 0; font-size: 19px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }
.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; }
.pick-list li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); }
.pick-list li:hover { background: var(--surface); }
.pick-list .who { flex: 1; min-width: 0; }
.pick-list .who small { display: block; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 14px; }
.add-row { display: flex; gap: 8px; }

/* ---------- Photos, account, admin ---------- */

.avatar.own { cursor: pointer; }
.avatar.photo, .mini-avatar.photo { background: var(--surface); overflow: hidden; padding: 0; }
.avatar.photo img, .mini-avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.me-btn { overflow: hidden; padding: 0; }
.me-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }

.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head .hint { margin: 2px 0 0; }
.profile-head .avatar, .profile-photo .avatar { width: 64px; height: 64px; font-size: 22px; border-radius: 14px; margin: 0; flex: none; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.block { width: 100%; text-align: left; }
.dialog-sub { margin: 6px 0 0; font-size: 14px; }
.add-row .btn { flex: none; }

.notify-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 16px;
  background: var(--bot-bg); border-bottom: 1px solid var(--border); font-size: 14px;
}
.notify-banner span { flex: 1 1 240px; }
.notify-banner .btn { padding: 4px 12px; font-size: 13px; }

.toast.note { box-shadow: 0 8px 24px rgba(10, 20, 18, 0.22), inset 3px 0 0 var(--link); }

.admin-section { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.admin-section:first-child { border-top: 0; padding-top: 0; }
.admin-users { max-height: 320px; }
.admin-users li { flex-wrap: wrap; }
.admin-users li.off { opacity: 0.65; }
.admin-users .who > span { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; }
.admin-users .who small { display: inline; font-weight: 400; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions .btn { padding: 3px 10px; font-size: 12px; }
.off-chip { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 4px; background: var(--surface); color: var(--danger); border: 1px solid var(--border); }
.invite-now { margin: 0; font-size: 16px; }
.invite-now code, .path { font-family: var(--mono); background: var(--code-bg); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.path { margin: 0; font-size: 12px; display: block; }
.secret { font-family: var(--mono); font-size: 16px; text-align: center; letter-spacing: 0.04em; }
.secret.small { font-size: 12px; letter-spacing: 0; text-align: left; }
.warn { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: var(--mention-bg); color: var(--mention-fg); font-size: 13px; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding-top: 4px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; min-width: 0; }
.bar i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: var(--link); opacity: 0.8; min-height: 2px; }
.bar i.full { background: var(--danger); opacity: 1; }
.bar span { font-size: 10px; color: var(--muted); }

/* ---------- Cards from connected apps ---------- */

.avatar.is-app, .mini-avatar.is-app { background: var(--side-bg); color: var(--marigold); }
.app-chip { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.msg-card { margin-top: 4px; padding: 2px 0 2px 12px; border-left: 4px solid #1FA971; display: grid; gap: 6px; justify-items: start; max-width: 640px; }
.msg-card.status { border-left-color: var(--link); }
.msg-card.comment { border-left-color: var(--marigold); }
.card-headline { overflow-wrap: anywhere; }
.card-quote { margin: 0; color: var(--fg); overflow-wrap: anywhere; white-space: pre-wrap; }
.card-project { font-size: 13px; color: var(--muted); }
.card-btn {
  display: inline-block; padding: 4px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-weight: 700; color: var(--fg); text-decoration: none; background: var(--bg);
}
.card-btn:hover { background: var(--surface); }

/* ---------- Notification check ---------- */

.diag { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.diag li { display: flex; gap: 8px; align-items: baseline; }
.diag li b { width: 16px; flex: none; text-align: center; }
.diag li.ok b { color: #2E7D4F; }
.diag li.bad b { color: var(--danger); }
.diag small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Site-wide notice ---------- */

.notice {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); font-size: 14px; font-weight: 700;
  background: var(--marigold); color: var(--marigold-ink);
}
.notice.warning { background: #B3232E; color: #fff; }
.notice span { overflow-wrap: anywhere; }

/* ---------- Daily summary ---------- */

.summary-view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 28px; }
.sv-wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; }
.sv-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sv-nav select { width: auto; min-width: 190px; font-weight: 700; }
.sv-nav .spacer { flex: 1; }
.sv-title { margin: 0; font-size: 22px; }
.sv-sub { margin: 0; color: var(--muted); font-size: 13px; }
.sv-readonly { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.sv-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.sv-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.sv-card b { display: block; font-size: 26px; line-height: 1.1; }
.sv-card span { font-size: 13px; color: var(--muted); }
.sv-section { display: grid; gap: 8px; }
.sv-section h3 { margin: 0; font-size: 16px; }
.sv-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sv-bars li { display: grid; grid-template-columns: 150px 1fr 40px; align-items: center; gap: 10px; font-size: 14px; }
.sv-bars .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sv-bars .who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-bars .track { height: 12px; border-radius: 6px; background: var(--surface); overflow: hidden; }
.sv-bars .fill { display: block; height: 100%; border-radius: 6px; background: var(--link); }
.sv-bars .count { text-align: right; font-weight: 700; }
.sv-story { padding: 14px 16px; border-radius: var(--radius); background: var(--bot-bg); box-shadow: inset 3px 0 0 var(--marigold); }
.sv-story h4 { margin: 14px 0 4px; font-size: 15px; }
.sv-story h4:first-of-type { margin-top: 0; }
.sv-story p { margin: 0 0 4px; }
.sv-story ul { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
.sv-empty { padding: 40px 12px; text-align: center; color: var(--muted); }
.sv-empty h3 { color: var(--fg); margin: 0 0 6px; }
.sv-note { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: var(--mention-bg); color: var(--mention-fg); font-size: 13px; }

/* ---------- Mobile ---------- */

.scrim { display: none; }

@media (max-width: 860px) {
  .app, body.thread-open .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(290px, 85vw); z-index: 30;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(10, 20, 18, 0.45); }
  .menu-btn { display: inline-grid; }
  .thread { position: fixed; inset: 0; z-index: 25; border-left: 0; }
  .chan-head { gap: 6px; padding-left: 8px; padding-right: 10px; }
  .chan-actions { gap: 4px; }
  .chan-actions .btn { padding: 5px 7px; font-size: 12px; }
  .chan-title { min-width: 56px; }
  .sv-bars li { grid-template-columns: 100px 1fr 32px; }
  .summary-view { padding: 12px 12px 24px; }
  .msg { padding-left: 12px; padding-right: 12px; }
  .msg-actions { right: 8px; }
  .composer-foot .tips { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
