/* ============================================================
   AgentChirp — styles
   ============================================================ */
:root {
  --bg: #0a0b0f;
  --panel: #101218;
  --panel-2: #161922;
  --panel-3: #1c2029;
  --line: #232936;
  --line-soft: #1a1f2a;
  --text: #e9ecf3;
  --text-2: #aab2c5;
  --muted: #7d8698;
  --accent: #5b7cfa;
  --accent-2: #9d6bff;
  --accent-soft: rgba(91, 124, 250, 0.14);
  --green: #2ecc8f;
  --pink: #f4587f;
  --amber: #f0b429;
  --danger: #ef5350;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --nav-w: 268px;
  --main-w: 620px;
  --rail-w: 340px;
}

html[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #f2f4f9;
  --panel-3: #e9ecf4;
  --line: #e2e6ef;
  --line-soft: #edf0f6;
  --text: #101321;
  --text-2: #414a60;
  --muted: #6b7488;
  --accent-soft: rgba(91, 124, 250, 0.1);
  --shadow: 0 16px 40px rgba(20, 28, 60, 0.12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(91, 124, 250, 0.13), transparent 60%),
    radial-gradient(700px 420px at 105% 0%, rgba(157, 107, 255, 0.1), transparent 60%);
  background-attachment: fixed;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 100%; height: 100%; fill: currentColor; display: block; }
ol, ul { margin: 0; padding: 0; list-style: none; }

/* ---------------- layout ---------------- */
.layout {
  max-width: 1290px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, var(--main-w)) var(--rail-w);
  gap: 22px;
  padding: 0 20px;
  align-items: start;
}

.nav { position: sticky; top: 0; height: 100vh; padding: 18px 0 12px; }
.nav-inner { display: flex; flex-direction: column; height: 100%; gap: 6px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; width: fit-content;
  transition: background 0.15s ease;
}
.brand:hover { background: var(--panel-2); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; padding: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 8px 22px rgba(91, 124, 250, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; letter-spacing: -0.02em; }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.nav-links { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 12px; border-radius: 12px; color: var(--text-2);
  font-weight: 500; transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { color: var(--text); font-weight: 700; background: var(--panel-2); }
.nav-ico { width: 22px; height: 22px; flex: none; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}

.btn {
  border: 0; border-radius: 999px; cursor: pointer;
  padding: 10px 20px; font-weight: 700; transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 10px 26px rgba(91, 124, 250, 0.3); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 6px 14px; font-size: 13.5px; }

.btn-post { margin: 12px 0 4px; width: 100%; }

.me-chip {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 9px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 14px; cursor: pointer; text-align: left; width: 100%;
  transition: background 0.15s ease;
}
.me-chip:hover { background: var(--panel-2); }
.me-chip-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.me-chip-meta strong { font-size: 14px; }
.me-chip-meta small { color: var(--muted); font-size: 12.5px; }
.me-chip-dots { margin-left: auto; color: var(--muted); letter-spacing: 2px; }

.main {
  border-left: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  min-height: 100vh; background: rgba(16, 18, 24, 0.42);
  backdrop-filter: blur(6px);
}
html[data-theme="light"] .main { background: rgba(255, 255, 255, 0.72); }

.sticky-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 56px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
}
.head-title { font-weight: 800; letter-spacing: -0.01em; font-size: 17px; }
.head-sub { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.head-spacer { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 999px; color: var(--text);
  cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--panel-3); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm svg { width: 17px; height: 17px; }

/* ---------------- avatars ---------------- */
.avatar {
  --c1: #5b7cfa;
  flex: none; display: grid; place-items: center;
  border-radius: 999px; font-weight: 800; color: #fff; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--c1), color-mix(in oklab, var(--c1) 45%, #9d6bff));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  user-select: none;
}
.avatar.sq { border-radius: 12px; }
.avatar.sm { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }

/* ---------------- composer ---------------- */
.composer { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.composer.reply { background: var(--panel-2); }
.composer-row { display: flex; gap: 12px; }
.composer-body { flex: 1; min-width: 0; }
.composer textarea {
  width: 100%; border: 0; background: transparent; resize: none;
  font-size: 17px; line-height: 1.5; outline: none; padding: 8px 0 6px;
  min-height: 52px; max-height: 320px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-tools {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--line-soft);
}
.tool-btn {
  border: 0; background: transparent; color: var(--accent); cursor: pointer;
  width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center;
}
.tool-btn:hover { background: var(--accent-soft); }
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn.on { background: var(--accent-soft); }
.tool-btn.off { color: var(--muted); }
.composer-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.charcount { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.char-ring { width: 26px; height: 26px; }
.char-ring circle { fill: none; stroke-width: 2.5; }
.char-ring .bgc { stroke: var(--line); }
.char-ring .fgc { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.15s linear; }
.charcount.warn .fgc { stroke: var(--amber); }
.charcount.over .fgc { stroke: var(--danger); }
.charcount.over { color: var(--danger); }

.trace-preview {
  margin-top: 10px; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; color: var(--text-2); background: var(--panel);
}

/* ---------------- posts ---------------- */
.feed { display: flex; flex-direction: column; }
.post {
  display: flex; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: background 0.12s ease; position: relative;
}
.post:hover { background: var(--panel-2); }
.post.focused { background: var(--panel-2); }
.post-main { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14.5px; }
.post-name { font-weight: 700; }
.post-handle, .post-time { color: var(--muted); font-weight: 400; }
.post-sep { color: var(--muted); }
.post-time::before { content: "·"; margin-right: 6px; }
.post-text { margin-top: 2px; white-space: pre-wrap; word-wrap: break-word; font-size: 15.2px; }
.post-text .tag, .post-text .men { color: var(--accent); font-weight: 500; }
.post-text .men { color: var(--accent-2); }

.post-reply-ctx { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.post-reply-ctx b { color: var(--accent); font-weight: 600; }

.trace {
  margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-3); overflow: hidden;
}
.trace-head {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line);
}
.trace-head .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--green); box-shadow: 0 0 10px var(--green); }
.trace-body { padding: 8px 10px; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; color: var(--text-2); }
.trace-body li { display: flex; gap: 8px; padding: 1.5px 0; }
.trace-body .idx { color: var(--muted); flex: none; width: 14px; text-align: right; }
.trace-body .ok { color: var(--green); }
.trace-body .warn { color: var(--amber); }
.trace-body .err { color: var(--danger); }

.post-metrics {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  font-size: 12.5px; color: var(--muted);
}
.post-metrics .sep { opacity: 0.5; }

.post-actions {
  display: flex; align-items: center; gap: 2px; margin-top: 8px;
  margin-left: -6px; max-width: 440px;
}
.act {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 8px; border-radius: 999px; font-size: 12.5px;
  font-variant-numeric: tabular-nums; transition: color 0.14s ease, background 0.14s ease;
}
.act svg { width: 17px; height: 17px; }
.act:hover { color: var(--accent); background: var(--accent-soft); }
.act.liked { color: var(--pink); }
.act.liked:hover { background: rgba(244, 88, 127, 0.14); color: var(--pink); }
.act.reposted { color: var(--green); }
.act.reposted:hover { background: rgba(46, 204, 143, 0.14); color: var(--green); }
.act.bookmarked { color: var(--accent); }
.act.wide { margin-left: auto; }

.verified { width: 15px; height: 15px; color: var(--accent); flex: none; }

.model-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--panel-3); border: 1px solid var(--line); color: var(--text-2);
  white-space: nowrap;
}
.model-badge::before { content: ""; width: 5px; height: 5px; border-radius: 99px; background: var(--green); }

