/* ============ LeanyLane — classic social-feed style ============ */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --hover: #f2f2f2;
  --text: #050505;
  --muted: #65676b;
  --line: #ced0d4;
  --line-soft: #e4e6eb;
  --accent: #1877f2;
  --accent-hover: #166fe5;
  --accent-soft: #e7f3ff;
  --success: #42b72a;
  --danger: #e41e3f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, .2), 0 2px 4px rgba(0, 0, 0, .1);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --header-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18191a; --surface: #242526; --surface-2: #3a3b3c; --hover: #303031; --text: #e4e6eb; --muted: #b0b3b8;
    --line: #3e4042; --line-soft: #3e4042; --accent: #2d88ff; --accent-hover: #4a98ff; --accent-soft: #263951;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18191a; --surface: #242526; --surface-2: #3a3b3c; --hover: #303031; --text: #e4e6eb; --muted: #b0b3b8;
  --line: #3e4042; --line-soft: #3e4042; --accent: #2d88ff; --accent-hover: #4a98ff; --accent-soft: #263951;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Keep every page locked to the phone's width: scroll up and down, never sideways. */
html { overflow-x: hidden; }
@supports (overflow-x: clip) { html, body { overflow-x: clip; } }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.34 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 12px 0; }
.mt { margin-top: 8px; }
.mt-lg { margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 6px;
  padding: 8px 14px; font-weight: 600; font-size: 15px; line-height: 20px; cursor: pointer; white-space: nowrap; transition: background .1s, filter .1s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary, .btn-ghost, .btn-soft { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover, .btn-ghost:hover, .btn-soft:hover { filter: brightness(.95); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-lg { padding: 11px 18px; font-size: 17px; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.danger-text { color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 14px; }
.icon-btn:hover { filter: brightness(.95); }
.icon-btn.danger { background: rgba(0, 0, 0, .6); color: #fff; }

/* ---------- Avatars ---------- */
.avatar {
  --hue: 210; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: hsl(var(--hue) 45% 52%); color: #fff; font-weight: 600; font-size: 14px; user-select: none; position: relative;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.avatar.xxl { width: 168px; height: 168px; font-size: 56px; }
img.avatar { object-fit: cover; background: var(--surface-2); }
.avatar-btn { display: block; border-radius: 50%; }
.avatar-wrap { position: relative; display: inline-flex; }
.avatar-wrap.online::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }
.avatar-edit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-edit-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.avatar-edit-actions small { flex-basis: 100%; }
.avatar.online::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--surface); box-shadow: var(--shadow); }
.topbar-inner { display: flex; align-items: center; gap: 10px; height: var(--header-h); padding: 0 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-mark { width: 40px; height: 40px; }
.brand-text { display: grid; line-height: 1.1; min-width: 0; }
.brand-word { font-weight: 700; font-size: 22px; color: var(--accent); letter-spacing: -.5px; }
.brand-tag { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { position: relative; width: 260px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; }
.topbar .search input[type="search"] { width: 100%; height: 40px; border-radius: 999px; border: 0; background: var(--surface-2); padding: 0 14px 0 36px; outline: none; box-shadow: none; }
.topbar .search input[type="search"]::placeholder { color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 320px; padding: 8px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); display: grid; gap: 2px; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px; border-radius: 6px; border: 0; background: none; cursor: pointer; font-size: 15px; font-weight: 500; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); }
.menu-pop form { margin: 0; }
.mi { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); font-size: 18px; }
.menu-head { display: flex; gap: 12px; align-items: center; padding: 8px 8px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line-soft); }
.menu-head > span:last-child { display: grid; min-width: 0; }
.menu-head small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catbar { display: none; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0; }
.leftnav { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 16px 8px; scrollbar-width: thin; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius); font-weight: 500; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item small { margin-left: auto; color: var(--muted); font-size: 13px; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); font-size: 18px; flex-shrink: 0; box-shadow: var(--shadow); }
.nav-icon.letter { --hue: 210; background: hsl(var(--hue) 45% 52%); color: #fff; font-weight: 700; font-size: 15px; box-shadow: none; border-radius: 8px; }
.nav-heading { margin: 16px 8px 6px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 17px; }
.nav-empty, .nav-foot { color: var(--muted); font-size: 13px; padding: 4px 8px; }
.nav-foot { margin-top: 16px; }
.content { padding: 16px 16px 48px; min-width: 0; }

.feed-layout { display: grid; grid-template-columns: minmax(0, 590px) 300px; gap: 32px; justify-content: center; }
.feed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }
.feed-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.rightcol { position: sticky; top: calc(var(--header-h) + 16px); align-self: start; display: grid; gap: 16px; }

