:root {
  color-scheme: light;
  --bg: #f4f5f9;
  --panel: #ffffff;
  --text: #14161c;
  --muted: #667085;
  --line: #e4e7ee;
  --hover: #eef0f6;
  /* --accent-base is the brand color (an admin can change it); each theme derives --accent from it. */
  --accent-base: #5b5bf0;
  --accent: var(--accent-base);
  --accent-text: var(--accent-text-light, #ffffff);
  --accent-strong: var(--accent-strong-light, #4545d6);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--panel));
  --danger: #d92d4b;
  --danger-strong: #b42340;
  --on-danger: #fff;
  --like: #e0245e;
  --on-like: #fff;
  --repost: #0b8040;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);

  --fs-xs: 13px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
}

/* Dark colors, twice: once for "follow the device" and once for the Dark button in Settings. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1016;
    --panel: #171a22;
    --text: #eceef4;
    --muted: #98a1b3;
    --line: #272b36;
    --hover: #1f232e;
    --accent: color-mix(in oklab, var(--accent-base) 65%, white);
    --accent-text: var(--accent-text-dark, #0e1016);
    --accent-strong: var(--accent);
    --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--panel));
    --danger: #ff6b84;
    --danger-strong: var(--danger);
    --on-danger: #0e1016;
    --like: #ff5c8d;
    --on-like: #0e1016;
    --repost: #3ecf7a;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1016;
  --panel: #171a22;
  --text: #eceef4;
  --muted: #98a1b3;
  --line: #272b36;
  --hover: #1f232e;
  --accent: color-mix(in oklab, var(--accent-base) 65%, white);
  --accent-text: var(--accent-text-dark, #0e1016);
  --accent-strong: var(--accent);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--panel));
  --danger: #ff6b84;
  --danger-strong: var(--danger);
  --on-danger: #0e1016;
  --like: #ff5c8d;
  --on-like: #0e1016;
  --repost: #3ecf7a;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: var(--fs-xl); margin: 0; line-height: 1.3; }
h2 { font-size: var(--fs-lg); font-weight: 700; line-height: 1.3; margin: 0 0 var(--sp-2); }
p { margin: 0; }
small { font-size: var(--fs-xs); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.center { text-align: center; }
.error { color: var(--danger); }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* layout */

.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 620px) 300px;
  gap: 24px;
  justify-content: center;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

.nav {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 0;
  height: 100vh;
}

.logo, .nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--text);
  font-size: var(--fs-md);
  position: relative;
}
.logo { font-weight: 800; font-size: var(--fs-lg); margin-bottom: 8px; }
.logo img { width: 30px; height: 30px; }
.logo:hover, .nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active { font-weight: 700; color: var(--accent); }
.badge {
  background: var(--like);
  color: var(--on-like);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 18px;
  min-width: 18px;
  padding: 0 5px;
  text-align: center;
  position: absolute;
  left: 26px;
  top: 4px;
}

.main { min-height: 100vh; padding: 16px 0 80px; min-width: 0; }
.side { padding: 16px 0; display: flex; flex-direction: column; gap: 16px; align-self: start; position: sticky; top: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.side-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; color: var(--text); }
.side-row small { color: var(--muted); }
.side-row.person { justify-content: flex-start; }
.side-row.person > span:nth-child(2) { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { color: var(--muted); font-size: var(--fs-xs); padding: 0 4px; }

/* shared pieces */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn, .action, .nav-item, .tabs a, .user-row, .notice { transition: background-color .15s, color .15s, border-color .15s; }
.btn:active, .action:active { transform: scale(.96); }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--hover); filter: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.wide { width: 100%; padding: 11px; }
.btn[aria-busy="true"]::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.more { display: flex; margin: 16px auto; }
button.link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
button.link:hover { text-decoration: underline; }

input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: none; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.avatar {
  --hue: 240;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: hsl(var(--hue) 55% 48%);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-lg);
  overflow: hidden;
  flex: none;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.small { width: 34px; height: 34px; font-size: 15px; }
