/* chattr — midnight-ink messenger.
   Deep slate surfaces, dragonfly-teal accent, warm parchment text. */

:root {
  --ink-0: #0b111b;   /* page background */
  --ink-1: #101827;   /* sidebar / panels */
  --ink-2: #16202f;   /* raised surfaces, other bubbles */
  --ink-3: #1f2c3f;   /* hover, borders */
  --line:  #223047;
  --text:  #e8e4d8;   /* warm parchment */
  --text-dim: #8b96a8;
  --accent: #2ec4b6;         /* dragonfly teal */
  --accent-deep: #17877d;
  --own-bubble: #14524c;     /* own messages */
  --danger: #ff6b6b;
  --font-ui: "Albert Sans", ui-sans-serif, sans-serif;
  --font-display: "Bricolage Grotesque", var(--font-ui);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--ink-0);
  color: var(--text);
  overflow: hidden;
  font-size: 15px;
  line-height: 1.45;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: rgba(46, 196, 182, .35); }

/* scrollbars */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------ wordmark */
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 44px;
  letter-spacing: -0.03em;
  color: var(--text);
}
.wordmark .tick { color: var(--accent); animation: blink 1.2s steps(1) infinite; }
.wordmark.small { font-size: 22px; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------------------------------------------------------- auth */
.auth {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 24px;
}
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(60vmax 60vmax at 15% -10%, rgba(46,196,182,.14), transparent 60%),
    radial-gradient(50vmax 50vmax at 110% 110%, rgba(23,135,125,.18), transparent 55%),
    var(--ink-0);
}
.auth-bg::after {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(rgba(232,228,216,.05) 1px, transparent 1.2px);
  background-size: 26px 26px;
}
.auth-logo {
  display: block;
  width: min(300px, 78%);
  margin: -12px auto 6px;
}
.auth-card {
  position: relative;
  width: min(400px, 100%);
  background: rgba(10, 20, 39, .92); /* matches the logo artwork's bg */
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 44px 36px 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  animation: card-in .5s cubic-bezier(.2,.9,.3,1.2);
  text-align: center;
}
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.tagline { color: var(--text-dim); margin: 6px 0 30px; font-size: 14px; }
.auth-pane { display: flex; flex-direction: column; gap: 12px; }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 16px; min-height: 1.2em; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field span {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-dim);
}
.field input, .side-search input, #user-search, #group-title,
#room-search, #new-room-name, #new-room-topic {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .side-search input:focus, #user-search:focus,
#group-title:focus, #room-search:focus, #new-room-name:focus,
#new-room-topic:focus { border-color: var(--accent-deep); }

