:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #16181c;
  --ink: #e7e9ea;
  --muted: #71767b;
  --line: #2f3336;
  --accent: #1fd18a;
  --accent-ink: #06120d;
  --accent-soft: rgba(31, 209, 138, 0.12);
  --danger: #f4212e;
  --danger-soft: rgba(244, 33, 46, 0.12);
  --warn: #ffd400;
  --warn-soft: rgba(255, 212, 0, 0.1);
  --k-color: #7c8cff;
  --k-soft: rgba(124, 140, 255, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  font-size: 15px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --ink: #0f1419;
  --muted: #536471;
  --line: #eff3f4;
  --accent: #0f9d6c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 157, 108, 0.09);
  --danger: #d21f34;
  --danger-soft: rgba(210, 31, 52, 0.08);
  --warn: #9a6700;
  --warn-soft: rgba(154, 103, 0, 0.08);
  --k-color: #5b21b6;
  --k-soft: rgba(91, 33, 182, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---- top bar ---- */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
[data-theme="light"] #topbar { background: rgba(255,255,255,0.85); }
.brand {
  font-weight: 800; font-size: 1.2rem; color: var(--ink);
  letter-spacing: -0.02em; display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.brand .mark { color: var(--accent); }
#topbar nav { display: flex; gap: 4px; }
#topbar nav a {
  color: var(--muted); font-weight: 600; font-size: 0.88rem;
  padding: 7px 11px; border-radius: 999px;
}
#topbar nav a:hover { background: var(--surface-2); color: var(--ink); }
#topbar nav a.active { color: var(--ink); }
.spacer { flex: 1; }

.search-wrap { position: relative; display: flex; align-items: center; }
#search-input {
  width: 240px; max-width: 40vw;
  background: var(--surface-2); border: 1px solid transparent;
  color: var(--ink); border-radius: 999px; padding: 8px 14px 8px 34px;
  font-size: 0.86rem; transition: width 0.15s;
}
#search-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.search-wrap::before {
  content: "⌕"; position: absolute; left: 12px; color: var(--muted);
  font-size: 1rem; pointer-events: none;
}
#search-toggle { display: none; }

.icon-btn {
  border: none; background: none; color: var(--ink); cursor: pointer;
  width: 34px; height: 34px; border-radius: 999px; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); }

.switcher { color: var(--muted); font-size: 0.78rem; display: flex; align-items: center; gap: 5px; }
.switcher select {
  font: inherit; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface-2); color: var(--ink);
  max-width: 26vw;
}
.badge {
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 0.68rem; padding: 1px 6px; vertical-align: 2px; font-weight: 700;
}