.avatar.medium { width: 50px; height: 50px; font-size: 22px; }
.avatar.large { width: 92px; height: 92px; font-size: 40px; }

.chip {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 600;
  vertical-align: middle;
}
.chip.danger { background: color-mix(in srgb, var(--danger) 12%, var(--panel)); color: var(--danger-strong); }
.chip.big { font-size: var(--fs-sm); padding: 6px 14px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.heading { padding: 4px 4px 14px; }
.heading.back { font-weight: 600; }
.section { margin: var(--sp-6) var(--sp-1) var(--sp-3); font-size: var(--fs-lg); font-weight: 700; line-height: 1.3; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.tabs {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 4px;
  margin-bottom: 12px;
  gap: 4px;
}
.tabs a { flex: 1; text-align: center; padding: 8px 4px; border-radius: var(--r-md); color: var(--muted); font-weight: 600; }
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a.active { background: var(--accent-soft); color: var(--accent-strong); }

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--sp-6);
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: var(--fs-sm);
  z-index: 40;
  max-width: calc(100vw - 32px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  animation: toast-in .15s ease-out;
}
.toast.error::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--sp-2); border-radius: 50%; background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* loading placeholders, empty and error states */

.post.skeleton { cursor: default; }
.skel-avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 6px 0 14px; }
.skel-bar { height: 12px; border-radius: 6px; width: 40%; }
.skel-bar:nth-child(2) { width: 90%; }
.skel-bar:nth-child(3) { width: 70%; }
.skel-avatar, .skel-bar {
  background: var(--hover) linear-gradient(90deg, transparent 25%, color-mix(in srgb, var(--panel) 55%, transparent) 50%, transparent 75%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: 40px var(--sp-4); text-align: center; }
.empty-icon { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; margin-bottom: var(--sp-1); border-radius: 50%; background: var(--hover); color: var(--muted); }
.empty-icon .icon { width: 28px; height: 28px; }
.empty-state.error .empty-icon { color: var(--danger); }
.empty-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.empty-hint { font-size: var(--fs-sm); color: var(--muted); max-width: 320px; }
.empty-state .btn { margin-top: var(--sp-2); }

/* posts */

.list { display: flex; flex-direction: column; gap: var(--sp-3); }

.post {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  cursor: pointer;
  transition: background-color .15s;
}
.post:hover { background: color-mix(in srgb, var(--hover) 50%, var(--panel)); }
.post.big { cursor: default; margin: 8px 0; }
.post.big:hover, .post.skeleton:hover { background: var(--panel); }
.post.big .text { font-size: var(--fs-lg); }
.post-avatar:hover { text-decoration: none; }
.post-main { flex: 1; min-width: 0; }
.post header { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.post header .name { color: var(--text); font-size: var(--fs-md); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post header .handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post header .muted { flex: none; font-size: var(--fs-sm); }
.post header .handle { flex: 0 1 auto; min-width: 0; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.replying { font-size: var(--fs-sm); }

.photo { display: block; width: 100%; padding: 0; cursor: zoom-in; margin-top: 0; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.photo img { display: block; width: 100%; max-height: 520px; object-fit: contain; }

.post footer { display: flex; justify-content: space-between; max-width: 420px; gap: 0; margin: 6px 0 0 -8px; }
.action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 36px;
  padding: 7px 8px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.icon-more { stroke-width: 3; }
.action .icon { width: 19px; height: 19px; }
.action:hover { background: var(--hover); color: var(--accent); text-decoration: none; }
.action.like:hover, .action.like.on { color: var(--like); }
.action.like.on .icon { fill: var(--like); }
.action.save.on { color: var(--accent); }
.action.save.on .icon { fill: var(--accent); }

.menu { position: relative; margin-left: auto; align-self: center; }
.menu summary { list-style: none; cursor: pointer; color: var(--muted); border-radius: 999px; padding: 2px 6px; display: flex; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--hover); }
.menu summary.btn { padding: 8px 10px; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 10;
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}
.menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.menu-list button:hover { background: var(--hover); }
.menu-list button.danger { color: var(--danger); }

/* reposts, polls, editing */

.label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; margin-bottom: 2px; }
.label .icon { width: 15px; height: 15px; }
.label a { color: inherit; }
.action.repost.on, .action.repost:hover { color: var(--repost); }
.editor { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; cursor: auto; }

.poll { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.poll-option {
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.poll-option:hover { background: var(--accent-soft); }
.poll-result {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--bg);
  overflow: hidden;
}
.poll-bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-radius: var(--r-md); transition: width .4s; }
.poll-result.mine .poll-bar { background: color-mix(in srgb, var(--accent) 35%, var(--panel)); }
.poll-text, .poll-result b { position: relative; }
.poll-text { overflow-wrap: anywhere; }

.poll-builder { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); }
.poll-inputs { display: flex; flex-direction: column; gap: 8px; }
.poll-builder .row { justify-content: space-between; }

select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.pill { display: block; margin: 0 auto 10px; padding: 8px 18px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }

.announcement { background: var(--accent-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: var(--r-lg); padding: 10px 16px; margin-bottom: 12px; font-weight: 500; overflow-wrap: anywhere; }

.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .88); display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); }
.lightbox-count { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #fff; font-weight: 600; background: rgba(0, 0, 0, .5); padding: 2px 12px; border-radius: 999px; }
.lightbox-count:empty { display: none; }
.sheet { cursor: default; }
.sheet-card { width: min(440px, 100%); max-height: 80vh; overflow-y: auto; cursor: auto; }
.sheet-head { justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; }
.dialog-card { width: min(400px, 100%); padding: 20px; display: flex; flex-direction: column; gap: var(--sp-3); }
.dialog-card h2 { margin: 0; overflow-wrap: anywhere; }
.dialog-body { font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-1); }
.photos { display: grid; gap: 4px; margin-top: 10px; border-radius: var(--r-lg); overflow: hidden; }
.photos .photo { margin: 0; border-radius: 0; border: 0; }
.photos.count-1 .photo { border: 1px solid var(--line); border-radius: var(--r-lg); }
.photos:not(.count-1) { grid-template-columns: 1fr 1fr; }
.photos:not(.count-1) img { aspect-ratio: 4 / 3; height: 100%; max-height: none; object-fit: cover; }
.photos.count-3 .photo:first-child { grid-row: span 2; }
.photos.count-3 .photo:first-child img { aspect-ratio: auto; }
.when { margin-top: 10px; }
.logo-preview { width: 44px; height: 44px; border-radius: var(--r-md); object-fit: cover; }
.logo img, .auth-logo { border-radius: 22%; object-fit: cover; }
.invite-link { overflow-wrap: anywhere; }
.invite-link .link { text-align: left; overflow-wrap: anywhere; }