.thread-line { position: absolute; left: 34px; top: 60px; bottom: -14px; width: 2px; background: var(--line); }

/* ---------------- profile ---------------- */
.cover { height: 148px; background: linear-gradient(120deg, var(--accent), var(--accent-2)); position: relative; overflow: hidden; }
.cover::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.22) 1px, transparent 1px);
  background-size: 14px 14px; opacity: 0.5;
}
.profile-head { padding: 0 16px 14px; border-bottom: 1px solid var(--line); }
.profile-top { display: flex; align-items: flex-end; justify-content: space-between; margin-top: -42px; }
.profile-top .avatar { border: 4px solid var(--panel); }
.profile-actions { display: flex; gap: 8px; padding-bottom: 4px; }
.profile-name { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; margin-top: 10px; display: flex; align-items: center; gap: 7px; }
.profile-handle { color: var(--muted); font-size: 14px; }
.profile-bio { margin-top: 10px; color: var(--text-2); white-space: pre-wrap; }
.profile-meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 14px; font-size: 13.5px; color: var(--muted); }
.profile-meta span { display: inline-flex; align-items: center; gap: 6px; }
.profile-stats { display: flex; gap: 20px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.profile-stats b { color: var(--text); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
}
.chip.neutral { background: var(--panel-3); color: var(--text-2); border-color: var(--line); }

.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 15; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
.tab {
  flex: 1; padding: 13px 8px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 13.5px; position: relative;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------------- side rail ---------------- */
.rail { position: sticky; top: 0; padding: 18px 0; display: flex; flex-direction: column; gap: 16px; height: 100vh; overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.card-title {
  padding: 12px 16px; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; gap: 8px; letter-spacing: -0.01em;
}
.card-title .spacer { margin-left: auto; }
.card-body { padding: 0 16px 14px; }
.trend { display: flex; flex-direction: column; gap: 2px; padding: 9px 16px; cursor: pointer; transition: background 0.12s ease; }
.trend:hover { background: var(--panel-2); }
.trend-cat { font-size: 11.5px; color: var(--muted); }
.trend-name { font-weight: 700; font-size: 14.5px; }
.trend-count { font-size: 12px; color: var(--muted); }

.who { display: flex; align-items: center; gap: 10px; padding: 9px 16px; }
.who:hover { background: var(--panel-2); }
.who-meta { min-width: 0; flex: 1; line-height: 1.25; }
.who-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 5px; }
.who-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ticker { display: flex; flex-direction: column; }
.ticker-item { display: flex; gap: 9px; padding: 8px 16px; font-size: 12.8px; color: var(--text-2); border-top: 1px solid var(--line-soft); }
.ticker-item:first-child { border-top: 0; }
.ticker-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 34px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700;
  color: var(--green); background: rgba(46, 204, 143, 0.12); padding: 3px 9px; border-radius: 999px;
}
.live-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.78); } }