.btn {
  border: none; border-radius: 12px;
  padding: 12px 18px;
  font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #06211e; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-big { padding: 15px 18px; font-size: 16px; }
.btn-ghost { background: transparent; color: var(--text-dim); font-weight: 500; }
.btn-ghost:hover { color: var(--text); }

/* ----------------------------------------------------------------- app */
.app { display: flex; height: 100dvh; }

.icon-btn {
  background: transparent; border: none;
  color: var(--text-dim);
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  flex: none;
}
.icon-btn:hover { background: var(--ink-3); color: var(--text); }

/* sidebar */
.sidebar {
  width: 340px; flex: none;
  background: var(--ink-1);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-emblem { width: 28px; height: 28px; border-radius: 26%; }
.side-actions { display: flex; gap: 4px; }
.side-search { padding: 0 12px 10px; }
.side-search input { width: 100%; }

.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.chat-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: transparent; border: none; color: inherit;
  padding: 10px 10px;
  border-radius: 12px;
  transition: background .12s;
}
.chat-item:hover { background: var(--ink-2); }
.chat-item.active { background: var(--ink-3); }
.chat-item .meta { flex: 1; min-width: 0; }
.chat-item .row1 { display: flex; align-items: baseline; gap: 8px; }
.chat-item .name {
  font-weight: 600; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item .time { font-size: 11.5px; color: var(--text-dim); flex: none; }
.chat-item .row2 { display: flex; align-items: center; gap: 8px; margin-top: 1px; }
.chat-item .preview {
  flex: 1; font-size: 13.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item .chevron {
  flex: none;
  color: var(--text-dim);
  font-size: 20px; line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
  transition: transform .15s;
}
.chat-item .chevron:hover { background: var(--ink-3); color: var(--text); }
.chat-item .chevron.open { transform: rotate(90deg); }

.topic-item {
  display: flex; align-items: center; gap: 8px;
  width: calc(100% - 44px);
  margin-left: 44px;
  text-align: left;
  background: transparent; border: none; color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  transition: background .12s, color .12s;
}
.topic-item:hover { background: var(--ink-2); color: var(--text); }
.topic-item.active { background: var(--ink-3); color: var(--text); }
.topic-item .topic-hash { color: var(--accent); font-weight: 700; }
.topic-item .topic-name {
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topic-item .badge { min-width: 18px; height: 18px; font-size: 11px; }

.badge {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--accent); color: #06211e;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.avatar-wrap { position: relative; flex: none; display: inline-flex; }
.p-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--ink-1);
}
.avatar {
  flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 17px; color: #071b18;
}
.avatar.group-avatar { border-radius: 38%; }

.side-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.me-avatar .avatar { width: 38px; height: 38px; font-size: 14px; }
.me-names { flex: 1; min-width: 0; }
.me-display { font-weight: 600; font-size: 14px; }
.me-username { font-size: 12px; color: var(--text-dim); }
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); flex: none;
  transition: background .3s;
}
.conn-dot.on { background: var(--accent); box-shadow: 0 0 8px rgba(46,196,182,.7); }

/* main pane */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: var(--text-dim);
  background:
    radial-gradient(45vmax 45vmax at 80% -10%, rgba(46,196,182,.06), transparent 60%),
    var(--ink-0);
}
.empty-bubble { font-size: 54px; filter: grayscale(.3); }

.chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--ink-1);
  border-bottom: 1px solid var(--line);
}
.icon-btn.back { display: none; }
.chat-head-avatar .avatar { width: 40px; height: 40px; font-size: 15px; }
.chat-head-names { flex: 1; min-width: 0; }
.chat-title { font-weight: 700; font-family: var(--font-display); letter-spacing: -.01em; }
.chat-sub { font-size: 12.5px; color: var(--text-dim); }
.chat-sub.online, .chat-sub.typing { color: var(--accent); }
.chat-item .preview.typing { color: var(--accent); font-style: italic; }

