/* ============================================================
   Discover demo. The tokens and the shell come from articles, app-builder and
   group-structure, which measured them on welley.social (theme-navy). The search
   popup and the rail follow web-apps/packages/search and apps/host/left-panel.
   ============================================================ */
:root {
  --bg-main: #f1f3f6;
  --bg-primary: #ffffff;
  --bg-secondary: #f1f3f6;
  --bg-secondary-hover: #e4e7ed;
  --bg-tertiary: #f8f9fb;
  --brand: #2259f0;
  --brand-hover: #1c4ace;
  --brand-soft: #ecf0fe;
  --badge-bg: #d9e2fd;
  --badge-text: #13318c;
  --t1: #1d2236;
  --t2: #434c63;
  --t3: #7b859e;
  --t4: #a5adc0;
  --border: #e4e7ed;
  --border-strong: #cfd4de;
  --r-sm: 8px;
  --r-m: 12px;
  --r-lg: 16px;
  --shadow-pop: 0 8px 28px rgba(29, 34, 54, 0.16);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg-main);
  color: var(--t1);
  font-size: 14px;
  line-height: 20px;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; text-align: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; flex-shrink: 0; }
.spacer { flex: 1; }
.muted { color: var(--t3); }
.dot-sep { color: var(--t4); }
mark { background: none; color: var(--brand); font-weight: 600; }

/* ---------- demo bar and address bar (scaffolding) ---------- */
.demo-bar {
  flex: 0 0 auto; min-height: 52px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 8px 16px; border-bottom: 1px dashed var(--border-strong);
}
.demo-brand { display: flex; align-items: center; gap: 10px; }
.brand-title { font-weight: 600; font-size: 15px; }
.brand-tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--t3); background: var(--bg-secondary-hover); padding: 2px 8px; border-radius: 999px;
}
.demo-controls { display: flex; align-items: center; gap: 12px; }
.seg { display: inline-flex; align-items: center; background: var(--bg-secondary-hover); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  height: 28px; padding: 0 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--t2);
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button.on { background: var(--bg-primary); color: var(--t1); box-shadow: 0 1px 2px rgba(29, 34, 54, .1); }
.seg-label { font-size: 12px; color: var(--t3); padding: 0 6px 0 4px; }

.address {
  flex: 0 0 auto; height: 34px; margin: 10px 16px 0;
  display: flex; align-items: center; gap: 6px; padding: 0 14px;
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; color: var(--t3); overflow: hidden; white-space: nowrap;
}
.addr-url { color: var(--t2); overflow: hidden; text-overflow: ellipsis; }
.addr-host { color: var(--t1); font-weight: 500; }

/* ---------- avatars ---------- */
.av, .gav {
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
}
.av { border-radius: 50%; }
.gav { border-radius: var(--r-m); }
.av.xs { width: 18px; height: 18px; font-size: 9px; }
.av.lg, .gav.lg { width: 56px; height: 56px; font-size: 19px; }
.gav.lg { border-radius: var(--r-lg); }
.av.xl, .gav.xl { width: 72px; height: 72px; font-size: 24px; }
.gav.xl { border-radius: 20px; }

/* ---------- product chrome ---------- */
.app { flex: 1 1 auto; min-height: 0; display: flex; gap: 16px; padding: 16px; }