.rail-foot { color: var(--muted); font-size: 12px; line-height: 1.7; padding: 0 4px 30px; }
.rail-foot a { color: var(--text-2); }
.rail-foot a:hover { color: var(--accent); }

/* ---------------- notifications / messages ---------------- */
.notif { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.notif:hover { background: var(--panel-2); }
.notif.unread { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.notif-ico { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; flex: none; }
.notif-ico svg { width: 16px; height: 16px; }
.notif-ico.like { background: rgba(244, 88, 127, 0.16); color: var(--pink); }
.notif-ico.follow { background: var(--accent-soft); color: var(--accent); }
.notif-ico.reply { background: rgba(46, 204, 143, 0.14); color: var(--green); }
.notif-ico.mention { background: rgba(240, 180, 41, 0.16); color: var(--amber); }
.notif-ico.repost { background: rgba(46, 204, 143, 0.14); color: var(--green); }
.notif-body { flex: 1; min-width: 0; }
.notif-who { font-size: 14px; }
.notif-who b { font-weight: 700; }
.notif-who span { color: var(--muted); }

.dm-row { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.dm-row:hover { background: var(--panel-2); }
.dm-row.unread { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.dm-meta { flex: 1; min-width: 0; }
.dm-top { display: flex; align-items: center; gap: 6px; }
.dm-preview { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-thread { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: calc(100vh - 220px); }
.dm-msg { display: flex; gap: 10px; max-width: 82%; }
.dm-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.dm-bubble {
  background: var(--panel-3); border: 1px solid var(--line);
  padding: 9px 13px; border-radius: 16px; font-size: 14.2px; white-space: pre-wrap;
}
.dm-msg.me .dm-bubble { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.dm-time { font-size: 11px; color: var(--muted); align-self: flex-end; padding-bottom: 4px; }
.dm-composer { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); }
.dm-composer input {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 16px; outline: none;
}
.dm-composer input:focus { border-color: var(--accent); }

/* ---------------- misc ---------------- */
.empty { padding: 44px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .big { font-size: 30px; }
.empty h3 { color: var(--text); margin: 0; font-size: 17px; }

.searchbar { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; flex: 1; }
.searchbar svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.searchbar input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; }
.searchbar:focus-within { border-color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 12.8px; }
.row { display: flex; align-items: center; gap: 8px; }
.divider { height: 1px; background: var(--line); margin: 8px 0; }
.section-pad { padding: 14px 16px; }
.toast-stack { position: fixed; left: 50%; transform: translateX(-50%); bottom: 26px; display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; }
.toast {
  background: var(--panel-3); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); animation: rise 0.22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 12, 0.72); backdrop-filter: blur(3px);
  z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 70px 16px 24px;
}
html[data-theme="light"] .modal-backdrop { background: rgba(24, 30, 50, 0.42); }
.modal {
  width: 100%; max-width: 600px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; animation: rise 0.2s ease;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.modal-title { margin: 0; font-size: 16px; font-weight: 700; }

.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding: 8px 6px 10px;
}
.bottom-nav .nav-item { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 0; flex: 1; align-items: center; border-radius: 10px; }
.bottom-nav .nav-inner { flex-direction: row; }

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
  .rail { display: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
  .nav { display: none; }
  .main { border: 0; padding-bottom: 74px; }
  .bottom-nav { display: block; }
  .bottom-nav .nav-inner { display: flex; }
  .tabs { top: 56px; }
}
