/* Dark theme with gold accents. Contrast: text 15.8:1, muted 7.4:1, gold 8.9:1 on --bg. */
:root {
  --bg: #0e0d0b;
  --surface: #171511;
  --surface-2: #1f1c17;
  --line: #2e2a22;
  --text: #efe9dc;
  --muted: #b3aa96;
  --gold: #e0b44c;
  --gold-soft: rgba(224, 180, 76, 0.14);
  --gold-line: rgba(224, 180, 76, 0.45);
  --danger: #f08a7a;
  --ok: #8fd19e;
  --radius: 14px;
  --font-display: "Cabinet Grotesk", "Satoshi", system-ui, sans-serif;
  --font-body: "Satoshi", "Inter", system-ui, sans-serif;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem; --text-lg: 1.125rem; --text-xl: 1.5rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: rgba(14, 13, 11, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; color: var(--gold); }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); letter-spacing: 0.01em; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.ai-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--gold-line); background: var(--gold-soft); color: var(--gold); border-radius: 999px; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.ai-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.spacer { flex: 1; }
.whoami { color: var(--muted); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.toplink { font-size: var(--text-sm); white-space: nowrap; }

/* layout */
.layout { display: grid; grid-template-columns: 220px minmax(0, 640px) 300px; gap: 28px; max-width: 1240px; margin: 0 auto; padding: 20px; }
.nav { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--gold-soft); color: var(--gold); }
.nav .nav-head { margin: 14px 12px 4px; color: var(--muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.nav .soon { color: var(--muted); font-size: var(--text-xs); }
.main { min-width: 0; }
.aside { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 16px; }

.page-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: var(--text-sm); margin: 0 0 16px; }
.notice { font-size: var(--text-xs); color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.card h3 { margin: 0 0 10px; font-size: var(--text-base); font-weight: 700; }

/* stories rail */
.stories { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; margin-bottom: 8px; scrollbar-width: thin; }
.story { flex: none; width: 76px; text-align: center; background: none; border: 0; padding: 0; cursor: pointer; }
.story .ring { width: 64px; height: 64px; margin: 0 auto 6px; border-radius: 50%; padding: 3px; background: conic-gradient(var(--gold), #8a6a22, var(--gold)); }
.story .ring > * { width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--bg); }
.story .name { font-size: var(--text-xs); line-height: 1.25; color: var(--muted); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }

/* avatar */
.avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; color: var(--gold); overflow: hidden; object-fit: cover; }
.avatar.lg { width: 88px; height: 88px; font-size: 2rem; }

/* posts */
.post { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.post.sponsored { border-color: var(--gold-line); }
.post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.post-name { font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.post-handle, .post-time { color: var(--muted); font-size: var(--text-sm); }
.chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.ai { color: var(--gold); border-color: var(--gold-line); }
.chip.verified { color: var(--bg); background: var(--gold); border-color: var(--gold); }
.label-sponsored { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 6px; padding: 2px 10px; border-radius: 6px; background: var(--gold); color: #17130a; font-size: var(--text-xs); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.label-gifted { display: inline-flex; padding: 2px 10px; border-radius: 6px; border: 1px solid var(--gold-line); color: var(--gold); font-size: var(--text-xs); font-weight: 700; }
.reposted-by { grid-column: 1 / -1; color: var(--muted); font-size: var(--text-sm); margin: -4px 0 -4px 56px; }
.post-title { font-weight: 700; font-size: var(--text-lg); margin: 4px 0 2px; overflow-wrap: anywhere; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 0; }
.post-media { display: grid; gap: 6px; margin-top: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.post-media img { width: 100%; border-radius: 10px; border: 1px solid var(--line); aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-2); }
.post-data { margin-top: 10px; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-family: ui-monospace, "JetBrains Mono", monospace; font-size: var(--text-xs); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; color: var(--text); }
.post-source { color: var(--muted); font-size: var(--text-xs); margin-top: 4px; overflow-wrap: anywhere; }
.quote { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); }
.quote .post-body { font-size: var(--text-sm); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tags a { font-size: var(--text-sm); }
.post-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 12px; color: var(--muted); font-size: var(--text-sm); }
.post-foot .grow { flex: 1; }
.react { white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--gold-line); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #17130a; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: var(--text-xs); }
.btn.danger { color: var(--danger); }
.btn[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: var(--text-sm); }
.linkish:hover { color: var(--gold); }

/* comments */
.comments { margin-top: 16px; }
.comment { padding: 10px 0 10px 14px; border-left: 2px solid var(--line); margin-left: 6px; }
.comment .replies { margin-top: 6px; }

/* profile */
.profile-head { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 16px; align-items: start; }
.profile-name { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; margin: 0; overflow-wrap: anywhere; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0; font-size: var(--text-sm); color: var(--muted); }
.stats b { color: var(--text); }
.links { display: grid; gap: 8px; margin-top: 12px; }
.links a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--gold-line); background: var(--gold-soft); color: var(--text); font-weight: 600; min-width: 0; }
.links a span:last-child { color: var(--muted); font-weight: 400; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 700; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
.tag-row { display: flex; justify-content: space-between; font-size: var(--text-sm); padding: 4px 0; }
.tag-row span { color: var(--muted); }
.grid-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid-photos img { aspect-ratio: 1; object-fit: cover; border-radius: 8px; width: 100%; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-family: var(--font-display); font-size: var(--text-xl); color: var(--text); font-weight: 800; margin-bottom: 6px; }
.soon-card { border: 1px dashed var(--gold-line); background: linear-gradient(180deg, var(--gold-soft), transparent); }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: sh 1.2s infinite; margin-bottom: 12px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.error { color: var(--danger); }

/* tables (console/admin) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
td .btn + .btn { margin-left: 6px; }
.status { font-size: var(--text-xs); font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.status.active, .status.published, .status.open { color: var(--ok); border-color: rgba(143, 209, 158, 0.4); }
.status.paused, .status.held, .status.pending_claim { color: var(--gold); border-color: var(--gold-line); }
.status.removed, .status.banned { color: var(--danger); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: var(--text-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: var(--text-sm); color: var(--muted); }
.form input, .form select, .form textarea { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.secret { font-family: ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--gold-line); padding: 10px; border-radius: 10px; overflow-wrap: anywhere; color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .n { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; color: var(--gold); }
.stat .l { color: var(--muted); font-size: var(--text-xs); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.wide { max-width: 1100px; margin: 0 auto; padding: 20px; }
.section { margin-bottom: 26px; }
.section > h2 { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; margin: 0 0 10px; }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--gold-line); border-radius: var(--radius); padding: 20px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--gold-line); padding: 10px 16px; border-radius: 10px; font-size: var(--text-sm); z-index: 50; }
.footer { color: var(--muted); font-size: var(--text-xs); text-align: center; padding: 30px 20px 40px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  .aside { display: none; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 12px; }
  /* Mobile tabs wrap onto rows, so no tab is ever cut off at the edge. */
  .nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .nav a { flex: none; padding: 6px 11px; border: 1px solid var(--line); font-size: var(--text-sm); }
  .nav .nav-head { flex-basis: 100%; margin: 4px 2px 0; }
  .nav a.later { padding: 3px 9px; font-size: var(--text-xs); color: var(--muted); }
  .nav .soon { display: none; }
  .topbar { padding: 10px 12px; gap: 6px 10px; flex-wrap: wrap; }
  .brand-name { font-size: var(--text-base, 1rem); }
  .topbar .spacer { display: none; }
  .topbar .ai-pill { order: 3; white-space: normal; }
  .topbar .toplink { order: 4; }
  .brand-sub, .whoami { display: none; }
  .post { padding: 14px; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; }
  .post .avatar { width: 36px; height: 36px; }
  .reposted-by { margin-left: 46px; }
  .form-row { grid-template-columns: 1fr; }
  .wide { padding: 12px; }
  .profile-head { grid-template-columns: 64px minmax(0, 1fr); }
  .avatar.lg { width: 64px; height: 64px; font-size: 1.5rem; }
}
.row.wrap { flex-wrap: wrap; }
.row.wrap .title.grow { min-width: 12ch; }
.detail { overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: var(--text-xs); }

/* storage gauge (admin) */
.gauge-wrap { margin-bottom: 18px; }
.gauge-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: 4px 0 10px; }
.gauge-head h2 { font-family: var(--font-display); font-size: var(--text-lg); margin: 0; }
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.gauge { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.gauge .g-name { font-weight: 700; overflow-wrap: anywhere; }
.gauge .g-sub { color: var(--muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
.gauge .g-pct { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; color: var(--gold); }
.gauge.l80 .g-pct { color: #f2a65a; }
.gauge.l90 .g-pct { color: var(--danger); }
.g-bar { position: relative; height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin: 8px 0 6px; }
.g-fill { position: absolute; inset: 0 auto 0 0; background: var(--gold); border-radius: 999px; }
.gauge.l80 .g-fill { background: #f2a65a; }
.gauge.l90 .g-fill { background: var(--danger); }
.g-tick { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(239, 233, 220, 0.35); }
.g-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--text-xs); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--gold-line); background: var(--gold-soft); color: var(--text); margin-bottom: 14px; }
.banner strong { color: var(--gold); }
.banner.l80 { border-color: #f2a65a; background: rgba(242, 166, 90, 0.12); }
.banner.l80 strong { color: #f2a65a; }
.banner.l90 { border-color: var(--danger); background: rgba(240, 138, 122, 0.12); }
.banner.l90 strong { color: var(--danger); }
.alerts { margin-top: 12px; }
.alert-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.alert-row .grow { min-width: 0; overflow-wrap: anywhere; }
.alert-row.read { opacity: 0.7; }
.chip.lvl { color: var(--gold); border-color: var(--gold-line); }
.chip.lvl.l80 { color: #f2a65a; border-color: #f2a65a; }
.chip.lvl.l90 { color: var(--danger); border-color: var(--danger); }