/* ---------- Boxes ---------- */
.box, .panel, .fpost, .side-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.box { padding: 12px 16px; }
.notice { background: var(--accent-soft); color: var(--text); box-shadow: none; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.share-box { padding: 12px 16px 8px; }
.share-row { display: flex; gap: 8px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.share-input { flex: 1; height: 40px; display: flex; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 16px; }
.share-input:hover { filter: brightness(.96); }
.share-actions { display: flex; padding-top: 6px; }
.share-actions a, .fpost-actions a { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.share-actions a:hover, .fpost-actions a:hover { background: var(--hover); }
.share-actions span, .fpost-actions span { font-size: 19px; }
@media (max-width: 400px) {
  .share-actions a { min-width: 0; padding: 8px 2px; gap: 4px; font-size: 14px; }
  .share-actions span { font-size: 17px; }
}

.side-box { padding: 12px 16px 14px; }
.side-box h3 { color: var(--muted); font-size: 16px; margin-bottom: 8px; }
.glance, .contacts { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.glance li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.glance li span { width: 28px; text-align: center; font-size: 18px; }
.contacts li { display: flex; align-items: center; gap: 12px; padding: 6px 4px; border-radius: 6px; font-weight: 500; }

/* Recent uploads (stories-style row) */
.recent { padding: 12px 16px 14px; }
.recent h2 { font-size: 17px; margin-bottom: 10px; }
.recent-row { display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; padding-bottom: 4px; }
.story { position: relative; height: 190px; border-radius: 10px; overflow: hidden; background: var(--surface-2); scroll-snap-align: start; }
.story img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.story:hover img { transform: scale(1.03); }
.story::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.25), transparent 30%, transparent 55%, rgba(0,0,0,.65)); }
.story .avatar { position: absolute; left: 8px; top: 8px; z-index: 1; box-shadow: 0 0 0 3px var(--accent); }
.story-kind { position: absolute; right: 8px; top: 10px; z-index: 1; color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.story-title { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 1; color: #fff; font-weight: 600; font-size: 13px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story .ph { position: absolute; inset: 0; }

/* Feed tabs */
.feed-tabs { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 4px; }
.cat-pick { min-width: 170px; }
.cat-pick select { padding-top: 6px !important; padding-bottom: 6px !important; border-radius: 999px !important; font-weight: 600; }
@media (max-width: 640px) { .feed-tabs { display: grid; grid-template-columns: 1fr auto; gap: 8px; } .feed-tabs .tabs:first-child { grid-column: 1 / -1; } .cat-pick { min-width: 0; } }
.tabs a { padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tabs a:hover { background: var(--line-soft); }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.tabs.small a { font-size: 13px; padding: 6px 10px; }
.load-more { margin-top: 4px; }
.clear-filters { padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; white-space: nowrap; }
.clear-filters:hover { filter: brightness(.96); }
@media (max-width: 640px) { .feed-tabs .clear-filters { grid-column: 1 / -1; justify-self: start; } }

/* ---------- Feed post ---------- */
.fpost { overflow: hidden; }
.fpost-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; }
.fpost-who { flex: 1; min-width: 0; font-size: 15px; }
.fpost-edit { flex-shrink: 0; align-self: flex-start; background: none; }
.fpost-edit:hover { background: var(--hover); }
.fpost-who strong { font-weight: 600; }
.cat-link { font-weight: 600; }
.cat-link:hover, .fpost-time:hover, .fpost-title:hover { text-decoration: underline; }
.fpost-time { display: inline-block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.fpost-title { display: block; padding: 10px 16px 0; font-size: 17px; font-weight: 600; }
h1.fpost-title { font-size: 22px; font-weight: 700; }
.fpost-text { margin: 6px 16px 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fpost-text.full { display: block; }
.fpost-media { display: grid; gap: 2px; margin-top: 12px; background: var(--surface-2); }
.fpost-media.count-1 { grid-template-columns: 1fr; }
.fpost-media.count-1 .fm { aspect-ratio: 16 / 10; max-height: 520px; }
.fpost-media.count-2 { grid-template-columns: 1fr 1fr; }
.fpost-media.count-2 .fm { aspect-ratio: 1; }
.fpost-media.count-3 { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
.fpost-media.count-3 .fm:first-child { grid-column: span 2; aspect-ratio: 16 / 9; }
.fpost-media.count-3 .fm:not(:first-child) { aspect-ratio: 4 / 3; }
.fpost-media.count-4 { grid-template-columns: 1fr 1fr; }
.fpost-media.count-4 .fm { aspect-ratio: 1; }
.fm { position: relative; overflow: hidden; display: block; background: #000; }
.fm img { width: 100%; height: 100%; object-fit: cover; }
.fm .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; font-size: 30px; font-weight: 700; }
.fpost-stats { display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; color: var(--muted); font-size: 15px; }
.fpost-stats a:hover { text-decoration: underline; }
.fpost-actions { display: flex; margin: 0 12px; padding: 4px 0; border-top: 1px solid var(--line-soft); }

.badge { position: absolute; padding: 2px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .7); }
.badge-br { right: 8px; bottom: 8px; }
.badge-tl { left: 8px; top: 8px; }
.play { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .55); border: 3px solid #fff; transition: transform .15s; }
.play svg { width: 28px; height: 28px; fill: #fff; margin-left: 4px; }
.play.small { width: 40px; height: 40px; border-width: 2px; }
.play.small svg { width: 18px; height: 18px; }
a:hover .play { transform: scale(1.06); }
.ph { width: 100%; height: 100%; min-height: 60px; display: grid; place-items: center; color: var(--muted); font-size: 14px; background: var(--surface-2); }
.shimmer { background: linear-gradient(100deg, var(--surface-2) 30%, var(--line-soft) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

.empty { text-align: center; padding: 40px 16px; display: grid; justify-items: center; gap: 8px; }
.empty-emoji { font-size: 44px; }
.empty p { margin: 0 0 8px; }

/* ---------- Single post ---------- */
.post { max-width: 760px; margin: 0 auto; }
.back { display: inline-block; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.back:hover { text-decoration: underline; }
.fpost.single .fpost-head { align-items: flex-start; }
.post-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.fpost.single .viewer { margin-top: 12px; }
.video-frame { background: #000; }
.video-frame video { width: 100%; max-height: 80vh; margin: 0 auto; background: #000; }
.photo-single { display: block; width: 100%; padding: 0; border: 0; background: #000; cursor: zoom-in; }
.photo-single img { width: 100%; height: auto; max-height: 80vh; object-fit: contain; margin: 0 auto; }
.album-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: var(--surface-2); }
.album-grid .album-cell:first-child:nth-last-child(n + 4) { grid-column: span 2; grid-row: span 2; }
.album-cell { position: relative; }
.album-cell .album-item { width: 100%; height: 100%; display: block; }
.dl-btn { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .6); color: #fff; font-size: 15px; opacity: 0; transition: opacity .15s; }
.album-cell:hover .dl-btn, .dl-btn:focus-visible { opacity: 1; }
@media (hover: none) { .dl-btn { opacity: .85; width: 28px; height: 28px; font-size: 13px; } }
.album-item { position: relative; aspect-ratio: 1; border: 0; padding: 0; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.album-item img { width: 100%; height: 100%; object-fit: cover; }
.album-item:hover img { filter: brightness(.92); }
.album-item:disabled { cursor: default; }
.processing-box { background: var(--surface-2); padding: 48px 20px; text-align: center; display: grid; justify-items: center; gap: 6px; margin: 0 16px; border-radius: var(--radius); }
.progress { width: min(320px, 90%); height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .6s ease; }

/* ---------- Comments ---------- */
.comments { padding: 0 16px 12px; }
.comments .fpost-stats { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.comment-list { display: grid; gap: 0; padding-top: 8px; }
.no-comments { color: var(--muted); margin: 4px 0 10px; font-size: 14px; }
.comment { display: grid; grid-template-columns: auto 1fr; gap: 6px; padding: 4px 0; scroll-margin-top: 90px; }
.comment.flash .comment-bubble { animation: flash 2.2s ease; }
@keyframes flash { 0%, 50% { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); } }
.comment-bubble { background: var(--surface-2); border-radius: 18px; padding: 8px 12px; justify-self: start; max-width: 100%; }
.comment-head { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.comment-head strong { font-weight: 600; }
.mention { color: var(--muted); font-weight: 500; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.comment-body a { color: var(--accent); }
.comment-body a:hover { text-decoration: underline; }
.comment-body.big-emoji { font-size: 32px; line-height: 1.2; }
.comment-media { margin-top: 6px; border-radius: 12px; max-height: 220px; max-width: min(100%, 300px); cursor: zoom-in; }
.comment.deleted .comment-bubble { font-style: italic; color: var(--muted); }
.comment-actions { display: flex; align-items: center; gap: 2px; padding: 2px 0 0 10px; font-size: 12px; }
.comment-actions button { border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 700; padding: 2px 6px; cursor: pointer; }
.comment-actions button:hover { text-decoration: underline; }
.c-time { color: var(--muted); padding-right: 6px; }
.replies { margin-left: 46px; }
.replies .avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.reply-slot:not(:empty) { margin: 4px 0 8px 46px; }

.composer { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 6px; align-items: start; padding-top: 8px; }
.composer-box { background: var(--surface-2); border-radius: 18px; padding: 6px 10px 4px; display: grid; gap: 2px; }
.composer textarea { border: 0; outline: none; resize: none; background: transparent; min-height: 24px; max-height: 240px; padding: 4px 2px; line-height: 1.35; font-size: 15px; }
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 2px; }
.composer-bar .spacer { flex: 1; }
.composer-bar .btn-sm { padding: 4px 12px; font-size: 13px; }
.tool-btn { height: 30px; min-width: 30px; padding: 0 6px; border-radius: 50%; border: 0; background: none; cursor: pointer; font-size: 17px; color: var(--muted); display: inline-grid; place-items: center; }
.tool-btn:hover, .tool-btn[aria-expanded="true"] { background: var(--line-soft); }
.tool-btn.gif { font: 700 11px/1 var(--font); border: 1.5px solid currentColor; height: 20px; min-width: 0; padding: 0 4px; border-radius: 4px; margin: 0 5px; }
.tool-btn.gif:hover { background: none; color: var(--accent); }
.attachment { position: relative; display: inline-block; justify-self: start; margin: 4px 0; }
.attachment img { max-height: 120px; border-radius: 10px; }
.attachment .icon-btn { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; font-size: 11px; background: var(--surface); box-shadow: var(--shadow); color: var(--text); }
.replying-to { font-size: 12px; color: var(--muted); padding: 2px 2px 0; }
.popover { position: absolute; z-index: 30; left: 40px; top: calc(100% + 6px); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.popover.up { top: auto; bottom: calc(100% + 6px); }
emoji-picker { --border-size: 0; --background: var(--surface); --input-border-color: var(--line); --button-hover-background: var(--hover); --indicator-color: var(--accent); --outline-color: var(--accent); width: min(350px, calc(100vw - 32px)); height: 350px; }
.gif-picker { width: min(370px, calc(100vw - 32px)); display: grid; grid-template-rows: auto 1fr auto; height: 380px; }
.gif-picker input { margin: 10px; height: 36px; border-radius: 999px; border: 0; padding: 0 14px; background: var(--surface-2); outline: none; }
.gif-results { overflow-y: auto; padding: 0 10px; columns: 2; column-gap: 6px; }
.gif-results button { display: block; width: 100%; padding: 0; margin: 0 0 6px; border: 0; border-radius: 6px; overflow: hidden; cursor: pointer; background: var(--surface-2); break-inside: avoid; }
.gif-results img { width: 100%; height: auto; }
.gif-foot { padding: 6px 10px; font-size: 11px; color: var(--muted); text-align: right; border-top: 1px solid var(--line-soft); }
.gif-msg.gif-head { padding: 6px 4px 2px; text-align: left; font-weight: 700; }
.gif-msg { column-span: all; padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Forms & panels ---------- */
.narrow { max-width: 680px; margin: 0 auto; }
.narrow.wide { max-width: 980px; }
.panel { padding: 16px 20px; margin-bottom: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.panel h2 { font-size: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head.compact { background: none; box-shadow: none; padding: 0; margin: 4px 0 14px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field-link { font-weight: 500; color: var(--accent); font-size: 13px; }
.field-link:hover { text-decoration: underline; }
.req { color: var(--danger); }
input:not([type="checkbox"], [type="radio"]):not([type="file"]), select, textarea {
  width: 100%; max-width: 100%; min-width: 0; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); padding: 11px 14px; font-size: 16px; outline: none;
}
/* Date and time pickers have a wide built-in minimum on phones; let them shrink to fit. */
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; min-height: 44px; }
/* iPhone zooms in (and stays zoomed, so the page slides sideways) when a box under 16px is tapped. */
@supports (-webkit-touch-callout: none) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { font-size: 16px !important; }
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
input:disabled { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer; }
.select-wrap::after { content: ''; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select-wrap.sm select { padding: 6px 32px 6px 10px; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-error, .form-ok { padding: 10px 14px; border-radius: 6px; margin: 0 0 4px; font-size: 14px; }
.form-error { background: #ffebe9; color: #b3261e; border: 1px solid #f5c2c0; }
.form-ok { background: #e6f4ea; color: #1e6b34; border: 1px solid #b7dfc3; }
:root[data-theme="dark"] .form-error { background: #3b1d1d; color: #ff9b9b; border-color: #5a2a2a; }
:root[data-theme="dark"] .form-ok { background: #1c3324; color: #8fd9a8; border-color: #2a4d36; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 14px; }
.check, .toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 10px 0; }
.check.highlight { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 12px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.check span, .toggle span:last-child { display: grid; gap: 2px; font-size: 14px; }
.check small, .toggle small { color: var(--muted); font-size: 13px; }
.toggle { border-bottom: 1px solid var(--line-soft); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 40px; height: 24px; border-radius: 99px; background: var(--line); flex-shrink: 0; transition: background .2s; }
.switch::after { content: ''; position: absolute; left: 2px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { box-shadow: 0 0 0 3px var(--accent-soft); }
.pill { display: inline-flex; padding: 2px 8px; border-radius: 4px; font-size: 13px; font-weight: 600; background: var(--surface-2); }

/* Upload */
.dropzone { position: relative; display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 32px 20px; text-align: center; cursor: pointer; background: var(--surface-2); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-inner { display: grid; gap: 4px; justify-items: center; pointer-events: none; }
.dz-emoji { font-size: 32px; }
.dropzone strong { font-size: 17px; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 6px; border-radius: var(--radius); background: var(--surface-2); }
.file-thumb { width: 48px; height: 48px; border-radius: 6px; overflow: hidden; background: var(--line-soft); display: grid; place-items: center; font-size: 20px; }
.file-thumb img, .file-thumb video { width: 100%; height: 100%; object-fit: cover; }
.file-info { min-width: 0; display: grid; gap: 3px; }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: 12.5px; color: var(--muted); }
.file-item .progress { width: 100%; height: 6px; margin: 0; }
.file-item.done .progress span { background: var(--success); }
.file-item.failed .file-sub { color: var(--danger); }

/* Edit / admin */
.edit-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.edit-media-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.edit-media-item img { width: 100%; height: 100%; object-fit: cover; }
.edit-media-item form { position: absolute; top: 4px; right: 4px; margin: 0; }
.edit-media-item .icon-btn { width: 26px; height: 26px; font-size: 12px; }
.danger-zone { grid-template-columns: 1fr auto; align-items: center; }
.danger-zone p { margin: 4px 0 0; }
.admin-list { display: grid; }
.admin-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.admin-row > .muted { font-size: 13px; min-width: 56px; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input { padding: 6px 10px !important; font-size: 14px !important; width: 170px !important; }
.admin-row .inline-form:first-of-type { margin-left: auto; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table form { margin: 0; }

.trash-list { display: grid; }
.trash-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.trash-row img, .trash-ph { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--surface-2); display: grid; place-items: center; font-size: 24px; }
.trash-info { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 14px; }
.trash-row form { margin: 0; }

.nav-item small.nav-badge, .nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-weight: 700; font-size: 12px; padding: 1px 7px; border-radius: 999px; }

/* ---------- Messenger ---------- */
.top-icon { position: relative; width: 40px; height: 40px; font-size: 18px; background: var(--surface-2); color: var(--text); }
.top-icon.on { background: var(--accent-soft); }
.top-badge { position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.avatar.xs { width: 28px; height: 28px; font-size: 11px; }
.avatar.xxs { width: 14px; height: 14px; font-size: 6px; }
.avatar.md { width: 48px; height: 48px; font-size: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-wrap.online::after { width: 12px; height: 12px; }
.contact { display: flex; align-items: center; gap: 12px; width: 100%; padding: 4px; border-radius: 6px; }
.contact:hover { background: var(--hover); }
.contact > span:last-child { display: grid; }
.contact small { font-size: 12px; font-weight: 400; }
.messenger-page .content { padding: 0; }
.msgr { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - var(--topbar-h, var(--header-h))); background: var(--surface); border-left: 1px solid var(--line-soft); }
.msgr-list { display: flex; flex-direction: column; border-right: 1px solid var(--line-soft); min-height: 0; }
.msgr-list-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.msgr-list-head h1 { font-size: 24px; }
.msgr-new { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 16px 10px; }
.msgr-new .btn { justify-content: center; }
.msgr-empty-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.msgr-search { padding: 4px 16px 8px; }
.msgr-search input { border-radius: 999px !important; border: 0 !important; background: var(--surface-2) !important; padding: 9px 14px !important; font-size: 15px !important; }
.msgr-online { display: flex; gap: 6px; overflow-x: auto; padding: 4px 12px 10px; scrollbar-width: none; }
.online-person { display: grid; justify-items: center; gap: 2px; border: 0; background: none; cursor: pointer; width: 60px; flex-shrink: 0; color: var(--text); }
.online-person small { font-size: 12px; max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgr-convos { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.convo { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: var(--radius); background: none; cursor: pointer; text-align: left; color: var(--text); }
.convo:hover { background: var(--hover); }
.convo.active { background: var(--accent-soft); }
.convo-text { flex: 1; min-width: 0; display: grid; }
.convo-text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-text span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo.unread .convo-text strong, .convo.unread .convo-text span { font-weight: 700; color: var(--text); }
.unread-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.avatar-stack { position: relative; width: 48px; height: 48px; flex-shrink: 0; display: inline-block; }
.avatar-stack .avatar { position: absolute; width: 32px; height: 32px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { right: 0; top: 0; }
.avatar-stack .avatar:nth-child(2) { left: 0; bottom: 0; }
.avatar-stack.lg { width: 64px; height: 64px; }
.avatar-stack.lg .avatar { width: 42px; height: 42px; }
.dot-online { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }
.msgr-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.msgr-empty { margin: auto; text-align: center; display: grid; gap: 8px; justify-items: center; padding: 20px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.1); z-index: 2; }
.chat-title { flex: 1; min-width: 0; display: grid; }
.chat-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title small { color: var(--muted); font-size: 12px; }
.back-btn { display: none; font-size: 24px; background: none; color: var(--accent); }
.chat-info { position: absolute; right: 12px; top: 64px; z-index: 5; width: 300px; max-width: calc(100% - 24px); background: var(--surface); box-shadow: var(--shadow-lg); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.info-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }
.info-members li { display: flex; gap: 10px; align-items: center; }
.info-members li > span:last-child { display: grid; }
.info-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 12px 12px 4px; min-height: 0; }
.chat-msgs { display: flex; flex-direction: column; gap: 2px; }
.chat-start { display: grid; justify-items: center; gap: 4px; padding: 24px 0 16px; text-align: center; }
.center { text-align: center; }
.time-div { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 6px; }
.sys-msg { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0; }
.msg { display: flex; align-items: flex-end; gap: 8px; position: relative; max-width: 100%; }
.msg.mine { flex-direction: row-reverse; }
.msg:not(.cont) { margin-top: 6px; }
.msg-avatar { width: 28px; flex-shrink: 0; }
.msg-body { display: flex; flex-direction: column; align-items: flex-start; max-width: min(70%, 520px); }
.msg.mine .msg-body { align-items: flex-end; }
.msg-name { color: var(--muted); font-size: 12px; margin: 0 0 2px 12px; }
.bubble { padding: 8px 12px; border-radius: 18px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.33; }
.bubble a { text-decoration: underline; }
.msg.mine .bubble { background: var(--accent); color: #fff; }
.msg.theirs.more .bubble { border-bottom-left-radius: 4px; }
.msg.theirs.cont .bubble { border-top-left-radius: 4px; }
.msg.mine.more .bubble { border-bottom-right-radius: 4px; }
.msg.mine.cont .bubble { border-top-right-radius: 4px; }
.bubble.big-emoji { background: none !important; font-size: 40px; padding: 0 4px; }
.bubble.removed { background: none !important; border: 1px solid var(--line); color: var(--muted) !important; font-style: italic; font-size: 13px; }
.chat-media { max-width: 260px; max-height: 300px; border-radius: 16px; margin-top: 2px; }
.reacts { margin-top: -6px; border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: 999px; padding: 1px 6px; font-size: 13px; cursor: default; position: relative; z-index: 1; }
.msg-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .1s; align-self: center; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
.msg-tools button { border: 0; background: none; cursor: pointer; font-size: 15px; padding: 4px; border-radius: 50%; }
.msg-tools button:hover { background: var(--hover); }
.react-bar { display: flex; gap: 2px; padding: 4px 6px; }
.react-bar button { border: 0; background: none; font-size: 24px; cursor: pointer; padding: 2px 4px; border-radius: 8px; transition: transform .1s; }
.react-bar button:hover { transform: scale(1.25); }
.msg .popover { left: auto; right: 0; }
.msg.theirs .popover { left: 36px; right: auto; }
.seen { display: flex; justify-content: flex-end; align-items: center; gap: 2px; margin: 2px 0; color: var(--muted); font-size: 11px; }
.seen small { margin-right: 4px; }
.typing { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; padding: 6px 4px; }
.dots { display: inline-flex; gap: 3px; background: var(--surface-2); padding: 8px 10px; border-radius: 14px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.chat-composer { position: relative; display: flex; align-items: flex-end; gap: 4px; padding: 8px 10px calc(12px + env(safe-area-inset-bottom)); }
.chat-composer .tool-btn { color: var(--accent); }
.chat-input { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 20px; display: flex; flex-wrap: wrap; align-items: flex-end; padding: 2px 4px 2px 12px; }
.chat-input .attachment { flex-basis: 100%; margin: 8px 0 2px; }
.chat-input textarea { flex: 1; border: 0 !important; background: none !important; box-shadow: none !important; resize: none; padding: 8px 0 !important; font-size: 15px !important; max-height: 140px; line-height: 1.3; min-height: 20px; }
.send-btn { border: 0; background: none; font-size: 22px; cursor: pointer; padding: 4px 6px; color: var(--accent); }
.chat-composer .popover { left: 8px; }
.msgr-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(480px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.msgr-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.msgr-dialog-inner { display: grid; gap: 10px; padding: 14px 16px 16px; margin: 0; }
.msgr-dialog-inner header { display: flex; justify-content: space-between; align-items: center; }
.msgr-dialog-inner footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-hint { margin: -4px 0 0; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.picked:empty { display: none; }
.picked .chip-sm { border: 0; cursor: pointer; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; }
.group-tag { font-size: 13px; }
.people-pick { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 6px; cursor: pointer; }
.pick-row:hover { background: var(--hover); }
.pick-row > span:nth-child(2) { flex: 1; display: grid; }
.pick-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.picked { display: flex; flex-wrap: wrap; gap: 4px; }
.picked:empty { display: none; }
.chip-sm { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.chat-heads { position: fixed; right: 16px; bottom: 16px; z-index: 150; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.chat-head-bubble { position: relative; }
.chat-head-bubble .avatar { width: 52px; height: 52px; font-size: 18px; box-shadow: var(--shadow-lg); border: 2px solid var(--surface); }
.head-count { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; border: 2px solid var(--surface); }
.head-x { position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 10px; cursor: pointer; opacity: 0; transition: opacity .1s; color: var(--text); }
.chat-head-bubble:hover .head-x { opacity: 1; }
.chat-head-bubbles { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; touch-action: none; -webkit-user-select: none; user-select: none; }
.chat-head-bubbles img { -webkit-user-drag: none; pointer-events: none; }
.chat-head-bubbles.moved { position: fixed; z-index: 150; }
.chat-head-bubbles.moved.left { align-items: flex-start; }
.chat-head-bubbles.dragging { cursor: grabbing; transition: none; }
.chat-head-bubbles.dragging .avatar { transform: scale(1.08); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.chat-head-bubbles.snapping { transition: left .24s cubic-bezier(.2, 1.2, .4, 1), top .24s ease; }
.heads-trash { position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 149; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; font-size: 22px; transition: transform .15s, background .15s; animation: rise .2s ease; }
.heads-trash.hot { transform: translateX(-50%) scale(1.25); background: var(--danger); }
/* New-message pop-up card */
.chat-peek { display: grid; gap: 10px; width: min(340px, calc(100vw - 32px)); background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 2px var(--accent); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.chat-peek.pop { animation: peek-in .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes peek-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
.chat-peek-main { display: flex; gap: 10px; align-items: center; min-width: 0; }
.chat-peek-main .avatar { width: 44px; height: 44px; flex-shrink: 0; }
.chat-peek-text { display: grid; gap: 1px; min-width: 0; }
.chat-peek-text small { color: var(--accent); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.chat-peek-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-peek-text span { color: var(--text); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chat-peek-btns { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
/* The 💬 button gives a little bounce when a message comes in */
.ping { animation: ping .6s ease 2; }
@keyframes ping { 30% { transform: scale(1.18); } 60% { transform: scale(.95); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 900px) {
  /* Pinned to the visible screen, under the top bar (--topbar-h is its real height, measured by app.js).
     Not sized with 100dvh: in the installed Android app that can include the area behind the
     navigation bar, which pushed the message box off the bottom. */
  .msgr { grid-template-columns: 1fr; position: fixed; top: var(--topbar-h, 70px); left: 0; right: 0; bottom: 0; height: auto; border-left: 0; }
  .messenger-page .catbar, .messenger-page .topbar .search { display: none; }
  .msgr-chat { display: none; }
  .msgr.show-chat .msgr-list { display: none; }
  .msgr.show-chat .msgr-chat { display: flex; }
  .back-btn { display: inline-grid; }
  .msg-body { max-width: 78%; }
  .msg-tools { opacity: .6; }
}

/* Chat: smoother sending and arriving */
.msgr-chat { position: relative; }
.msg.pending .bubble, .msg.pending .chat-media { opacity: .6; }
.msg-sending { display: block; text-align: right; color: var(--muted); font-size: 11px; margin-top: 2px; }
.msg-failed { display: block; margin: 3px 0 0 auto; border: 0; background: none; color: var(--danger); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; }
.msg.failed .bubble { box-shadow: 0 0 0 2px var(--danger); }
.msg.arrive { animation: msg-in .22s cubic-bezier(.2, 1.2, .4, 1); }
.msg.mine.arrive { transform-origin: bottom right; }
.msg.theirs.arrive { transform-origin: bottom left; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.chat-scroll { scroll-behavior: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.chat-loading { display: grid; place-items: center; padding: 40px 0; color: var(--muted); }
.jump-new { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 5; border: 0; border-radius: 999px; padding: 8px 14px; background: var(--accent); color: #fff; font: inherit; font-size: 13px; font-weight: 700; box-shadow: var(--shadow-lg); cursor: pointer; animation: rise .2s ease; }
.jump-new[hidden] { display: none; }
.attachment.uploading { position: relative; }
.attachment.uploading::after { content: ''; position: absolute; inset: 0; border-radius: 8px; background: rgba(255, 255, 255, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%231877f2' stroke-width='3' stroke-dasharray='40 20'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center / 22px no-repeat; }
/* ---------- Pop-up chats on a computer (chat-dock.js): bottom-left 💬 button, chat list, chat windows ---------- */
.chat-dock { display: none; }
@media (min-width: 901px) and (hover: hover) and (pointer: fine) {
  .chat-dock { display: block; }
  .shell-open .chat-dock { display: none; }
  .dock-launcher { position: fixed; left: 16px; bottom: 16px; z-index: 95; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-size: 26px; cursor: pointer; display: grid; place-items: center; transition: transform .12s, background .12s; }
  .dock-launcher:hover { transform: scale(1.06); }
  .dock-launcher.on { background: var(--accent-soft); }
  .dock-launcher .top-badge { position: absolute; top: -2px; right: -2px; }
  .dock-panel { position: fixed; left: 16px; bottom: 84px; z-index: 96; width: 360px; height: min(560px, calc(100vh - var(--header-h) - 110px)); display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; animation: rise .18s ease; }
  .dock-panel[hidden] { display: none; }
  .dock-panel-head { display: flex; align-items: center; gap: 2px; padding: 12px 10px 6px 16px; }
  .dock-panel-head h2 { flex: 1; font-size: 22px; margin: 0; }
  .dock-panel-head .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .dock-panel .msgr-convos { flex: 1; min-height: 0; }
  .dock-panel-foot { display: block; text-align: center; padding: 10px; border-top: 1px solid var(--line-soft); color: var(--accent); font-weight: 600; font-size: 14px; }
  .dock-panel-foot:hover { background: var(--hover); text-decoration: none; }
  .dock-wins { position: fixed; left: 88px; bottom: 0; z-index: 94; display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
  .dock-win { pointer-events: auto; width: 330px; height: min(455px, calc(100vh - var(--header-h) - 16px)); display: flex; flex-direction: column; background: var(--surface); border-radius: 10px 10px 0 0; box-shadow: 0 2px 16px rgba(0, 0, 0, .22), 0 0 0 1px var(--line-soft); position: relative; }
  .dock-win.pop { animation: rise .2s ease; }
  .dock-win.min { height: auto; width: 250px; }
  .dock-win.min .dock-win-body { display: none; }
  .dock-win-head { display: flex; align-items: center; padding: 4px 4px 4px 6px; border-bottom: 1px solid var(--line-soft); border-radius: 10px 10px 0 0; }
  .dock-win.min .dock-win-head { border-bottom: 0; }
  .dock-win.attention .dock-win-head { background: var(--accent); color: #fff; }
  .dock-win.attention .dock-win-head .icon-btn, .dock-win.attention .chat-title small { color: #fff; }
  .dock-win-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 4px; border-radius: 8px; }
  .dock-win-title:hover { background: var(--hover); }
  .dock-win.attention .dock-win-title:hover { background: rgba(255, 255, 255, .15); }
  .dock-win-title .chat-title strong { font-size: 15px; }
  .dock-win-title .avatar-stack { width: 32px; height: 32px; }
  .dock-win-title .avatar-stack .avatar { width: 22px; height: 22px; font-size: 9px; border-width: 1px; }
  .dock-win-count { min-width: 20px; height: 20px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; flex-shrink: 0; }
  .dock-win-head .icon-btn { width: 30px; height: 30px; font-size: 14px; color: var(--accent); background: none; flex-shrink: 0; }
  .dock-win-head .icon-btn:hover { background: var(--hover); }
  .dock-win.attention .dock-win-head .icon-btn:hover { background: rgba(255, 255, 255, .15); }
  .dock-win-head a.icon-btn:hover { text-decoration: none; }
  .dock-win-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
  .dock-win .chat-scroll { padding: 8px 8px 4px; }
  .dock-win .msg { gap: 6px; }
  .dock-win .msg-avatar { width: 24px; }
  .dock-win .msg-avatar .avatar { width: 24px; height: 24px; font-size: 10px; }
  .dock-win .msg-body { max-width: 76%; }
  .dock-win .bubble { font-size: 14px; padding: 7px 11px; }
  .dock-win .chat-media { max-width: 200px; max-height: 220px; }
  .dock-win .chat-start { padding: 16px 0 10px; }
  .dock-win .chat-composer { padding: 6px 6px 8px; gap: 2px; }
  .dock-win .chat-composer .popover { left: -2px; }
  .dock-win .chat-input textarea { font-size: 14px !important; max-height: 100px; }
  .dock-win .jump-new { bottom: 62px; }
  .has-dock .toast-host { left: 88px; }
  /* Inside the upload page's "keep browsing" frame, its progress tray sits in the bottom-left corner. */
  .in-upload-shell .dock-launcher { bottom: 76px; }
  .in-upload-shell .dock-panel { bottom: 144px; }
  .in-upload-shell .dock-wins { bottom: 66px; }
}
.att-ph { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 8px; background: var(--surface-2); font-size: 22px; }

/* ---------- Install to home screen ---------- */
.install-banner { position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 160; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); animation: rise .25s ease; }
.install-banner img { border-radius: 10px; flex-shrink: 0; }
.install-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 13px; }
.install-text strong { font-size: 15px; }
.install-btns { flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.ios-share { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1.5px solid currentColor; border-radius: 4px; font-size: 11px; vertical-align: -3px; }
.install-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.install-steps > div { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; }
.install-steps p { margin: 4px 0 0; }
@media (max-width: 640px) { .install-steps { grid-template-columns: 1fr; } }
body:has(.install-banner) .chat-heads { bottom: 96px; }
/* Room at the bottom so nothing ends up hidden behind the banner. */
body:has(.install-banner) .content { padding-bottom: 140px; }

/* ---------- Reactions ---------- */
.stats-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.react-sum { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.react-sum[hidden] { display: none; }
.react-sum.bump .react-icons { animation: bump .45s ease; }
@keyframes bump { 40% { transform: scale(1.35); } }
.react-sum:hover .react-n { text-decoration: underline; }
.react-icons { display: inline-flex; }
.react-icons span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 2px var(--surface); font-size: 14px; line-height: 1; }
.react-icons span + span { margin-left: -4px; }
.fpost-actions .react-btn, .fpost-actions .share-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
@media (hover: hover) { .fpost-actions .react-btn:hover, .fpost-actions .share-btn:hover { background: var(--hover); } }
.fpost-actions .react-btn span, .fpost-actions .share-btn span { font-size: 19px; }
.fpost-actions .share-btn span { filter: grayscale(1); opacity: .75; }
.fpost-actions .react-btn:not(.on) span { filter: grayscale(1); opacity: .75; }
.react-btn.on { color: var(--accent); }
.comment-actions .react-btn.compact.on { color: var(--accent); }
.post-page-actions { margin: 0; }
.comment-bubble { position: relative; }
.comment-bubble .react-sum { position: absolute; right: 4px; bottom: -12px; padding: 1px 6px 1px 3px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-size: 12px; }
.comment-bubble .react-icons span { width: 16px; height: 16px; font-size: 12px; }
.comment-bubble:has(.react-sum:not([hidden])) { margin-bottom: 8px; }
.react-pop { position: fixed; z-index: 220; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-lg); animation: rise .15s ease; }
.react-bar { display: flex; gap: 2px; padding: 4px 6px; }
.react-pop.react-bar button { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; padding: 6px; border-radius: 50%; transition: transform .1s; }
.react-pop.react-bar button { position: relative; transition: transform .12s ease; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.react-pop.react-bar button.hover, .react-pop.react-bar button:focus-visible { transform: scale(1.4) translateY(-4px); }
@media (hover: hover) { .react-pop.react-bar button:hover { transform: scale(1.4) translateY(-4px); } }
.react-label { position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .78); color: #fff; font-size: 11px; font-weight: 700; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .1s; }
.react-pop.react-bar button.hover .react-label, .react-pop.react-bar button:focus-visible .react-label { opacity: 1; }
@media (hover: hover) { .react-pop.react-bar button:hover .react-label { opacity: 1; } }
.react-pop.react-bar { overflow: visible; animation: bar-in .18s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes bar-in { from { opacity: 0; transform: translateY(8px) scale(.9); } }
.react-pop.react-bar button.react-more-btn { width: 40px; height: 40px; margin: auto 2px auto 4px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); font: 600 26px/1 var(--font); }
@media (max-width: 420px) {
  .react-pop.react-bar button { font-size: 25px; padding: 5px; }
  .react-pop.react-bar button.react-more-btn { width: 36px; height: 36px; font-size: 24px; }
}
@media (max-width: 360px) {
  .react-pop.react-bar { padding: 3px 4px; }
  .react-pop.react-bar button { font-size: 23px; padding: 4px; }
  .react-pop.react-bar button.react-more-btn { width: 32px; height: 32px; font-size: 22px; margin-left: 2px; }
}
.react-pop.react-more { border-radius: var(--radius); overflow: hidden; width: min(350px, calc(100vw - 16px)); height: 350px; }
.react-more emoji-picker { width: 100%; height: 350px; }
.react-btn { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.react-pop.react-bar button.on { background: var(--accent-soft); }
.react-who { border-radius: var(--radius); padding: 8px; width: min(260px, calc(100vw - 16px)); max-height: 320px; overflow-y: auto; }
.react-who ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.react-who a { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; font-weight: 600; }
.react-who a:hover { background: var(--hover); }
.react-who-emoji { font-size: 18px; width: 22px; text-align: center; }
.react-who p { margin: 4px 8px; }

/* Post page header on phones: buttons go on their own row under the name instead of squeezing it. */
@media (max-width: 640px) {
  .fpost.single .fpost-head { flex-wrap: wrap; }
  .fpost.single .fpost-who { flex: 1 1 calc(100% - 60px); }
  .fpost.single .post-actions { flex-basis: 100%; justify-content: flex-start; flex-wrap: wrap; }
}

/* ---------- Upload: status, and "keep browsing" frame + tray ---------- */
.upload-status { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); font-weight: 600; font-size: 14px; }
.upload-tip { margin: 0; }
.file-btns { display: flex; align-items: center; gap: 6px; }
.bg-shell { position: fixed; inset: 0; z-index: 300; background: var(--bg); }
.bg-shell[hidden] { display: none; }
.bg-shell iframe { width: 100%; height: 100%; border: 0; display: block; }
body.shell-open { overflow: hidden; }
.upload-tray { position: fixed; left: 16px; bottom: 16px; z-index: 310; display: flex; align-items: center; gap: 10px; max-width: min(440px, calc(100vw - 32px)); padding: 8px 8px 8px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 2px var(--accent); font-size: 14px; font-weight: 600; animation: rise .2s ease; }
.upload-tray[hidden] { display: none; }
.upload-tray.alert { box-shadow: var(--shadow-lg), 0 0 0 2px var(--danger); }
.tray-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-bar { flex: 1 0 60px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.tray-bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
@media (max-width: 640px) {
  .upload-tray { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); max-width: none; }
}
/* Inside the frame, keep the page's own bottom-corner things clear of the tray */
.in-upload-shell .install-banner { display: none; }
.in-upload-shell .chat-heads { bottom: 76px; }

/* ---------- Record a video (upload page) ---------- */
.record-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.rec-dialog { border: 0; padding: 0; border-radius: var(--radius); width: min(720px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.rec-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.rec-inner { display: grid; gap: 10px; padding: 12px 14px 16px; }
.rec-inner header { display: flex; justify-content: space-between; align-items: center; }
.rec-stage { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; }
.rec-video { width: 100%; height: 100%; object-fit: contain; }
.rec-video[hidden] { display: none; }
.rec-video.mirror { transform: scaleX(-1); }
.rec-timer { position: absolute; top: 10px; left: 10px; background: #e41e3f; color: #fff; font-weight: 800; font-size: 13px; padding: 4px 10px; border-radius: 6px; }
.rec-timer[hidden] { display: none; }
.rec-flip { position: absolute; right: 10px; bottom: 10px; }
.rec-msg { position: absolute; inset: auto 16px; color: #fff; text-align: center; margin: 0; }
.rec-btns { display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 64px; }
.rec-shutter { width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; }
.rec-shutter span { width: 46px; height: 46px; border-radius: 50%; background: #e41e3f; transition: all .15s; }
.rec-shutter.stop span { width: 24px; height: 24px; border-radius: 5px; }
.rec-shutter[hidden] { display: none; }

/* ---------- Private nicknames ---------- */
.profile-realname { margin: 2px 0 0 !important; font-weight: 600; }
.profile-msg { margin: 0; }
.nick-edit { position: relative; }
.nick-edit > summary { list-style: none; cursor: pointer; }
.nick-edit > summary::-webkit-details-marker { display: none; }
.nick-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(320px, calc(100vw - 32px)); display: grid; gap: 8px; padding: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); text-align: left; }
.nick-form label { display: grid; gap: 2px; }
.nick-row { display: flex; gap: 6px; }
.nick-row input { flex: 1; min-width: 0; padding: 8px 12px !important; }
@media (max-width: 640px) { .nick-form { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; } }
.nick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.nick-list a { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 8px; }
.nick-list a:hover { background: var(--hover); }
.nick-list span { display: grid; }

/* ---------- Reels ---------- */
.reels-page .topbar, .reels-page .leftnav, .reels-page .install-banner, .reels-page .chat-heads, .reels-page .ann-banner { display: none !important; }
.reels-page .content { padding: 0; }
.reels { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; }
.reels-top { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: linear-gradient(rgba(0, 0, 0, .55), transparent); pointer-events: none; }
.reels-top > * { pointer-events: auto; }
.reels-top strong { font-size: 18px; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.reels-top-btns { display: flex; gap: 8px; }
.reels-close, .reels-sound, .reels-add { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff; font-size: 18px; cursor: pointer; }
.reels-add { font-size: 24px; font-weight: 700; }
.reels-scroll { height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.reels-scroll::-webkit-scrollbar { display: none; }
.reel { position: relative; height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always; display: grid; place-items: center; overflow: hidden; }
.reel-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
@media (max-aspect-ratio: 3 / 4) { .reel-video { object-fit: cover; } }
@media (min-width: 701px) { .reel-video { width: min(100%, calc(100dvh * 9 / 16)); border-radius: 12px; } }
.reel-paused { position: absolute; inset: 0; z-index: 1; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.reel-paused span { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; font-size: 30px; padding-left: 5px; opacity: 0; transition: opacity .15s; }
.reel.paused .reel-paused span { opacity: 1; }
.reel-info { position: absolute; left: 0; right: 76px; bottom: 0; z-index: 2; display: grid; gap: 6px; padding: 40px 14px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .65)); text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
@media (min-width: 701px) { .reel-info { left: max(0px, calc(50% - 100dvh * 9 / 32)); right: max(76px, calc(50% - 100dvh * 9 / 32 + 76px)); } }
.reel-who { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; }
.reel-who .avatar { box-shadow: 0 0 0 2px #fff; }
.reel-title { color: #fff; font-weight: 700; font-size: 16px; }
.reel-desc { margin: 0; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #eee; }
.reel-desc a { color: #fff; }
.reel-actions { position: absolute; right: 8px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 2; display: grid; justify-items: center; gap: 14px; }
@media (min-width: 701px) { .reel-actions { right: max(8px, calc(50% - 100dvh * 9 / 32 - 64px)); } }
.reel-actions .react-btn, .reel-act { display: grid; justify-items: center; gap: 2px; border: 0; background: none; color: #fff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.reel-actions .react-btn span, .reel-act span { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: rgba(0, 0, 0, .4); font-size: 24px; }
.reel-actions .react-btn:not(.on) span { filter: grayscale(1) brightness(1.6); }
.reel-actions .react-sum { color: #fff; font-size: 12px; margin-top: -10px; }
.reel-actions .react-icons span { background: rgba(0, 0, 0, .4); box-shadow: none; }
.reel-empty, .reel-end { text-align: center; padding: 24px; }
.reel-empty p, .reel-end p { color: #ccc; max-width: 320px; margin: 8px auto 16px; }
/* Home: Reels row */
.reels-row-box h2 { display: flex; justify-content: space-between; align-items: baseline; font-size: 17px; margin-bottom: 10px; }
.reels-row { display: grid; grid-auto-flow: column; grid-auto-columns: 108px; gap: 8px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
.reel-tile { position: relative; aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden; background: #111; }
.reel-tile img { width: 100%; height: 100%; object-fit: cover; }
.reel-tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(0, 0, 0, .7)); }
.reel-tile span { position: absolute; left: 6px; right: 6px; bottom: 6px; z-index: 1; color: #fff; font-size: 12px; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reel-tile .reel-tile-play { position: absolute; top: 6px; right: 6px; left: auto; bottom: auto; font-size: 13px; }
.reel-new { display: grid; place-content: center; justify-items: center; gap: 6px; aspect-ratio: 9 / 16; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; text-align: center; padding: 6px; }
.reel-new b { font-size: 28px; }
.reel-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #111; color: #fff; font-size: 11px; font-weight: 700; vertical-align: 2px; }
.reel-toggle { margin-top: -4px; }

/* ---------- RSVP ---------- */
.rsvp h2 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rsvp-form { display: grid; gap: 10px; }
.rsvp-form p { margin: 0; }
.rsvp-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rsvp-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.rsvp-btn span { font-size: 22px; }
.rsvp-btn:hover { background: var(--hover); }
.rsvp-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.rsvp-note { display: flex; gap: 8px; align-items: center; }
.rsvp-note input { flex: 1; min-width: 0; }
.rsvp-group h3 { font-size: 15px; margin: 6px 0; }
.rsvp-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rsvp-people li { display: flex; gap: 10px; align-items: center; }
.rsvp-people li > span { display: grid; min-width: 0; }

/* ---------- Live video ---------- */
.live-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; max-width: 1200px; margin: 0 auto; align-items: start; }
.live-stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; max-height: calc(100dvh - var(--header-h) - 48px); display: grid; place-items: center; color: #fff; }
.live-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.live-video.mirror { transform: scaleX(-1); }
.live-overlay-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; pointer-events: none; z-index: 2; }
.live-badge { background: #e41e3f; color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .03em; padding: 4px 10px; border-radius: 6px; }
.live-viewers { background: rgba(0, 0, 0, .55); color: #fff; font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 6px; }
.live-camera-off, .live-waiting, .live-ended { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; text-align: center; background: #111; z-index: 3; }
.live-camera-off[hidden], .live-waiting[hidden], .live-ended[hidden] { display: none; }
.live-camera-off p, .live-waiting p, .live-ended p { margin: 0; color: #ddd; }
.live-ended h2 { color: #fff; }
.live-stage-btns { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; z-index: 2; }
.live-round { width: 44px; height: 44px; font-size: 20px; background: rgba(0, 0, 0, .55); color: #fff; }
.live-unmute { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; border: 0; border-radius: 999px; padding: 8px 14px; background: rgba(0, 0, 0, .7); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.live-unmute[hidden] { display: none; }
.live-floats { position: absolute; right: 8px; bottom: 60px; width: 90px; height: 70%; pointer-events: none; z-index: 2; }
.live-float { position: absolute; bottom: 0; font-size: 30px; animation: float-up 3s ease-out forwards; }
@keyframes float-up { 0% { transform: translateY(0) scale(.6); opacity: 0; } 10% { opacity: 1; transform: translateY(-20px) scale(1); } 100% { transform: translateY(-260px) scale(1.1) translateX(-14px); opacity: 0; } }
.live-side { display: grid; gap: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.live-setup { display: grid; gap: 12px; }
.live-setup h1 { font-size: 22px; }
.live-setup p { margin: 0; }
.live-go { background: #e41e3f; }
.live-go:hover { filter: brightness(1.05); }
.live-running-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.live-end { background: #e41e3f; color: #fff; }
.live-running p { margin: 4px 0 0; }
.live-who { display: flex; gap: 10px; align-items: center; }
.live-who > div { display: grid; min-width: 0; }
.live-react-bar { display: flex; justify-content: space-between; gap: 4px; }
.live-react-bar button { flex: 1; border: 0; background: var(--surface-2); border-radius: 999px; font-size: 22px; padding: 6px 0; cursor: pointer; transition: transform .1s; }
.live-react-bar button:active { transform: scale(1.2); }
.live-chat { display: grid; gap: 8px; }
.live-chat[hidden] { display: none; }
.live-comments { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; align-content: start; max-height: 46vh; min-height: 120px; overflow-y: auto; }
.live-comment { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; overflow-wrap: anywhere; }
.live-comment-form { display: flex; gap: 6px; }
.live-comment-form input { flex: 1; padding: 8px 12px !important; border-radius: 999px !important; }
.live-page .install-banner, .live-page .chat-heads { display: none; }
.live-now { display: flex; align-items: center; gap: 12px; border: 2px solid #e41e3f; }
.live-now-badge { background: #e41e3f; color: #fff; font-weight: 800; font-size: 12px; padding: 3px 8px; border-radius: 6px; flex-shrink: 0; }
.live-now-text { flex: 1; min-width: 0; display: grid; }
.live-peek { box-shadow: var(--shadow-lg), 0 0 0 2px #e41e3f; }
.live-peek .chat-peek-text small { color: #e41e3f; }
@media (max-width: 900px) {
  .live-wrap { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .live-stage { border-radius: 0; aspect-ratio: auto; height: min(62dvh, 560px); }
  .live-side { border-radius: 0; }
}

/* ---------- Profiles ---------- */
.who-link { color: inherit; }
.who-link:hover { text-decoration: underline; }
a.mention-tag:hover { text-decoration: underline; }
a.menu-head:hover { background: var(--hover); border-radius: 6px; }
.profile { max-width: 940px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.profile-head { padding: 0; overflow: hidden; }
.profile-cover { height: 200px; background: linear-gradient(135deg, hsl(var(--hue) 55% 62%), hsl(calc(var(--hue) + 40) 60% 42%)); }
.profile-main { display: flex; align-items: flex-end; gap: 16px; padding: 0 24px 16px; margin-top: -56px; flex-wrap: wrap; }
.profile-pic { display: block; border-radius: 50%; box-shadow: 0 0 0 4px var(--surface); flex-shrink: 0; line-height: 0; }
.profile-pic .avatar { display: grid; place-items: center; }
.profile-id { flex: 1 1 240px; min-width: 0; padding-bottom: 4px; }
.profile-id h1 { font-size: 30px; line-height: 1.15; overflow-wrap: anywhere; }
.profile-id p { margin: 4px 0 0; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 6px; }
.profile-tabs { display: flex; gap: 4px; padding: 4px 16px; border-top: 1px solid var(--line-soft); overflow-x: auto; scrollbar-width: none; }
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tabs a { flex-shrink: 0; white-space: nowrap; padding: 12px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }
.profile-tabs a:hover { background: var(--hover); border-radius: 6px 6px 0 0; }
.profile-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.profile-body { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.profile-side { display: grid; gap: 16px; position: sticky; top: calc(var(--header-h) + 16px); }
.profile-side h2, .profile-photos-all h2 { font-size: 20px; margin-bottom: 10px; }
.profile-side-head { display: flex; justify-content: space-between; align-items: baseline; }
.profile-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.profile-facts li { display: flex; gap: 10px; align-items: flex-start; }
.profile-facts li > span:first-child { width: 22px; text-align: center; flex-shrink: 0; }
.profile-family { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.profile-family > * { display: grid; justify-items: center; gap: 4px; width: 64px; font-size: 13px; text-align: center; }
.profile-family > * > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; border-radius: 8px; overflow: hidden; }
.profile-grid.big { gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.profile-grid a { position: relative; aspect-ratio: 1; background: var(--surface-2); }
.profile-grid img { width: 100%; height: 100%; object-fit: cover; }
.profile-grid-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.tab-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px; border-radius: 10px; background: var(--surface-2); font-size: 12px; }
.profile-tabs a.on .tab-count { background: var(--accent-soft); }
.profile-feed-head h2 { font-size: 18px; }
.profile-feed-head p { margin: 4px 0 0; }
.fpost-tagnote { display: grid; gap: 4px; margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 14px; }
.fpost-tagnote strong { color: var(--text); }
.fpost-tagnote:hover { background: var(--hover); }
.fpost-tagquote { color: var(--text); font-style: italic; overflow-wrap: anywhere; }
.people-results h2 { font-size: 17px; margin-bottom: 10px; }
.people-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.person-chip { display: grid; justify-items: center; gap: 6px; width: 92px; flex-shrink: 0; padding: 8px 4px; border-radius: 8px; text-align: center; font-size: 13px; font-weight: 600; }
.person-chip:hover { background: var(--hover); }
@media (max-width: 900px) {
  .profile-body { grid-template-columns: minmax(0, 1fr); }
  .profile-side { position: static; }
  .profile-side.m-hide { display: none; }
}
@media (max-width: 640px) {
  .profile { gap: 8px; }
  .profile-cover { height: 140px; }
  .profile-main { flex-direction: column; align-items: center; text-align: center; padding: 0 16px 12px; margin-top: -84px; }
  .profile-id { flex: none; width: 100%; }
  .profile-id h1 { font-size: 26px; }
  .profile-actions { justify-content: center; width: 100%; }
  .profile-actions .btn { flex: 1; justify-content: center; }
  .profile-tabs { padding: 0 8px; justify-content: center; }
  .profile-body, .profile-side { gap: 8px; }
  .profile-photos-all h2 { padding: 0 4px; }
}

/* ---------- Home: "Turn on notifications" card ---------- */
.push-prompt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-left: 4px solid var(--accent); }
.push-prompt[hidden] { display: none; }
.push-prompt-icon { font-size: 26px; flex-shrink: 0; }
.push-prompt-text { flex: 1 1 220px; min-width: 0; display: grid; gap: 2px; font-size: 14px; }
.push-prompt-text strong { font-size: 16px; }
.push-prompt-text span { color: var(--muted); }
.push-prompt-btns { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Review fixes: phones, overlays, dark mode ---------- */
.messenger-page .ann-banner, .messenger-page .install-banner { display: none; }
.chat-heads { z-index: 60; }
body:has(.lightbox) .chat-heads, body:has(.lightbox) .install-banner { display: none; }
@media (hover: none) { .head-x { opacity: 1; } }
@media (max-width: 640px) { .popover { z-index: 170; } }
@media (max-width: 900px) {
  /* 16px+ stops iPhones from zooming in when a box is tapped */
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { font-size: 16px !important; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .form-error { background: #3b1d1d; color: #ff9b9b; border-color: #5a2a2a; }
  :root:not([data-theme="light"]) .form-ok { background: #1c3324; color: #8fd9a8; border-color: #2a4d36; }
  :root:not([data-theme="light"]) .xmas-warn { color: #f5b971; }
}
:root[data-theme="dark"] .xmas-warn { color: #f5b971; }

.cal-month-list { display: none; margin-top: 14px; }
.cal-month-list h3 { font-size: 16px; margin: 0 4px 6px; }
@media (max-width: 640px) { .cal-month-list { display: block; } .cal-upcoming { display: none; } }

/* ---------- Directory ---------- */
.dir-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dir-search { margin: 0 0 14px; }
.dir-search input { border-radius: 999px !important; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.dir-card { margin: 0; gap: 10px; }
.dir-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dir-address { display: flex; gap: 6px; font-size: 14px; color: var(--muted); white-space: pre-line; }
.dir-address:hover span { text-decoration: underline; }
.dir-people, .dir-everyone { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dir-people li, .dir-everyone li { display: flex; align-items: flex-start; gap: 10px; }
.dir-everyone li { align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.dir-person { flex: 1; min-width: 0; display: grid; gap: 1px; }
.dir-phone { color: var(--accent); font-size: 14px; }
.dir-note { color: var(--muted); font-size: 12px; white-space: pre-wrap; }
.tag-muted { justify-self: start; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 4px; padding: 0 6px; }
.tag-account { font-size: 13px; color: var(--accent); font-weight: 600; }
.dir-member { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); margin: 0; scroll-margin-top: 80px; }
.dir-member:last-of-type { border-bottom: 0; }
.dir-member-opts { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }

/* ---------- Facebook-style phone layout ---------- */
.m-only, .mtabs { display: none; }
@media (max-width: 640px) {
  .m-only { display: inline-grid; }
  .catbar { display: none !important; }
  .topbar-inner { height: auto; padding: 8px 12px 4px; }
  .brand-mark { width: 34px; height: 32px; flex-shrink: 0; }
  .brand { gap: 8px; }
  .brand-word { display: inline !important; font-size: 27px; letter-spacing: -1px; }
  .brand { flex: 1 1 0; min-width: 0; }
  .brand-tag { font-size: 12px; white-space: normal; }
  .top-actions { gap: 6px; }
  .top-actions .xmas-btn, .top-actions .menu { display: none; }
  .top-actions .upload-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; background: var(--surface-2); color: var(--text); }
  .top-actions .upload-btn svg { width: 20px; height: 20px; }
  .topbar .search { display: none; order: 5; flex-basis: 100%; }
  body.search-open .topbar .search { display: block; }
  .mtabs { display: flex; border-top: 1px solid var(--line-soft); }
  .mtabs a { flex: 1; position: relative; display: grid; place-items: center; height: 46px; color: var(--muted); border-bottom: 3px solid transparent; }
  .mtabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
  .mtabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mtabs a.on svg { stroke-width: 2.3; }
  .mtabs .top-badge { top: 4px; right: calc(50% - 22px); }
  .content { padding-top: 6px; }
  .messenger-page .mtabs { display: none; }
}
.mmenu { max-width: 680px; margin: 0 auto; padding: 4px 12px 32px; }
.mmenu h1 { font-size: 26px; margin: 4px 0 12px; }
.mmenu h2 { font-size: 16px; color: var(--muted); margin: 18px 4px 6px; }
.mmenu-me { display: flex; align-items: center; gap: 12px; background: var(--surface); padding: 12px; border-radius: var(--radius); box-shadow: var(--shadow); }
.mmenu-me > span { display: grid; }
.mmenu-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.mmenu-tiles a { position: relative; display: grid; gap: 6px; padding: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 600; font-size: 15px; }
.mmenu-tiles a span { font-size: 24px; }
.mmenu-tiles b { position: absolute; top: 10px; right: 10px; background: var(--danger); color: #fff; font-size: 12px; border-radius: 10px; padding: 1px 7px; }
.mmenu-list { display: grid; gap: 2px; margin-top: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.mmenu-list a, .mmenu-list button { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 6px; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; width: 100%; cursor: pointer; }
.mmenu-list a:hover, .mmenu-list button:hover { background: var(--hover); }
.mmenu-list small { margin-left: auto; }
.mmenu-list form { margin: 0; }

/* ---------- Statuses ---------- */
.share-row textarea.share-input { height: 40px; min-height: 40px; resize: none; border: 0 !important; padding: 9px 14px !important; line-height: 22px; border-radius: 20px !important; background: var(--surface-2) !important; color: var(--text); box-shadow: none !important; overflow: hidden; }
.share-row textarea.share-input:focus { background: var(--surface-2) !important; }
.share-row .btn { align-self: flex-end; }
.status-text { margin: 10px 16px 4px; white-space: pre-wrap; font-size: 15px; overflow-wrap: anywhere; }
.status-text.big { font-size: 22px; line-height: 1.3; }
.dir-edit-form { display: grid; gap: 0; }
.dir-member.removing > :not(.dir-member-opts), .dir-member.removing .dir-member-opts > :not(.dir-remove) { opacity: .4; pointer-events: none; }
body:has(.dir-save-bar) .install-banner { display: none; }
.dir-save-bar { position: sticky; bottom: 0; z-index: 20; display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); margin-bottom: 16px; background: var(--surface); border-top: 1px solid var(--line-soft); box-shadow: 0 -4px 12px rgba(0, 0, 0, .06); border-radius: var(--radius); }
.add-household > summary { cursor: pointer; list-style: none; }
.add-household > summary::-webkit-details-marker { display: none; }
.add-household > summary h2 { display: inline; }
.add-household .stack { margin-top: 0; }
.text-link { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }
.text-link:hover { text-decoration-thickness: 2px; }
.story-status { background: linear-gradient(160deg, hsl(var(--hue) 60% 55%), hsl(calc(var(--hue) + 40) 60% 38%)); }
.story-status::after { display: none; }
.story-quote { position: absolute; inset: 44px 8px 28px; color: #fff; font-weight: 600; font-size: 13px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; }

/* ---------- @mentions ---------- */
.mention-tag { color: var(--accent); font-weight: 600; background: var(--accent-soft); border-radius: 4px; padding: 0 2px; }
.msg.mine .mention-tag { color: #fff; background: rgba(255, 255, 255, .22); }
.mention-box { position: fixed; z-index: 300; background: var(--surface); box-shadow: var(--shadow-lg); border-radius: var(--radius); padding: 4px; display: grid; }
.mention-opt { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 6px 8px; border-radius: 6px; cursor: pointer; text-align: left; color: var(--text); font-size: 14px; }
.mention-opt.active, .mention-opt:hover { background: var(--accent-soft); }

/* ---------- Announcements ---------- */
.ann-banner { display: flex; align-items: center; gap: 12px; max-width: 1240px; margin: 0 auto 16px; padding: 12px 14px; border-radius: var(--radius); background: #fff8e1; border: 1px solid #f5d77a; color: #3d2e00; box-shadow: var(--shadow); }
:root[data-theme="dark"] .ann-banner { background: #3a3218; border-color: #5c4d1d; color: #f6e7b8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ann-banner { background: #3a3218; border-color: #5c4d1d; color: #f6e7b8; } }
.ann-icon { font-size: 24px; }
.ann-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ann-text span { font-size: 14px; }
.ann-text small { opacity: .75; font-size: 12px; }
.ann-text a { text-decoration: underline; }
.ann-btns { display: flex; gap: 6px; align-items: center; }
.ann-btns form { margin: 0; }
.ann-list { list-style: none; margin: 0; padding: 0; display: grid; }
.ann-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.ann-list li.unseen .ann-main > strong { color: var(--accent); }
.ann-main { flex: 1; display: grid; gap: 4px; }
.ann-body { margin: 0; white-space: pre-wrap; }
.ann-actions { display: flex; gap: 6px; }
.ann-actions form { margin: 0; }
@media (max-width: 640px) { .ann-banner { margin: 0 0 8px; border-radius: 0; } }

/* ---------- Calendar ---------- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; max-width: 1240px; margin: 0 auto; align-items: start; }
.cal-box { padding: 12px 12px 14px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 4px 12px; }
.cal-nav, .cal-actions { display: flex; align-items: center; gap: 6px; }
.cal-nav h1 { font-size: 22px; margin: 0 6px; }
.cal-nav .icon-btn { font-size: 22px; width: 36px; height: 36px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); }
.cal-dow { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.cal-day { min-height: 110px; padding: 4px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-num { color: var(--muted); }
.cal-num { align-self: flex-start; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.cal-num:hover { background: var(--hover); }
.cal-day.today .cal-num { background: var(--accent); color: #fff; }
.ev-chip { display: block; font-size: 12px; line-height: 1.3; padding: 2px 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--accent-soft); color: var(--accent); }
.ev-chip b { font-weight: 700; }
.ev-chip:hover { filter: brightness(.95); }
/* Calendar colors (--k): blue by default, set per kind. Rules below must not reset --k, or every card turns blue. */
body { --k: var(--accent); }
.kind-birthday { --k: #e4405f; }
.kind-anniversary { --k: #8b5cf6; }
.kind-event { --k: var(--accent); }
.kind-holiday { --k: #2e8b57; }
.ev-chip.kind-holiday { background: color-mix(in srgb, var(--k) 14%, transparent); color: var(--k); }
a.ev-chip:not([href]), .agenda a:not([href]) { cursor: default; }
.ev-chip.kind-birthday, .ev-chip.kind-anniversary { background: color-mix(in srgb, var(--k) 14%, transparent); color: var(--k); }
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.agenda a { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 6px; }
.agenda a:hover { background: var(--hover); }
.agenda-text { display: grid; min-width: 0; font-size: 14px; }
.agenda-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-text .muted { font-size: 13px; }
.agenda.compact a { padding: 5px 4px; }
.date-badge { flex-shrink: 0; width: 44px; border-radius: 8px; overflow: hidden; text-align: center; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-soft); display: grid; }
.date-badge small { background: var(--k); color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 1px 0; }
.date-badge strong { font-size: 18px; padding: 2px 0 3px; }
.date-badge.lg { width: 64px; }
.date-badge.lg small { font-size: 12px; padding: 2px 0; }
.date-badge.lg strong { font-size: 28px; }
.side-box h3 a:hover { text-decoration: underline; }
.event-top { display: flex; gap: 16px; align-items: center; }
.event-top h1 { font-size: 26px; }
.milestone { font-size: 18px; font-weight: 500; }
.event-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.event-facts li { display: flex; gap: 10px; align-items: baseline; }
.event-facts span { width: 22px; text-align: center; }
.event-notes { white-space: pre-wrap; margin: 0; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); }
.form-actions.start { justify-content: flex-start; }
.form-actions form { margin: 0; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }
.small { font-size: 13px; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.linklike:hover { text-decoration: underline; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.kind-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.kind-opt { position: relative; }
.kind-opt input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.kind-opt span { display: inline-block; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 14px; cursor: pointer; }
.kind-opt input:checked + span { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.kind-opt input:focus-visible + span { outline: 2px solid var(--accent); }
.subscribe-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.subscribe-steps > div { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; align-content: start; justify-items: start; }
.subscribe-steps p { margin: 0; font-size: 13px; }
.copy-row { display: flex; gap: 6px; width: 100%; }
.copy-row input { font-size: 12px !important; padding: 6px 8px !important; }
@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cal-box { border-radius: 0; padding: 8px 4px; }
  .cal-day { min-height: 64px; padding: 2px; }
  .cal-dow { padding: 4px 2px; text-align: center; font-size: 11px; }
  .cal-num { font-size: 12px; min-width: 22px; height: 22px; }
  .ev-chip { font-size: 0; height: 6px; padding: 0; border-radius: 3px; background: var(--k, var(--accent)); }
  .ev-chip.kind-birthday, .ev-chip.kind-anniversary { background: var(--k); }
  .cal-upcoming { border-radius: 0; }
  .field-row, .subscribe-steps { grid-template-columns: minmax(0, 1fr); }
  .cal-actions { width: 100%; }
  .cal-actions .btn { flex: 1; }
}

/* New events in Recent activity + event pictures */
.story-event { background: linear-gradient(160deg, var(--k), color-mix(in srgb, var(--k) 55%, #000)); }
.story-event img { position: absolute; inset: 0; }
.story-event::after { background: linear-gradient(to bottom, rgba(0,0,0,.35), rgba(0,0,0,.05) 40%, rgba(0,0,0,.7)); }
.story-event.stage-today .story-tag { background: #e41e3f; color: #fff; }
.story-event.stage-tomorrow .story-tag { background: #f7b928; color: #050505; }
.story-tag { position: absolute; left: 8px; top: 8px; z-index: 1; background: #fff; color: var(--k); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.story-date { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 1; width: 52px; border-radius: 8px; overflow: hidden; text-align: center; background: #fff; color: #050505; display: grid; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.story-date small { background: var(--k); color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 1px 0; }
.story-date strong { font-size: 20px; padding: 2px 0 3px; }
.event-image { display: block; margin: -16px -20px 0; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: #000; }
.event-image img { width: 100%; max-height: 520px; object-fit: contain; margin: 0 auto; }
.event-image-edit { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.event-image-edit img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; }

/* ---------- Christmas Names ---------- */
.xmas-btn { background: #e7f6ec; color: #1b7a3a; padding: 8px 12px; }
.xmas-btn:hover, .xmas-btn.on { background: #c9ecd5; }
:root[data-theme="dark"] .xmas-btn { background: #1c3324; color: #8fd9a8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .xmas-btn { background: #1c3324; color: #8fd9a8; } }
.xmas { max-width: 900px; margin: 0 auto; display: grid; gap: 16px; }
.xmas > .form-ok { margin: 0; }
.xmas .panel { margin: 0; }
.xmas-hero { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(120deg, #1b7a3a, #2f9e55 55%, #c0392b); color: #fff; padding: 18px 20px; }
.xmas-hero .muted { color: rgba(255, 255, 255, .85); margin: 4px 0 0; }
.xmas-hero select { background: #fff; color: #050505; }
.xmas-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.xmas-hero-actions { display: flex; gap: 8px; align-items: center; }
.btn-light { background: #fff; color: #1b7a3a; }
.btn-light:hover { background: #f0fff4; }
.xmas-list { display: grid; }
.xmas-house { margin: 14px 0 2px; padding-bottom: 4px; font-weight: 700; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--line-soft); }
.xmas-house:first-child { margin-top: 0; }
.xmas-out { margin-top: 12px; }
.xmas-line { display: grid; grid-template-columns: minmax(130px, 1fr) 40px minmax(130px, 1fr) minmax(110px, .8fr); gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.xmas-line:last-child { border-bottom: 0; }
.xmas-line.inactive { opacity: .6; }
.xmas-line .xmas-giver { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.xmas-receiver { display: grid; }
.xmas-receiver small { font-size: 12px; }
.xmas-actions form { margin: 0; }
.xmas-table { display: grid; }
.xmas-row { display: grid; grid-template-columns: minmax(120px, 1fr) 44px minmax(160px, 1.3fr) minmax(90px, .8fr); gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.xmas-row.head { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 0; }
.xmas-row.inactive { opacity: .6; }
.xmas-giver { display: grid; }
.xmas-giver small { font-size: 12px; }
.xmas-arrow { text-align: center; }
.xmas-warn { display: block; color: #b45309; font-size: 12px; margin-top: 2px; }
.xmas-last { font-size: 14px; }
.xmas-people { display: grid; gap: 6px; }
.xmas-person { display: grid; grid-template-columns: 1fr 1fr auto auto auto auto; gap: 6px; align-items: center; margin: 0; }
.xmas-person.add { grid-template-columns: 1fr 1fr auto auto; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.age-tag { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; vertical-align: middle; }
.age-tag.adult { background: #e7f3ff; color: #1877f2; }
.age-tag.kid { background: #fff4e5; color: #b45309; }
.xmas-budgets { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
.xmas-budgets .field { width: 160px; }
.xmas-budgets .field span { font-weight: 600; font-size: 14px; }
.scan-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.xmas-person input:not([type="checkbox"]) { padding: 7px 10px !important; font-size: 14px !important; }
.check.mini { padding: 0; font-size: 13px; align-items: center; gap: 6px; white-space: nowrap; }
.stack .check.mini { white-space: normal; }
.xmas-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.xmas-history > li { padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
.xmas-history ul { margin: 4px 0 0; padding-left: 18px; }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2 { display: inline; }
details.panel > summary::after { content: ' ▾'; color: var(--muted); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
@media (max-width: 900px) { .xmas-btn-label { display: none; } }
@media (max-width: 640px) {
  .xmas { gap: 8px; }
  .xmas-row { grid-template-columns: 1fr 28px 1.4fr; }
  .xmas-row .xmas-last, .xmas-row.head span:last-child { display: none; }
  .xmas-line { grid-template-columns: 1fr 28px 1fr; }
  .xmas-line .xmas-last { grid-column: 1 / -1; margin-top: -6px; }
  .xmas-hero-actions { width: 100%; justify-content: space-between; }
  .xmas-person { grid-template-columns: 1fr 1fr; }
  .xmas-person.add { grid-template-columns: 1fr 1fr; }
  .xmas-person.add .btn { grid-column: span 2; }
}

/* ---------- Auth (login / sign up) ---------- */
.auth-body { background: var(--bg); }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 64px; padding: 40px 20px; flex-wrap: wrap; }
.auth-intro { max-width: 500px; }
.auth-logo { display: flex; align-items: center; gap: 12px; color: var(--accent); font-size: 52px; font-weight: 800; letter-spacing: -2px; }
.auth-intro p { font-size: 24px; line-height: 1.25; margin: 12px 0 0; }
.auth-card { width: 400px; max-width: 100%; background: var(--surface); border-radius: var(--radius); box-shadow: 0 2px 4px rgba(0,0,0,.1), 0 8px 16px rgba(0,0,0,.1); padding: 20px 16px 24px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card > .muted { margin: 0 0 4px; font-size: 14px; }
.auth-switch { text-align: center; color: var(--muted); margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.auth-switch a { color: var(--accent); font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }
.secret label { color: var(--accent); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .94); display: grid; grid-template-rows: auto 1fr auto; touch-action: pan-y; }
.lb-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; color: #fff; }
.lb-top .lb-actions { display: flex; gap: 8px; }
.lb-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; cursor: pointer; font-size: 18px; }
.lb-btn:hover { background: rgba(255, 255, 255, .28); }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 64px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; user-select: none; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 26px; }
.lb-prev { left: 10px; } .lb-next { right: 10px; }
.lb-count { font-weight: 600; opacity: .85; }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; left: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--surface); color: var(--text); padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-weight: 500; }
.toast.error { border-left: 4px solid var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 1260px) {
  .feed-layout { grid-template-columns: minmax(0, 590px); }
  .rightcol { display: none; }
}
@media (max-width: 900px) {
  .layout { display: block; }
  .leftnav { display: none; }
  .catbar { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
  .catbar::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 14px; }
  .chip.active { background: var(--accent-soft); color: var(--accent); }
  .auth { gap: 24px; align-content: center; }
  .auth-intro { text-align: center; }
  .auth-logo { justify-content: center; font-size: 40px; }
  .auth-intro p { font-size: 18px; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 8px 12px 6px; gap: 8px; flex-wrap: wrap; height: auto; }
  .brand-word { display: none; }
  .search { order: 5; flex-basis: 100%; width: auto; }
  .topbar .search input[type="search"] { height: 36px; }
  .upload-btn span { display: none; }
  .upload-btn { padding: 8px 10px; }
  .content { padding: 8px 0 40px; }
  .feed, .feed-list { gap: 8px; }
  .box, .panel, .fpost { border-radius: 0; }
  .feed-tabs { padding: 0 12px; }
  .post .back { margin-left: 12px; }
  .narrow .page-head.compact { padding: 0 12px; }
  .lb-stage { padding: 0; }
  .lb-prev, .lb-next { display: none; }
  .danger-zone { grid-template-columns: 1fr; }
  .admin-row .inline-form:first-of-type { margin-left: 0; }
  .popover { position: fixed; left: 8px !important; right: 8px; top: auto !important; bottom: 8px !important; }
  .popover emoji-picker, .gif-picker { width: 100%; }
  .auth-card { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
