/* OnlyBugs: layout of a creator page, colours of a leaf, content of a nature documentary. */

:root {
  /* Greens taken from the OnlyBugs logo: #9aba62 (Only) and #76974f (Bugs). */
  --brand-light: #9aba62;
  --brand: #76974f;
  --bg: #f1f4ec;
  --surface: #ffffff;
  --ink: #1b2114;
  --muted: #616a57;
  --line: #dfe5d5;
  --accent: #587538;        /* darker logo green, readable with white text */
  --accent-ink: #ffffff;
  --accent-soft: #e9f1dc;
  --danger: #d6344b;
  --danger-soft: #fde8eb;

  --badge-creator: #e0263d;
  --badge-mod: #00a33a;
  --badge-vip: #d4169f;
  --badge-sub: #7b2fd0;

  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11140e;
    --surface: #181c14;
    --ink: #e8ede1;
    --muted: #97a08b;
    --line: #2a3122;
    --accent: #9aba62;
    --accent-ink: #10170a;
    --accent-soft: #26301b;
    --danger: #ff5c73;
    --danger-soft: #3a1820;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

[hidden] { display: none !important; }

.icon-cut { stroke: var(--surface); }
.stack { display: grid; gap: 12px; }
.stack-tight { gap: 8px; }
.muted { color: var(--muted); }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.grow { flex: 1; }
.test-result { margin: 0; font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px;
  font: 600 14px/1 var(--font); cursor: pointer;
  background: transparent; color: var(--ink);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-outline { border-color: var(--line); background: var(--surface); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--line); background: var(--surface); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn svg { flex: none; width: 18px; height: 18px; }
.btn-small svg { width: 16px; height: 16px; }
.btn-wide { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted);
  font: 500 14px/1 var(--font); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 900px; margin: 0 auto; height: 58px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.logo { display: inline-flex; align-items: center; }
.logo:hover { text-decoration: none; }
.logo-img { height: 44px; width: auto; }

.userbox { display: flex; align-items: center; gap: 10px; }
.userbox-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--line); }
.userbox-name { font-weight: 600; font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { white-space: nowrap; }

@media (max-width: 560px) {
  .userbox-name { display: none; }
  .userbox { gap: 6px; }
  .userbox .btn-label { display: none; }
  .userbox .btn-small { padding: 0 10px; }
}

/* ---------- Page layout ---------- */

.shell {
  max-width: 900px; margin: 0 auto; padding: 20px 16px 60px;
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start;
}
.rail { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 2px; }
.rail a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 999px;
  color: var(--ink); font-weight: 500;
}
.rail a:hover { background: var(--surface); text-decoration: none; }
.rail a[aria-current="page"] { font-weight: 700; }
.rail svg { width: 22px; height: 22px; color: var(--muted); }

