/* ==========================================================================
   Glint web — app frame + home, built to docs/mockups/web-home.png (the source of truth for the
   signed-in shell). Loaded last. Measured at 1536×1024:

     frame 1376 wide, centred, rounded 20, on a soft page background
     ├─ sidebar 260  (colourful icons, tinted active pill, counts, Saved / Settings / More, Pro card)
     ├─ 16 ─ feed column 750 (stories card 115 tall, post cards; video box ≈ 716×371)
     ├─ 16 ─ right column 316 (profile card with cover, Suggested for you, Trending today)
     └─ 18
     top bar 66 (search 484×44, sun / messages / bell / account chip)

   Responsive by layout only — text never shrinks and nothing below 12px:
     ≥ 1264   the full frame; the feed column flexes (≤ 750) as the window narrows; centred at ≥ 1400 (4K too)
     768–1263 icon sidebar (72), feed column ≤ 750, no right column
     < 768    phone: top bar + bottom tabs, edge-to-edge cards
   Short windows tighten the sidebar's spacing (never its type) and the feed media is capped by the
   window height so header + media + actions + the start of the caption fit one screen (≥ 600px tall).
   ========================================================================== */

:root, [data-theme="light"] {
  --fr-page: #F1F3F8;
  --fr-bg: #FAFBFD;
  --fr-side: #FFFFFF;
  --fr-card: #FFFFFF;
  --fr-line: #E7EBF0;
  --fr-line-strong: #DDE3EA;
  --fr-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 10px rgba(16, 24, 40, 0.035);
  --fr-frame-shadow: 0 10px 40px rgba(31, 45, 90, 0.07), 0 1px 3px rgba(31, 45, 90, 0.05);
  --fr-text: #14171C;
  --fr-muted: #687080;
  --fr-pill: #E7EFFE;
  --fr-input: #F0F3F7;
  --fr-input-border: #E1E6ED;
  --fr-story-border: #EFDF9C;
  --fr-story-bg: #FFFEF8;
  --fr-promo: linear-gradient(135deg, #E3ECFC 0%, #ECE7FD 55%, #F3E8FB 100%);
  --fr-promo-text: #5E6478;
  --fr-blue: #1A6DF5;
  --fr-link: #2453C9;
  --fr-badge: #F2304F;
  --fr-ring: conic-gradient(from 210deg, #FDCB52, #F77737, #E1306C, #A13BD8, #5B51D8, #FDCB52);
  --fr-seeall: #EEF0FB;
  --fr-hover: #F2F5FA;
}
/* Dark: the same frame and boxes in charcoal (the generated tokens stay untouched). */
:root:not([data-theme="light"]):not([data-theme="system"]), [data-theme="dark"] {
  --fr-page: #0B0C0F;
  --fr-bg: #121317;
  --fr-side: #16171C;
  --fr-card: #1A1B21;
  --fr-line: #272A31;
  --fr-line-strong: #30343C;
  --fr-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --fr-frame-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --fr-text: #ECEDEF;
  --fr-muted: #9EA3AE;
  --fr-pill: #1D2A47;
  --fr-input: #22242B;
  --fr-input-border: #30333B;
  --fr-story-border: #5B4D1F;
  --fr-story-bg: #1B1A16;
  --fr-promo: linear-gradient(135deg, #1D2645 0%, #272048 55%, #301F45 100%);
  --fr-promo-text: #B4B8C8;
  --fr-blue: #3D84FF;
  --fr-link: #7AA2FF;
  --fr-badge: #FF3B5C;
  --fr-seeall: #262838;
  --fr-hover: #22242B;
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --fr-page: #0B0C0F; --fr-bg: #121317; --fr-side: #16171C; --fr-card: #1A1B21; --fr-line: #272A31; --fr-line-strong: #30343C;
    --fr-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); --fr-frame-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    --fr-text: #ECEDEF; --fr-muted: #9EA3AE; --fr-pill: #1D2A47; --fr-input: #22242B; --fr-input-border: #30333B;
    --fr-story-border: #5B4D1F; --fr-story-bg: #1B1A16; --fr-promo: linear-gradient(135deg, #1D2645 0%, #272048 55%, #301F45 100%);
    --fr-promo-text: #B4B8C8; --fr-blue: #3D84FF; --fr-link: #7AA2FF; --fr-badge: #FF3B5C; --fr-seeall: #262838; --fr-hover: #22242B;
  }
}

/* --- Frame geometry ------------------------------------------------------------------------ */
body.is-signed-in {
  --frame-max: 1376px;
  --frame-top: 0px;
  --top-h: 66px;
  --header-h: calc(var(--frame-top) + var(--top-h));
  --sidebar-w: 260px;
  --layout-web-sidebar: 260px;
  --rail-w: 316px;
  --feed-w: 750px;
  --card-radius: 14px;
  --shell-max: var(--frame-max);
}
@media (min-width: 768px) {
  html:has(body.is-signed-in) { background: var(--fr-page); }
  body.is-signed-in { --frame-top: 12px; --shell-gutter: max(12px, calc((100vw - var(--frame-max)) / 2)); background: transparent; color: var(--fr-text); }
  /* The frame itself: a fixed rounded panel the page scrolls inside. */
  body.is-signed-in::before {
    content: ""; position: fixed; z-index: -1; top: var(--frame-top); bottom: -24px;
    left: var(--shell-gutter); right: var(--shell-gutter);
    background: var(--fr-bg); border: 1px solid var(--fr-line); border-radius: 20px;
    box-shadow: var(--fr-frame-shadow);
  }
}
@media (min-width: 768px) and (max-width: 1263px) {
  body.is-signed-in { --sidebar-w: 72px; --layout-web-sidebar: 72px; }
}
@media (max-width: 767px) {
  body.is-signed-in { --sidebar-w: 0px; --layout-web-sidebar: 0px; --shell-gutter: 0px; }
}

/* --- Sidebar ---------------------------------------------------------------------------------- */
@media (min-width: 768px) {
  body.is-signed-in .sidebar {
    top: var(--frame-top); bottom: 0; left: var(--shell-gutter); width: var(--sidebar-w);
    padding: 0 18px 16px 18px; background: var(--fr-side); border: 0; border-right: 1px solid var(--fr-line);
    border-radius: 20px 0 0 0; box-shadow: inset 1px 1px 0 var(--fr-line);
    overflow: visible;
  }
}
.sidebar-brand { position: relative; height: 94px; padding: 0 0 0 8px; align-items: center; gap: 0; }
.sidebar-brand .wordmark img { height: 40px; width: auto; }
.sidebar-brand .brand-sparkle { position: static; flex: none; width: 18px; height: 18px; margin: -20px 0 0 2px; }  /* hugs the "t", whatever the wordmark width (light / dark images differ) */
.sidebar .nav { display: flex; flex-direction: column; gap: 8.5px; flex: none; }
.sidebar .nav-item {
  position: relative; display: flex; align-items: center; gap: 18px; width: 100%;
  height: 46px; min-height: 46px; padding: 0 12px; border-radius: 12px;
  font-size: 16px; font-weight: 500; color: var(--fr-text); background: transparent;
}
.sidebar .nav-item:hover { background: var(--fr-hover); }
.sidebar .nav-item[data-current], .sidebar .nav-item.is-active { background: var(--fr-pill); }
.sidebar .nav-item[data-current]:hover { background: var(--fr-pill); }
.sidebar .nav-item[data-current] .nav-label, .sidebar .nav-item.is-active .nav-label { font-weight: 700; }
.sidebar .nav-icon, .sidebar .nav-icon .icon { width: 26px; height: 26px; }
.sidebar .nav-label { flex: 1; min-width: 0; text-overflow: ellipsis; }
.sidebar .nav-count {
  position: static; flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; line-height: 1;
  background: var(--fr-badge); color: #fff; box-shadow: none;
}
/* Icon colours (mockup): Home blue, Reels pink→violet, Messages blue, Search ink, Explore green,
   Notifications orange, Create blue, Profile blue, Saved violet, Settings / More ink. */
.ni-home .nav-icon, .ni-home .nav-icon .icon { color: #1A6DF5; }
.ni-reels .nav-icon, .ni-reels .nav-icon .icon { color: #E14BCB; }
.ni-reels .nav-icon .icon { fill: url(#ni-grad-reels); }
.ni-messages .nav-icon, .ni-messages .nav-icon .icon { color: #2F6BF0; }
.ni-messages .nav-icon .duo, .ni-create .nav-icon .duo { opacity: 0.16; fill: currentColor; }
.ni-search .nav-icon .icon, .ni-settings .nav-icon .icon, .ni-more .nav-icon .icon { color: var(--fr-text); }
.ni-explore .nav-icon, .ni-explore .nav-icon .icon { color: #16B34F; }
.ni-notifications .nav-icon, .ni-notifications .nav-icon .icon { color: #F47216; }
.ni-create .nav-icon, .ni-create .nav-icon .icon { color: #1A88E8; }
.ni-profile .nav-icon, .ni-profile .nav-icon .icon { color: #2563EB; }
.ni-saved .nav-icon, .ni-saved .nav-icon .icon { color: #6A2EE8; }
.sidebar .nav-item .nav-icon { transition: transform 120ms; }
.sidebar .nav-utilities-list { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--fr-line); gap: 4px; }
.sidebar .nav-utilities-list .nav-item { height: 42px; min-height: 42px; }
.sidebar .nav-bottom { margin: 0; padding: 0; display: block; position: relative; }
.sidebar .more-menu { left: 0; bottom: calc(100% + 6px); width: 266px; }
.sidebar-inspiration { display: none !important; }

/* Pro card. */
.pro-card {
  margin-top: 18px; padding: 16px 15px 15px; border-radius: 14px; background: var(--fr-promo);
  border: 1px solid color-mix(in srgb, #8B7CF6 12%, transparent);
}
.pro-card h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; color: var(--fr-text); letter-spacing: -0.01em; }
.pro-card p { margin: 8px 0 14px; font-size: 14px; line-height: 1.45; color: var(--fr-promo-text); }
.pro-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border-radius: 10px;
  font-size: 15px; font-weight: 600; color: #fff; background: linear-gradient(90deg, #2438FB 0%, #6B39F7 50%, #D836F6 100%);
  box-shadow: 0 6px 16px rgba(76, 56, 247, 0.25); transition: filter 120ms;
}
.pro-btn:hover { filter: brightness(1.06); }
.pro-btn .icon { width: 16px; height: 16px; }

/* Icon-only sidebar (768–1263): the same icons, counts become corner badges, no Pro card. */
@media (min-width: 768px) and (max-width: 1263px) {
  body.is-signed-in .sidebar { padding: 0 12px 16px; }
  .sidebar .sidebar-brand { height: 76px; padding: 0 0 0 8px; }
  .sidebar .brand-sparkle { display: none; }
  .sidebar .nav-item { width: 46px; padding: 0 10px; justify-content: center; }
  .sidebar .nav-count { position: absolute; top: 2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 12px; box-shadow: 0 0 0 2px var(--fr-side); }
  .sidebar .nav-label { display: none; }
  .pro-card { display: none; }
}
/* Short windows: tighter rows (type unchanged); the Pro card steps aside first. */
@media (min-width: 768px) and (max-height: 860px) {
  .pro-card { display: none; }
}
@media (min-width: 768px) and (max-height: 760px) {
  .sidebar-brand { height: 74px; }
  .sidebar .nav { gap: 4px; }
  .sidebar .nav-item { height: 42px; min-height: 42px; }
  .sidebar .nav-utilities-list { margin-top: 8px; padding-top: 8px; gap: 2px; }
  .sidebar .nav-utilities-list .nav-item { height: 40px; min-height: 40px; }
}
@media (min-width: 768px) and (max-height: 640px) {
  .sidebar-brand { height: 64px; }
  .sidebar .nav { gap: 2px; }
  .sidebar .nav-item { height: 40px; min-height: 40px; }
  .sidebar .nav-utilities-list .nav-item { height: 38px; min-height: 38px; }
}
@media (min-width: 768px) and (max-height: 580px) {
  body.is-signed-in .sidebar { overflow-x: hidden; overflow-y: auto; }
}

/* --- Top bar ------------------------------------------------------------------------------------ */
@media (min-width: 768px) {
  body.is-signed-in .desktop-header {
    position: sticky; top: 0; z-index: 31; isolation: isolate;
    height: var(--header-h); padding: var(--frame-top) 24px 0 16px; gap: 16px;
    margin-left: calc(var(--shell-gutter) + var(--sidebar-w)); margin-right: var(--shell-gutter);
    background: var(--fr-page); border: 0;
  }
  /* The frame's own surface under the bar (and its rounded top-right corner); the strip above it stays page colour. */
  body.is-signed-in .desktop-header::before {
    content: ""; position: absolute; z-index: -1; inset: var(--frame-top) 0 0 0;
    background: var(--fr-bg); border-top: 1px solid var(--fr-line); border-right: 1px solid var(--fr-line); border-top-right-radius: 20px;
  }
}
.desktop-search { flex: 1 1 auto; max-width: 680px; height: auto; padding: 0; background: none; border-radius: 0; }
.desktop-search-field { height: 44px; padding: 0 10px 0 16px; gap: 12px; border-radius: 14px; background: var(--fr-input); border: 1px solid transparent; }
.desktop-search-field .icon { width: 20px; height: 20px; color: var(--fr-text); }
.desktop-search-field input { font-size: 15px; }
.desktop-search-field input::placeholder { color: var(--fr-muted); }
.desktop-search-field:focus-within { background: var(--fr-card); box-shadow: 0 0 0 2px color-mix(in srgb, var(--fr-blue) 45%, transparent); }
.desktop-header-actions { gap: 14px; }
.header-btn { width: 40px; height: 40px; color: var(--fr-text); }
.header-btn .icon { width: 25px; height: 25px; }
.header-btn:hover { background: var(--fr-hover); }
.header-btn .badge { top: 0; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; font-size: 12px; font-weight: 700; background: var(--fr-badge); color: #fff; box-shadow: 0 0 0 2px var(--fr-bg); display: grid; place-items: center; }
.header-theme .ht-moon { display: none; }
[data-theme="dark"] .header-theme .ht-sun { display: none; }
[data-theme="dark"] .header-theme .ht-moon { display: grid; }
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .header-theme .ht-sun { display: none; }
  [data-theme="system"] .header-theme .ht-moon { display: grid; }
}
.header-theme span { display: grid; place-items: center; }
.account-menu { margin-left: 10px; }
.desktop-account { height: 44px; gap: 12px; padding: 4px 8px 4px 4px; max-width: 260px; }
.desktop-account .avatar { --size: 36px; }
.desktop-account strong { font-size: 15px; font-weight: 700; color: var(--fr-text); }
.desktop-account:hover, .desktop-account[aria-expanded="true"] { background: var(--fr-hover); }

/* --- Main column ------------------------------------------------------------------------------- */
@media (min-width: 768px) {
  body.is-signed-in .main { min-height: calc(100dvh - var(--header-h)); background: transparent; }
}
.page-feed .feed-layout { display: flex; justify-content: flex-start; align-items: flex-start; gap: 16px; padding: 12px 18px 40px 16px; }
.page-feed .feed-col { flex: 1 1 var(--feed-w); width: auto; max-width: var(--feed-w); min-width: 0; padding-top: 0; }
.page-feed .rail {
  position: sticky; top: calc(var(--header-h) + 12px); flex: none; width: var(--rail-w); padding: 0 0 12px;
  max-height: calc(100dvh - var(--header-h) - 12px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
}
.page-feed .rail::-webkit-scrollbar { display: none; }
@media (min-width: 768px) and (max-width: 1263px) {
  .page-feed .feed-layout { justify-content: center; padding: 12px 16px 40px; }
}

/* Cards share one look: white (charcoal), hairline border, 14 radius, soft shadow. */
.page-feed .post-card, .page-feed .story-tray, .rail-card {
  --bg-surface: var(--fr-card);
  background: var(--fr-card); border: 1px solid var(--fr-line); border-radius: 14px; box-shadow: var(--fr-shadow);
}

/* --- Stories card ------------------------------------------------------------------------------ */
.page-feed .story-tray {
  --bg-surface: var(--fr-story-bg);
  background: var(--fr-story-bg); border: 1.5px solid var(--fr-story-border);
  height: 115px; padding: 0 4px; margin-bottom: 14px; display: flex; align-items: center;
}
.page-feed .story-track { gap: 0; padding: 0; width: 100%; align-items: center; }
.page-feed .story-link { width: 84px; gap: 9px; padding-top: 0; }
.page-feed .story-tray .avatar { --size: 58px; --ring-inset: 4px; }
.page-feed .story-tray .avatar[data-ring="unseen"] { --ring-stroke: 2.5px; }
.page-feed .story-tray .avatar[data-ring="none"] { box-shadow: 0 0 0 4px var(--fr-story-bg), 0 0 0 5.5px var(--fr-line-strong); border-radius: 50%; }
.page-feed .story-name { max-width: 78px; font-size: 13px; font-weight: 500; color: var(--fr-text); }
.page-feed .story-name.is-seen { color: var(--fr-muted); }
.story-add { width: 22px; height: 22px; right: -4px; bottom: -3px; background: var(--fr-blue); border: 2px solid var(--fr-story-bg, #fff); }
.story-all-dot { display: grid; place-items: center; width: 62px; height: 62px; margin: -2px; border-radius: 50%; background: var(--fr-seeall); color: var(--fr-text); }
.story-all .story-name { color: var(--fr-muted); }
.page-feed .tray-arrow { top: 36px; }
/* Unseen rings: the mockup's warm gradient (stories, post headers, suggestions). */
body.is-signed-in .avatar[data-ring="unseen"] { --ring-bg: var(--fr-ring); }

/* --- Post card ----------------------------------------------------------------------------------- */
.page-feed .post-card, .feed-list .post-card { padding: 0 16px 16px; margin-bottom: 22px; }
.post-card .post-head { padding: 13px 0 12px; gap: 12px; min-height: 0; }
.post-card .post-head > .avatar, .post-card .post-head .avatar-group > .avatar:first-child { --size: 40px; --ring-inset: 3px; }
.post-card .post-head-line { font-size: 15px; }
.post-card .post-head-line .username { font-weight: 700; }
.post-card .post-when { font-size: 14px; color: var(--fr-muted); }
.post-card .post-sub { font-size: 13px; color: var(--fr-text); gap: 6px; }
.post-card .post-head .icon-btn .icon { width: 24px; height: 24px; }
.post-card .post-media { border-radius: 12px; overflow: hidden; }
/* One screen: header + media + actions + caption start fit (≥ 600px tall windows). */
body.is-signed-in { --feed-media-max: max(300px, calc(100dvh - var(--header-h) - 200px)); }
.post-card .post-media > .media, .post-card .post-media > .carousel { max-height: var(--feed-media-max); }
.post-card .post-media > .media-video.has-controls { width: 100%; aspect-ratio: 1.93 !important; max-height: var(--feed-media-max); background-color: #000 !important; background-image: none !important; }
.post-card .media-grid { max-height: var(--feed-media-max); }

/* Feed video player: big play button, bottom control bar with time, volume, full screen, ⋮, seek line. */
.media-video.has-controls video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.media-bigplay {
  position: absolute; left: 50%; top: 50%; z-index: 3; width: 64px; height: 64px; transform: translate(-50%, -50%);
  display: grid; place-items: center; border-radius: 50%; color: #fff;
  background: rgba(0, 0, 0, 0.38); border: 2.5px solid rgba(255, 255, 255, 0.92); transition: transform 120ms, background-color 120ms;
}
.media-bigplay .icon { width: 28px; height: 28px; margin-left: 4px; }
.media-bigplay:hover { background: rgba(0, 0, 0, 0.55); transform: translate(-50%, -50%) scale(1.05); }
.vbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 34px 14px 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55)); transition: opacity 160ms;
}
.vbar-row { display: flex; align-items: center; gap: 6px; }
.vbar-spacer { flex: 1; }
.vtime { font-size: 14px; font-weight: 500; letter-spacing: 0.01em; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.vbtn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; }
.vbtn:hover { background: rgba(255, 255, 255, 0.16); }
.vbtn .icon { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35)); }
.vbtn-play { margin-left: -8px; }
.vvolume { display: flex; align-items: center; }
.vvolume input { width: 0; opacity: 0; transition: width 160ms, opacity 160ms; accent-color: #fff; height: 4px; }
.vvolume:hover input, .vvolume:focus-within input { width: 76px; opacity: 1; margin-right: 4px; }
.vseek { position: relative; height: 14px; margin: 4px 4px 0; cursor: pointer; touch-action: none; }
.vseek::before, .vseek-buf, .vseek-fill { content: ""; position: absolute; left: 0; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 2px; }
.vseek::before { right: 0; background: rgba(255, 255, 255, 0.32); }
.vseek-buf { background: rgba(255, 255, 255, 0.5); }
.vseek-fill { background: #fff; }
.vseek-knob { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.media-video.has-controls:fullscreen .vbar { padding: 40px 24px 20px; }

/* Actions: ♡ 1.2K · 💬 48 · 🔁 · ➤ … 🔖 */
.post-card .post-actions { padding: 8px 0 4px; margin: 0 -8px; gap: 6px; }
.post-card .post-actions .pa-btn { height: 40px; gap: 8px; }
/* Audit WL-01: the row already bleeds -8px; Save's own -8px pushed it 4px past a 390px phone (sideways scroll). */
.post-card .post-actions .action-save { margin-right: 0; }
[dir="rtl"] .post-card .post-actions .action-save { margin-left: 0; }
.post-card .pa-icon .icon { width: 26px; height: 26px; }
.post-card .pa-count { font-size: 15px; font-weight: 500; color: var(--fr-text); }
.post-card .post-body { gap: 3px; }
.post-card .caption, .post-card .caption-more { font-size: 15px; line-height: 1.5; }
.post-card .caption-text .caption-user .username { font-weight: 700; }
.post-card .caption-text a.hashtag, .post-card .caption-text .hashtag, .post-card .caption-text a[href^="/explore/tags/"] { color: var(--fr-link); }
.post-card .view-comments { font-size: 15px; color: var(--fr-muted); margin-top: 2px; }

/* Composer: your avatar, then a rounded field with emoji and photo buttons inside. */
.post-card .post-comment { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 0; }
.post-card .post-comment-me { --size: 40px; flex: none; }
.post-comment-field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; min-height: 46px; padding: 4px 8px 4px 16px;
  border: 1px solid var(--fr-input-border); border-radius: 14px; background: color-mix(in srgb, var(--fr-input) 45%, var(--fr-card));
  transition: border-color 120ms, box-shadow 120ms;
}
.post-comment-field:focus-within { border-color: color-mix(in srgb, var(--fr-blue) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fr-blue) 14%, transparent); }
.post-comment-field textarea { flex: 1; min-width: 0; font-size: 14px; padding: 8px 0; background: transparent; border: 0; }
/* Tools match the post-window composer (.cmt-tool): same 32px round hit area, 20px icons, one row, centred. */
.post-comment-field .emoji { position: relative; display: flex; flex: none; }
.post-comment-field .icon-btn { width: 32px; height: 32px; margin: 0; flex: none; color: var(--text-secondary); }
.post-comment-field .icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.post-comment-field .icon-btn .icon { width: 20px; height: 20px; display: block; }

/* --- Right column cards -------------------------------------------------------------------------- */
.rail-card { margin-bottom: 14px; padding: 14px 16px; overflow: visible; }
.rail-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rail-card-head h2 { font-size: 15px; font-weight: 700; color: var(--fr-text); letter-spacing: 0; }
.rail-card-head a { font-size: 15px; font-weight: 500; color: var(--fr-blue); }
.rail-card-head a:hover { text-decoration: underline; }

/* Profile card: cover, overlapping avatar, name ✓, handle, bio, stats, Edit Profile + gear. */
.page-feed .home-profile { padding: 0 14px 14px; text-align: center; overflow: hidden; }
.page-feed .home-profile-cover { height: 90px; margin: 0 -14px; background: linear-gradient(135deg, #8EA6F2, #F2B880); overflow: hidden; }
.page-feed .home-profile-cover img { width: 100%; height: 100%; object-fit: cover; object-position: center 62%; display: block; }
.home-profile-avatar { display: block; width: fit-content; margin: -40px auto 0; position: relative; line-height: 0; }
.page-feed .home-profile .home-profile-avatar .avatar { --size: 72px; border-radius: 50%; box-shadow: 0 0 0 3px var(--fr-card); border: 0; }
.page-feed .home-profile h2 { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 6px; font-size: 18px; font-weight: 700; color: var(--fr-text); }
.page-feed .home-profile h2 .verified { color: var(--fr-blue); }
.home-profile-handle { display: block; margin-top: 2px; font-size: 13px; color: var(--fr-muted); }
.page-feed .home-profile .home-profile-bio { margin: 14px 6px 0; font-size: 14px; line-height: 1.4; color: var(--fr-text); text-align: left; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.page-feed .home-profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 16px 0 14px; }
.page-feed .home-profile-stats span { display: grid; gap: 1px; font-size: 13px; color: var(--fr-muted); }
.page-feed .home-profile-stats strong { font-size: 16px; font-weight: 700; color: var(--fr-text); }
.home-profile-actions { display: flex; gap: 10px; }
.home-profile-actions .btn { flex: 1; height: 36px; min-height: 36px; border-radius: 9px; font-size: 15px; font-weight: 600; background: var(--fr-input); color: var(--fr-text); border: 0; }
.home-profile-actions .btn:hover { background: color-mix(in srgb, var(--fr-input) 80%, var(--fr-text)); }
.home-profile-actions .home-profile-gear { flex: none; width: 36px; padding: 0; display: grid; place-items: center; background: var(--fr-card); border: 1px solid var(--fr-line-strong); }

/* Suggested for you. */
.suggest-rail .rail-list { padding: 0; border: 0; background: none; box-shadow: none; border-radius: 0; display: grid; gap: 1px; }
.suggest-rail .user-row { padding: 4px 0; gap: 10px; }
.suggest-rail .user-row .avatar { --size: 38px; --ring-inset: 3px; }
.suggest-rail .user-row-text .username { font-size: 14px; font-weight: 700; }
.suggest-rail .user-row-sub { font-size: 13px; color: var(--fr-muted); }
.suggest-rail .user-row .btn { height: 32px; min-height: 32px; padding: 0 14px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.suggest-rail .user-row .btn-primary { background: var(--fr-blue); color: #fff; }
.suggest-rail .follow { flex: none; margin-left: auto; }
.suggest-more { position: relative; flex: none; margin-right: -8px; }
.suggest-more .icon-btn { width: 28px; height: 32px; color: var(--fr-muted); }
.suggest-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 200px; display: grid; }
.suggest-menu .menu-item { display: flex; align-items: center; gap: 10px; }

/* Trending today. */
.trending-list { display: grid; gap: 4px; }
.trending-row { display: flex; align-items: center; gap: 12px; padding: 2px 0; border-radius: 10px; color: var(--fr-text); }
.trending-row:hover strong { text-decoration: underline; }
.trending-rank { width: 14px; flex: none; font-size: 14px; font-weight: 500; color: var(--fr-text); text-align: center; }
.trending-row img { width: 44px; height: 44px; flex: none; border-radius: 9px; object-fit: cover; background: var(--fr-input); }
.trending-text { display: grid; min-width: 0; }
.trending-text strong { font-size: 14px; font-weight: 700; }
.trending-text small { font-size: 13px; color: var(--fr-muted); }
.page-feed .rail .site-footer { margin-top: 6px; padding-left: 4px; }

/* --- Phone (< 768): same cards, edge to edge ----------------------------------------------------- */
@media (max-width: 767px) {
  .page-feed .feed-layout { padding: 0; gap: 0; }
  .page-feed .story-tray { height: auto; padding: 12px 4px; margin-bottom: 8px; border-radius: 0; border-inline: 0; box-shadow: none; }
  .page-feed .post-card, .feed-list .post-card { padding: 0 12px 12px; margin-bottom: 8px; border-radius: 0; border-inline: 0; box-shadow: none; }
  .page-feed .story-link { width: 78px; }
  body.is-signed-in { --feed-media-max: max(280px, calc(100dvh - 260px)); }
  .post-card .post-media > .media-video.has-controls { aspect-ratio: 1.2 !important; }
  .vtime { font-size: 13px; }
  .vbar { padding: 28px 10px 8px; }
}

/* --- Reels: full-screen black viewer (≥768), after Facebook's reel viewer ------------------------------
   No sidebar, top bar or frame. The 9:16 video is centred in the window at window height − 32; the action
   rail hangs just right of it (bottom-aligned, white icons, counts under); ↑ / ↓ sit at the right edge;
   ✕ + app mark top-left, Messages / Notifications / profile top-right. The overlay viewer (.rv) matches. */
.reels-chrome { display: none; }
@media (min-width: 768px) {
  html:has(body.page-reels) { background: #000; }
  body.page-reels { --header-h: 0px; --frame-top: 0px; background: #000; color: #fff; }
  body.page-reels::before, body.page-reels .sidebar, body.page-reels .desktop-header, body.page-reels .guest-bar { display: none !important; }
  body.page-reels .main { margin: 0 !important; min-height: 100dvh; background: #000; }
  body.page-reels .reels-page { height: 100dvh; background: #000; }
  body.page-reels .reel { height: 100dvh !important; }
  body.page-reels .reels-scroller, .rv .rv-scroller { container-type: size; }
  /* Video centred: the stage is video + 12 + rail(56); shifting it by half the rail keeps the video itself on the axis. */
  body.page-reels .reel-stage, .rv .reel-stage { height: min(100%, calc((100cqw - 150px) * 16 / 9)) !important; transform: translateX(34px); }
  body.page-reels .reel-media, .rv .reel-media { border-radius: 10px; }
  body.page-reels .reel-action, .rv .reel-action { color: #fff !important; }
  body.page-reels .reel-rail .reel-icon .icon, .rv .reel-rail .reel-icon .icon { width: 26px; height: 26px; }
  body.page-reels .reel-rail .reel-icon.liked .icon, .rv .reel-rail .reel-icon.liked .icon { color: var(--accent-flash); }
  body.page-reels .reel-count, .rv .reel-count { color: #fff; font-size: 13px; font-weight: 600; }
  body.page-reels .reel-rail .reel-action:hover .reel-icon { background: rgba(255, 255, 255, 0.12); }
  body.page-reels .reel-disc { border-color: #fff; }
  /* For You | Following centred at the top of the video; mute in the video's top-right corner.
     --rw = width of the player column, --vw = the video's width (same formula as the stage height). */
  body.page-reels .reels-page { --rw: 100vw; --vw: min(calc((100dvh - 32px) * 9 / 16), calc(var(--rw) - 150px)); }
  body.page-reels .reels-page.has-comments { --rw: calc(100vw - 424px); }
  body.page-reels .reels-hud { top: 28px !important; left: 0 !important; right: auto !important; width: var(--rw) !important; height: 40px !important; transform: none !important; justify-content: center; }
  body.page-reels .reels-hud .reels-tabs { pointer-events: auto; }
  body.page-reels .reels-hud-sound { position: absolute !important; top: 2px; right: auto; left: calc(var(--rw) / 2 + var(--vw) / 2 - 12px - 38px); width: 38px; height: 38px; background: rgba(10, 12, 17, 0.5); }
  body.page-reels .reels-nav, .rv .reels-nav { right: 20px; gap: 22px; }
  body.page-reels .reels-nav-btn, .rv .reels-nav-btn { width: 44px; height: 44px; background: transparent; color: rgba(255, 255, 255, 0.85); border: 2px solid rgba(255, 255, 255, 0.55); box-shadow: none; }
  body.page-reels .reels-nav-btn:hover, .rv .reels-nav-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
  body.page-reels .reel-comments-panel { top: 16px; bottom: 16px; }

  .reels-chrome { position: absolute; top: 12px; left: 16px; right: 16px; z-index: 8; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
  @media (max-width: 1100px) { body.page-reels .reels-page.has-comments { --rw: calc(100vw - 384px); } }
  .rc-group { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
  .rc-close { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: #E4E6EB; color: #050505; }
  .rc-close:hover { background: #fff; }
  .rc-logo img { width: 40px; height: 40px; border-radius: 50%; display: block; }
  .rc-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: #3A3B3C; color: #E4E6EB; }
  .rc-btn:hover { background: #4E4F50; }
  .rc-btn .badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 12px; font-weight: 700; background: var(--fr-badge); color: #fff; display: grid; place-items: center; }
  .rc-me { background: none; }
  .rc-me .avatar { --size: 40px; }
  .reels-page.has-comments .reels-chrome .rc-group:last-child, .rv.has-comments .reels-chrome .rc-group:last-child { margin-right: 424px; }
  /* Overlay viewer: the same chrome replaces its old corner ✕. */
  .rv .rv-close { display: none; }
  .rv .reels-chrome { position: fixed; z-index: 7; }
  .rv:not(.is-open) .reels-chrome { display: none; }
}
@media (max-width: 767px) {
  .reels-page .reels-top .reels-sound { width: 38px; height: 38px; border-radius: 50%; background: rgba(10, 12, 17, 0.45); color: #fff; }
}
/* Overlay viewer: mute in the video's top-right corner (same geometry as the /reels page). */
.rv { --rw: 100vw; --vw: min(calc((100dvh - 32px) * 9 / 16), calc(var(--rw) - 150px)); }
.rv.has-comments { --rw: calc(100vw - 424px); }
.rv .rv-sound { position: absolute; z-index: 6; top: 28px; right: auto; left: calc(var(--rw) / 2 + var(--vw) / 2 - 12px - 38px); width: 38px; height: 38px; background: rgba(10, 12, 17, 0.5); }
.rv:not(.is-ready) .rv-sound { display: none; }
@media (max-width: 767px) { .rv .rv-sound { top: calc(env(safe-area-inset-top) + 15px); left: auto; right: 12px; } .rv .rv-close { left: 12px; right: auto; } }

/* --- In-video controls: hover / tap to reveal (glint wake() in app.js) ------------------------------- */
.media-video.has-controls .vbar, .reels-hud-sound { opacity: 0; transition: opacity 200ms; }
.media-video.has-controls.is-awake .vbar, .media-video.has-controls .vbar:focus-within,
.reels-page.is-awake .reels-hud-sound, .rv.is-awake .rv-sound, .reels-hud-sound:hover, .reels-hud-sound:focus-visible { opacity: 1; }
.media-video.has-controls:not(.is-awake) .vbar:not(:focus-within) { pointer-events: none; }
@media (hover: none) { .reels-page .reels-top .reels-sound { transition: opacity 200ms; } }

/* --- Reels contrast: scrims at the top (tabs / mute) and bottom (caption); a darker tab pill --------- */
.reel-media::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 120px; z-index: 2; pointer-events: none; background: linear-gradient(rgba(0, 0, 0, 0.38), transparent); border-radius: inherit; }
.reel-media::after { content: ""; position: absolute; inset: auto 0 0 0; height: 45%; z-index: 2; pointer-events: none; background: linear-gradient(transparent, rgba(0, 0, 0, 0.6)); border-radius: inherit; }
.reel-overlay { z-index: 3; }
.reels-tabs { background: rgba(0, 0, 0, 0.45) !important; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.14); }
.reels-tabs a:not(.is-active) { color: #fff !important; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
body.page-reels .reels-nav-btn:disabled, .rv .reels-nav-btn:disabled { opacity: 0.35; border-color: rgba(255, 255, 255, 0.7); }

/* --- Video in the post window (.pw.is-theater): black stage behind the player; the window follows the site theme --- */
.pw.is-theater .pw-media, .pw.is-theater .pw-stage, .pw.is-theater .pw-preview-media { background: #000; }
.pw-video .pw-video-bar { transition: opacity 200ms; }
.pw-video:not(.is-awake):not(:focus-within).is-playing .pw-video-bar { opacity: 0; }

/* --- Photos: full card width, true aspect, side bars in the photo's own average colour -------------- */
.post-card .post-media > .media:not(.media-video) { width: 100%; max-height: var(--feed-media-max); background-image: none !important; }
.post-card .post-media > .media:not(.media-video) img { width: 100%; height: 100%; object-fit: contain; }
.pw-photo .media { background-image: none; }

/* --- "{name} is in {place}." header -------------------------------------------------------------- */
.post-in { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--fr-text); font-weight: 400; }
/* Narrow feed column (WF-01): "Name is in Place. • 2w" wraps like Facebook instead of cutting the name. */
.post-card .post-head-line:has(.post-in) { flex-wrap: wrap; row-gap: 0; }
.post-card .post-head-line:has(.post-in) > .post-authors { flex-shrink: 0; max-width: 100%; }
.post-head-line .post-meta { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.post-head-line:has(.post-in) .post-meta > .sep:first-child { display: none; }
.post-in a { font-weight: 700; color: inherit; }
.post-in a:hover { text-decoration: underline; }

/* People you may know: equal-height cards; Follow / Follow back always on the same baseline, whatever
   the name or "Followed by …" length (the reason is clamped to two lines and reserves that space). */
.people-block .fb-track { align-items: stretch; }
.people-block .person-card { display: flex; flex-direction: column; align-items: center; }
.people-block .person-name { display: block; min-height: 1.35em; line-height: 1.35; }
.people-block .person-sub { min-height: calc(2 * 1.35em); line-height: 1.35; display: flex; align-items: flex-start; justify-content: center; gap: 4px; text-align: center; }
.people-block .person-sub > span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.people-block .person-follow { margin-top: auto; width: 100%; }

/* Audience icon after a post's time (🌐 Public …). */
.post-audience { display: inline-flex; flex: none; align-items: center; align-self: center; width: 15px; height: 15px; vertical-align: -3px; color: var(--text-secondary); opacity: 1; }
.post-audience .icon { width: 15px; height: 15px; display: block; }
.post-audience.is-close_friends { color: #1DB954; }

/* Reels For You | Following pill: phones only, hidden while scrolling forward (reelsPage.tabsShown). */
.reels-tabs { transition: transform 220ms ease, opacity 180ms ease; }
.reels-tabs.is-hidden { opacity: 0; transform: translateY(-140%); pointer-events: none !important; }
@media (prefers-reduced-motion: reduce) { .reels-tabs { transition: none; } }
@media (min-width: 768px) { .reels-page .reels-tabs { display: none !important; } }

/* Top bar lines up with the columns under it (wide screens, where the right rail shows): the search
   bar spans exactly the feed column, and the theme / messages / notifications / account cluster spans
   the right rail. */
/* WF-01: on the home feed a portrait (4:5) post fits the screen with its header — the feed column
   narrows on short screens (laptops ~620–640px tall) instead of cropping or side bars; 750px (mockup)
   once there's room. 160px = top bar + feed padding + post header. Feed + rail (and the top bar
   above them) then sit centred, so the narrower column leaves no empty strip on one side. */
@media (min-width: 768px) {
  body.is-signed-in:has(.page-feed) { --feed-w: clamp(360px, calc((100dvh - 160px) * 0.8), 750px); }
}
@media (min-width: 1264px) {
  body.is-signed-in .desktop-header { padding-right: 18px; gap: 16px; }
  body.is-signed-in .desktop-search { flex: 1 1 var(--feed-w); max-width: var(--feed-w); }
  body.is-signed-in .desktop-header-actions { flex: 0 0 var(--rail-w); width: var(--rail-w); justify-content: space-between; margin-left: 0; }
  body.is-signed-in:has(.page-feed) .desktop-header,
  .page-feed .feed-layout { justify-content: center; }
}



/* =========================================================================
   Feed media box (batch 3 items 12 + 26): full card width, height from the first
   item's aspect clamped to 4:5 … 1.91:1 (--box-ratio, PostCard), photos and videos
   always cover-fill it around their focal point (inline object-position) — no side
   bars on posts, ads or reposts. The uncropped media lives in the post window.
   Several items: swipe carousel with ‹ › (desktop), a 1/N pill and dots.
   ========================================================================= */
.post-card .post-media.is-feed-box { width: 100%; aspect-ratio: var(--box-ratio, 1); max-height: none; }
.post-card .post-media.is-feed-box > .media,
.post-card .post-media.is-feed-box > .carousel,
.post-card .post-media.is-feed-box > .media-video.has-controls { width: 100%; height: auto; aspect-ratio: var(--box-ratio, 1) !important; max-height: none !important; background-image: none !important; }
.post-card .post-media.is-feed-box .media img,
.post-card .post-media.is-feed-box .media video,
.post-card .post-media.is-feed-box .media-video.has-controls video { width: 100%; height: 100%; object-fit: cover !important; }
.post-card .post-media.is-feed-box .carousel-slide .media { height: 100%; }
.post-card .post-media.is-feed-box .carousel-count { top: 12px; right: 12px; padding: 4px 10px; font-size: 12px; letter-spacing: .02em; background: rgba(10, 12, 17, .66); z-index: 2; }
.post-card .post-media.is-feed-box .carousel-arrow { width: 32px; height: 32px; margin-top: -16px; background: rgba(255, 255, 255, .88); color: #0E1117; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.post-card .post-media.is-feed-box .carousel-arrow:hover { background: #fff; }
.post-card .post-media.is-feed-box .carousel-arrow.prev { left: 12px; }
.post-card .post-media.is-feed-box .carousel-arrow.next { right: 12px; }
.carousel-dots-overlay { position: absolute; left: 0; right: 0; bottom: 12px; justify-content: center; gap: 5px; pointer-events: none; z-index: 2; }
.carousel-dots-overlay span { width: 6px; height: 6px; background: rgba(255, 255, 255, .55); box-shadow: 0 0 2px rgba(0, 0, 0, .35); }
.carousel-dots-overlay span.is-on { background: #fff; }
/* A video slide's own corner buttons sit above the dots. */
.post-card .post-media.is-feed-box .carousel .media-sound, .post-card .post-media.is-feed-box .carousel .media-fullscreen { bottom: 30px; }
/* Browser full screen (Fullscreen API) shows the whole frame. */
.post-card .post-media.is-feed-box > .media-video:fullscreen { aspect-ratio: auto !important; width: 100vw; height: 100vh; }
.post-card .post-media.is-feed-box .media-video:fullscreen video { object-fit: contain !important; }
