/* ============================================================
   Chirp — design tokens
   ============================================================ */
:root {
  --brand: #1d9bf0;
  --brand-hover: #1a8cd8;
  --like: #f91880;
  --repost: #00ba7c;
  --bookmark: #1d9bf0;
  --bg: #000000;
  --bg-elev: #16181c;
  --surface: #16181c;
  --surface-2: #1e2027;
  --border: #2f3336;
  --border-soft: #23262b;
  --text: #e7e9ea;
  --text-dim: #71767b;
  --text-faint: #536471;
  --accent-wash: rgba(29, 155, 240, 0.1);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  --radius: 16px;
  --nav-w: 275px;
  --rail-w: 350px;
  --main-w: 600px;
}
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --surface: #f7f9f9;
  --surface-2: #eff3f4;
  --border: #eff3f4;
  --border-soft: #e6ecf0;
  --text: #0f1419;
  --text-dim: #536471;
  --text-faint: #5b7083;
  --accent-wash: rgba(29, 155, 240, 0.08);
  --shadow: 0 8px 28px rgba(15, 20, 25, 0.14);
}

* { 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, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(29, 155, 240, 0.35); }

/* layout ---------------------------------------------------- */
#app { min-height: 100%; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, var(--nav-w)) minmax(0, var(--main-w)) minmax(0, var(--rail-w));
  justify-content: center;
  gap: 0;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 12px;
}
.main { min-height: 100vh; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }

/* nav ------------------------------------------------------- */
.nav { position: sticky; top: 0; height: 100vh; }
.nav-inner {
  display: flex; flex-direction: column; gap: 4px;
  height: 100%; padding: 10px 12px; align-items: flex-start;
}
.brand {
  display: inline-flex; align-items: center; justify-content: center;
  width: 50px; height: 50px; border-radius: 50%;
  color: var(--text); transition: background .15s;
}
.brand:hover { background: var(--surface-2); }
.nav-links { display: flex; flex-direction: column; gap: 2px; width: 100%; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  padding: 11px 14px; border-radius: 999px;
  font-size: 19px; font-weight: 500; color: var(--text);
  background: none; border: 0; cursor: pointer; width: max-content;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item .ic { display: inline-flex; width: 26px; height: 26px; }
.nav-item .ic svg { width: 26px; height: 26px; fill: currentColor; }
.nav-item.active { font-weight: 800; }
.nav-item.active .ic svg { fill: var(--text); }
.nav-item.active .nav-badge { background: var(--brand); color: #fff; }
.nav-label { display: inline; }
.nav-badge {
  margin-left: 6px; min-width: 20px; padding: 0 6px; height: 20px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-post { width: 100%; max-width: 232px; margin-top: 14px; padding: 15px; font-size: 17px; }
.me-chip {
  margin-top: auto; display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 999px; background: none; border: 0; cursor: pointer;
  transition: background .15s; text-align: left;
}
.me-chip:hover { background: var(--surface-2); }
.me-chip-meta { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.me-chip-meta strong { font-size: 15px; }
.me-chip-meta small { color: var(--text-dim); font-size: 14px; }
.me-chip-dots { margin-left: auto; color: var(--text-dim); }

/* avatars --------------------------------------------------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff; overflow: hidden;
  background: linear-gradient(135deg, #667eea, #764ba2);
  user-select: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; border: 4px solid var(--bg); }

/* buttons --------------------------------------------------- */
.btn {
  border: 0; border-radius: 999px; cursor: pointer; font-weight: 700;
  padding: 9px 18px; background: var(--surface-2); color: var(--text);
  transition: filter .15s, background .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); filter: none; }
.btn-outline { background: transparent; border: 1px solid var(--border); }
.btn-outline:hover { background: var(--accent-wash); }
.btn-follow.on { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-follow.on:hover { border-color: #f4212e; color: #f4212e; background: rgba(244,33,46,.08); }
.btn-follow.on:hover .lbl-follow { display: none; }
.btn-follow.on .lbl-unfollow { display: none; }
.btn-follow.on:hover .lbl-unfollow { display: inline; }
.icon-btn {
  background: none; border: 0; cursor: pointer; color: var(--text);
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 16px;
  transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }

/* main header ----------------------------------------------- */
.col-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.col-head-row { display: flex; align-items: center; gap: 22px; padding: 12px 16px; min-height: 53px; }
.col-head h1 { font-size: 20px; font-weight: 800; margin: 0; }
.col-head .sub { font-size: 13px; color: var(--text-dim); margin: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; background: none; border: 0; cursor: pointer; padding: 16px 0;
  font-weight: 600; color: var(--text-dim); position: relative; transition: background .15s;
}
.tab:hover { background: var(--surface-2); }
.tab.active { color: var(--text); font-weight: 800; }
.tab.active::after {
  content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 56px; height: 4px; border-radius: 999px; background: var(--brand);
}

/* composer -------------------------------------------------- */
.composer { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.composer-body { flex: 1; min-width: 0; }
.composer textarea {
  width: 100%; background: none; border: 0; outline: none; resize: none;
  font-size: 20px; line-height: 1.4; padding: 10px 0; min-height: 52px; color: var(--text);
  font-family: inherit;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer-bar {
  display: flex; align-items: center; gap: 4px;
  border-top: 1px solid var(--border-soft); padding-top: 10px; margin-top: 4px;
}
.composer-bar .spacer { flex: 1; }
.tool {
  background: none; border: 0; cursor: pointer; color: var(--brand);
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; transition: background .15s;
}
.tool:hover { background: var(--accent-wash); }
.tool svg { width: 19px; height: 19px; fill: currentColor; }
.tool[disabled] { color: var(--text-faint); cursor: default; }
.tool[disabled]:hover { background: none; }
.char-ring { width: 26px; height: 26px; margin: 0 8px; }
.char-ring circle { fill: none; stroke-width: 2.5; }
.reply-hint { font-size: 14px; color: var(--text-dim); padding: 6px 0 2px; }

/* tweet card ------------------------------------------------ */
.tweet {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .12s; position: relative;
}
.tweet:hover { background: color-mix(in srgb, var(--bg) 94%, var(--text)); }
.tweet.expanded { cursor: default; }
.tweet-body { flex: 1; min-width: 0; }
.tweet-head { display: flex; align-items: baseline; gap: 4px; font-size: 15px; flex-wrap: wrap; }
.tweet-head .dn { font-weight: 700; color: var(--text); }
.tweet-head .dn:hover { text-decoration: underline; }
.tweet-head .hd, .tweet-head .dot, .tweet-head .ts { color: var(--text-dim); font-size: 15px; }
.tweet-head .spacer { flex: 1; }
.tweet-menu { opacity: 0; color: var(--text-dim); transition: opacity .12s; }
.tweet:hover .tweet-menu { opacity: 1; }
.tweet-text { margin: 2px 0 0; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tweet-text .tag, .tweet-text .mention { color: var(--brand); }
.tweet-text .tag:hover, .tweet-text .mention:hover { text-decoration: underline; }
.reply-context { color: var(--text-dim); font-size: 14px; margin: 0 0 2px; }
.reply-context a { color: var(--brand); }

.tweet-actions { display: flex; align-items: center; max-width: 480px; margin-top: 8px; margin-left: -6px; }
.act {
  display: inline-flex; align-items: center; gap: 5px; background: none; border: 0;
  cursor: pointer; color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums;
  padding: 6px 8px; border-radius: 999px; transition: color .15s, background .15s;
}
.act svg { width: 18px; height: 18px; fill: currentColor; }
.act .cnt { min-width: 8px; }
.act.reply:hover { color: var(--brand); background: var(--accent-wash); }
.act.repost:hover, .act.repost.on { color: var(--repost); background: rgba(0,186,124,.1); }
.act.like:hover, .act.like.on { color: var(--like); background: rgba(249,24,128,.1); }
.act.bookmark:hover, .act.bookmark.on { color: var(--bookmark); background: var(--accent-wash); }
.act.share:hover { color: var(--brand); background: var(--accent-wash); }
.act .spacer { flex: 1; }
.act-wrap { display: flex; flex: 1; }
.act-wrap:nth-child(1) { flex: 0 0 auto; }
.like.pop svg { animation: pop .32s ease; }
@keyframes pop { 0% { transform: scale(.6); } 55% { transform: scale(1.28); } 100% { transform: scale(1); } }

/* profile --------------------------------------------------- */
.banner { height: 200px; background: linear-gradient(120deg, #1d9bf0, #7856ff 55%, #f91880); }
.profile-head { padding: 12px 16px 16px; border-bottom: 1px solid var(--border); }
.profile-top { display: flex; justify-content: space-between; align-items: flex-start; margin-top: -68px; }
.profile-meta { margin-top: 12px; }
.profile-meta h2 { margin: 0; font-size: 21px; font-weight: 800; }
.profile-meta .handle { color: var(--text-dim); }
.profile-bio { margin: 12px 0 0; }
.profile-facts { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; color: var(--text-dim); font-size: 14px; }
.profile-facts b { color: var(--text); }
.profile-follow { display: flex; gap: 20px; margin-top: 12px; font-size: 14px; color: var(--text-dim); }
.profile-follow b { color: var(--text); }

/* rail ------------------------------------------------------ */
.rail { padding: 10px 0 40px 24px; }
.rail-sticky { position: sticky; top: 10px; display: flex; flex-direction: column; gap: 16px; }
.search-box { position: relative; }
.search-box svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; fill: var(--text-dim); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 12px 16px 12px 44px; border-radius: 999px;
  background: var(--surface); border: 1px solid transparent; outline: none;
}
.search-box input:focus { border-color: var(--brand); background: var(--bg); }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.card h3 { margin: 0; padding: 14px 16px 6px; font-size: 19px; font-weight: 800; }
.card-sub { padding: 0 16px 10px; color: var(--text-dim); font-size: 13px; }
.trend { display: block; padding: 11px 16px; cursor: pointer; transition: background .12s; }
.trend:hover { background: var(--surface-2); }
.trend .cat, .trend .cnt { color: var(--text-dim); font-size: 13px; }
.trend .topic { font-weight: 700; margin: 2px 0; }
.who { display: flex; align-items: center; gap: 10px; padding: 11px 16px; transition: background .12s; }
.who:hover { background: var(--surface-2); }
.who .meta { flex: 1; min-width: 0; line-height: 1.25; }
.who .meta strong { display: block; font-size: 15px; }
.who .meta strong:hover { text-decoration: underline; }
.who .meta small { color: var(--text-dim); }
.card-link { display: block; padding: 15px 16px; color: var(--brand); cursor: pointer; }
.card-link:hover { background: var(--surface-2); }
.rail-footer { color: var(--text-dim); font-size: 13px; padding: 0 4px; line-height: 1.7; }

/* modal ----------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(91,112,131,.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px; backdrop-filter: blur(3px); animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 600px; background: var(--bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; animation: rise .2s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.modal-title { margin: 0; font-size: 18px; font-weight: 800; }

/* search results -------------------------------------------- */
.result-row { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.result-row:hover { background: var(--surface-2); }
.result-row .meta { line-height: 1.3; }
.result-row .meta small { color: var(--text-dim); display: block; }

/* misc ------------------------------------------------------ */
.empty { padding: 40px 24px; text-align: center; color: var(--text-dim); }
.empty h3 { color: var(--text); margin: 0 0 6px; }
.section-label { padding: 14px 16px; font-weight: 800; font-size: 18px; border-bottom: 1px solid var(--border); }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s;
}
.list-row:hover { background: var(--surface-2); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow small { color: var(--text-dim); display: block; }
.list-row .grow p { margin: 3px 0 0; color: var(--text-dim); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: 0 0 auto; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.back-link:hover { color: var(--brand); }

/* toasts ---------------------------------------------------- */
.toast-stack { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-weight: 600; box-shadow: var(--shadow); animation: rise .2s ease;
}

/* mobile ---------------------------------------------------- */
.mobile-bar { display: none; }
@media (max-width: 1080px) {
  .layout { grid-template-columns: 88px minmax(0, var(--main-w)) minmax(0, var(--rail-w)); }
  .nav-label, .me-chip-meta, .me-chip-dots { display: none; }
  .nav-item { padding: 12px; justify-content: center; }
  .btn-post { width: 52px; height: 52px; padding: 0; font-size: 0; margin: 14px auto 0; }
  .btn-post::after { content: "+"; font-size: 26px; font-weight: 400; }
  .me-chip { justify-content: center; }
  .rail { padding-left: 16px; }
}
@media (max-width: 900px) {
  .rail { display: none; }
  .layout { grid-template-columns: 88px minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; padding: 0; }
  .nav { display: none; }
  .main { border: 0; padding-bottom: 68px; }
  .mobile-bar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-bar button {
    flex: 1; background: none; border: 0; padding: 8px 0; cursor: pointer;
    color: var(--text-dim); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px;
  }
  .mobile-bar button svg { width: 24px; height: 24px; fill: currentColor; }
  .mobile-bar button.active { color: var(--brand); }
  .banner { height: 130px; }
}