main { max-width: 600px; margin: 0 auto; padding: 0 0 70px; min-height: 70vh; }
main.wide { max-width: 680px; }
footer {
  max-width: 600px; margin: 10px auto 30px; padding: 0 16px;
  color: var(--muted); font-size: 0.74rem;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 12px 16px;
}
.card h2, .card h3 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- band chips — public reputation display, core differentiator ---- */
.bands { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.dot.v-Provisional { background: #71767b; }
.dot.v-Building     { background: #6b93ff; }
.dot.v-Good         { background: #1fd18a; }
.dot.v-Strong       { background: #17b881; }
.dot.v-Pillar       { background: #ffd400; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; border: 1px solid transparent;
  white-space: nowrap; letter-spacing: 0.01em;
}
.chip.v { background: var(--surface-2); color: var(--muted); }
.chip.c-Marked { background: var(--warn-soft); color: var(--warn); }
.chip.c-Restricted, .chip.c-Frozen { background: var(--danger-soft); color: var(--danger); }
.chip.k { background: var(--k-soft); color: var(--k-color); }
.chip.mod { background: var(--accent-soft); color: var(--accent); }
.chip.topic {
  background: var(--surface-2); color: var(--muted); font-weight: 600;
  cursor: pointer;
}
.chip.topic:hover { color: var(--ink); background: var(--line); }

.bands-tip {
  position: relative; cursor: default; display: inline-flex;
}
.bands-tip .tip {
  display: none; position: absolute; bottom: 130%; left: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 0.72rem;
  white-space: nowrap; z-index: 30; color: var(--ink);
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
}
.bands-tip:hover .tip, .bands-tip:focus-within .tip, .bands-tip.open .tip { display: block; }
.tip .tip-row { display: flex; justify-content: space-between; gap: 14px; padding: 1px 0; }
.tip .tip-row b { font-weight: 700; }

/* ---- composer ---- */
.composer { padding: 14px 16px; border-bottom: 8px solid var(--line); }
.composer textarea {
  width: 100%; border: none; background: none; color: var(--ink);
  font-size: 1.05rem; resize: none; min-height: 24px; padding: 6px 0;
  font-family: inherit;
}
.composer textarea:focus { outline: none; }
.composer-title {
  width: 100%; border: none; background: none; color: var(--ink);
  font-size: 1.05rem; font-weight: 700; padding: 6px 0; font-family: inherit;
}
.composer-title:focus { outline: none; }
.composer-title::placeholder, .composer textarea::placeholder { color: var(--muted); }
.composer-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 8px; border-top: 1px solid transparent;
}
.composer.expanded .composer-foot { border-top-color: var(--line); padding-top: 10px; }
.topic-picker {
  font: inherit; font-size: 0.78rem; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.composer-err { color: var(--danger); font-size: 0.8rem; margin-top: 6px; }

/* ---- feed / post card ---- */
.feed-list { border-top: 1px solid var(--line); }
.post-card {
  display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.post-card:hover { background: var(--surface-2); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--k-color));
  display: flex; align-items: center; justify-content: center;
  color: #06120d; font-weight: 800; font-size: 1rem;
}
.post-body-col { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; font-size: 0.92rem; }
.post-head .name { font-weight: 700; color: var(--ink); }
.post-head .handle, .post-head .dot-sep, .post-head .time { color: var(--muted); }
.post-title { font-weight: 700; font-size: 0.98rem; margin: 2px 0 1px; color: var(--ink); }
.post-text { white-space: pre-wrap; word-break: break-word; margin: 0 0 6px; color: var(--ink); }
.topic-row { margin: 4px 0 6px; }
.live-badge {
  background: var(--accent); color: var(--accent-ink); font-size: 0.66rem;
  padding: 1px 7px; border-radius: 4px; font-weight: 700;
}
.removed-note {
  font-size: 0.82rem; color: var(--muted); font-style: italic;
  border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px;
}

.action-row { display: flex; align-items: center; gap: 26px; margin-top: 6px; }
.action-btn {
  display: inline-flex; align-items: center; gap: 6px; border: none;
  background: none; color: var(--muted); cursor: pointer; font-size: 0.82rem;
  padding: 6px 8px; margin: -6px -8px; border-radius: 999px;
}
.action-btn:hover { color: var(--accent); background: var(--accent-soft); }
.action-btn.report:hover { color: var(--danger); background: var(--danger-soft); }
.action-btn.on { color: var(--accent); font-weight: 700; }
.action-btn .ic { font-size: 0.95rem; }

/* ---- thread ---- */
.thread-post { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.thread-post .post-title { font-size: 1.3rem; margin-top: 8px; }
.thread-post .post-text { font-size: 1.05rem; margin-top: 8px; }
.thread-post .post-head { font-size: 0.95rem; }
.back-link {
  display: flex; align-items: center; gap: 18px; padding: 8px 12px;
  position: sticky; top: 49px; background: rgba(0,0,0,0.72);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  z-index: 15; font-weight: 700; border-bottom: 1px solid var(--line);
}
[data-theme="light"] .back-link { background: rgba(255,255,255,0.85); }

.comment { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.comment.reply { padding-left: 44px; }
.comment .avatar { width: 32px; height: 32px; font-size: 0.82rem; }
.comment-body { flex: 1; min-width: 0; }
.comment .post-text { font-size: 0.92rem; margin: 2px 0 4px; }

.reply-form-wrap { padding: 10px 16px; }

/* ---- forms ---- */
form.stack { display: flex; flex-direction: column; gap: 10px; max-width: 480px; }
input, textarea, select {
  font: inherit; border-radius: 8px; border: 1px solid var(--line);
  padding: 9px 12px; background: var(--surface-2); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; font-family: inherit; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  font-weight: 700; cursor: pointer; align-self: flex-start;
  border-radius: 999px; padding: 8px 18px; font-size: 0.9rem;
}
button.primary:disabled { opacity: 0.5; cursor: default; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.ghost {
  cursor: pointer; border-radius: 999px; padding: 7px 14px; font-size: 0.85rem;
  border: 1px solid var(--line); background: none; color: var(--ink);
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.notice { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 0.85rem; }
.error { border-left: 3px solid var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 0.85rem; color: var(--danger); }

table.plain { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.plain td, table.plain th { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
code.invite { background: var(--surface-2); border: 1px dashed var(--line); padding: 2px 8px; border-radius: 6px; font-size: 0.9rem; }

/* ---- reputation statement ---- */
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 4px; }
.score-cell {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; text-align: center;
}
.score-cell .num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.score-cell .axis { font-size: 0.72rem; color: var(--muted); }

.statement-entry {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.statement-entry:last-child { border-bottom: none; }
.statement-entry .delta { text-align: right; font-size: 0.82rem; color: var(--muted); max-width: 46%; }
.statement-entry.neg .delta { color: var(--danger); }

/* ---- search results ---- */
.search-group h3 {
  padding: 10px 16px 4px; margin: 0; font-size: 0.95rem; color: var(--muted);
}
.search-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.user-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.user-row .who { flex: 1; min-width: 0; }
.user-row .display-name { font-weight: 700; }

/* ---- load more / spinner ---- */
.load-more-wrap { display: flex; justify-content: center; padding: 16px; }
.spinner {
  width: 22px; height: 22px; border: 2.5px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- bottom tab bar (mobile) ---- */
#tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.9); -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  z-index: 20; padding-bottom: env(safe-area-inset-bottom);
}
[data-theme="light"] #tabbar { background: rgba(255,255,255,0.92); }
#tabbar .tabs { display: flex; }
#tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 9px 0 7px; color: var(--muted); font-size: 1.25rem;
  position: relative;
}
#tabbar a.active { color: var(--ink); }
#tabbar a .tab-label { font-size: 0.6rem; font-weight: 600; }

/* ---- invite link landing: presentation + status screens ---- */
.iv-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 100;
  display: flex; flex-direction: column;
}
.iv-topbar { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 0; }
.iv-dots { display: flex; gap: 6px; }
.iv-dot {
  flex: 1; height: 3px; background: var(--line); border-radius: 3px;
  overflow: hidden; cursor: pointer;
}
.iv-dot-fill { display: block; height: 100%; width: 0%; background: var(--accent); }
.iv-dot.done .iv-dot-fill { width: 100%; }
.iv-dot.active .iv-dot-fill { animation: ivFill 5s linear forwards; }
@keyframes ivFill { from { width: 0%; } to { width: 100%; } }
.iv-toprow { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.iv-countdown-chip {
  font-size: 0.78rem; font-variant-numeric: tabular-nums; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px;
}
.iv-countdown-low { color: var(--danger) !important; }
.iv-skip {
  border: none; background: none; color: var(--muted); font-size: 0.82rem;
  cursor: pointer; padding: 6px 4px;
}
.iv-skip:hover { color: var(--ink); }
.iv-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 30px 24px;
  cursor: pointer;
}
.iv-step { max-width: 480px; width: 100%; }
.iv-eyebrow {
  color: var(--accent); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; font-size: 0.72rem; margin-bottom: 14px;
}
.iv-headline {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 14px; line-height: 1.22;
}
.iv-sub { color: var(--muted); font-size: 1.05rem; margin: 0 0 8px; }
.iv-beats { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 18px; }
.iv-beat {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.iv-beat b { color: var(--ink); }
.iv-beat span { display: block; color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.iv-cta { margin-top: 26px; display: flex; justify-content: center; cursor: default; }
.iv-signup { max-width: 380px; width: 100%; text-align: left; cursor: default; }

/* staggered fade/slide reveal per line, respects reduced motion */
.iv-line { opacity: 0; transform: translateY(14px); animation: ivFadeUp 0.6s ease forwards; }
.iv-line:nth-child(1) { animation-delay: 0.05s; }
.iv-line:nth-child(2) { animation-delay: 0.22s; }
.iv-line:nth-child(3) { animation-delay: 0.4s; }
.iv-line:nth-child(4) { animation-delay: 0.58s; }
@keyframes ivFadeUp { to { opacity: 1; transform: none; } }
.iv-overlay.no-motion .iv-line,
.iv-overlay.no-motion .iv-dot.active .iv-dot-fill { animation: none !important; opacity: 1 !important; transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  .iv-line { animation: none !important; opacity: 1 !important; transform: none !important; }
  .iv-dot.active .iv-dot-fill { animation: none !important; width: 100%; }
}

.iv-status-screen { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.iv-status-card { text-align: center; max-width: 380px; }
.iv-status-mark { font-size: 2.4rem; color: var(--accent); margin-bottom: 10px; }

.invite-new-panel {
  margin-top: 10px; padding: 12px 14px; border: 1px dashed var(--accent);
  background: var(--accent-soft); border-radius: var(--radius-sm);
}
.invite-new-panel code.invite { display: block; white-space: nowrap; }

/* ---- welcome modal (first signup only) ---- */
.welcome-modal-wrap {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: ivFadeIn 0.2s ease;
}
@keyframes ivFadeIn { from { opacity: 0; } to { opacity: 1; } }
.welcome-modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 24px; max-width: 380px;
  text-align: center; animation: ivPopIn 0.3s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes ivPopIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.welcome-mark { font-size: 2.2rem; color: var(--accent); margin-bottom: 8px; }
.welcome-modal h2 { margin: 0 0 10px; }
.welcome-modal p { color: var(--muted); margin: 6px 0; }
.welcome-modal button.primary { margin-top: 14px; width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .welcome-modal-wrap, .welcome-modal { animation: none !important; }
}

/* ---- mobile ---- */
@media (max-width: 640px) {
  #topbar { padding: 8px 10px; gap: 6px; }
  #topbar nav { display: none; }
  .search-wrap { display: none; }
  .search-wrap.open {
    display: flex; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg); z-index: 40; padding: 10px 12px; align-items: flex-start;
  }
  .search-wrap.open #search-input { width: 100%; max-width: none; }
  #search-toggle { display: flex; }
  .switcher { font-size: 0.68rem; }
  .switcher select { max-width: 22vw; }
  main { padding-bottom: 78px; }
  #tabbar { display: block; }
  .card { margin: 10px 10px; padding: 13px; }
  .post-card, .comment { padding: 11px 10px; }
  .comment.reply { padding-left: 34px; }
  .score-grid { gap: 6px; }
  .score-cell { padding: 8px 6px; }
  .score-cell .num { font-size: 1.35rem; }
  .score-cell .axis { font-size: 0.64rem; }
  .statement-entry { flex-direction: column; gap: 3px; }
  .statement-entry .delta { text-align: left; max-width: 100%; }
  footer { flex-direction: column; gap: 6px; padding: 10px 14px; }
  table.plain { font-size: 0.8rem; }
  .action-row { gap: 18px; }
  .iv-headline { font-size: 1.5rem; }
  .iv-sub { font-size: 0.95rem; }
  .iv-stage { padding: 22px 18px; }
  .welcome-modal { padding: 22px 18px; }
}