/* verified tick, videos */

.verified { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; border-radius: 50%; background: var(--accent); color: var(--accent-text); vertical-align: -2px; flex: none; }
.verified .icon { width: 11px; height: 11px; stroke-width: 3.500; }
h1 .verified { width: 20px; height: 20px; vertical-align: -1px; }
h1 .verified .icon { width: 13px; height: 13px; }
.video { margin-top: 10px; position: relative; aspect-ratio: 16 / 9; cursor: pointer; }
.video img { height: 100%; max-height: none; object-fit: cover; }
iframe.video { border: 0; cursor: auto; }
.play { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; display: flex; align-items: center; justify-content: center; }
.play .icon { width: 30px; height: 30px; fill: #fff; stroke: none; margin-left: 4px; }
.share-url { flex: 1; width: auto; min-width: 0; }
input.color { width: 56px; height: 38px; padding: 3px; cursor: pointer; }

/* composer */

.composer-bar .menu { margin-left: 0; }
.composer-bar .menu summary.action { padding: 7px 8px; color: var(--accent); margin-left: -8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; right: auto; left: -8px; min-width: 0; width: max-content; }
.emoji-grid button { padding: 4px 6px; font-size: 20px; text-align: center; }
.suggestions { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-bottom: 8px; }
.suggestions button { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.suggestions button:hover, .suggestions button:first-child { background: var(--hover); }


.composer {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px 10px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.composer:focus-within, .chat-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-main { flex: 1; min-width: 0; }
.composer textarea { border: 0; background: none; padding: 8px 0; font-size: var(--fs-lg); min-height: 44px; max-height: 320px; outline: none; field-sizing: content; }
.composer-bar { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.composer-bar .action { margin-left: -8px; color: var(--accent); }
.composer-bar .counter { margin-left: auto; font-size: var(--fs-sm); }
.composer-bar .btn { margin-left: 0; }
.composer-bar .counter:empty + .btn { margin-left: 0; }
.preview { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.thumb { position: relative; }
.thumb img { display: block; max-width: 100%; max-height: 260px; border-radius: var(--r-md); }
.thumb:not(:only-child) img { width: 120px; height: 120px; object-fit: cover; }
.preview .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .7);
  color: #fff;
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
}

/* profile */

.profile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.profile-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.profile-actions { display: flex; gap: 8px; align-items: center; }
.profile .text { margin-top: 10px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: var(--fs-sm); }
.stats a { color: var(--muted); }
.stats b { color: var(--text); }

.user-row, .notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  color: var(--text);
}
.user-row:hover, .notice:hover { background: var(--hover); text-decoration: none; }
.user-row > span, .notice > span { min-width: 0; }
.user-bio { display: block; color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice.unseen { border-color: var(--accent); background: var(--accent-soft); }

/* forms */

.form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select { font-weight: 400; }
.note { font-size: var(--fs-sm); color: var(--muted); }
.note.error { color: var(--danger); }
.auth { max-width: 400px; margin: 6vh auto 0; padding: 28px; }
.auth-logo { width: 52px; height: 52px; }
.search { display: flex; gap: 8px; margin-bottom: 8px; }
.search input { border-radius: 999px; background: var(--panel); padding-left: 18px; }

.welcome { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.welcome h1, .welcome p { flex-basis: 100%; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; text-align: center; display: flex; flex-direction: column; }
.stat b { font-size: var(--fs-xl); }
.report { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.rules { display: flex; flex-direction: column; gap: 14px; }

/* reactions, quotes, banners, badges, games, chat */

.face { display: inline-flex; align-items: center; font-size: var(--fs-md); line-height: 1; }
.post footer .menu { margin-left: 0; align-self: auto; }
.post footer .menu summary.action { padding: 7px 8px; }
.react .emoji-grid { grid-template-columns: repeat(6, 1fr); left: -60px; bottom: calc(100% + 4px); top: auto; }
.action.like.on .icon-heart { fill: var(--like); }
.face.pop { animation: heart-pop .2s ease-out; }
@keyframes heart-pop { 50% { transform: scale(1.25); } }
.avatar.tiny { width: 20px; height: 20px; font-size: 11px; }
.quote { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); color: var(--text); font-size: var(--fs-sm); overflow-wrap: anywhere; }
a.quote:hover { background: var(--hover); text-decoration: none; }
.quote-head { display: flex; align-items: center; gap: 6px; }
.quote-text { white-space: pre-wrap; }
.quote img { max-height: 160px; max-width: 100%; border-radius: var(--r-sm); object-fit: cover; align-self: flex-start; }
video.photo { cursor: auto; max-height: 520px; background: #000; margin-top: 10px; border-radius: var(--r-lg); }
.thumb video { display: block; max-width: 100%; max-height: 220px; border-radius: var(--r-md); }
.sheet .composer, .sheet .composer:focus-within { margin: 0; border: 0; box-shadow: none; padding: 0; }
.profile.has-banner { padding-top: 0; overflow: hidden; }
.banner { display: block; width: calc(100% + 40px); margin: 0 -20px; height: 150px; object-fit: cover; }
.profile.has-banner .profile-top { margin-top: -46px; }
.profile.has-banner .profile-top .avatar { border: 4px solid var(--panel); }
.profile.has-banner .profile-actions { margin-top: 56px; }
.preview-banner { width: 100%; margin: 0; height: 110px; border-radius: var(--r-md); }
.links, .badges { margin-top: 10px; }
.chip.big:is(a):hover { text-decoration: none; filter: brightness(1.1); }
.badges .chip { background: var(--hover); color: var(--text); font-weight: 500; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #1fb85c; margin-left: auto; flex: none; }
.spread { justify-content: space-between; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 16px; }
.game { display: flex; flex-direction: column; gap: 8px; }
.game img { width: calc(100% + 32px); margin: -16px -16px 4px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.game h2 { margin: 0; }
.game .row { margin-top: auto; }
.more-row { align-items: center; }
.more-item { display: none; }
.badge.inline { position: static; margin-left: auto; align-self: center; }
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.bubble { max-width: 80%; align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px; padding: 8px 12px; display: flex; flex-direction: column; }
.bubble.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg); }
.bubble .text { margin: 0; }
.chat-form { position: sticky; bottom: 12px; display: flex; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px; box-shadow: var(--shadow); }
.chat-form textarea { border: 0; background: none; max-height: 140px; field-sizing: content; outline: none; }
.heading.back.row .name { color: var(--text); font-weight: 700; }
.log { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }

.topbar { display: none; }
.message-btn .icon { display: none; }

/* narrower screens */

@media (max-width: 1100px) {
  .shell { grid-template-columns: 72px minmax(0, 620px); }
  .side { display: none; }
  .nav-label { display: none; }
  .logo, .nav-item { justify-content: center; padding: 12px; }
  .badge { left: 34px; }
}

@media (max-width: 640px) {
  .shell { display: block; padding: 0 var(--sp-3); }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 14;
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 var(--sp-3);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }
  .topbar a { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; color: var(--text); font-size: var(--fs-lg); font-weight: 800; }
  .topbar a:hover { text-decoration: none; }
  .topbar img { width: 28px; height: 28px; border-radius: 22%; object-fit: cover; flex: none; }
  .topbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 15;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    padding: 0 4px env(safe-area-inset-bottom);
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .logo { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; min-width: 0; min-height: 52px; padding: 6px 4px; border-radius: 0; }
  .nav-item.active { box-shadow: inset 0 3px 0 var(--accent); }
  .nav .nav-label { display: block; max-width: 100%; font-size: 10px; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .badge { left: calc(50% + 2px); top: 2px; }
  .badge.inline { left: auto; top: auto; }
  .main { padding: var(--sp-3) 0 90px; }
  .post { gap: 10px; }
  .post .post-avatar .avatar:not(.medium) { width: 36px; height: 36px; font-size: 16px; }
  .skel-avatar { width: 36px; height: 36px; }
  .action { min-width: 44px; min-height: 44px; justify-content: center; }
  .post footer { justify-content: space-between; gap: 0; margin-left: -12px; }
  .post header .menu summary { padding: 11px; margin: -11px -8px -11px auto; }
  .emoji-grid, .react .emoji-grid {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    top: auto;
    width: auto;
    grid-template-columns: repeat(6, 1fr);
  }
  .emoji-grid button { min-width: 44px; min-height: 44px; }
  .profile-actions { flex-wrap: wrap; justify-content: flex-end; }
  .avatar.large { width: 72px; height: 72px; font-size: 32px; }
  .message-btn { padding: 8px 10px; }
  .message-btn .icon { display: block; }
  .message-btn .btn-label { display: none; }
  .extra { display: none; }
  .more-item { display: flex; }
  .chat-form { bottom: 76px; }
  .auth { margin-top: 2vh; }
  .toast { bottom: 84px; }
  .sheet.dialog { align-items: flex-end; padding: 0; }
  .dialog-card { width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .action, .nav-item, .tabs a, .user-row, .notice, .post { transition: none; }
  .btn:active, .action:active { transform: none; }
  .skel-avatar, .skel-bar, .face.pop, .toast { animation: none; }
  .btn[aria-busy="true"]::before { animation: none; }
}
