/* OpenBook design system.
   Own brand identity: a fresh indigo on a clean light-gray chrome,
   with a familiar social layout (top bar, feed, side rails). */

:root {
  --brand: #4f46e5;          /* indigo */
  --brand-dark: #4338ca;
  --brand-soft: #eef0ff;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1c1e21;
  --text-soft: #65676b;
  --line: #e4e6eb;
  --hover: #f2f2f5;

  --like: #e0245e;
  --green: #16a34a;
  --danger: #dc2626;

  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.18);
  --topbar-h: 56px;
}

/* Dark theme: override the same variables, so every surface adapts. Toggled by
   setting data-theme="dark" on <html> (persisted in localStorage). */
html[data-theme="dark"] {
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-soft: #2a2c4d;

  --bg: #18191a;
  --card: #242526;
  --text: #e4e6eb;
  --text-soft: #b0b3b8;
  --line: #3a3b3c;
  --hover: #3a3b3c;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Brand wordmark ---------- */
.brand {
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-right: 0.06em;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--brand-grad);
  color: #fff;
  font-weight: 800;
  font-size: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  background: var(--hover);
  color: var(--text);
  transition: filter 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.btn:hover { filter: brightness(0.96); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); filter: none; }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: #fde8e8; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Inputs ---------- */
.input, textarea.input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea.input { resize: vertical; min-height: 60px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 5px; font-weight: 600; }

/* ---------- Avatars ---------- */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-soft);
  flex: none;
}
.avatar-fallback {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex: none;
  text-transform: uppercase;
}

/* ---------- Landing / auth ---------- */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 70% -10%, #e9e9ff 0%, var(--bg) 60%);
}
.landing-grid {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}
.landing-pitch h1 { font-size: 56px; margin: 0 0 4px; line-height: 1; }
.landing-pitch p { font-size: 22px; color: var(--text-soft); max-width: 420px; }
.landing-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.landing-logo .name { font-size: 34px; }

/* Manifesto / promises checklist (left pitch column, visible during login + signup) */
.promises { margin-top: 30px; max-width: 460px; }
.landing-pitch .promises-eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  max-width: none;
  margin: 0 0 16px;
}
.promise-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.promise {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  text-align: left;
}
.promise-check {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--brand-grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
  margin-top: 1px;
}
.promise-check svg { width: 15px; height: 15px; display: block; }
.promise-text {
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-soft);
}
.promise-text strong {
  display: block;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 1px;
}
/* Supporting line sits muted and a touch smaller under each bold claim, so the
   five headlines are the primary scan layer. */
.promise-sub {
  display: block;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.4;
}
.promise-link {
  color: var(--brand);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.promise-link:hover { color: var(--brand-dark); }
/* Defense in depth: the entrance animation is JS-only (no opacity:0 default in
   CSS), but if motion is reduced we also force rows visible so nothing can be
   left hidden. */
@media (prefers-reduced-motion: reduce) {
  .promise { opacity: 1 !important; }
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}
.auth-card h2 { margin: 0 0 4px; }
.auth-card .sub { color: var(--text-soft); margin: 0 0 18px; }
.auth-switch { text-align: center; margin-top: 14px; color: var(--text-soft); }
.auth-switch button { background: none; border: none; color: var(--brand); font-weight: 600; cursor: pointer; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.alert {
  background: #fde8e8;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 12px;
}
.alert-ok { background: #e7f6ec; color: var(--green); }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.topbar .logo { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.topbar .logo .name { font-size: 22px; }
.topbar .search {
  width: 240px;
  position: relative;
}
.topbar .search input {
  width: 100%;
  border: none;
  background: var(--hover);
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 14px;
  outline: none;
}

/* Center: primary destination tabs, Facebook-style with an active underline.
   Auto width with equal-width (flex:1) left and right zones keeps these tabs at
   the true center of the viewport. */
.nav-primary {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  height: 100%;
}
.nav-tab {
  position: relative;
  border: none;
  background: transparent;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 92px;
  padding: 0 16px;
  height: 100%;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-size: 12px;
  font-weight: 600;
}
.nav-tab .ti { font-size: 21px; line-height: 1; }
.nav-tab:hover { background: var(--hover); }
.nav-tab.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }

/* Right: utility cluster (messages, notifications, your avatar). flex:1 mirrors
   the left zone so the center tabs stay centered; content is pushed right. */
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; justify-content: flex-end; }

/* Mobile bottom navigation: the primary tabs move here on small screens so they
   are always visible and tappable (the top bar can't fit them on a phone). */
.bottom-nav { display: none; }
.topbar .nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--hover);
  color: var(--text-soft);
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:hover { background: var(--line); }
.nav-btn.active { color: var(--brand); background: var(--brand-soft); }
.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--like);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--card);
}

/* ---------- App layout ---------- */
.layout {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}
.rail { position: sticky; top: calc(var(--topbar-h) + 16px); }
.center { min-width: 0; }

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.side-link:hover { background: var(--hover); }
.side-link.active { background: var(--brand-soft); color: var(--brand); }
.side-link .ic { font-size: 20px; width: 24px; text-align: center; }
.side-link .side-badge { position: static; margin-left: auto; border: none; }

/* ---------- Email verification banner ---------- */
.verify-banner {
  max-width: 1100px;
  margin: 12px auto 0;
  padding: 10px 16px;
  background: #fff7e6;
  border: 1px solid #f0c36d;
  color: #6b4e00;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.verify-banner span { flex: 1; }

/* ---------- Moderation ---------- */
.modbanner {
  background: #fdecea;
  border: 1px solid #f5b5ae;
  color: #8a1c10;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin: 8px 0;
}
.modbanner-soft { background: var(--hover); border-color: #ddd; color: var(--text-soft); }
.cbubble.cremoved { opacity: 0.6; font-style: italic; }

/* ---------- Password show/hide ---------- */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 64px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 8px;
}
.pw-toggle:hover { text-decoration: underline; }

/* ---------- Dashboard ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stat .sval { font-size: 28px; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat .slabel { font-weight: 700; margin-top: 4px; }
.stat .shint { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.analytics-table { width: 100%; border-collapse: collapse; }
.analytics-table th, .analytics-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.analytics-table th { color: var(--text-soft); font-weight: 600; }
.analytics-table td:not(:first-child), .analytics-table th:not(:first-child) { text-align: right; width: 70px; }
.analytics-table tr.link:hover td { background: var(--hover); }

/* ---------- Reels (vertical video) ---------- */
.reels-viewer {
  height: calc(100vh - var(--topbar-h) - 96px);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
}
.reel-stage {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  background: #000;
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reel-video { width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }
.reel-overlay { position: absolute; inset: 0; pointer-events: none; }
.reel-overlay > * { pointer-events: auto; }
.reel-actions { position: absolute; right: 12px; bottom: 96px; display: flex; flex-direction: column; gap: 14px; }
.reel-act {
  background: rgba(0, 0, 0, 0.4);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  gap: 1px;
}
.reel-act .ra-ic { font-size: 22px; line-height: 1; }
.reel-meta {
  position: absolute;
  left: 14px;
  right: 76px;
  bottom: 16px;
  color: #fff;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.reel-meta .rname { font-weight: 700; cursor: pointer; }
.reel-meta .rcap { font-size: 14px; margin-top: 2px; }
.reel-meta .rcap a { color: #cfe1ff; }
.reel-meta .rviews { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.reel-mute {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 16px;
}
.card-pad-0 { padding: 0; overflow: hidden; }
.section-title { font-size: 17px; font-weight: 700; margin: 0 0 10px; }

/* ---------- Composer ---------- */
.composer .row { display: flex; gap: 10px; align-items: center; }
.composer textarea {
  border: none;
  background: var(--hover);
  border-radius: 20px;
  padding: 11px 16px;
  width: 100%;
  resize: none;
  font-size: 15px;
  outline: none;
  min-height: 42px;
}
.composer .preview { margin-top: 10px; position: relative; }
.composer .preview img { border-radius: 10px; max-height: 320px; width: 100%; object-fit: cover; }
.composer .preview .remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.6); color: #fff; border: none;
  width: 30px; height: 30px; border-radius: 50%; font-size: 16px;
}
.composer .actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.composer .actions .spacer { flex: 1; }
.icon-action { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; background: transparent; border: none; color: var(--text-soft); font-weight: 600; }
.icon-action:hover { background: var(--hover); }

/* ---------- Stories ---------- */
.stories { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.story {
  flex: none;
  width: 110px;
  height: 180px;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: #ddd;
  box-shadow: var(--shadow);
}
.story img { width: 100%; height: 100%; object-fit: cover; }
.story .who {
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  color: #fff; font-size: 12px; font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.story .ring {
  position: absolute; top: 8px; left: 8px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--brand);
}
.story.add { background: var(--card); display: flex; flex-direction: column; }
.story.add .plus {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); font-size: 30px;
}
.story.add .label { padding: 8px; font-size: 12px; font-weight: 700; text-align: center; }

/* ---------- Posts ---------- */
.post-head { display: flex; align-items: center; gap: 10px; }
.post-head .meta { flex: 1; min-width: 0; }
.post-head .name { font-weight: 700; cursor: pointer; }
.post-head .name:hover { text-decoration: underline; }
.post-head .time { font-size: 12px; color: var(--text-soft); }
.post-body { margin: 10px 0; white-space: pre-wrap; word-wrap: break-word; }
.post-image { margin: 0 -14px; }
.post-image img { width: 100%; max-height: 560px; object-fit: cover; }
.post-stats { display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 13px; padding: 8px 0; }
.post-stats .heart { color: var(--like); }
.post-actions { display: flex; border-top: 1px solid var(--line); padding-top: 4px; }
.post-action {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: transparent; border: none; color: var(--text-soft);
  font-weight: 600; padding: 8px; border-radius: 8px;
}
.post-action:hover { background: var(--hover); }
.post-action.liked { color: var(--like); }
.menu-btn { background: transparent; border: none; color: var(--text-soft); font-size: 20px; width: 34px; height: 34px; border-radius: 50%; }
.menu-btn:hover { background: var(--hover); }

/* comments */
.comments { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.comment { display: flex; gap: 8px; margin-bottom: 10px; }
.comment .bubble { background: var(--hover); border-radius: 16px; padding: 8px 12px; }
.comment .bubble .name { font-weight: 700; font-size: 13px; }
.comment-form { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.comment-form input {
  flex: 1; border: none; background: var(--hover); border-radius: 18px;
  padding: 9px 14px; outline: none; font-size: 14px;
}

/* ---------- Profile ---------- */
.profile-cover {
  height: 260px;
  background: var(--brand-grad);
  border-radius: 0 0 var(--radius) var(--radius);
  position: relative;
  background-size: cover;
  background-position: center;
}
.profile-cover .edit-cover {
  position: absolute; right: 14px; bottom: 14px;
  background: rgba(255,255,255,0.9); color: var(--text);
}
.profile-head {
  display: flex; align-items: flex-end; gap: 18px;
  margin: -60px 0 0; padding: 0 24px 16px;
  border-bottom: 1px solid var(--line);
}
.profile-head .av-wrap { position: relative; }
.profile-head .av-wrap .cam {
  position: absolute; right: 4px; bottom: 4px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--hover); border: 2px solid var(--card);
  display: flex; align-items: center; justify-content: center;
}
.profile-head .pname { font-size: 28px; font-weight: 800; }
.profile-head .pmeta { color: var(--text-soft); }
.profile-head .pactions { margin-left: auto; display: flex; gap: 8px; align-items: center; padding-bottom: 8px; }

/* ---------- Lists / people ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.person {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; text-align: center; padding-bottom: 12px;
}
.person .ph { height: 120px; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; }
.person .pn { font-weight: 700; margin: 10px 8px 8px; cursor: pointer; }
.person .pb { padding: 0 10px; display: flex; flex-direction: column; gap: 6px; }
.contact { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.contact:hover { background: var(--hover); }
.contact .nm { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot-online { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }

/* ---------- Notifications dropdown ---------- */
.dropdown {
  position: absolute; right: 16px; top: calc(var(--topbar-h) - 4px);
  width: 360px; max-width: calc(100vw - 24px);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 60; overflow: hidden;
}
.dropdown .dhead { display: flex; align-items: center; padding: 12px 14px; }
.dropdown .dhead h3 { margin: 0; flex: 1; }
.notif {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 14px; cursor: pointer;
}
.notif:hover { background: var(--hover); }
.notif.unread { background: var(--brand-soft); }
.notif .nt { flex: 1; min-width: 0; }
.notif .nt .tm { font-size: 12px; color: var(--text-soft); }
.empty { text-align: center; color: var(--text-soft); padding: 28px 14px; }

/* ---------- Messages ---------- */
.messenger { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - var(--topbar-h) - 32px); }
.mlist { border-right: 1px solid var(--line); overflow-y: auto; }
.mlist .convo { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; }
.mlist .convo:hover, .mlist .convo.active { background: var(--hover); }
.mlist .convo .cm { flex: 1; min-width: 0; }
.mlist .convo .cm .nm { font-weight: 700; }
.mlist .convo .cm .lm { font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mthread { display: flex; flex-direction: column; min-width: 0; }
.mthread .thead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.mbody { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: #fafafd; }
.bubble-msg { max-width: 70%; padding: 9px 13px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); word-wrap: break-word; }
.bubble-msg.mine { align-self: flex-end; background: var(--brand); color: #fff; }
.bubble-msg .bt { font-size: 11px; opacity: 0.7; margin-top: 3px; }
.mfoot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.mfoot input { flex: 1; border: none; background: var(--hover); border-radius: 20px; padding: 11px 16px; outline: none; }
.chat-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-soft); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--card); border-radius: var(--radius-lg);
  width: 100%; max-width: 500px; box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.modal .mh { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; flex: 1; text-align: center; font-size: 18px; }
.modal .mc { padding: 18px; }

/* story viewer */
.story-view-back { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 110; display: flex; align-items: center; justify-content: center; }
.story-view { width: min(420px, 92vw); height: min(86vh, 760px); border-radius: 14px; overflow: hidden; position: relative; background: #000; }
.story-view img { width: 100%; height: 100%; object-fit: contain; }
.story-view .sv-head { position: absolute; top: 0; left: 0; right: 0; padding: 14px; display: flex; gap: 10px; align-items: center; background: linear-gradient(rgba(0,0,0,0.6), transparent); color: #fff; }
.story-view .sv-cap { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.7)); }
.story-view .sv-close { position: absolute; top: 12px; right: 12px; z-index: 2; background: rgba(0,0,0,0.5); color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1c1e21; color: #fff; padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 200; font-size: 14px;
}

/* ---------- Shared bits ---------- */
.mk-head { display: flex; align-items: center; gap: 10px; }
.pill { display: inline-block; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; vertical-align: middle; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; color: var(--text-soft); border-radius: 16px; padding: 6px 14px; font-size: 13px; font-weight: 600; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Marketplace ---------- */
.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.mk-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: transform 0.08s ease; }
.mk-card:hover { transform: translateY(-2px); }
.mk-photo { position: relative; aspect-ratio: 1 / 1; background: var(--hover); }
.mk-photo img { width: 100%; height: 100%; object-fit: cover; }
.mk-noimg { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 34px; opacity: 0.5; }
.mk-sold { position: absolute; top: 8px; left: 8px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 6px; }
.mk-info { padding: 8px 10px 12px; }
.mk-price { font-weight: 800; }
.mk-title { font-size: 14px; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-loc { font-size: 12px; color: var(--text-soft); }

/* ---------- Groups ---------- */
.grp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.grp-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.grp-cover { height: 90px; background: var(--brand-grad); background-size: cover; background-position: center; cursor: pointer; }
.grp-body { padding: 10px; }
.grp-name { font-weight: 700; cursor: pointer; }
.grp-name:hover { text-decoration: underline; }
.grp-act { margin-top: 8px; }
.grp-hero { height: 200px; background: var(--brand-grad); background-size: cover; background-position: center; border-radius: 0 0 var(--radius) var(--radius); }
.grp-hd { display: flex; align-items: flex-end; gap: 12px; padding: 14px 18px; }
.grp-hd-act { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Albums ---------- */
.alb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.alb-card { cursor: pointer; }
.alb-cover { aspect-ratio: 4 / 3; border-radius: 10px; background: var(--brand-soft) center/cover no-repeat; box-shadow: var(--shadow); }
.alb-info { padding: 6px 2px; }
.alb-title { font-weight: 700; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ph-item { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.ph-item img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.ph-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 12px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.7)); }

/* ---------- Communities + voting ---------- */
.link { color: var(--brand); cursor: pointer; }
.link:hover { text-decoration: underline; }

.votebox { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 34px; flex: none; }
.vote { background: none; border: none; color: var(--text-soft); font-size: 14px; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.vote:hover { background: var(--hover); }
.vote.up.on { color: var(--brand); }
.vote.down.on { color: var(--like); }
.vscore { font-weight: 700; font-size: 13px; }
.vscore.pos { color: var(--brand); }
.vscore.neg { color: var(--like); }

.cpost { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.cpost-full { cursor: default; }
.cpost-body { flex: 1; min-width: 0; }
.cpost-title { font-weight: 700; font-size: 16px; cursor: pointer; }
.cpost-link { font-size: 13px; word-break: break-all; }
.cpost-snippet { color: var(--text-soft); font-size: 14px; margin-top: 4px; white-space: pre-wrap; }
.cpost-thumb { margin-top: 8px; }
.cpost-thumb img { max-height: 340px; width: 100%; object-fit: cover; border-radius: 10px; }
.cpost-meta { color: var(--text-soft); font-size: 12px; margin-top: 8px; }

.comm-hero { height: 90px; background: var(--brand-grad); border-radius: 0 0 var(--radius) var(--radius); }
.comm-hd { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.comm-hd .avatar, .comm-hd .avatar-fallback { margin-top: -44px; border: 4px solid var(--card); }
.comm-act { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.comm-row { display: flex; gap: 10px; align-items: center; cursor: pointer; }

.tabs { display: flex; gap: 4px; }
.tab { background: none; border: none; padding: 6px 14px; border-radius: 18px; font-weight: 600; color: var(--text-soft); }
.tab.active { background: var(--brand-soft); color: var(--brand-dark); }

.ctree { margin-top: 10px; }
.crow { display: flex; gap: 8px; align-items: flex-start; }
.cmain { flex: 1; min-width: 0; }
.cbubble { background: var(--hover); border-radius: 12px; padding: 8px 12px; }
.cname { font-weight: 700; font-size: 13px; }
.ctime { font-size: 11px; color: var(--text-soft); margin-left: 6px; }
.cactions { display: flex; gap: 10px; padding: 4px 0 0 12px; }
.clink { background: none; border: none; color: var(--text-soft); font-weight: 600; font-size: 12px; cursor: pointer; }
.clink:hover { color: var(--text); }
.cchildren { margin-left: 22px; border-left: 2px solid var(--line); padding-left: 10px; }

/* ---------- Reactions + edit history ---------- */
.post-actions { position: relative; }
.rx-ctl { position: relative; display: inline-flex; }
.post-actions > [data-react] { flex: 1; display: flex; }
.post-actions > [data-react] > .rx-ctl { flex: 1; }
.post-actions .post-action.react { flex: 1; }
.rx-mine { color: var(--brand); font-weight: 700; }
.rx-picker {
  position: absolute; bottom: 115%; left: 0; z-index: 40;
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg);
  display: flex; gap: 2px; padding: 5px 8px;
}
.rx-opt { background: none; border: none; font-size: 24px; line-height: 1; padding: 4px; border-radius: 50%; transition: transform 0.1s ease; }
.rx-opt:hover { transform: scale(1.3); }
.rx-opt.on { background: var(--brand-soft); }
.rx-sum { color: var(--text-soft); font-size: 13px; }
.rx-emoji { font-size: 14px; }
.rxbtn-sm { background: none; border: none; color: var(--text-soft); font-weight: 600; font-size: 12px; cursor: pointer; padding: 0; }
.cmeta { display: flex; align-items: center; gap: 8px; margin-left: 12px; margin-top: 3px; font-size: 12px; color: var(--text-soft); flex-wrap: wrap; }
.edited-link { color: var(--text-soft); cursor: pointer; }
.edited-link:hover { text-decoration: underline; }
.hist-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; white-space: pre-wrap; word-wrap: break-word; }
.hist-current { border-color: var(--brand); background: var(--brand-soft); }
.hist-when { font-size: 12px; color: var(--text-soft); margin-bottom: 4px; font-weight: 600; }
.hist-title { font-weight: 700; margin-bottom: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 640px; }
  /* Hide the suggestions (right) rail, but keep the destination menu reachable
     by turning the left rail into a horizontal scroller above the content. */
  #rightRail { display: none; }
  #leftRail { position: static; }
  #leftRail .card { display: flex; flex-direction: row; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 8px; }
  #leftRail .side-link { flex: 0 0 auto; white-space: nowrap; }
  /* Primary tabs move to the bottom bar on mobile, so hide them in the top bar
     and let the search flex to fill the space next to the utility cluster. */
  .nav-primary { display: none; }
  .topbar .search { width: auto; flex: 1; min-width: 0; }
  .topbar { gap: 8px; padding: 0 10px; }
  /* Bottom navigation bar: the four primary destinations, always tappable. */
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    height: 58px;
    background: var(--card);
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.08);
  }
  .bottom-nav .nav-tab { flex: 1; min-width: 0; padding: 0; height: 100%; border-bottom: none; border-top: 3px solid transparent; }
  .bottom-nav .nav-tab .tl { display: block; font-size: 10px; }
  .bottom-nav .nav-tab.active { color: var(--brand); border-top-color: var(--brand); border-bottom-color: transparent; }
  /* Leave room above the fixed bottom bar so content is never hidden behind it. */
  .layout { padding-bottom: 76px; }
  .landing-grid { grid-template-columns: 1fr; gap: 24px; }
  .landing-pitch { text-align: center; }
  .landing-pitch h1 { font-size: 40px; }
  /* Center the manifesto block and left-align the eyebrow + each row inside it
     for legibility (the column itself is centered on mobile). */
  .promises { margin-left: auto; margin-right: auto; }
  .promises-eyebrow, .promise { text-align: left; }
  .messenger { grid-template-columns: 1fr; }
  .messenger.show-thread .mlist { display: none; }
  .messenger:not(.show-thread) .mthread { display: none; }

  /* Stack the profile header so the avatar never overlaps the name. */
  .profile-cover { height: 180px; }
  .profile-head {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    margin-top: -64px;
  }
  .profile-head .pactions { margin-left: 0; justify-content: center; flex-wrap: wrap; padding-bottom: 0; }
}
@media (max-width: 520px) {
  .topbar .search { max-width: none; }
  .topbar .logo .name { display: none; }
}