/* Halloween link: orange pumpkin, bright orange glow on hover. */
.rail-sep { height: 1px; margin: 10px 14px; background: var(--line); }
.rail a.rail-haunt {
  transition: color .2s, background-color .2s, box-shadow .25s, text-shadow .25s;
}
.rail a.rail-haunt svg { color: #ff7a00; transition: filter .25s; }
.rail a.rail-haunt:hover,
.rail a.rail-haunt:focus-visible {
  color: #ff7a00;
  background: rgb(255 122 0 / .14);
  box-shadow: 0 0 0 1px rgb(255 140 26 / .95), 0 0 18px rgb(255 122 0 / .8), 0 0 44px rgb(255 122 0 / .5);
  text-shadow: 0 0 10px rgb(255 140 26 / .9);
  text-decoration: none;
  outline: none;
}
.rail a.rail-haunt:hover svg,
.rail a.rail-haunt:focus-visible svg { filter: drop-shadow(0 0 6px #ff8c1a); }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-top: 12px; }
  .rail { display: none; }
}

.feed { min-width: 0; max-width: 620px; display: flex; flex-direction: column; gap: 16px; }
.post-list { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.disclaimer {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 14px;
  background: var(--accent-soft); color: var(--ink);
  border-radius: var(--radius-sm); font-size: 14px;
}
.disclaimer svg { flex: none; width: 20px; height: 20px; color: var(--accent); }

/* ---------- Profile header ---------- */

.profile { border-radius: var(--radius-lg); overflow: hidden; }

.profile-cover {
  height: 190px;
  background-color: var(--accent-soft);
  background-image: url("/ob/static/default-banner.svg");
  background-size: cover; background-position: center;
}
.profile-cover.has-image { background-image: none; }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }

.profile-body { padding: 0 20px 20px; }
.profile-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.profile-avatar {
  width: 112px; height: 112px; margin-top: -56px;
  border-radius: 50%; border: 4px solid var(--surface);
  background: var(--surface); object-fit: cover;
}
.profile-name { margin: 12px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 6px; }
.profile-name .verified { width: 20px; height: 20px; color: var(--brand); }
.profile-handle { color: var(--muted); font-size: 14px; }
.profile-handle .online { color: var(--accent); }
.profile-bio { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-stats { display: flex; gap: 18px; margin-top: 12px; color: var(--muted); font-size: 14px; }
.profile-stats strong { color: var(--ink); font-weight: 700; }

.subscribe-box {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  display: grid; gap: 10px;
}
.subscribe-box h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.btn-sub { justify-content: space-between; padding: 0 22px; min-height: 48px; font-size: 15px; }
.btn-sub .price { font-weight: 700; }
.btn-sub.is-subscribed { border-color: var(--accent); color: var(--accent); }
.btn-sub.is-subscribed .price { font-weight: 500; font-size: 13px; color: var(--muted); }
.btn-sub.is-subscribed:hover .price { color: var(--danger); }
.subscribe-note { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Posts ---------- */

.post { padding: 16px 0 6px; }
.post-head { display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.post-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: var(--line); }
.post-who { min-width: 0; flex: 1; line-height: 1.3; }
.post-name { font-weight: 700; display: flex; align-items: center; gap: 4px; }
.post-name .verified { width: 16px; height: 16px; color: var(--brand); }
.post-handle { color: var(--muted); font-size: 14px; }
.post-time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.post-time:hover { color: var(--accent); }

.post-media { position: relative; margin-top: 12px; overflow: hidden; }
.post-content { display: grid; gap: 12px; }
.post-text { margin: 0; padding: 0 16px; white-space: pre-wrap; overflow-wrap: anywhere; }

.post-images { display: grid; gap: 3px; }
.post-images.n1 { grid-template-columns: 1fr; }
.post-images:not(.n1) { grid-template-columns: 1fr 1fr; }
.post-images a { display: block; background: var(--line); overflow: hidden; }
.post-images img { width: 100%; height: 100%; object-fit: cover; }
.post-images.n1 img { max-height: 640px; object-fit: contain; background: var(--bg); }
.post-images:not(.n1) a { aspect-ratio: 1 / 1; }
.post-images.n3 a:first-child { grid-column: 1 / -1; aspect-ratio: 2 / 1; }

.post-actions {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px 0; margin-top: 6px;
}

/* 18+ cover: the one loud thing on the page. */
.post.is-covered .post-content {
  filter: blur(26px) saturate(.5);
  pointer-events: none; user-select: none;
  min-height: 260px; overflow: hidden;
}
.nsfw-cover {
  position: absolute; inset: 0; z-index: 2;
  display: none; place-items: center; text-align: center; padding: 20px;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.post.is-covered .nsfw-cover { display: grid; }
.nsfw-cover-inner { display: grid; justify-items: center; gap: 10px; max-width: 300px; }
.nsfw-sticker {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border: 3px solid var(--danger); border-radius: 14px;
  background: var(--surface); color: var(--danger);
  font-size: 30px; font-weight: 900; letter-spacing: -0.02em;
  transform: rotate(-7deg);
  box-shadow: 4px 4px 0 var(--danger);
}
.nsfw-sticker svg { width: 30px; height: 30px; }
.nsfw-cover p { margin: 6px 0 0; font-weight: 600; }

/* ---------- Polls ---------- */

.poll { margin: 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; gap: 8px; }
.poll-question { margin: 0 0 4px; font-weight: 700; }
.poll-option {
  position: relative; overflow: hidden;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; min-height: 42px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: 500 15px/1.3 var(--font); text-align: left;
}
button.poll-option { cursor: pointer; }
button.poll-option:hover:not(:disabled) { border-color: var(--accent); }
.poll-option .bar {
  position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%);
  background: var(--accent-soft); z-index: 0;
  transition: width .5s ease;
}
.poll-option > span { position: relative; z-index: 1; }
.poll-option.mine { border-color: var(--accent); }
.poll-option.mine .label::after { content: " ✓"; color: var(--accent); font-weight: 700; }
.poll-option .pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.poll-foot { font-size: 13px; color: var(--muted); }

/* ---------- Comments ---------- */

.comments { margin-top: 6px; padding: 12px 16px 10px; border-top: 1px solid var(--line); display: grid; gap: 14px; }
.comments[hidden] { display: none; }
.comment-list { display: grid; gap: 14px; }
.comment { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: start; }
.comment-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--line); }
.comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; line-height: 1.3; }
.comment-name { font-weight: 700; font-size: 14px; }
.comment-time { color: var(--muted); font-size: 12px; }
.comment-body { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.comment-delete { padding: 4px 6px; }
.comment-delete svg { width: 16px; height: 16px; }
.comments-empty { color: var(--muted); font-size: 14px; margin: 0; }

.badge {
  display: inline-block; padding: 2px 6px; border-radius: 5px;
  font-size: 11px; font-weight: 700; line-height: 1.2; color: #fff;
}
.badge-creator { background: var(--badge-creator); }
.badge-mod { background: var(--badge-mod); }
.badge-vip { background: var(--badge-vip); }
.badge-sub { background: var(--badge-sub); }

.comment-form { display: grid; gap: 8px; }
.comment-form textarea,
.field textarea,
.field input[type="text"],
.field input[type="url"],
.field input:not([type]) {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 var(--font); resize: vertical;
}
.comment-form textarea:focus,
.field textarea:focus,
.field input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.comment-form-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.counter { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; }
.login-hint { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- Feed states ---------- */

.state { padding: 36px 20px; text-align: center; color: var(--muted); }
.state h2 { margin: 0 0 6px; color: var(--ink); font-size: 18px; }
.state p { margin: 0 0 14px; }
.load-more { justify-self: center; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

.footer { color: var(--muted); font-size: 13px; text-align: center; padding: 8px 0; }
.footer a { color: var(--muted); text-decoration: underline; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translate(-50%, 20px); opacity: 0;
  padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 14px;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Simple message page and privacy ---------- */

.message-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.message-card { max-width: 440px; padding: 28px; display: grid; gap: 12px; justify-items: start; }
.message-card h1 { margin: 0; font-size: 22px; }
.message-card p { margin: 0; color: var(--muted); }

.prose { padding: 24px; }
.prose h1 { margin: 0 0 12px; font-size: 24px; }
.prose h2 { margin: 24px 0 8px; font-size: 17px; }
.prose p, .prose li { max-width: 68ch; }
.prose ul { padding-left: 20px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---------- Admin ---------- */

.admin-shell { max-width: 900px; margin: 0 auto; padding: 20px 16px 80px; display: grid; gap: 16px; }
.admin-title { margin: 0; font-size: 22px; font-weight: 800; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-tabs button {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: 500 14px/1 var(--font); cursor: pointer;
}
.admin-tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.panel { padding: 20px; display: grid; gap: 16px; }
.panel h2 { margin: 0; font-size: 18px; }
.panel-intro { margin: -8px 0 0; color: var(--muted); font-size: 14px; }

.field { display: grid; gap: 6px; }
.field > span, .field > label { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row-between { justify-content: space-between; }

.poll-builder { display: grid; gap: 8px; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.poll-builder .option-row { display: flex; gap: 8px; }
.poll-builder .option-row input { flex: 1; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.admin-item { padding: 16px; display: grid; gap: 12px; }
.admin-item-meta { color: var(--muted); font-size: 13px; }
.admin-results { display: grid; gap: 4px; font-size: 14px; }
.admin-results .res { display: flex; justify-content: space-between; gap: 10px; }

.admin-comment { display: grid; gap: 6px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.admin-comment:last-child { border-bottom: 0; }
.admin-comment .filtered { color: var(--muted); font-size: 13px; }

.image-setting { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.image-setting .preview-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.image-setting .preview-banner { width: 220px; height: 72px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: var(--accent-soft); }

.status-list { display: grid; gap: 6px; margin: 0; font-size: 14px; }
.status-list div { display: flex; gap: 8px; }
.status-list dt { color: var(--muted); min-width: 130px; }
.status-list dd { margin: 0; font-weight: 600; }
.status-error { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ======================================================================
   Added: live status, tabs, media, pinned posts, messages, bans, admin extras
   ====================================================================== */

/* ---------- Live ---------- */

.profile-avatar-wrap { position: relative; display: inline-block; margin-top: -56px; border-radius: 50%; }
.profile-avatar-wrap .profile-avatar { margin-top: 0; display: block; }
.profile-avatar-wrap.is-live { box-shadow: 0 0 0 4px var(--danger); }
.live-pill {
  display: none; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  padding: 2px 8px; border-radius: 6px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; border: 2px solid var(--surface);
}
.profile-avatar-wrap.is-live .live-pill { display: block; }

.live-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--danger); color: #fff;
}
.live-banner:hover { text-decoration: none; filter: brightness(1.05); }
.live-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: live-pulse 1.4s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .35; } }
.live-text { display: grid; min-width: 0; flex: 1; }
.live-text span { font-size: 13px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-cta { flex: none; padding: 6px 14px; border-radius: 999px; background: #fff; color: var(--danger); font-weight: 700; font-size: 14px; }

/* ---------- Feed tabs and media ---------- */

.feed-tabs { display: flex; border-bottom: 1px solid var(--line); }
.feed-tabs button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); font: 600 14px/1 var(--font); cursor: pointer;
}
.feed-tabs button svg { width: 18px; height: 18px; }
.feed-tabs .feed-tab-link {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-bottom: 2px solid transparent; color: var(--muted); font: 600 14px/1 var(--font);
}
.feed-tabs .feed-tab-link:hover { color: var(--accent); text-decoration: none; }
.feed-tabs .feed-tab-link svg { width: 18px; height: 18px; }
.feed-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; border-radius: var(--radius); overflow: hidden; }
.media-item { position: relative; aspect-ratio: 1 / 1; background: var(--line); overflow: hidden; display: block; }
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item.is-covered img { filter: blur(18px) saturate(.5); transform: scale(1.15); }
.media-nsfw {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-7deg);
  padding: 3px 8px; border: 2px solid var(--danger); border-radius: 8px;
  background: var(--surface); color: var(--danger); font-weight: 900; font-size: 14px;
}

/* ---------- Pinned ---------- */

.pinned-label { display: flex; align-items: center; gap: 6px; padding: 0 16px 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.pinned-label svg { width: 16px; height: 16px; }
.post.is-pinned { border-color: var(--brand-light); }

/* ---------- Subscribe box extras ---------- */

.subscribe-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.subscribe-actions:has(> :only-child) { grid-template-columns: 1fr; }
.subscribe-actions svg { width: 18px; height: 18px; }

/* ---------- Comments: tools and ban dialog ---------- */

.comment-tools { display: flex; gap: 2px; }
.dialog { max-width: 420px; width: calc(100% - 32px); padding: 22px; color: var(--ink); }
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog h2 { margin: 0; font-size: 19px; }
.dialog p { margin: 0; }
.plain { border: 0; padding: 0; margin: 0; }
.plain legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; }

/* ---------- Top bar: messages ---------- */

.msg-link { position: relative; padding: 8px; }
.msg-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; line-height: 1;
}
.msg-link .msg-count { position: absolute; top: 0; right: -2px; }
.admin-tabs .msg-count { margin-left: 6px; }

/* ---------- Chat ---------- */

.chat { display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 420px; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-back { display: inline-flex; padding: 6px; border: 0; border-radius: 999px; background: none; color: var(--ink); cursor: pointer; }
.chat-back:hover { background: var(--accent-soft); }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--line); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; }
.chat-older { align-self: center; margin-bottom: 10px; }
.chat-list { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.chat-empty { margin: auto; max-width: 320px; text-align: center; color: var(--muted); }
.chat-day { align-self: center; margin: 12px 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.chat-msg { display: flex; flex-direction: column; max-width: 78%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.theirs { align-self: flex-start; align-items: flex-start; }
.chat-bubble {
  padding: 9px 13px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px;
}
.chat-msg.mine .chat-bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.chat-msg.mine .chat-bubble a { color: inherit; text-decoration: underline; }
.chat-msg.theirs .chat-bubble { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.chat-meta { display: flex; align-items: center; gap: 6px; margin: 2px 4px 6px; font-size: 11px; color: var(--muted); }
.chat-seen { display: none; font-weight: 600; }
.chat-msg.seen .chat-seen { display: inline; }
.chat-del { padding: 2px; opacity: 0; }
.chat-del svg { width: 14px; height: 14px; }
.chat-msg:hover .chat-del, .chat-del:focus-visible { opacity: 1; }
.chat-foot { border-top: 1px solid var(--line); padding: 10px 12px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; }
.chat-form textarea {
  flex: 1; resize: none; max-height: 160px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--bg); color: var(--ink);
  font: 400 15px/1.4 var(--font);
}
.chat-form textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.chat-send { width: 44px; min-height: 44px; padding: 0; flex: none; }
.chat-send svg { width: 20px; height: 20px; }
.chat-blocker { display: grid; justify-items: center; gap: 10px; padding: 8px; text-align: center; }
.chat-blocker p { margin: 0; color: var(--muted); }
.chat-note { padding: 4px 6px; color: var(--muted); font-size: 13px; text-align: center; }
.chat-note-top { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--danger-soft); color: var(--danger); }

/* ---------- Admin inbox ---------- */

.inbox { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 12px; align-items: start; }
.inbox-side { max-height: calc(100vh - 140px); overflow-y: auto; }
.inbox-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit;
}
.inbox-item:hover { background: var(--bg); }
.inbox-item.active { background: var(--accent-soft); }
.inbox-item.unread .inbox-last { color: var(--ink); font-weight: 600; }
.inbox-text { display: grid; min-width: 0; flex: 1; gap: 2px; }
.inbox-top { display: flex; align-items: center; gap: 6px; }
.inbox-time { margin-left: auto; font-size: 12px; }
.inbox-last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-empty { padding: 20px; margin: 0; }
.inbox .chat { height: calc(100vh - 140px); }
.inbox .chat-back { display: none; }
@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; }
  .inbox-thread { display: none; }
  .inbox.thread-open .inbox-side { display: none; }
  .inbox.thread-open .inbox-thread { display: block; }
  .inbox .chat-back { display: inline-flex; }
  .chat-head .row .btn { padding: 0 10px; }
}

/* ---------- Admin extras ---------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
}
.tag svg { width: 14px; height: 14px; }
.tag-scheduled { background: #fff3d6; color: #8a5a00; }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) { .tag-scheduled { background: #3a2e12; color: #f2c56b; } }
.schedule-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.schedule-box { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg); }
.field input[type="datetime-local"], .field input[type="number"] {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: 400 14px/1.3 var(--font);
}
.settings-box summary { cursor: pointer; font-weight: 700; }
.settings-box:not([open]) { gap: 0; }
.settings-box .panel-intro { margin: 0; }