.messages {
  flex: 1; overflow-y: auto;
  padding: 18px 8% 12px;
  display: flex; flex-direction: column; gap: 3px;
  background:
    radial-gradient(50vmax 40vmax at 90% 0%, rgba(46,196,182,.05), transparent 55%),
    var(--ink-0);
}
.day-sep {
  align-self: center;
  margin: 14px 0 8px;
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  background: var(--ink-2);
  border: 1px solid var(--line);
  padding: 3px 12px; border-radius: 999px;
}
.msg {
  max-width: min(72%, 560px);
  padding: 8px 12px 6px;
  border-radius: var(--radius);
  background: var(--ink-2);
  align-self: flex-start;
  animation: msg-in .18s ease-out;
  overflow-wrap: break-word;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg.own {
  align-self: flex-end;
  background: var(--own-bubble);
}
.msg.first { border-top-left-radius: 6px; margin-top: 8px; }
.msg.own.first { border-top-left-radius: var(--radius); border-top-right-radius: 6px; }
.msg .sender {
  font-size: 12.5px; font-weight: 700;
  margin-bottom: 2px;
}
.msg .body { white-space: pre-wrap; }
.msg .body.jumbo { font-size: 42px; line-height: 1.2; }
.msg img.photo {
  display: block;
  max-width: 100%; max-height: 380px;
  border-radius: 9px;
  margin: 2px 0 4px;
  cursor: zoom-in;
}
.msg .file-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(11, 17, 27, .45);
  border: 1px solid rgba(232, 228, 216, .12);
  border-radius: 10px;
  padding: 9px 12px;
  margin: 2px 0 4px;
  color: inherit; text-decoration: none;
  max-width: 320px;
  transition: border-color .15s;
}
.msg .file-card:hover { border-color: var(--accent); }
.msg .file-icon { font-size: 22px; }
.msg .file-meta { min-width: 0; display: flex; flex-direction: column; }
.msg .file-name {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg .file-size { font-size: 12px; color: var(--text-dim); }

.msg { position: relative; }
.msg .del-btn {
  position: absolute; top: -8px; right: -6px;
  width: 20px; height: 20px;
  border: none; border-radius: 50%;
  background: var(--ink-3); color: var(--text-dim);
  font-size: 11px; line-height: 1;
  display: none; align-items: center; justify-content: center;
  z-index: 2;
}
.msg:hover .del-btn { display: inline-flex; }
.msg .del-btn:hover { background: var(--danger); color: #1b0505; }
.msg.ephemeral { border: 1px dashed rgba(255, 154, 60, .55); }
.msg.burning {
  animation: burn-away 6s ease-in forwards;
  pointer-events: none;
}
@keyframes burn-away {
  0% { opacity: 1; filter: none; }
  60% { opacity: 1; filter: sepia(.4) saturate(1.4); }
  100% { opacity: 0; filter: sepia(1) saturate(3) blur(2px); transform: scale(.96); }
}
.icon-btn.armed { color: #ff9a3c; background: rgba(255, 154, 60, .12); }

.msg .stamp {
  float: right;
  font-size: 10.5px; color: var(--text-dim);
  margin: 6px 0 0 10px;
}
.msg.own .stamp { color: rgba(232,228,216,.55); }

/* ------------------------------------------------------------- gallery */
.messages.gallery { display: block; padding: 20px 5% 16px; }

.album-grid, .photo-grid { display: grid; gap: 14px; }
.album-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-bottom: 8px;
}
.album-card {
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 0 10px;
  color: inherit;
  text-align: left;
  overflow: hidden;
  transition: transform .12s, border-color .15s;
}
.album-card:hover { transform: translateY(-2px); border-color: var(--accent-deep); }
.album-cover {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--ink-2);
  overflow: hidden;
}
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-cover .badge { position: absolute; top: 8px; right: 8px; }
.album-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  font-size: 34px; color: var(--text-dim);
}
.album-new { border-style: dashed; }
.album-new:hover .album-empty { color: var(--accent); }
.album-name {
  display: block;
  padding: 8px 12px 0;
  font-weight: 700;
  font-family: var(--font-display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.album-count { display: block; padding: 0 12px; font-size: 12px; color: var(--text-dim); }

/* docs rooms */
.docs-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.folder-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  color: inherit;
  text-align: left;
  transition: transform .12s, border-color .15s;
  min-height: 104px;
}
.folder-card:hover { transform: translateY(-2px); border-color: var(--accent-deep); }
.folder-card.album-new { border-style: dashed; }
.folder-card.album-new:hover .folder-icon { color: var(--accent); }
.folder-head { display: flex; align-items: center; gap: 9px; min-width: 0; }
.folder-icon { font-size: 21px; }
.folder-head .album-name { padding: 0; flex: 1; }
.folder-desc {
  font-size: 13px; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 1.2em;
}
.folder-foot { font-size: 12px; color: var(--text-dim); margin-top: auto; }

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
}
.doc-row:hover { border-color: var(--accent-deep); }
.doc-icon { font-size: 24px; flex: none; }
.doc-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-name {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-sub { font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-dl { text-decoration: none; font-size: 17px; }
.doc-row .del-btn { position: static; display: none; }
.doc-row:hover .del-btn { display: inline-flex; }

/* FAQ rooms */
.faq-filter {
  width: 100%;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  outline: none;
  margin-bottom: 12px;
}
.faq-filter:focus { border-color: var(--accent-deep); }
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-card {
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.faq-card.open { border-color: var(--accent-deep); }
.faq-q {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: none; color: inherit;
  padding: 12px 14px;
  font-size: 14.5px; font-weight: 600;
}
.faq-q:hover { background: var(--ink-2); }
.faq-mark { flex: none; }
.faq-question { flex: 1; min-width: 0; }
.faq-chevron {
  flex: none; color: var(--text-dim);
  font-size: 18px; transition: transform .15s;
}
.faq-card.open .faq-chevron { transform: rotate(90deg); }
.faq-a { padding: 0 14px 12px 38px; }
.faq-answer { white-space: pre-wrap; font-size: 14px; }
.faq-foot {
  margin-top: 8px;
  font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; gap: 12px;
}
.faq-foot button {
  background: transparent; border: none;
  color: var(--accent); font-size: 12px;
  padding: 0;
}
.faq-foot button.faq-del { color: var(--danger); }
.faq-foot button:hover { text-decoration: underline; }
#faq-answer {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none; resize: vertical;
}
#faq-answer:focus, #faq-question:focus { border-color: var(--accent-deep); }
#faq-question {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none;
}
.msg .faq-inline-answer { margin-top: 4px; color: var(--text); opacity: .92; }

.gallery-sep {
  margin: 20px 0 12px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-dim);
}
.gallery-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--text-dim);
}

.photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.photo-cell {
  position: relative;
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--ink-2);
  aspect-ratio: 1;
}
.photo-cell img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  cursor: zoom-in;
  transition: transform .15s;
}
.photo-cell:hover img { transform: scale(1.04); }
.photo-cell figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 8px 6px;
  font-size: 11.5px;
  color: #fff;
  background: linear-gradient(transparent, rgba(5, 9, 15, .8));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.photo-cell .del-btn { top: 6px; right: 6px; }
.photo-cell:hover .del-btn { display: inline-flex; }

.gallery-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--ink-1);
  border-top: 1px solid var(--line);
}
.gallery-hint { font-size: 12.5px; color: var(--text-dim); }

/* lightbox chrome */
.lightbox figure { margin: 0; max-width: 94vw; text-align: center; }
#lb-caption {
  margin-top: 10px;
  color: var(--text);
  font-size: 14px;
}
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(16, 24, 39, .8);
  color: var(--text);
  font-size: 30px; line-height: 1;
  z-index: 61;
}
.lb-nav:hover { background: var(--ink-3); }
.lb-prev { left: 22px; }
.lb-next { right: 22px; }

.room-format { display: flex; flex-direction: column; gap: 6px; }
.room-format label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
  cursor: pointer;
}
.room-format input { accent-color: var(--accent); }

/* image pending preview */
.image-preview {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: var(--ink-1);
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--text-dim);
}
.image-preview img { height: 44px; border-radius: 8px; }
.image-preview span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* composer */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--ink-1);
  border-top: 1px solid var(--line);
}
.composer-box {
  flex: 1;
  display: flex; align-items: flex-end;
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 4px 4px 4px 14px;
  transition: border-color .15s;
}
.composer-box:focus-within { border-color: var(--accent-deep); }
#composer-input {
  flex: 1;
  background: transparent; border: none; outline: none; resize: none;
  padding: 7px 0;
  max-height: 140px;
  line-height: 1.4;
}
.send-btn {
  flex: none;
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: var(--accent); color: #06211e;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .1s, filter .15s;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn:active { transform: scale(.92); }
.send-btn svg { margin-left: 2px; }

/* emoji panel */
.emoji-panel {
  position: absolute;
  right: 18px; bottom: 76px;
  width: 330px; height: 320px;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop-in .16s ease-out;
  z-index: 30;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.emoji-tabs {
  display: flex; gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.emoji-tabs button {
  flex: 1; background: transparent; border: none;
  font-size: 17px; padding: 5px 0; border-radius: 8px;
}
.emoji-tabs button.active, .emoji-tabs button:hover { background: var(--ink-3); }
.emoji-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr);
  padding: 8px;
  align-content: start;
}
.emoji-grid button {
  background: transparent; border: none;
  font-size: 21px; padding: 5px 0;
  border-radius: 8px;
  transition: transform .08s;
}
.emoji-grid button:hover { background: var(--ink-3); transform: scale(1.18); }

/* ---------------------------------------------------------------- feed */
.feed-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.feed-scroll {
  flex: 1; overflow-y: auto;
  padding: 18px 8%;
  background:
    radial-gradient(50vmax 40vmax at 90% 0%, rgba(46,196,182,.05), transparent 55%),
    var(--ink-0);
}
.feed-compose {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
#feed-body {
  background: transparent; border: none; outline: none; resize: vertical;
  min-height: 44px; line-height: 1.4;
}
.feed-compose-row { display: flex; align-items: center; gap: 8px; }
#feed-visibility {
  flex: 1; min-width: 0;
  background: var(--ink-0); color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px; font-size: 13px;
}
.feed-posts { display: flex; flex-direction: column; gap: 12px; }
.feed-posts .none { color: var(--text-dim); text-align: center; padding: 30px 0; }
.feed-post {
  display: flex; gap: 12px;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.feed-avatar { background: none; border: none; padding: 0; cursor: pointer; align-self: flex-start; }
.feed-main { flex: 1; min-width: 0; }
.feed-head-row { display: flex; align-items: baseline; gap: 10px; }
.feed-author {
  background: none; border: none; padding: 0;
  color: var(--text); font-weight: 700; font-size: 14.5px;
  cursor: pointer; font-family: var(--font-display);
}
.feed-author:hover { color: var(--accent); }
.feed-when { flex: 1; font-size: 12px; color: var(--text-dim); }
.feed-post .del-btn { position: static; }
.feed-post:hover .del-btn { display: inline-flex; }
.feed-status { font-size: 12px; color: var(--accent); font-style: italic; }
.feed-body { white-space: pre-wrap; margin-top: 3px; overflow-wrap: break-word; }
.feed-img {
  display: block; max-width: 100%; max-height: 420px;
  border-radius: 10px; margin-top: 8px; cursor: zoom-in;
}
#feed-more { align-self: center; margin: 14px auto; display: block; }

/* ask AI */
.ask-modal { width: min(520px, calc(100vw - 32px)); }
.ask-form { display: flex; gap: 8px; }
.ask-form input {
  flex: 1;
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px; outline: none;
}
.ask-form input:focus { border-color: var(--accent-deep); }
.ask-answer {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  white-space: pre-wrap;
  font-size: 14px; line-height: 1.55;
  max-height: 260px; overflow-y: auto;
}
.ask-sources { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.ask-source {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--ink-2); border: none; color: inherit;
  border-radius: 10px; padding: 9px 12px;
  text-align: left; cursor: pointer;
}
.ask-source:hover { background: var(--ink-3); }
.ask-source-n { color: var(--accent); font-weight: 700; flex: none; }
.ask-source-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ask-source-title { font-weight: 600; font-size: 13.5px; }
.ask-source-snippet {
  font-size: 12px; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* status */
.me-names {
  background: none; border: none; padding: 0;
  text-align: left; color: inherit; cursor: pointer;
  flex: 1; min-width: 0;
  border-radius: 8px;
}
.me-names:hover .me-status { color: var(--accent); }
.me-status {
  font-size: 11.5px; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.me-status.empty { color: var(--text-dim); font-style: italic; }
#status-input {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px; outline: none;
}
#status-input:focus { border-color: var(--accent-deep); }
.status-history { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.status-history-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-dim); margin: 4px 0;
}
.status-prev {
  background: var(--ink-2); border: none; color: var(--text);
  text-align: left; border-radius: 8px;
  padding: 8px 12px; font-size: 13.5px; cursor: pointer;
}
.status-prev:hover { background: var(--ink-3); }
.status-actions { display: flex; justify-content: space-between; gap: 10px; }

/* e2ee */
.e2e-note { font-size: 13.5px; color: var(--text-dim); line-height: 1.5; }
.e2e-code {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: 17px; letter-spacing: .06em;
  text-align: center;
  color: var(--accent);
  background: var(--ink-0);
  border: 1px dashed var(--accent-deep);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
  user-select: all;
}
#e2e-setup, #e2e-unlock { display: flex; flex-direction: column; gap: 12px; }
#e2e-code-input {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none;
  font-family: ui-monospace, monospace;
  text-align: center;
}
#e2e-code-input:focus { border-color: var(--accent-deep); }
.msg .enc-locked { color: var(--text-dim); font-style: italic; }