/* The rail: a fixed top block, then the groups, then the avatar pinned to the bottom. */
.rail {
  flex: 0 0 64px; background: var(--bg-primary); border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 0;
}
.rail-logo { margin-bottom: 4px; }
.rail-btn {
  width: 40px; height: 40px; border-radius: var(--r-m); flex: none;
  display: grid; place-items: center; color: var(--t3);
}
.rail-btn:hover { background: var(--bg-secondary); }
.rail-btn.active { background: var(--bg-secondary); color: var(--t1); }
.rail-sep { width: 40px; height: 1px; background: var(--border); flex: none; }
.rail-groups {
  flex: 1 1 auto; min-height: 0; width: 100%; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 2px;
}
.rail-group { width: 40px; height: 40px; border-radius: var(--r-m); flex: none; color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.rail-group.active { box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--brand); }
.rail-more {
  width: 40px; height: 24px; flex: none; border-radius: 999px;
  background: var(--bg-secondary); color: var(--t2); font-size: 12px; font-weight: 700; text-align: center;
}
.rail-more:hover { background: var(--bg-secondary-hover); }
.rail-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.rail-signin { width: 40px; height: 40px; border-radius: var(--r-m); flex: none; background: var(--brand); color: #fff; display: grid; place-items: center; }
.blurred { filter: blur(1.5px); opacity: .45; pointer-events: none; }
.flash { animation: flash 2s ease-out; }
@keyframes flash {
  0%, 35% { box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--brand); }
  100% { box-shadow: 0 0 0 2px transparent; }
}

.sidebar {
  flex: 0 0 260px; background: var(--bg-primary); border-radius: var(--r-lg);
  overflow-y: auto; overflow-x: hidden; padding-bottom: 16px;
}
.side-title { font-size: 19px; line-height: 24px; font-weight: 600; padding: 20px 20px 12px; }
.sections { padding: 0 12px; }
.row { width: 100%; display: flex; align-items: center; padding: 8px; margin-bottom: 2px; border-radius: var(--r-m); text-align: left; }
.row:hover { background: var(--bg-secondary); }
.row.active { background: var(--bg-secondary); }
.row.active .ic-plain { color: var(--t1); }
.row-icon { width: 24px; height: 24px; display: grid; place-items: center; flex-shrink: 0; }
.row-text { margin-left: 12px; min-width: 0; flex: 1; }
.row-title { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic-plain { color: var(--t3); }
.sec-head { font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; color: var(--t3); padding: 16px 8px 4px; }

.content {
  flex: 1 1 auto; min-width: 0; background: var(--bg-primary); border-radius: var(--r-lg);
  overflow-y: auto;
}
.page { max-width: 980px; margin: 0 auto; padding: 24px 28px 56px; }
.page-title { font-size: 26px; line-height: 32px; font-weight: 700; }
.topics-select { display: none; }

/* ---------- shared bits ---------- */
.btn {
  height: 40px; padding: 0 16px; border-radius: var(--r-m); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; flex: none;
}
.btn.small { height: 32px; padding: 0 12px; border-radius: var(--r-sm); font-size: 13px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.secondary, .btn.following { background: var(--bg-secondary); color: var(--t1); }
.btn.secondary:hover, .btn.following:hover { background: var(--bg-secondary-hover); }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; color: var(--t3);
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--t1); }
.link { color: var(--brand); font-weight: 500; }
.link:hover { text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-primary); font-weight: 500; font-size: 13px; color: var(--t1);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; max-width: 100%;
}
.chip:hover { background: var(--bg-secondary); }
.chip.followed { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); color: var(--brand); }
.chip.sm { height: 24px; padding: 0 9px; font-size: 12px; background: var(--bg-tertiary); }
.chip.sm.primary { background: var(--brand-soft); border-color: transparent; color: var(--badge-text); }
.new {
  font-size: 10px; line-height: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  color: #fff; background: var(--brand); border-radius: 6px; padding: 1px 5px; flex: none;
}
.meta { display: inline-flex; align-items: center; gap: 4px; color: var(--t3); font-size: 13px; }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  color: var(--t4); padding: 48px 24px;
}
.empty b { color: var(--t1); font-weight: 600; }
.empty p { color: var(--t3); max-width: 360px; }

.tabs { display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--border); margin-top: 22px; overflow-x: auto; }
.tab {
  padding: 12px 0 10px; font-weight: 600; color: var(--t3); white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--t1); }
.tab.active { color: var(--t1); border-bottom-color: var(--t1); }

