/* =========================================================
   Signalline — design tokens
   Palette:  bg #090D12 · panel #10161D · panel-alt #161D26
             line #202A35 · text #E7EDF3 · muted #6C7A8A
             signal (primary) #3E8EFF · relay (secondary) #B14EFF
             live (success) #37E6B0 · alert #FF5D7A
   Type:     system UI stack for body copy, system monospace stack
             for labels/timestamps/data — no font files are downloaded,
             which keeps the app's data footprint close to zero.
   Signature: the "signal bars" connection indicator + packet-style
             message bubbles (thin glowing rail = transmission direction).
   ========================================================= */

:root {
  --bg: #090d12;
  --panel: #10161d;
  --panel-alt: #161d26;
  --line: #202a35;
  --text: #e7edf3;
  --muted: #6c7a8a;
  --signal: #3e8eff;
  --signal-dim: #3e8eff33;
  --relay: #b14eff;
  --live: #37e6b0;
  --alert: #ff5d7a;

  --font-body: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --nav-h: 60px;
  --tabbar-h: 64px;
  --gap: clamp(12px, 2vw, 20px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: clamp(14px, 1.4vw + 8px, 16px);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* subtle ambient grid — pure CSS, no images, so it costs 0kb of data */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.15;
  mask-image: radial-gradient(ellipse at top, black, transparent 75%);
}

a { color: inherit; }
h1, h2, h3, p { margin: 0; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted { color: var(--muted); }

/* ---------- layout shell ---------- */

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

main.view {
  flex: 1;
  width: min(920px, 100%);
  margin: 0 auto;
  padding: calc(var(--gap) * 1.5) var(--gap) calc(var(--tabbar-h) + var(--gap));
}

@media (min-width: 700px) {
  main.view { padding-bottom: var(--gap); }
}

/* ---------- top nav ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gap);
  background: rgba(9, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  font-size: 15px;
}

/* signature element: animated signal-strength bars = connection status */
.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.signal-bars span {
  width: 3px;
  background: var(--line);
  border-radius: 1px;
  animation: pulse-bar 1.6s ease-in-out infinite;
}
.signal-bars span:nth-child(1) { height: 5px;  animation-delay: 0s;   }
.signal-bars span:nth-child(2) { height: 8px;  animation-delay: 0.15s;}
.signal-bars span:nth-child(3) { height: 11px; animation-delay: 0.3s; }
.signal-bars span:nth-child(4) { height: 14px; animation-delay: 0.45s;}
.signal-bars.online span { background: var(--live); }
.signal-bars.offline span { animation: none; background: var(--alert); height: 4px !important; }

@keyframes pulse-bar {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.nav-links {
  display: none;
  gap: 4px;
}
.nav-links a {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-links a:hover { color: var(--text); background: var(--panel-alt); }
.nav-links a.active { color: var(--signal); background: var(--signal-dim); }

.nav-user {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  display: none;
  align-items: center;
  gap: 10px;
}

@media (min-width: 700px) {
  .nav-links { display: flex; }
  .nav-user { display: flex; }
}

/* ---------- bottom tab bar (mobile) ---------- */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  height: var(--tabbar-h);
  display: flex;
  background: rgba(16, 22, 29, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.tabbar a.active { color: var(--signal); }
.tabbar svg { width: 20px; height: 20px; }

@media (min-width: 700px) {
  .tabbar { display: none; }
}

/* ---------- cards / panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

/* ---------- forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field textarea {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field textarea:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
.btn-primary { background: var(--signal); color: #04101f; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--signal); }
.btn-block { width: 100%; }

.form-error {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--alert);
  min-height: 16px;
}

.auth-card {
  max-width: 400px;
  margin: 6vh auto 0;
  padding: 28px;
}
.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}
.auth-switch a { color: var(--signal); text-decoration: none; }

/* ---------- search / index page ---------- */

.hero {
  padding: clamp(24px, 6vw, 56px) 0 clamp(16px, 4vw, 28px);
  text-align: center;
}
.hero h1 {
  font-family: var(--font-mono);
  font-size: clamp(24px, 5vw, 38px);
  letter-spacing: -0.01em;
  margin: 10px 0 8px;
}
.hero p { color: var(--muted); font-size: clamp(13px, 2vw, 15px); }

.search-box {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}
.search-box input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.search-box input:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-dim);
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.result-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 14px 16px;
  border-left: 2px solid var(--signal);
}
.result-item:hover { background: var(--panel-alt); }
.result-item .source {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--signal);
}
.result-item p { margin-top: 6px; font-size: 14px; color: var(--text); }
.result-item mark { background: var(--signal-dim); color: var(--signal); padding: 0 2px; border-radius: 2px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.quicklinks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 32px;
}
.quicklinks a {
  text-decoration: none;
  color: var(--text);
  padding: 16px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.quicklinks a:hover { border-color: var(--signal); }

/* ---------- chats ---------- */

.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  height: calc(100dvh - var(--nav-h) - var(--tabbar-h) - (var(--gap) * 3));
}
@media (min-width: 800px) {
  .chat-layout {
    grid-template-columns: 280px 1fr;
    height: calc(100dvh - var(--nav-h) - (var(--gap) * 3));
  }
}

.conversation-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.conversation-list.mobile-hidden { display: none; }
@media (min-width: 800px) {
  .conversation-list.mobile-hidden { display: flex; }
}

.conversation-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: transparent;
  border-left: 2px solid transparent;
}
.conversation-item:hover { background: var(--panel-alt); }
.conversation-item.active { border-left-color: var(--signal); background: var(--panel-alt); }
.conversation-item .name { font-weight: 600; font-size: 14px; }
.conversation-item .preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.new-dm {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.new-dm input {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.thread {
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.thread.mobile-active { display: flex; }
@media (min-width: 800px) {
  .thread { display: flex; }
}

.thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 13px;
}
.thread-header .back-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}
@media (min-width: 800px) {
  .thread-header .back-btn { display: none; }
}

.thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* signature: message bubbles as glowing "packets" — the left rail
   colour + alignment tells you the transmission direction at a glance */
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-left: 2px solid var(--line);
  background: var(--panel-alt);
  border-radius: 4px 10px 10px 4px;
  align-self: flex-start;
}
.msg.mine {
  align-self: flex-end;
  border-left: none;
  border-right: 2px solid var(--signal);
  border-radius: 10px 4px 4px 10px;
  background: #14202e;
}
.msg .meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  gap: 8px;
}
.msg img, .msg video {
  max-width: 100%;
  border-radius: 6px;
  display: block;
  margin-top: 4px;
}
.msg .media-expired {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--alert);
  padding: 8px;
  border: 1px dashed var(--alert);
  border-radius: 6px;
}

.typing-indicator {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  height: 16px;
  padding: 0 16px;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.composer input[type="text"] {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.composer input[type="text"]:focus { border-color: var(--signal); }
.composer .icon-btn {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.composer .icon-btn.send { background: var(--signal); color: #04101f; border: none; }

.media-note {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 0;
}

/* ---------- updates ---------- */

.update-item {
  padding: 18px;
  margin-bottom: 12px;
}
.update-item h3 { font-size: 16px; margin-bottom: 6px; }
.update-item time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.update-item p { margin-top: 8px; font-size: 14px; color: var(--text); }

/* ---------- info page ---------- */

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 20px;
}
@media (min-width: 640px) {
  .info-grid { grid-template-columns: 1fr 1fr; }
}
.info-card h3 {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--signal);
  margin-bottom: 8px;
}
.info-card p { font-size: 14px; color: var(--muted); }

/* ---------- gate screen (shown when a logged-out visitor hits chats/updates) ---------- */

.gate {
  max-width: 420px;
  margin: 10vh auto;
  text-align: center;
  padding: 32px 24px;
}
.gate .signal-bars { margin: 0 auto 16px; justify-content: center; }
.gate h2 { font-family: var(--font-mono); font-size: 20px; margin-bottom: 8px; }
.gate p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.gate .actions { display: flex; gap: 10px; justify-content: center; }

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

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