/* sound menu */
.sound-menu {
  position: absolute;
  right: 14px; top: 58px;
  width: 300px;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
  padding: 12px 14px;
  z-index: 30;
  display: flex; flex-direction: column; gap: 10px;
  animation: pop-in .16s ease-out;
}
.sound-head { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.sound-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13.5px;
}
.sound-row span {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sound-row select {
  background: var(--ink-0);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
}
.sound-hint { font-size: 11.5px; color: var(--text-dim); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 9, 15, .72);
  display: grid; place-items: center;
  z-index: 50;
  animation: fade-in .15s;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  width: min(420px, calc(100vw - 32px));
  max-height: min(560px, 84dvh);
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  animation: card-in .25s ease-out;
}
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
}
.modal input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) { width: 100%; }
/* Tall modals scroll instead of squashing or spilling past the card edge. */
.modal { overflow-y: auto; }
.modal > * { flex-shrink: 0; }
.modal .user-results {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 240px;
  overflow-y: auto;
}
.modal .bot-list { max-height: 300px; }
.picked-users { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink-3);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px; border: none; color: var(--text);
}
.chip:hover { background: var(--danger); color: #1b0505; }
.user-results { flex: 1; overflow-y: auto; min-height: 120px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: none; color: inherit;
  padding: 8px; border-radius: 10px;
}
.user-row:hover { background: var(--ink-2); }
.user-row .avatar { width: 36px; height: 36px; font-size: 13px; }
.user-row .u-display { font-weight: 600; font-size: 14px; }
.user-row .u-name { font-size: 12px; color: var(--text-dim); }
.user-results .none { color: var(--text-dim); font-size: 13px; padding: 14px; text-align: center; }

/* rooms */
.room-row { gap: 12px; }
.room-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-meta .u-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-join {
  flex: none;
  font-size: 12.5px; font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent-deep);
  padding: 4px 12px; border-radius: 999px;
}
.room-create {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.room-visibility {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
  cursor: pointer;
}
.room-visibility input { accent-color: var(--accent); }

/* bots */
.bot-list { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.bot-list .none { color: var(--text-dim); font-size: 13px; padding: 10px 4px; }
.bot-list code, .bot-token { font-family: ui-monospace, monospace; }
.bot-row {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.bot-head { display: flex; align-items: center; gap: 10px; }
.bot-head .avatar { width: 34px; height: 34px; font-size: 13px; }
.bot-names { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bot-token {
  font-size: 11.5px;
  color: var(--accent);
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: copy;
  overflow-wrap: anywhere;
}
.bot-webhook {
  background: var(--ink-0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}
.bot-webhook:focus { border-color: var(--accent-deep); }

/* lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(5, 9, 15, .9);
  display: grid; place-items: center;
  z-index: 60; cursor: zoom-out;
  animation: fade-in .15s;
}
.lightbox img { max-width: 94vw; max-height: 92dvh; border-radius: 10px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink-3); color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 12px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: pop-in .2s;
}
.toast.error { border-color: var(--danger); color: #ffb3b3; }

/* ------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  .sidebar { width: 100%; border-right: none; }
  .app.chat-open .sidebar { display: none; }
  .main { display: none; }
  .app.chat-open .main { display: flex; }
  .icon-btn.back { display: inline-flex; }
  .messages { padding: 14px 12px 8px; }
  .msg { max-width: 84%; }
  .emoji-panel { left: 12px; right: 12px; width: auto; }
}