.block { margin-top: 28px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.block-title { font-size: 17px; line-height: 24px; font-weight: 600; }
.block > .block-title { margin-bottom: 12px; }
.hint { color: var(--t3); font-size: 13px; margin-top: 10px; }

/* Person and group cards, in rows that scroll sideways. */
.cards { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 6px; }
.card {
  flex: 0 0 172px; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 12px 14px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; cursor: pointer;
}
.card:hover { border-color: var(--border-strong); background: var(--bg-tertiary); }
.card > .av, .card > .gav { margin-bottom: 6px; }
.card-name { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: var(--t3); font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.card .chip { margin-top: 4px; }
.card .btn { margin-top: auto; width: 100%; }
.card .card-gap { flex: 1; min-height: 8px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 12px; margin-top: 20px; }

.post { display: flex; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.post:last-child { border-bottom: 0; }
.post > button { align-self: flex-start; }
.post-main { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.post-author { font-weight: 600; }
.post-author:hover { text-decoration: underline; }
.post-text { margin-top: 2px; }
.post-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.lrow { display: flex; align-items: flex-start; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.lrow:hover { background: var(--bg-tertiary); }
.lrow-main { flex: 1; min-width: 0; }
.lrow-title { font-weight: 600; }
.lrow-title .muted { font-weight: 400; }
.lrow-sub { color: var(--t2); margin-top: 2px; }
.lrow .chips { margin-top: 8px; gap: 6px; }

/* ---------- landing ---------- */
.landing-head { display: flex; flex-direction: column; gap: 16px; }
.search-box {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px; width: 100%; max-width: 560px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--bg-tertiary); color: var(--t3);
}
.search-box:hover { border-color: var(--t4); background: var(--bg-primary); }
.signin-strip {
  display: flex; align-items: center; gap: 12px; margin-top: 20px;
  background: var(--brand-soft); color: var(--badge-text); border-radius: var(--r-m); padding: 12px 16px;
}
.signin-strip span { flex: 1; font-weight: 500; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 10px;
}
.tile:hover { border-color: var(--border-strong); background: var(--bg-tertiary); }
.tile-head { display: flex; align-items: center; gap: 10px; }
.tile-icon { width: 36px; height: 36px; border-radius: var(--r-m); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.tile-name { font-weight: 600; flex: 1; }
.tile-subs { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 13px; }
.tile-subs .link { color: var(--t2); font-weight: 400; }
.tile-subs .link:hover { color: var(--brand); }

/* ---------- topic page ---------- */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--t4); font-size: 13px; }
.crumbs .link { color: var(--t3); font-weight: 500; }
.crumbs .link:hover { color: var(--t1); }
.topic-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.topic-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topic-desc { color: var(--t2); margin: 6px 0 16px; }
.siblings { margin-top: 14px; color: var(--t3); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.siblings .link { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- previews ---------- */
.modal {
  margin: auto; border: 0; border-radius: var(--r-lg); width: min(560px, calc(100vw - 32px));
  max-height: 86vh; box-shadow: var(--shadow-pop); padding: 0; color: var(--t1);
}
.modal.narrow { width: min(420px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(241, 243, 246, 0.7); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 4px 20px; }
.modal-head h2 { font-size: 17px; line-height: 24px; font-weight: 600; }
.modal-body { padding: 8px 20px 4px; color: var(--t2); }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 16px 20px 20px; }
.pv { padding: 0 20px 20px; }
.pv-top { display: flex; align-items: center; gap: 16px; }
.pv-id { flex: 1; min-width: 0; }
.pv-id h2 { font-size: 20px; line-height: 26px; font-weight: 700; }
.pv-bio { margin-top: 12px; color: var(--t2); }
.pv-stats { margin-top: 8px; color: var(--t3); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pv-stats b { color: var(--t1); }
.pv-h { font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--t3); margin: 20px 0 10px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); align-items: center; gap: 12px; }
.bar-row .chip { justify-self: start; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 8px; border-radius: 4px; background: var(--bg-secondary); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.pv .post { padding-left: 0; padding-right: 0; }

/* ---------- search popup ---------- */
.search-dlg {
  margin: 56px auto auto; width: min(600px, calc(100vw - 32px)); height: 80vh; max-height: 80vh;
  border: 0; padding: 0; background: transparent; overflow: visible;
}
.search-dlg::backdrop { background: rgba(241, 243, 246, 0.7); backdrop-filter: blur(5px); }
.sd-card {
  background: var(--bg-primary); border-radius: var(--r-m); box-shadow: var(--shadow-pop);
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
}
.sd-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 16px; border-bottom: 1px solid var(--border); }
.sd-icon { color: var(--t3); }
.sd-head:focus-within .sd-icon { color: var(--brand); }
.sd-input { flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; font-size: 15px; background: none; }
.sd-input::placeholder { color: var(--t4); }
.sd-clear { color: var(--t2); font-weight: 600; font-size: 13px; padding: 4px 6px; border-radius: var(--r-sm); }
.sd-clear:hover { background: var(--bg-secondary); }
.sd-divider { width: 1px; height: 24px; background: var(--border); }
.sd-body { overflow-y: auto; padding: 4px 8px; }
.sd-body:empty { display: none; }
.sd-h { font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; color: var(--t3); padding: 12px 8px 6px; }
.sd-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-m); cursor: pointer; text-align: left; }
.sd-row:hover, .sd-row:focus-visible { background: var(--bg-secondary); outline: none; }
.sd-circle { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-secondary); color: var(--t2); display: grid; place-items: center; flex: none; }
.sd-square { width: 40px; height: 40px; border-radius: var(--r-m); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.sd-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sd-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.sd-sub { font-size: 13px; color: var(--t3); display: inline-flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-explore .chips { padding: 2px 8px 6px; }
.sd-discover { display: inline-flex; align-items: center; gap: 6px; color: var(--brand); font-weight: 600; padding: 8px; margin-bottom: 4px; }
.sd-discover:hover { text-decoration: underline; }
.sd-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 28px 16px; color: var(--t3); }
.sd-empty b { color: var(--t1); }
.sd-empty .btn { margin-top: 8px; }
.sd-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--t3); font-size: 13px; }
.tag-chip { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 6px; background: var(--bg-secondary); color: var(--t2); font-weight: 600; }

