:root {
  --bg: #0e1621;
  --panel: #17212b;
  --bubble: #2b5278;
  --text: #f5f5f5;
  --muted: #8ea1b3;
  --accent: #5288c1;
  --danger: #e06c75;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: #6ab3f3; }

.topbar {
  position: sticky; top: 0; z-index: 2; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid #0b1118;
}
.topbar form { margin: 0; }
.brand { font-weight: 600; font-size: 18px; }
.spacer { flex: 1; }

.btn {
  font: inherit; border: 0; border-radius: 8px; padding: 8px 14px;
  cursor: pointer; text-decoration: none; color: var(--text);
}
.btn-primary { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--danger); }

.flashes { flex: none; width: 100%; max-width: 720px; margin: 8px auto 0; padding: 0 12px; }
.flash { margin: 0 0 6px; padding: 8px 12px; border-radius: 8px; background: #3a2a2e; color: #ffd7dc; }

/* Landing page (anonymous /) */
.landing {
  display: flex; flex-direction: column; align-items: center;
  max-width: 760px; margin: 0 auto; padding: 48px 16px; text-align: center;
}
.landing-title { font-size: clamp(26px, 5vw, 36px); line-height: 1.2; margin: 0 0 12px; }
.landing-lead { color: var(--muted); font-size: 17px; max-width: 560px; margin: 0 auto 24px; }
.btn-cta {
  display: inline-block; padding: 12px 30px; border-radius: 999px;
  font-size: 17px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(82, 136, 193, 0.35);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn-cta:hover { background: #6497cf; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(82, 136, 193, 0.45); }
.btn-cta:active { transform: translateY(0); }
.btn-cta:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.features {
  list-style: none; padding: 0; margin: 36px 0 0; width: 100%; text-align: left;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px;
}
.features li {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid #22303e; border-radius: 12px; padding: 14px 16px;
}
.features strong { font-size: 15px; }
.features span { color: var(--muted); font-size: 14px; }
@media (prefers-reduced-motion: reduce) {
  .btn-cta { transition: none; }
}

/* Auth */
.auth { max-width: 360px; margin: 48px auto; padding: 0 16px; }
.auth h1, .auth h2 { font-size: 24px; margin: 0 0 16px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 14px; }
.auth-form input {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid #2a3a4a; border-radius: 8px; padding: 10px 12px;
}

/* Feed: full-height column; the feed scrolls, the composer is a normal flex item below it,
   so a growing textarea shrinks the feed instead of covering it. */
body.feed-page {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
}
.feed {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px max(12px, calc((100% - 720px) / 2));
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.feed-note { flex: none; align-self: center; margin: 0; font-size: 13px; color: var(--muted); }
a.feed-note { color: #6ab3f3; }
.empty { align-self: center; color: var(--muted); margin-top: 30vh; text-align: center; }

.msg {
  flex: none;
  max-width: min(85%, 560px);
  background: var(--bubble);
  border-radius: 14px 14px 4px 14px;
  padding: 8px 10px 6px;
  overflow-wrap: anywhere;
}
.msg-text { white-space: pre-wrap; }
.msg-image img { display: block; max-width: 100%; max-height: 60vh; border-radius: 10px; margin-bottom: 4px; }

.file-chip {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; padding: 4px 2px;
}
.file-icon { font-size: 28px; }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 500; }
.file-size { color: #b5c8db; font-size: 13px; }

.msg-foot {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px;
  margin-top: 6px; font-size: 12px; color: #b5c8db;
}
.msg-foot form { margin: 0; }
.msg-foot time { margin-left: 4px; }
.msg-btn {
  font: inherit; font-size: 13px; min-height: 32px; padding: 4px 12px;
  background: rgba(255, 255, 255, 0.08); border: 0; border-radius: 16px;
  color: #d8e4ef; cursor: pointer;
}
.msg-btn:hover, .msg-btn:focus-visible { background: rgba(255, 255, 255, 0.16); color: var(--text); }
.msg-btn-danger:hover, .msg-btn-danger:focus-visible { color: var(--danger); }

/* Composer */
.composer {
  flex: none;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px max(12px, calc((100% - 720px) / 2));
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid #0b1118;
}
.attach {
  position: relative; font-size: 24px; padding: 6px; cursor: pointer; line-height: 1;
}
.attach input {
  position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer;
}
.attach:focus-within { outline: 2px solid var(--accent); border-radius: 8px; }
.composer-main { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.file-chosen { font-size: 13px; color: #6ab3f3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid #2a3a4a; border-radius: 18px; padding: 8px 14px;
  resize: none; max-height: 40vh; width: 100%;
}
.send { border-radius: 18px; }
.composer.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }

