/* ---------- design tokens (light default, dark via system or toggle) ---------- */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --hover: #ececea;
  --ink: #1b1b1f;
  --ink-2: #3d3d45;
  --muted: #6c6c76;
  --line: #e4e4e0;
  --line-2: #d2d2cd;
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #ecebfb;
  --ok: #15803d;
  --bad: #c92a2a;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05);
  --shadow-lg: 0 14px 36px -10px rgba(20, 20, 30, .22);
  --radius: 14px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113; --surface: #19191c; --surface-2: #202024; --hover: #26262b;
    --ink: #ececef; --ink-2: #c9c9cf; --muted: #9a9aa4; --line: #2a2a2f; --line-2: #3a3a40;
    --accent: #8b8cf8; --accent-ink: #111113; --accent-soft: #25254a;
    --ok: #4ade80; --bad: #f87171;
    --shadow: none; --shadow-lg: 0 14px 36px -10px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111113; --surface: #19191c; --surface-2: #202024; --hover: #26262b;
  --ink: #ececef; --ink-2: #c9c9cf; --muted: #9a9aa4; --line: #2a2a2f; --line-2: #3a3a40;
  --accent: #8b8cf8; --accent-ink: #111113; --accent-soft: #25254a;
  --ok: #4ade80; --bad: #f87171;
  --shadow: none; --shadow-lg: 0 14px 36px -10px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: 60px;
  display: flex; align-items: center; gap: 16px; padding: 0 max(20px, calc((100% - 1120px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.orb { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); flex: none; position: relative; }
.orb::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; box-shadow: inset -5px -1px 0 0 var(--accent-ink); } /* crescent moon */
.links { display: flex; gap: 2px; margin-left: 8px; }
.links a {
  text-decoration: none; padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.links a:hover { color: var(--ink); background: var(--hover); }
.links a.active { color: var(--ink); background: var(--hover); }
.links .badge { margin-left: 2px; }
.lock { font-size: 12px; }
.auth { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.who { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.theme-toggle { font-size: 16px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 12px; color: var(--accent); background: var(--accent-soft);
}

/* ---------- controls ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: 600 14px var(--sans); text-decoration: none;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; flex: none;
  border-radius: 8px; cursor: pointer; font-size: 17px; display: inline-grid; place-items: center; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
label { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px; }
input, textarea {
  width: 100%; font: 16px var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.field { margin-bottom: 16px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 4px 0 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
main { flex: 1; width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 72px; outline: none; }
.page-in { animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.reveal { opacity: 1; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 40px 20px; max-width: 380px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }
.empty h2 { color: var(--ink); margin: 0 0 8px; font-size: 20px; }

/* ---------- home ---------- */
.hero { padding: 48px 0 24px; max-width: 720px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.hero h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.08; letter-spacing: -0.03em; margin: 14px 0 16px; font-weight: 700; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p.lead { font-size: clamp(17px, 2.2vw, 19px); color: var(--muted); max-width: 600px; margin: 0 0 28px; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 36px 0 52px; }
.feature { padding: 22px; }
.feature .ic { font-size: 20px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); margin-bottom: 14px; }
.feature h3 { margin: 0 0 4px; font-size: 17px; }
.feature p { margin: 0; color: var(--muted); font-size: 15px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.section-head h2 { font-size: 24px; letter-spacing: -0.02em; margin: 0; }
.section-head h2 em { font-style: normal; }
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.post-card { display: flex; flex-direction: column; padding: 20px; min-height: 200px; text-decoration: none; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.post-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-lg); }
.post-card .thumb { width: calc(100% + 40px); margin: -20px -20px 16px; aspect-ratio: 16/9; object-fit: cover; border-bottom: 1px solid var(--line); }
.post-card .card-text { color: var(--ink); font-size: 16px; font-weight: 600; line-height: 1.4; margin: 12px 0 16px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); align-self: flex-start; }
.meta { margin-top: auto; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.post-card:hover .arrow { color: var(--accent); }

/* ---------- markdown ---------- */
.prose { font-size: 16.5px; line-height: 1.7; }
.prose h2 { font-size: 21px; letter-spacing: -0.01em; margin: 22px 0 8px; line-height: 1.3; }
.prose h3 { font-size: 18px; margin: 18px 0 6px; }
.prose a { color: var(--accent); }
.prose code { font: .86em var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--line); padding: 14px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; }
.prose blockquote { margin: 14px 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--line-2); color: var(--muted); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }

/* ---------- auth ---------- */
.auth-wrap { max-width: 420px; margin: 24px auto; overflow: hidden; }
.auth-form { padding: 30px; }
.auth-form h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.auth-form .sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.auth-form .btn { width: 100%; margin-top: 6px; }
.secure-note { display: flex; gap: 8px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 0 0 18px; }
.switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.switch a { color: var(--accent); font-weight: 600; }
.strength { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.strength i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 150px); min-height: 500px; overflow: hidden; }
.people { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.people-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.people-head h2 { margin: 0 0 10px; font-size: 18px; }
.people-head input { height: 38px; padding: 6px 12px; background: var(--surface-2); }
.people-list { overflow-y: auto; padding: 6px; flex: 1; }
.person { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; }
.person:hover { background: var(--hover); }
.person.active { background: var(--accent-soft); }
.person .name { font-weight: 600; font-size: 15px; }
.person .sub { font-size: 12px; color: var(--muted); }
.badge { margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.convo { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.convo-head { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.convo-head .name { font-weight: 700; }
.e2e { font-size: 12px; color: var(--ok); display: flex; align-items: center; gap: 4px; }
.safety { margin-left: auto; text-align: right; font: 11px var(--mono); color: var(--muted); cursor: help; }
.safety b { display: block; color: var(--ink); font-weight: 600; letter-spacing: .03em; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 5px; background: var(--surface-2); }
.msg { max-width: min(520px, 78%); padding: 8px 13px; border-radius: 16px; font-size: 15px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.msg.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg time { display: block; font-size: 11px; opacity: .65; margin-top: 2px; }
.msg.broken { font-style: italic; opacity: .6; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.unlock { max-width: 420px; margin: 40px auto; padding: 30px; text-align: center; }

/* ---------- feed ---------- */
.feed-layout { display: grid; grid-template-columns: 300px minmax(0, 660px); gap: 24px; justify-content: center; align-items: start; }
.feed { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#feed-list { display: flex; flex-direction: column; gap: 14px; }
.single { max-width: 680px; margin: 0 auto; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 12px; }
.back:hover { color: var(--ink); }

.profile { position: sticky; top: 84px; overflow: hidden; text-align: center; }
.profile .cover { height: 84px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.profile .p-body { padding: 0 20px 20px; }
.avatar.xl { width: 80px; height: 80px; font-size: 26px; margin: -40px auto 10px; border: 4px solid var(--surface); background: var(--accent); color: var(--accent-ink); }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.profile h2 { margin: 2px 0 4px; font-size: 20px; }
.profile p { font-size: 14px; margin: 0 0 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); padding: 12px 0; margin-bottom: 16px; }
.stats b { display: block; font-size: 18px; }
.stats span { font-size: 12px; color: var(--muted); }
.profile .btn { width: 100%; }
.verified { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 9px; font-weight: 800; vertical-align: 1px; }

.search { display: flex; align-items: center; gap: 8px; padding: 2px 6px 2px 14px; border-radius: 10px; }
.search input { border: 0; background: transparent; padding: 10px 4px; box-shadow: none; }
.search input:focus { box-shadow: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; font: 500 14px var(--sans); color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.chip:hover { background: var(--hover); }
.chip.on { color: var(--accent-ink); background: var(--ink); border-color: var(--ink); }

.create-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.create-bar .fake-input {
  flex: 1; height: 40px; display: flex; align-items: center; padding: 0 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); text-decoration: none;
}
.create-bar .fake-input:hover { border-color: var(--accent); color: var(--ink); }

.fb-post { padding: 0; overflow: visible; transition: opacity .3s; }
.fb-post.gone { opacity: 0; }
.fb-post.skeleton { height: 200px; background: var(--surface-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.fb-post.pinned { border-color: var(--accent); }
.pin-label { padding: 12px 18px 0; font-size: 12px; font-weight: 700; color: var(--accent); }
.fb-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px 4px; }
.fb-who { min-width: 0; }
.fb-name { font-weight: 600; font-size: 15px; }
.fb-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.fb-meta a { color: inherit; text-decoration: none; }
.fb-meta a:hover { text-decoration: underline; }
.fb-meta .tag { padding: 1px 8px; font-size: 11px; }
.more-wrap { margin-left: auto; position: relative; }
.menu { position: absolute; right: 0; top: 40px; z-index: 20; min-width: 180px; padding: 6px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: 500 14px var(--sans); cursor: pointer; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--bad); }
.fb-title { margin: 6px 18px 4px; font-size: 19px; line-height: 1.3; letter-spacing: -0.01em; }
.fb-body { padding: 2px 18px 6px; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.fb-body > :first-child { margin-top: 0; }
.fb-body p { margin: 0 0 10px; }
.fb-body h2 { font-size: 18px; margin: 14px 0 6px; color: var(--ink); }
.fb-body h3 { font-size: 16px; margin: 12px 0 6px; color: var(--ink); }
.fb-body.clamp { max-height: 9.6em; overflow: hidden; mask-image: linear-gradient(#000 60%, transparent); -webkit-mask-image: linear-gradient(#000 60%, transparent); }
.see-more { margin: 0 18px 8px; padding: 0; border: 0; background: none; color: var(--accent); font: 600 14px var(--sans); cursor: pointer; }
.fb-img { position: relative; margin-top: 8px; border-block: 1px solid var(--line); background: var(--surface-2); user-select: none; }
.fb-img img { width: 100%; max-height: 620px; object-fit: contain; display: block; }
.burst { position: absolute; left: 50%; top: 50%; font-size: 84px; transform: translate(-50%, -50%) scale(0); opacity: 0; pointer-events: none; }
.fb-img.pop .burst { animation: burst .8s ease; }
@keyframes burst { 30% { transform: translate(-50%,-50%) scale(1.1); opacity: 1; } 70% { transform: translate(-50%,-50%) scale(1); opacity: 1; } 100% { transform: translate(-50%,-50%) scale(1); opacity: 0; } }
.fb-stats { display: flex; justify-content: space-between; align-items: center; padding: 8px 18px; font-size: 13px; color: var(--muted); min-height: 20px; }
.fb-stats:empty { padding: 4px; }
.rx-emojis { letter-spacing: -3px; margin-right: 6px; }
.linkish { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.linkish:hover { text-decoration: underline; color: var(--ink); }
.fb-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 12px; padding: 4px 0; border-top: 1px solid var(--line); }
.act { appearance: none; border: 0; background: none; color: var(--muted); font: 600 14px var(--sans); padding: 8px 6px; border-radius: 8px; cursor: pointer; width: 100%; white-space: nowrap; }
.act:hover { background: var(--hover); color: var(--ink); }
.act.on { color: var(--accent); }
.act.rx-love { color: #e03159; } .act.rx-haha, .act.rx-wow, .act.rx-sad { color: #c98a00; } .act.rx-fire { color: #e8590c; }
.react-wrap { position: relative; }
.rx-picker {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 30; display: flex; gap: 2px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .15s, transform .15s;
}
.react-wrap:hover .rx-picker, .react-wrap.open .rx-picker, .rx-picker:focus-within { opacity: 1; transform: none; pointer-events: auto; transition-delay: .25s; }
.react-wrap.open .rx-picker, .rx-picker:focus-within { transition-delay: 0s; }
.rx-picker button { border: 0; background: none; font-size: 24px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transition: transform .12s; }
.rx-picker button:hover, .rx-picker button:focus-visible { transform: scale(1.2); background: var(--hover); }
.fb-comments { border-top: 1px solid var(--line); margin: 0 12px; padding: 12px 6px 14px; }
.comment { display: flex; gap: 8px; margin-bottom: 10px; }
.bubble { background: var(--surface-2); border-radius: 14px; padding: 7px 12px; display: inline-block; max-width: 100%; }
.bubble b { font-size: 13px; }
.bubble p { margin: 2px 0 0; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.c-meta { font-size: 12px; color: var(--muted); margin: 3px 0 0 12px; }
.c-meta .linkish { font-size: 12px; font-weight: 600; }
.c-empty { font-size: 14px; margin: 0 0 12px 6px; }
.c-form { display: flex; gap: 8px; align-items: center; }
.c-form input { border-radius: 999px; padding: 8px 14px; font-size: 15px; background: var(--surface-2); }
.c-form .send { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-size: 14px; }
.c-signin { font-size: 14px; margin: 0 6px; }
.c-signin a { color: var(--accent); }

/* ---------- create post (Reddit-style) ---------- */
.submit-layout { display: grid; grid-template-columns: minmax(0, 740px) 300px; gap: 24px; justify-content: center; align-items: start; }
.submit-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.submit-top h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.submit-top .muted { font-size: 13px; }
.community-pick { display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px 7px 8px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 15px; }
.community-pick .orb { width: 22px; height: 22px; border-radius: 6px; }
.community-pick .orb::after { inset: 5px; box-shadow: inset -4px -1px 0 0 var(--accent-ink); }
.submit-card { overflow: hidden; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.tabs button {
  appearance: none; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted);
  font: 600 14px var(--sans); padding: 14px 8px; cursor: pointer;
}
.tabs button + button { border-left: 1px solid var(--line); }
.tabs button:hover { background: var(--hover); color: var(--ink); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.submit-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.counter-wrap { position: relative; }
.counter-wrap input { padding-right: 72px; font-size: 16px; }
.counter { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 12px var(--mono); color: var(--muted); }
.flair-row { display: flex; gap: 8px; }
.flair-btn {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--line-2); background: none;
  color: var(--muted); font: 600 13px var(--sans); padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.flair-btn:hover { color: var(--ink); background: var(--hover); }
.flair-btn.on { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.flair-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.flair-pick .flair {
  appearance: none; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: 600 13px var(--sans); padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.flair-pick .flair:hover { border-color: var(--accent); }
.flair-pick .flair.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.flair-pick input { width: 140px; padding: 4px 12px; font-size: 13px; border-radius: 999px; }
.md-editor { border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--surface); }
.md-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.md-toolbar { display: flex; align-items: center; gap: 2px; padding: 5px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.md-toolbar button { appearance: none; border: 0; background: none; color: var(--muted); min-width: 32px; height: 30px; padding: 0 8px; border-radius: 6px; cursor: pointer; font: 600 14px var(--sans); }
.md-toolbar button:hover { background: var(--hover); color: var(--ink); }
.md-toolbar .spacer { flex: 1; }
.md-toolbar .preview-toggle { border: 1px solid var(--line-2); font-size: 13px; background: var(--surface); }
.md-toolbar .preview-toggle.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.md-editor textarea { border: 0; border-radius: 0; min-height: 200px; box-shadow: none; }
.md-editor textarea:focus { box-shadow: none; }
.md-preview { min-height: 200px; padding: 12px; }
.drop {
  display: grid; place-items: center; min-height: 230px; padding: 20px; margin: 0; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-2); border-radius: 10px; color: var(--muted); font-size: 15px; font-weight: 400;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.drop b { color: var(--ink); }
.drop-ic { display: block; font-size: 26px; margin-bottom: 8px; }
.drop img { max-height: 420px; border-radius: 8px; display: block; }
.drop .spinner { display: inline-block; vertical-align: -2px; margin-right: 6px; }
.drop-actions { display: flex; justify-content: flex-end; }
.submit-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.submit-foot .err { margin: 0 auto 0 0; }
.submit-side { padding: 18px 20px; position: sticky; top: 84px; }
.submit-side h3 { margin: 0 0 10px; font-size: 15px; }
.rules { margin: 0 0 12px; padding: 0; list-style: none; counter-reset: rule; }
.rules li { counter-increment: rule; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rules li:first-child { border-top: 0; }
.rules li::before { content: counter(rule) ". "; color: var(--muted); }

/* ---------- secure terminal (hidden channel) ---------- */
body.term-open { overflow: hidden; }
.term { position: fixed; inset: 0; z-index: 200; background: #030503; color: #39ff7a; font: 14.5px/1.55 var(--mono); display: flex; flex-direction: column; padding: 18px 20px; }
.t-out { flex: 1; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.t-line { min-height: 1.55em; }
.t-head { color: #b6ffcf; font-weight: 600; letter-spacing: .06em; }
.t-dim { color: #1f8a45; }
.t-ok { color: #6dffa0; }
.t-warn { color: #ffcc4d; }
.t-err { color: #ff5f5f; }
.t-nick { color: #b6ffcf; }
.t-me .t-nick { color: #7cf2ff; }
.t-in { display: flex; gap: 10px; align-items: center; border-top: 1px solid #0f3b1e; padding-top: 10px; }
.t-prompt { color: #6dffa0; white-space: nowrap; }
.t-in input { flex: 1; background: transparent; border: 0; border-radius: 0; padding: 4px 0; color: #39ff7a; font: inherit; caret-color: #39ff7a; box-shadow: none; }
.t-in input:focus { box-shadow: none; outline: none; }
.term ::selection { background: #39ff7a; color: #000; }

/* ---------- footer & toast ---------- */
.foot { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 22px 0 30px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); z-index: 100;
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); transition: transform .25s ease; max-width: calc(100% - 32px);
}
#toast.show { transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .feed-layout { grid-template-columns: minmax(0, 660px); }
  .profile { position: static; }
  .submit-layout { grid-template-columns: minmax(0, 740px); }
  .submit-side { position: static; }
}
@media (max-width: 860px) {
  .features { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 130px); }
  .chat.has-peer .people { display: none; }
  .chat:not(.has-peer) .convo { display: none; }
  .people { border-right: 0; }
  .safety { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .nav { gap: 6px; padding: 0 12px; }
  .brand-name { display: none; }
  .links { margin-left: 0; }
  .links a { padding: 7px 9px; }
  .who .uname { display: none; }
  .btn { padding: 0 12px; }
  main { width: calc(100% - 24px); padding-top: 16px; }
  .foot .brand-name { display: inline; }
  .hero { padding-top: 24px; }
  .fb-head, .fb-body { padding-left: 14px; padding-right: 14px; }
  .fb-title { margin-left: 14px; margin-right: 14px; }
  .tabs button { font-size: 13px; padding: 12px 4px; }
  .submit-body { padding: 14px; }
  .submit-foot { padding: 10px 14px; }
  .auth-form { padding: 24px 20px; }
  .msg { max-width: 88%; }
  .term { font-size: 13px; padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