/* ---------- search page ---------- */
.sp-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; }
.sp-title { text-align: center; font-size: 17px; line-height: 24px; font-weight: 600; }
.sp-input {
  display: flex; align-items: center; gap: 10px; height: 48px; margin-top: 14px; padding: 0 8px 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-m);
}
.sp-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.sp-input svg { color: var(--t3); }
.sp-input input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 15px; height: 100%; background: none; }
.sp-go { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--brand); display: grid; place-items: center; }
.sp-go svg { color: #fff; }
.sp-topics { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.sp-topics > span { color: var(--t3); font-weight: 500; margin-right: 2px; }
.sp-tabs { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.sp-tab { height: 32px; padding: 0 14px; border-radius: 999px; font-weight: 600; color: var(--t2); background: var(--bg-secondary); }
.sp-tab:hover { background: var(--bg-secondary-hover); }
.sp-tab.on { background: var(--t1); color: #fff; }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center;
}
.toast {
  background: #292929; color: #fff; padding: 10px 16px; border-radius: var(--r-m);
  font-size: 14px; box-shadow: var(--shadow-pop); animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- narrow screens ----------
   The Discover sidebar turns into a Topics dropdown and the document itself scrolls, because
   mobile browsers scroll a page far more reliably than a fixed-height container. The rail keeps
   a fixed height so its groups can still overflow into the +N pill. */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { display: block; }
  .app { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: start; gap: 12px; padding: 12px; }
  .rail { position: sticky; top: 12px; height: calc(100vh - 24px); }
  .sidebar { display: none; }
  .content { overflow: visible; }
  .page { padding: 16px 16px 48px; }
  .topics-select {
    display: block; width: 100%; height: 40px; margin-bottom: 16px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--r-m); background: var(--bg-primary);
  }
  .bar-row { grid-template-columns: minmax(0, 150px) minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .lrow .btn { display: none; }
  .demo-controls { flex-wrap: wrap; }
}
