:root {
  --bg: #0c0d10;
  --panel: #131419;
  --panel-2: #191a21;
  --line: #24262f;
  --fg: #e8e9ed;
  --muted: #8b8f9e;
  --accent: #7dd3a0;
  --accent-dim: #2a4a39;
  --danger: #ff7b72;
  --radius: 12px;
}
html[data-theme="light"] {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-2: #f1f1ee;
  --line: #e2e2dc;
  --fg: #16171a;
  --muted: #6b6f7a;
  --accent: #157f4f;
  --accent-dim: #d7ece0;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand .mark { font-size: 22px; }
.brand strong { display: block; font-size: 14px; letter-spacing: .2px; }
.brand small { color: var(--muted); font-size: 11px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 10px; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-size: 13.5px; font-weight: 500;
}
nav a:hover { background: var(--panel-2); color: var(--fg); }
nav a.active { background: var(--accent-dim); color: var(--fg); }
nav a b { font-weight: 500; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
nav a b.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.lock-state { font-size: 11px; color: var(--muted); padding-left: 4px; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; gap: 10px; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); z-index: 5;
}
.search-wrap { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; }
.search-wrap svg { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-wrap input {
  width: 100%; padding: 9px 12px 9px 34px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  color: var(--fg); font-size: 13.5px; outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.view { padding: 26px 24px 80px; max-width: 900px; width: 100%; }

/* ---------- buttons ---------- */
.btn {
  background: var(--accent); color: #08130d; border: 0; border-radius: 8px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
html[data-theme="light"] .btn { color: #fff; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--fg); border-color: var(--muted); }
.btn.icon { padding: 8px 10px; }

/* ---------- headings ---------- */
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 15px; margin: 0 0 2px; }
.muted { color: var(--muted); font-size: 13px; }
.page-head { margin-bottom: 22px; }

/* ---------- message list ---------- */
.msgs { display: flex; flex-direction: column; gap: 10px; }
.msg {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.msg.out { background: var(--panel-2); }
.msg-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg-who { font-weight: 600; font-size: 13px; }
.msg-time { margin-left: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.msg-body { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-body em { color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  text-decoration: none;
}
.chip:hover { color: var(--fg); border-color: var(--accent); }
.chip.person { color: #9bc6ff; border-color: #26374d; }
.chip.project { color: #ffd08a; border-color: #4a3a22; }
.chip.topic { color: #c3a6ff; border-color: #362c4d; }
.pub-btn {
  margin-left: 6px; font-size: 10px; padding: 2px 7px; border-radius: 99px;
  background: transparent; border: 1px solid var(--line); color: var(--muted); cursor: pointer;
}
.pub-btn.on { background: var(--accent-dim); color: var(--fg); border-color: var(--accent); }

/* ---------- tag grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; text-decoration: none; color: inherit; display: block;
}
.card:hover { border-color: var(--accent); }
.card .kind { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.card .label { font-weight: 600; font-size: 14px; margin: 2px 0 3px; }

/* ---------- states ---------- */
.empty { color: var(--muted); font-size: 13.5px; padding: 40px 0; text-align: center; }
.locked {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 34px; text-align: center; background: var(--panel);
}
.locked h2 { margin-bottom: 6px; }
.skeleton { height: 64px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); opacity: .55; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; width: min(400px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px;
}
.modal-card h2 { font-size: 16px; }
.modal-card input {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font-size: 14px; outline: none;
}
.modal-card input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.err { color: var(--danger); font-size: 12px; min-height: 15px; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; overflow-x: auto; }
  .brand small, .side-foot .lock-state { display: none; }
  nav { flex-direction: row; }
  .side-foot { margin: 0; }
  .view { padding: 18px 14px 60px; }
}
