    :root {
      --bg-root: #020208;
      --bg-shell: #05050a;
      --bg-elevated: #0a0a12;
      --bg-elevated-soft: #0e0e19;
      --bg-chip: #10101b;
      --bg-body-top: #171427;
      --bg-shell-top: #141323;
      --border-subtle: rgba(255, 255, 255, 0.04);
      --border-strong: rgba(255, 255, 255, 0.18);
      --border-accent-soft: rgba(168, 130, 255, 0.4);
      --border-accent-strong: rgba(168, 130, 255, 0.9);
      --chrome-rgb: 255, 255, 255;
      --accent-soft: rgba(168, 130, 255, 0.16);
      --accent-strong: #b796ff;
      --accent-stronger: #d1b7ff;
      --accent-muted: #6c5ea8;
      --danger: #ff4b81;
      --danger-rgb: 255, 75, 129;
      --danger-soft: rgba(255, 75, 129, 0.1);
      /* The "positive/active" counterpart to --danger - same rgb-triplet
         convention as --chrome-rgb/--danger-rgb so callers needing a tinted
         background/border at their own alpha can derive it with
         rgba(var(--success-rgb), x) instead of each picking their own raw
         literal (both #4ade80 and #22c55e used to exist for this one
         meaning, only in the default theme - whisper themes already define
         their own --success). */
      --success: #4ade80;
      --success-rgb: 74, 222, 128;
      --text-main: #f7f3ff;
      --text-subtle: #b5b0c9;
      --muted: #787393;
      --muted-softer: #4d4864;
      --radius-card: 14px;
      --radius-pill: 999px;
      /* The one shared radius for every interactive control that isn't a
         full card/tile and isn't a genuinely circular element (status
         dots, badges, the universal round phone-call buttons, progress
         tracks) - icon buttons, toggles, chips, small action buttons.
         --radius-btn-sm is the same shape one size down, for compact
         22-24px controls (sheet close buttons, hover-reveal icons) where
         the full value reads too heavy. Previously every one of these
         redeclared its own copy of "10px" (or stayed a 999px pill) rather
         than sharing one value - this is that one value. */
      --radius-btn: 10px;
      --radius-btn-sm: 8px;
      --shadow-card: 0 3px 3px rgba(0, 0, 0, 0.85);
      --gem-conic: conic-gradient(from 220deg, #b796ff, #7a6dd6, #27213f, #b796ff);
      --gem-inner-top: #171427;
      --gem-inner-bot: #05050a;
      --gem-fill-from: #d2c0ff;
      --gem-fill-via: #a57eff;
      --gem-fill-to: #5b35d4;
      --gem-fill-end: #241241;
      --gem-glow: rgba(177, 142, 255, 0.8);
      --bg-card: rgba(10, 10, 20, 0.96);
      --bg-deep: rgba(6, 6, 16, 0.96);
      --bg-deep-98: rgba(6, 6, 16, 0.98);
      --bg-sheet: rgba(6, 6, 14, 0.96);
      --bg-sheet-solid: #050509;
      --bg-expanded-top: rgba(39, 33, 95, 0.96);
      --btn-primary-top: rgba(214, 186, 255, 0.1);
      --btn-primary-bot: rgba(135, 109, 210, 0.9);
      --btn-active-top: rgba(214, 186, 255, 0.18);
      --btn-active-bot: rgba(135, 109, 210, 0.55);
      --btn-active-border: rgba(192, 157, 255, 0.9);
      --bg-toggle: rgba(5, 5, 12, 0.94);
      --bg-chip-dark: rgba(12, 12, 22, 0.94);
      --bg-input: rgba(8, 8, 16, 0.96);
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      margin: 0;
      padding: 0;
      min-height: 100%;
      background: radial-gradient(circle at top, var(--bg-body-top) 0, var(--bg-root) 42%);
      color: var(--text-main);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
      -webkit-font-smoothing: antialiased;
    }

    body {
      display: flex;
      align-items: flex-start;
      justify-content: center;
      overflow-y: auto;
    }

    /* Mobile-first: the app fills the whole screen edge-to-edge, like an
       installed app, not a card floating on a background. The "phone in a
       frame" look only shows up once there's room for it to make sense
       (desktop browser preview) - see the min-width block below. */
    #app-root {
      width: 100%;
      padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }

    .shell {
      background: radial-gradient(circle at top, var(--bg-shell-top) 0, var(--bg-shell) 48%);
      /* Single source of truth for how far this padding insets a normal-
         flow child like .shell-main from .shell's own left edge - read by
         #brand-menu-overlay (nested in .shell-main) to compensate its own
         left:68px back to the same origin .rail-overlay (a direct,
         absolutely-positioned child of .shell, unaffected by this padding)
         uses for the rail. Keeping it here means the two can't drift apart
         if this padding (or the desktop breakpoint's border, below) ever
         changes. */
      --shell-inset-x: 10px;
      padding: 12px var(--shell-inset-x) 14px;
      display: flex;
      flex-direction: column;
      height: 100vh;
      height: 100dvh;
      position: relative;
      /* Vertical overflow (eg. a larger font-size scale inflating content
         past the shell's own height) scrolls the shell itself rather than
         spilling out to body - that's what lets .app-header below stay
         position:sticky and never scroll out of view with the rest of the
         page. Horizontal stays hidden, same as before, so rounded corners
         (see the desktop breakpoint) keep clipping child content. */
      overflow-x: hidden;
      overflow-y: auto;
    }

    /* Rail flyout - the app's primary navigation (Chat, Stories, Tasks,
       Journal, More). Hidden by default, toggled by the brand icon in the
       header, auto-closes after a destination is picked - see
       switchRailPage()/toggleRail() in app.js. Same backdrop+slide-in-panel
       pattern as the "More" drawer (.side-menu-overlay/.side-menu below). */
    .rail-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.82);
      display: flex;
      align-items: stretch;
      justify-content: flex-start;
      padding: 0;
      z-index: 20;
      backdrop-filter: blur(3px);
      -webkit-backdrop-filter: blur(3px);
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity 0.2s ease-out, visibility 0s linear 0.2s;
    }

    .rail-overlay.active {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transition: opacity 0.2s ease-out, visibility 0s linear 0s;
    }

    .rail {
      display: flex;
      flex-direction: column;
      align-items: center;
      flex: 0 0 68px;
      width: 68px;
      height: 100%;
      gap: 10px;
      padding: 14px 10px;
      background: var(--bg-sheet-solid);
      border-radius: 0 18px 18px 0;
      border-right: 1px solid var(--border-subtle);
      box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
      transform: translateX(-100%);
      transition: transform 0.22s ease-out;
      overflow-y: auto;
    }

    .rail-overlay.active .rail {
      transform: translateX(0);
    }

    .rail-item {
      position: relative;
      flex: 0 0 auto;
      width: 42px;
      height: 42px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 13px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      cursor: pointer;
    }

    .rail-item.active {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    .rail-icon {
      display: flex;
      line-height: 0;
    }

    .rail-icon svg {
      width: 20px;
      height: 20px;
    }

    .rail-item .archive-badge {
      position: absolute;
      top: -4px;
      right: -4px;
    }

    .shell-main {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      min-width: 0;
      min-height: 0;
      overflow: hidden;
      /* The containing block for every full-screen overlay nested inside it
         (.story-editor-overlay's inset:0, used by the story/call/chat/
         profile overlays) - now that .app-header lives outside
         .shell-main, those overlays stop at its top edge instead of
         covering the header. Most of them (story viewer, call screen)
         leave the header as is (rail toggle + avatar + call button all
         stay put). The two full-bleed creation editors - the Story
         composer and the profile gallery post editor - hide the header
         entirely instead (see setAppHeaderHidden in app.js), since there's
         nothing you'd need it for mid-draft; the chat room view and the
         profile view instead each swap just the hamburger for their own
         back-btn (+ title, for chat) via setAppHeaderSwap in app.js. Both
         leave the call button reachable (useful mid-chat, and equally
         useful - or needed as the in-call return indicator - while
         looking at a partner's profile); the profile view additionally
         hides just the avatar (see updateHeaderControlsVisibility in
         app.js) since its own hero avatar already fills that role. */
      position: relative;
    }

    .rail-page {
      display: flex;
      flex-direction: column;
      flex: 1 1 auto;
      min-height: 0;
      overflow: hidden;
    }

    @media (min-width: 600px) {
      #app-root {
        max-width: 536px;
        padding: 18px 14px 22px;
      }
      .shell {
        border-radius: 22px;
        border: 1px solid rgba(var(--chrome-rgb), 0.06);
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.85);
        /* +1px over the base value - the border above is new at this
           breakpoint and, like the padding, insets .shell-main (a normal-
           flow child) but not .rail-overlay (absolutely positioned,
           ignores both) - see --shell-inset-x's own comment above. */
        --shell-inset-x: 13px;
        padding: 14px var(--shell-inset-x) 18px;
        min-height: 560px;
        max-height: 760px;
        height: calc(100vh - 40px);
      }
    }

    /* 1fr/auto/1fr - the two 1fr side columns always match each other
       exactly regardless of how much the brand label or call button
       actually need, which is what keeps the middle (avatar) column
       mathematically centered on the row instead of just "between" two
       unevenly-sized siblings the way flex space-between would. */
    .app-header {
      display: grid;
      grid-template-columns: 1fr auto 1fr;
      align-items: center;
      /* The one shared gap every tab's content sits below - none of them
         add their own top spacing (admin-tabs, date-nav-wrap, sheet-body,
         fill-list all start flush), so this single value is what unifies
         the breathing room under the header across the whole app instead
         of each tab accidentally inheriting whatever this happened to be. */
      margin-bottom: 16px;
      gap: 10px;
      /* Sticky (not static) so the rail toggle, avatar and call button -
         most of the app's persistent nav - can never scroll out of view,
         even if .shell itself ends up needing to scroll (see .shell's own
         overflow-y comment). top:0 sticks it right at .shell's padding
         edge, i.e. exactly where it already sits unscrolled, so this is a
         no-op visually until there's actually something to scroll past.
         Also still the containing block for #chat-room-switch-dropdown
         (nested deep inside #app-header-col1's swap slot) - see that
         rule's own comment for why it needs to anchor here instead of its
         closer .chat-room-view-titlewrap parent. No other header child is
         absolutely positioned against it, so this is safe to add. */
      position: sticky;
      top: 0;
      z-index: 5;
      background: var(--bg-shell-top);
    }

    /* Explicit columns for all three header children - without this, a
       grid falls back to auto-placement in DOM order, and a
       display:none'd item (the avatar, hidden on Home/profile - see
       updateHeaderControlsVisibility in app.js) is skipped entirely by
       that algorithm rather than just leaving its column empty. That
       silently shifted the call button one column left into the
       avatar's own slot (dead center) whenever the avatar was hidden,
       instead of staying put in column 3. */
    #app-header-col1 {
      grid-column: 1;
    }
    #identity-avi-btn {
      grid-column: 2;
    }
    #app-header-call-btn {
      grid-column: 3;
    }
    #home-tasks-hud-btn {
      grid-column: 3;
    }

    /* While the chat room or profile view has swapped the hamburger out
       (see setAppHeaderSwap in app.js), this row's margin is the only gap
       left between it and whatever sits right below (the pinned-messages
       strip for chat, the profile card for profile) - that view's own
       topbar, which used to provide that spacing, is emptied out and
       hidden, so this is trimmed down to keep things tight under the
       back/title row instead of floating 16px below it. */
    .app-header.app-header-swap-open {
      margin-bottom: 4px;
      /* .app-header's own position:sticky + z-index:5 makes it establish a
         stacking context, so #chat-room-switch-dropdown's z-index:25
         (anchored here - see that rule's own comment) only ever wins inside
         THIS box, not against siblings - the whole header, dropdown
         included, still only carries a 5 into the page's real stacking
         order. .story-editor-overlay (the chat room/profile panel this
         header is standing in as the titlebar for) sits at 15, so its
         message list/photos/previews painted over the "25" dropdown
         regardless. Raised past that overlay's 15 and the pinned-list's 20
         (but still well under any real dialog - mini-popup 30, lightbox 40,
         the call screen's 500) only while swapped in as a panel's own
         titlebar; the normal (non-swapped) z-index:5 is unchanged so other
         full-screen panels still correctly cover the header as before. */
      z-index: 21;
    }
    /* Profile view only, and only once there's an actual banner photo
       behind it (.has-image - see paintProfileBanner in app.js; editing
       with nothing uploaded yet still renders .identity-card-banner, but
       as a flat placeholder color, not a photo worth seeing through to) -
       never chat, which shares .app-header-swap-open but never
       .identity-card-banner. The header itself is NOT repositioned here -
       it stays exactly where it's always been (sticky, in normal flow,
       same box) so it never moves regardless of whether a banner is
       behind it; without a banner photo it's left as its own normal solid
       background (no rule here overrides it). Just transparent, no scrim
       - an earlier version darkened the banner behind this with a
       gradient for icon legibility, but it ended up just getting in the
       way visually, so this is plain see-through now: the icons sit
       directly on the banner photo with nothing between them. What
       actually lets the banner reach up behind the header in the first
       place is .shell-main (see its own rule below), taken out of flow
       entirely and pinned to .shell's full content box. */
    .shell:has(#profile-view-overlay.active .identity-card-banner.has-image) .app-header.app-header-swap-open {
      background: transparent;
    }
    /* The back/call buttons next to #profile-view-title survive any banner
       color fine - they're icons on their own solid pill background
       (.story-editor-icon-btn/.app-header-call-btn), not bare glyphs on the
       photo. The "Profile" title itself has no such pill, so a banner
       whose brightness happens to land near this text's own muted color
       swallows it completely (confirmed: a banner with a light/mid-gray
       region made it unreadable, not just low-contrast - try one before
       touching this). No single fixed text color survives an arbitrary
       photo (dark text vanishes on dark photos, light text on light ones)
       - forcing it to white plus a dark halo is the standard fix for text
       floating over unknown image content for exactly that reason: the
       shadow buys contrast against light photos, the white fill buys it
       against dark ones, between them covering most real photos. Not
       themed (this white/black pairing is deliberately the same in every
       theme) because the photo behind it, not the theme, is what this is
       reacting to. */
    .shell:has(#profile-view-overlay.active .identity-card-banner.has-image) #profile-view-title {
      color: #fff;
      text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 1px 10px rgba(0, 0, 0, 0.55);
    }
    /* Pins .shell-main to .shell's full content box (position:absolute +
       inset:0, .shell already being position:relative) instead of leaving
       it in flow pushed down by the header's box. This is a pure overlap,
       not a guess: an earlier version used a negative margin-top sized to
       match the header's rendered height, which silently drifted a couple
       px off whenever that height changed (font-size settings, a longer
       title) - position:absolute sidesteps needing to know that height at
       all, since removing .shell-main from flow this way doesn't change
       where the header (first child, still in flow) renders one bit - a
       later sibling leaving flow never moves an earlier one. */
    .shell:has(#profile-view-overlay.active) .shell-main {
      position: absolute;
      inset: 0;
    }

    .app-header-col1 {
      display: flex;
      align-items: center;
      min-width: 0;
    }

    /* Hidden until the chat room or profile view swaps the hamburger out
       for that view's own back-btn (+ titlewrap, for chat) - moved in
       here, not cloned, see setAppHeaderSwap in app.js. */
    .app-header-swap-slot {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      min-width: 0;
    }

    .brand {
      justify-self: start;
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
    }

    .brand-text-main {
      font-size: 12px;
      font-weight: 600;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    /* Global date pill bar */

    .date-nav-wrap {
      position: relative;
      margin: 0 0 6px;
    }

    .date-nav-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-radius: 999px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-deep);
      padding: 4px 4px;
      transition: opacity 0.6s ease;
      opacity: 1;
    }

    .date-nav-bar.idle {
      opacity: 0.3;
    }

    .date-nav-arrow {
      appearance: none;
      border: none;
      background: none;
      color: var(--muted);
      font-size: 16px;
      line-height: 1;
      padding: 6px 12px;
      cursor: pointer;
    }

    .date-nav-label {
      flex: 1 1 auto;
      appearance: none;
      border: none;
      background: none;
      text-align: center;
      font-size: 12px;
      color: var(--text-subtle);
      cursor: pointer;
      padding: 6px 4px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .date-pill-dropdown {
      position: absolute;
      top: 100%;
      left: 50%;
      transform: translateX(-50%);
      margin-top: 4px;
      padding: 4px;
      border-radius: 10px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-deep-98);
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.85);
      width: 100%;
      max-width: 280px;
      z-index: 8;
    }

    .date-pill-option {
      padding: 4px 6px;
      border-radius: 6px;
      font-size: 12px;
      color: var(--text-subtle);
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 6px;
    }

    .date-pill-option:hover {
      background: rgba(var(--chrome-rgb), 0.04);
    }

    .date-pill-option.active {
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    .date-pill-option-meta {
      font-size: 10px;
      color: var(--muted-softer);
    }

    .view {
      display: none;
      flex-direction: column;
      flex: 1 1 auto;
      min-height: 0;
      gap: 6px;
    }

    .view.active {
      display: flex;
    }

    /* user/admin sections */


    .section {
      background: transparent;
      border-radius: 0;
      border: none;
      padding: 8px 0 6px;
      box-shadow: none;
      position: relative;
    }

    .fill-section {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      background: transparent;
    }

    .fill-list {
      flex: 1 1 auto;
      min-height: 0;
      margin: 0;
      padding: 4px 0 8px;
      list-style: none;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: var(--accent-muted) transparent;
    }

    .fill-list::-webkit-scrollbar {
      width: 6px;
    }

    .fill-list::-webkit-scrollbar-track {
      background: transparent;
    }

    .fill-list::-webkit-scrollbar-thumb {
      background: var(--accent-muted);
      border-radius: 999px;
    }

    /* empty state */
    .task-empty {
      font-size: 11px;
      color: var(--muted);
      text-align: center;
      padding: 8px 0 4px;
    }

    /* main lists scroll inside the panel */
    #admin-task-list,
    #history-list,
    #archive-list,
    #admin-journal-list {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
    }

    .task-card {
      border-radius: 12px;
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      padding: 7px 8px 7px;
      background: var(--bg-card);
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
      margin-bottom: 10px;
      display: flex;
      align-items:flex-start;
      gap: 8px;
    }

    .task-card.card-pulse {
      animation: cardPulse 0.26s ease-out;
    }

    @keyframes cardPulse {
      0%   { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6); }
      40%  { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), 0 0 18px var(--gem-glow); }
      100% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6); }
    }

    .task-main {
      flex: 1;
      min-width: 0;
    }

    .task-title {
      font-size: 13px;
      font-weight: 500;
      margin-bottom: 2px;
    }

    .task-title-row {
      position: relative;
    }

    .task-title-row .task-title {
      padding-right: 22px;
    }

    .task-meta-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 2px;
    }

    .task-meta {
      font-size: 11px;
      color: var(--muted);
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
      flex: 1;
      min-width: 0;
    }

    .task-meta-dot {
      width: 3px;
      height: 3px;
      border-radius: 999px;
      background: var(--muted-softer);
    }

    .task-note {
      font-size: 11px;
      color: var(--text-subtle);
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .task-checkbox-wrap {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      margin: 0;
      flex-shrink: 0;
    }

    /* 20x20 gem checkbox */
    .task-checkbox {
      width: 20px;
      height: 20px;
      min-height: 20px;
      line-height: 0;
      border-radius: 6px;
      padding: 2px;
      border: none;
      cursor: pointer;
      position: relative;
      background: var(--gem-conic);
      box-shadow:
        0 0 0 1px rgba(var(--chrome-rgb), 0.09),
        0 0 18px rgba(0, 0, 0, 0.75);
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .task-checkbox:active {
      transform: scale(0.94);
    }

    .task-checkbox::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 5px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 60%);
      border: 1px solid rgba(var(--chrome-rgb), 0.06);
      box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.9);
    }

    .task-checkbox-icon {
      position: absolute;
      inset: 4px;
      border-radius: 4px;
      background:
        radial-gradient(circle at 20% 0%, #ffffff 0, transparent 70%),
        linear-gradient(135deg, var(--gem-fill-from) 0, var(--gem-fill-via) 45%, var(--gem-fill-to) 80%, var(--gem-fill-end) 100%);
      box-shadow:
        inset 0 0 2px rgba(var(--chrome-rgb), 0.7),
        0 0 8px var(--gem-glow);
      opacity: 0;
      transform: scale(0.9);
      transition: opacity 0.16s ease-out, transform 0.16s ease-out;
    }

    .task-checkbox.checked .task-checkbox-icon {
      opacity: 1;
      transform: scale(1);
    }

    /* Whisper is matte/no-glow - drop the glossy sparkle highlight baked
       into .task-checkbox-icon's background (it's a literal #ffffff, not
       theme-variable driven, so it can't be flattened via tokens alone). */
    [data-theme^="whisper-charcoal"] .task-checkbox-icon,
    [data-theme^="whisper-cloud"] .task-checkbox-icon {
      background: var(--gem-fill-from);
    }

    .task-checkbox input {
      display: none;
    }

    /* history */

    .history-list {
      margin: 0;
      padding: 4px 0 8px;
      list-style: none;
      scrollbar-width: thin;
      scrollbar-color: var(--accent-muted) transparent;
    }

    .history-list::-webkit-scrollbar {
      width: 6px;
    }

    .history-list::-webkit-scrollbar-thumb {
      background: var(--accent-muted);
      border-radius: 999px;
    }

    .history-row {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      padding: 6px 7px;
      border-radius: 12px;
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      background: var(--bg-card);
      font-size: 12px;
      margin-bottom: 10px;
      cursor: pointer;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
      transition: border-color 0.12s ease-out, background 0.12s ease-out;
    }

    .history-row.expanded {
      border-color: var(--border-accent-soft);
      background: radial-gradient(circle at top, var(--bg-expanded-top), var(--bg-deep-98));
      box-shadow: 0 0 0 1px var(--border-accent-strong), 0 6px 16px rgba(0, 0, 0, 0.6);
    }

    .history-row-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .history-row-title-wrap {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .history-journal-dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: var(--accent-strong);
      box-shadow: 0 0 4px var(--gem-glow);
      flex-shrink: 0;
    }

    .history-journal-dot.empty {
      background: transparent;
      border: 1px solid var(--border-strong);
      box-shadow: none;
    }

    .history-penalty-dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: var(--danger);
      box-shadow: 0 0 4px rgba(255, 75, 129, 0.7);
      flex-shrink: 0;
    }

    .history-penalty-status {
      font-size: 10px;
      color: var(--danger);
      flex-shrink: 0;
    }

    .history-penalty-status.done {
      color: var(--muted);
    }

    .history-row-title {
      font-size: 12px;
    }

    .history-row-meta {
      font-size: 11px;
      color: var(--muted);
    }

    .history-row-detail {
      margin-top: 6px;
      padding-top: 6px;
      border-top: 1px solid rgba(var(--chrome-rgb), 0.05);
      display: none;
    }

    .history-row.expanded .history-row-detail {
      display: block;
    }

    .scheduled-date-group {
      margin-bottom: 6px;
    }

    .scheduled-date-group:last-child {
      margin-bottom: 0;
    }

    .scheduled-date-heading {
      font-size: 10px;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--muted);
      padding: 4px 2px 4px;
      margin-bottom: 4px;
    }

    .scheduled-task-row {
      border-radius: 12px;
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      padding: 6px 8px;
      background: var(--bg-card);
      box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
      margin-bottom: 5px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      cursor: pointer;
      transition: border-color 0.12s ease-out, background 0.12s ease-out;
    }

    .scheduled-task-row:hover {
      border-color: var(--border-accent-soft);
      background: radial-gradient(circle at top, var(--bg-expanded-top), var(--bg-deep-98));
    }

    .scheduled-task-title {
      font-size: 12px;
      font-weight: 500;
      color: var(--text-main);
      flex: 1;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .scheduled-task-badge {
      font-size: 10px;
      color: var(--muted);
      white-space: nowrap;
      flex-shrink: 0;
    }

    .scheduled-trigger {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      border-radius: 12px;
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      padding: 7px 10px;
      background: var(--bg-card);
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
      margin-bottom: 10px;
      cursor: pointer;
      transition: border-color 0.12s ease-out, background 0.12s ease-out;
      text-align: left;
    }

    .scheduled-trigger:hover {
      border-color: var(--border-accent-soft);
      background: radial-gradient(circle at top, var(--bg-expanded-top), var(--bg-deep-98));
    }

    .scheduled-trigger-label {
      font-size: 12px;
      color: var(--text-subtle);
    }

    .scheduled-trigger-meta {
      font-size: 11px;
      color: var(--muted);
    }

    /* QUANTITY TASK (e.g. water) - whole card is the tap target, same as a checkbox card */
    .task-row-compact-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .quantity-bar-row {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-top: 6px;
    }

    .quantity-bar-track {
      position: relative;
      flex: 1 1 auto;
      min-width: 0;
      height: 20px;
      border-radius: 999px;
      background: var(--bg-elevated);
      border: 1px solid var(--border-strong);
      overflow: hidden;
      transition: border-color 0.3s ease, box-shadow 0.3s ease;
    }

    .quantity-bar-track.complete {
      border-color: var(--border-accent-soft);
      box-shadow: 0 0 3px var(--gem-glow);
    }

    .quantity-bar-fill {
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      width: 0%;
      background: linear-gradient(90deg, var(--gem-fill-from) 0, var(--gem-fill-via) 55%, var(--gem-fill-to) 100%);
      box-shadow: inset 0 0 6px rgba(var(--chrome-rgb), 0.2);
      transition: width 0.3s ease;
    }

    .quantity-bar-label {
      position: relative;
      z-index: 1;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 10px;
      color: var(--text-main);
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
      white-space: nowrap;
      padding: 0 4px;
    }

    /* small edit door-in, sits top-right next to the title, out of flow so it can't affect row height */
    .quantity-edit-btn {
      position: absolute;
      top: 1px;
      right: 0;
      width: 18px;
      height: 18px;
      display: flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
      border: none;
      background: none;
      color: var(--muted-softer);
      font-size: 11px;
      cursor: pointer;
    }

    .quantity-edit-btn svg {
      width: 12px;
      height: 12px;
      padding: 0;
    }

    .quantity-size-row {
      display: flex;
      gap: 4px;
      flex-shrink: 0;
    }

    .quantity-size-pill {
      font-size: 9px;
      padding: 3px 10px;
      line-height: 1;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      cursor: pointer;
      white-space: nowrap;
    }

    .quantity-size-pill.active {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    /* Task editor: type toggle + quantity fields */
    .task-type-toggle {
      display: flex;
      gap: 6px;
      margin-bottom: 10px;
    }

    .task-type-toggle button {
      flex: 1;
      border-radius: var(--radius-btn);
      padding: 6px 8px;
      border: 1px solid rgba(var(--chrome-rgb), 0.06);
      background: var(--bg-sheet);
      color: var(--muted);
      font-size: 12px;
      cursor: pointer;
    }

    .task-type-toggle button.active {
      border-color: var(--btn-active-border);
      background: radial-gradient(circle at top, var(--btn-active-top), var(--btn-active-bot));
      color: #fefbff;
    }

    .quantity-fields-row {
      display: flex;
      gap: 6px;
    }

    .quantity-fields-row .field {
      flex: 1;
    }

    .quantity-cap-btn {
      flex-shrink: 0;
      width: 34px;
      min-height: 34px;
      border-radius: 12px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: var(--muted);
      opacity: 0.5;
      padding: 0;
    }
    .quantity-cap-btn svg {
      width: 15px;
      height: 15px;
    }
    .quantity-cap-btn.active {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
      opacity: 1;
    }


    .archive-list {
      margin: 0;
      padding: 4px 0 8px;
      list-style: none;
      scrollbar-width: thin;
    }

    .archive-list::-webkit-scrollbar {
      width: 6px;
    }

    .archive-list::-webkit-scrollbar-thumb {
      background: var(--accent-muted);
      border-radius: 999px;
    }

    .archive-meta {
      font-size: 11px;
      color: var(--muted);
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
      margin-bottom: 3px;
    }

    .archive-actions {
      margin-top: 6px;
      display: flex;
      gap: 6px;
    }

    .archive-actions button {
      flex: 1;
      font-size: 11px;
      border-radius: var(--radius-btn);
      padding: 4px 8px;
      border: 1px solid rgba(var(--chrome-rgb), 0.08);
      background: transparent;
      color: var(--text-subtle);
      cursor: pointer;
    }

    .archive-actions button.primary {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    .admin-tabs {
      display: flex;
      gap: 4px;
      margin-bottom: 8px;
    }

    .admin-tabs button {
      flex: 1;
      border-radius: var(--radius-btn);
      padding: 4px 8px;
      border: 1px solid rgba(var(--chrome-rgb), 0.06);
      background: var(--bg-sheet);
      color: var(--muted);
      font-size: 11px;
      cursor: pointer;
    }

    .admin-tabs button.active {
      border-color: var(--btn-active-border);
      background: radial-gradient(circle at top, var(--btn-active-top), var(--btn-active-bot));
      color: #fefbff;
      box-shadow: none;
    }

    .archive-badge {
      min-width: 16px;
      height: 16px;
      border-radius: 999px;
      background: var(--danger);
      color: rgb(var(--chrome-rgb));
      font-size: 10px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 4px;
      box-shadow: 0 0 0 1px rgba(255, 75, 129, 0.7);
    }

    .admin-tab {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }

    /* CHAT */

    .chat-message-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
      /* Small edge gutter by default - bubbles/photos should sit close to
         their corresponding side, not float toward the center. Widened
         only for mouse/hover-capable viewports below, where it's actually
         needed (see .msg-hover-action-btn's comment) - on touch, that
         button never shows (long-press opens the action sheet instead), so
         reserving room for it there was just wasted space pushing every
         message inward on the primary (touch) use case. */
      padding: 4px 10px 8px;
    }

    @media (hover: hover) and (pointer: fine) {
      .chat-message-list {
        padding-left: 34px;
        padding-right: 34px;
      }
    }

    /* One per calendar day the room's messages span (see
       chatDateSeparatorLabel() in app.js) - centered regardless of the
       list's own align-items, since .chat-msg-wrap siblings set that per
       message (flex-end/flex-start for mine/theirs). */
    .chat-date-sep {
      align-self: center;
      margin: 4px 0;
    }

    .chat-date-sep span {
      font-size: 11px;
      color: var(--muted);
      background: var(--bg-input);
      padding: 3px 10px;
      border-radius: 999px;
    }

    .chat-msg-wrap {
      position: relative;
      display: flex;
      flex-direction: column;
      max-width: 78%;
    }

    .chat-msg-wrap.mine {
      align-self: flex-end;
      align-items: flex-end;
    }

    .chat-msg-wrap.theirs {
      align-self: flex-start;
      align-items: flex-start;
    }

    /* Faint outline on both (not a loud one - --border-strong read too
       heavy here) so each bubble reads as a defined shape rather than just
       a color fill. display: flow-root (not just block) so
       .chat-msg-time's float is actually contained - otherwise the
       bubble's own background/padding box wouldn't account for the
       floated span's height on a message where the time wraps to its own
       line. */
    .chat-msg {
      display: flow-root;
      max-width: 100%;
      /* Bottom trimmed well below top - the trailing time's own
         line-height already provides real breathing room under the last
         line of text, so matching the top's 7px here just added dead
         space under it on top of that. */
      padding: 7px 10px 3px;
      border-radius: 14px;
      background: var(--bg-input);
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      font-size: 13px;
      line-height: 1.35;
      word-break: break-word;
      /* Stops a long-press from triggering the browser's own text-selection
         handles - this app owns the long-press gesture, not the browser. */
      -webkit-user-select: none;
      user-select: none;
      touch-action: manipulation;
    }

    .chat-msg-wrap.mine .chat-msg {
      background: var(--accent-soft);
    }

    /* --bg-input sits almost flush against --bg-shell (the page itself) on
       every theme - fine for an actual input field, but it meant the
       partner's bubble barely read as a shape at all against the dark
       background. */
    .chat-msg-wrap.theirs .chat-msg {
      background: var(--bg-chip);
    }

    /* A message that's only emoji (see isEmojiOnlyText() in app.js) drops
       the bubble chrome entirely and just renders big, the same "big
       emoji" treatment every major chat app uses - specificity has to beat
       .chat-msg-wrap.mine/.theirs .chat-msg above, hence the compound
       selectors rather than a plain .chat-msg.emoji-only rule. */
    .chat-msg-wrap.mine .chat-msg.emoji-only,
    .chat-msg-wrap.theirs .chat-msg.emoji-only {
      background: none;
      border: none;
      padding: 0;
      font-size: 40px;
      line-height: 1.1;
    }

    /* Trails the message text, Signal-style - float:right as the bubble's
       last node shares the last line with the text when there's room, and
       wraps to its own right-aligned line otherwise (see .chat-msg's
       flow-root above). Only true for a short/normal message that never
       gets a Read more toggle at all - a truncated one moves this into
       .chat-msg-footer-time instead (see that rule below), which resets
       the float there. */
    .chat-msg-time {
      float: right;
      margin: 3px 0 0 8px;
      font-size: 9px;
      color: var(--muted);
      -webkit-user-select: none;
      user-select: none;
    }

    /* Sits right before .chat-msg-time (see renderChatMessageList in
       app.js) - the trailing time becomes the edit time once a message
       has one, so this reads as "Edited <when>" rather than a separate
       unexplained second timestamp. */
    .chat-msg-edited {
      font-size: 9px;
      font-style: italic;
      color: var(--muted);
      margin-left: 8px;
      -webkit-user-select: none;
      user-select: none;
    }

    /* Wall-of-text messages only - see applyChatMessageTruncation() in
       app.js, which adds this once a message actually measures as needing
       the Read more/Show less toggle. Block for good from that point on,
       collapsed or expanded - a plain inline span's last line is still
       fair game for .chat-msg-time's float to tuck into even once this is
       -webkit-box/line-clamped (a float may rise only as high as the TOP
       of a prior block box, not its bottom, so a short last line left
       plenty of room for the float to sneak up beside the text instead of
       dropping below it) - which is why time/edited move into their own
       .chat-msg-footer row below instead, rather than trying to out-CSS
       that. */
    .chat-msg-text.truncatable {
      display: block;
    }

    /* display:-webkit-box (required for line-clamp) wins over the plain
       .truncatable block above via source order, both being equal-
       specificity single classes - this rule must stay declared after it. */
    .chat-msg-text.collapsed {
      display: -webkit-box;
      -webkit-line-clamp: 12;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    /* Button-left, time-right - built once per render in
       applyChatMessageTruncation() by moving the already-rendered time
       (+ edited label, if any) in here alongside the new readmore button,
       rather than leaning on float/inline-tucking tricks that only ever
       worked by accident against a clamped block (see .truncatable's own
       comment above). Tight margin-top - this sits right under text
       that's already been clamped to its max height, not floating free
       space that needs much separation. */
    .chat-msg-footer {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 8px;
      margin-top: 2px;
    }

    .chat-msg-footer-time {
      flex-shrink: 0;
      white-space: nowrap;
    }

    /* Reset the standalone-message float/margin-top now that both sit
       inline together inside .chat-msg-footer-time as plain flow content -
       the left-margin stays, so edited/time still keep their usual gap
       from whatever precedes them. */
    .chat-msg-footer-time .chat-msg-time {
      float: none;
      margin: 0 0 0 8px;
    }

    .chat-msg-readmore {
      padding: 0;
      border: none;
      background: none;
      font-size: 11px;
      font-weight: 700;
      color: var(--accent-stronger);
      cursor: pointer;
    }

    /* Images get no card/background at all - just the photo itself. */
    /* border-radius + overflow:hidden live here (not on the <img>) so
       .chat-content-stack's :first-child/:last-child rules have a single
       element per message piece to round - the <img> itself always
       stays square and just gets clipped to whatever shape this wrap
       currently has. */
    .chat-img-wrap {
      position: relative;
      display: inline-block;
      max-width: 100%;
      line-height: 0;
      overflow: hidden;
      border-radius: 14px;
    }

    /* Overlaid directly on the photo (no text flow to trail here the way
       .chat-msg-time does) - its own small scrim keeps it legible
       regardless of how bright the photo is underneath. Fixed white, not
       rgb(var(--chrome-rgb)) - that token is dark ink on a light theme
       (Cloud), which reads fine against that theme's own surfaces but
       landed near-invisible here, since the backing is always a black
       pill (and, on video, the black .chat-video-poster-scrim too)
       regardless of theme - same reasoning as the in-call controls
       staying a fixed matte look instead of inheriting theme tokens. */
    .chat-img-time {
      position: absolute;
      bottom: 6px;
      right: 6px;
      font-size: 9px;
      color: #fff;
      background: rgba(0, 0, 0, 0.45);
      padding: 1px 6px;
      border-radius: 8px;
      -webkit-user-select: none;
      user-select: none;
    }

    .chat-img-wrap img {
      display: block;
      max-width: 100%;
      cursor: pointer;
      /* Stops iOS's long-press "save/copy image" callout and Android's
         drag-to-save ghost - our own long-press menu replaces it. */
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      user-select: none;
      touch-action: manipulation;
    }

    /* No `controls` (see buildChatMessageElement in app.js) - just a
       poster frame plus .chat-media-play-badge, tap opens the lightbox.
       Same tap/long-press affordances as the img rule above since it's
       now a plain tappable image, not a native video surface. Fixed,
       cropped thumbnail box (same idea as .profile-gallery-tile video)
       rather than scaling to the video's own resolution - an
       uncapped height let a portrait phone video's poster balloon to
       fill most of the screen, dwarfing every photo/text message
       around it. The real, uncropped video still plays at full size in
       the lightbox on tap. */
    .chat-img-wrap video {
      display: block;
      width: 160px;
      max-width: 100%;
      aspect-ratio: 4 / 5;
      object-fit: cover;
      cursor: pointer;
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      user-select: none;
      touch-action: manipulation;
    }

    /* Bottom fade behind the poster's own .chat-img-time (below) - a plain
       pill scrim isn't reliably legible over a bright/light video frame
       the way it is over most photos, since the poster can land on any
       frame of the clip. Tighter/heavier than a first pass at this: most
       of the fade now happens right near the bottom edge (where the time
       actually sits) rather than creeping a near-invisible tint halfway
       up the poster, and it lands fully opaque rather than topping out at
       55%. Video-only (see buildChatMessageElement) - photos keep just
       the pill. */
    .chat-video-poster-scrim {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      height: 32%;
      background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.85) 100%);
      pointer-events: none;
    }

    /* Generic file attachment - reuses .chat-msg's own bubble chrome (see
       buildChatMessageElement in app.js: class="chat-msg chat-file-chip"),
       so mine/theirs background still comes from the existing
       .chat-msg-wrap.mine/.theirs .chat-msg rules above for free. This
       rule only overrides the internal layout (flex row, icon + text)
       and resets the <button> defaults .chat-msg's own div never had to
       fight (font, text-align, cursor). */
    .chat-file-chip {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      max-width: 260px;
      font: inherit;
      text-align: left;
      color: inherit;
      cursor: pointer;
      padding: 8px 10px;
    }
    .chat-file-chip-icon {
      flex-shrink: 0;
      width: 34px;
      height: 34px;
      border-radius: 10px;
      background: rgba(var(--chrome-rgb), 0.08);
      color: var(--accent-stronger);
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .chat-file-chip-icon svg {
      width: 17px;
      height: 17px;
    }
    .chat-file-chip-info {
      flex: 1 1 auto;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 1px;
    }
    .chat-file-chip-name {
      font-size: 13px;
      font-weight: 600;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .chat-file-chip-meta {
      font-size: 10px;
      color: var(--muted);
    }

    /* Whichever of quote/photo/text-caption a message has, they render as
       one continuous rounded shape, Signal-style, rather than separate
       floating pieces - see renderChatMessageList() in app.js, which
       always puts them in this shared stack regardless of which pieces
       are present. align-items defaults to stretch here, which is what
       makes every piece match the stack's widest member (almost always
       the photo, when there is one) - flex sizes the column by that
       widest piece's intrinsic width first, then stretches the rest
       (e.g. a short caption like "test", or the quote chip) to match it,
       rather than each shrinking to fit its own content independently.
       Specificity note: the :not()/:first-child/:last-child selectors
       below (two class-equivalents each) are what let this win over each
       piece's own border-radius (.chat-msg-quote, .chat-img-wrap,
       .chat-msg - all single-class rules) without needing !important. */
    .chat-content-stack {
      display: flex;
      flex-direction: column;
      /* No visible effect on its own (the stack has no border/background of
         its own - each piece inside already clips to this same 14px radius
         at the stack's outer top/bottom edges) - exists purely so
         .jump-flash's box-shadow ring below traces the same rounded-rect
         silhouette the joined quote+photo+text pieces already form,
         instead of needing to match it some other way. */
      border-radius: 14px;
    }

    .chat-content-stack > *:not(:first-child) {
      border-top: none;
      border-top-left-radius: 0;
      border-top-right-radius: 0;
    }

    .chat-content-stack > *:not(:last-child) {
      border-bottom-left-radius: 0;
      border-bottom-right-radius: 0;
    }

    .chat-content-stack > *:first-child {
      border-top-left-radius: 14px;
      border-top-right-radius: 14px;
    }

    .chat-content-stack > *:last-child {
      border-bottom-left-radius: 14px;
      border-bottom-right-radius: 14px;
    }

    /* An emoji-only reply (see .chat-msg.emoji-only below) drops its own
       bubble chrome entirely - when it follows a quote-like chip (a
       message reply's .chat-msg-quote - a story reply never reaches this
       combo, see its own emoji handling in buildChatMessageElement), the
       generic :not(:last-child) flattening above left that chip with
       square bottom corners and nothing visible underneath to continue
       the shape, reading as cut off rather than a finished pill. Restoring
       its own bottom corners here needs to win over that same-specificity
       rule by coming after it in the cascade. */
    .chat-content-stack > *:has(+ .chat-msg.emoji-only) {
      border-bottom-left-radius: 14px;
      border-bottom-right-radius: 14px;
    }

    /* Pulls the giant emoji up closer to the chip above it - a bare
       .chat-msg.emoji-only (no quote preceding it) is left alone via the
       sibling combinator, since it has nothing above to tuck up against. */
    .chat-content-stack > * + .chat-msg.emoji-only {
      margin-top: -4px;
    }

    /* .story-link-preview-card's own margin-top:8px (for the Stories feed/
       composer, where it visually separates from the piece above) would
       otherwise leave a gap here that every other piece in this stack
       deliberately doesn't have - zeroed so a message's link preview
       sits flush under its text, same as everything else. */
    .chat-content-stack > .story-link-preview-card {
      margin-top: 0;
    }

    /* Desktop-only hover affordance (Signal's pattern: hover reveals it on
       desktop, a long-press opens the same menu on touch - see
       attachLongPress() wiring in renderChatMessageList). Sits outside the
       bubble/photo entirely, on the side with room to spare, rather than on
       top of the content. */
    .msg-hover-action-btn {
      position: absolute;
      top: 2px;
      width: 22px;
      height: 22px;
      border-radius: var(--radius-btn-sm);
      border: none;
      background: none;
      color: var(--muted);
      font-size: 13px;
      cursor: pointer;
      padding: 0;
      opacity: 0;
      transition: opacity 0.12s ease, color 0.12s ease;
    }

    .chat-msg-wrap.mine .msg-hover-action-btn { right: calc(100% + 6px); }
    .chat-msg-wrap.theirs .msg-hover-action-btn { left: calc(100% + 6px); }

    .msg-hover-action-btn:hover {
      color: var(--text-main);
    }

    @media (hover: hover) and (pointer: fine) {
      .chat-msg-wrap:hover .msg-hover-action-btn {
        opacity: 1;
      }
    }

    /* Hangs off the bottom of the bubble/photo, pulled in from the corner
       (not flush against it, which collided with the bubble's own
       border-radius curve) - a small badge mostly outside it, not a bar
       laid over the content. Fixed height + overflow:hidden because emoji
       glyphs render much taller than their font-size implies, which
       otherwise blows this up into a bar that covers half the message.
       --bg-sheet-solid (fully opaque) instead of --bg-sheet (96%) so it
       reads as a solid chip rather than faintly showing through. */
    .msg-reactions {
      position: absolute;
      bottom: -11px;
      right: 10px;
      display: flex;
      align-items: center;
      gap: 2px;
      height: 18px;
      overflow: hidden;
      background: var(--bg-sheet-solid);
      border-radius: 999px;
      padding: 0 6px;
      font-size: 10px;
      line-height: 1;
    }

    .msg-reaction-chip {
      display: inline-flex;
      align-items: center;
      gap: 2px;
      height: 18px;
      border: none;
      background: transparent;
      color: var(--text-main);
      padding: 0;
      font-size: 11px;
      line-height: 1;
      cursor: pointer;
    }

    .msg-reaction-chip.mine {
      color: var(--accent-stronger);
    }

    /* Room for the overlapping reaction pill so it doesn't collide with the
       next message. */
    .chat-msg-wrap.has-reactions {
      margin-bottom: 12px;
    }

    .pinned-section {
      position: relative;
      /* Pulls this up tighter under the persistent header than the shared
         .app-header margin-bottom: 16px (every other tab's own content
         gap, see that rule's own comment) leaves by default - a thin
         divider bar reads better sitting close under the nav than with a
         full page-title's worth of breathing room above it. Scoped to
         this one element rather than touching that shared value, which
         every other tab also depends on. */
      margin-top: -16px;
      margin-bottom: 4px;
      /* var(--border-subtle)/--border-strong resolve to the same near-bg
         value on Whisper Cloud (barely visible by design against a card,
         but this divider sits directly on the page background, which it's
         nearly identical to there - genuinely invisible, not just subtle).
         --chrome-rgb is dark-ink-on-light/light-ink-on-dark across every
         theme instead of matching a specific surface, so it reads as an
         actual line regardless of what's behind it. Also the positioning
         context for .pinned-section-icon, which sits right on this line -
         see its own comment. */
      border-bottom: 1px solid rgba(var(--chrome-rgb), 0.15);
      flex: 0 0 auto;
    }

    /* No label text any more (just the icon below) - still the full-
       width tap target toggling the section, just sized by its own
       padding now rather than a line of text. */
    .pinned-section-toggle {
      display: block;
      width: 100%;
      height: 16px;
      border: none;
      background: none;
      padding: 0;
      cursor: pointer;
    }

    /* Sits on the divider itself (half above, half below, like a handle),
       off-center toward the left rather than centered across the whole
       bar. Still a descendant of the toggle button (position:absolute
       looks past the button's own static positioning straight to
       .pinned-section, its nearest positioned ancestor), so it still
       toggles on tap with no separate listener. A static pin glyph now
       (in place of the up/down chevron this used to be) - it isn't
       standing in for an expand/collapse arrow any more, just labeling
       the bar as the pinned section, so there's no rotate-on-state rule
       to go with it. */
    .pinned-section-icon {
      position: absolute;
      left: 4px;
      bottom: -9px;
      width: 18px;
      height: 18px;
      color: var(--muted);
    }

    .pinned-section.collapsed .pinned-strip {
      display: none;
    }

    /* Single pinned item at a time (see renderPinnedStrip() in app.js) -
       .pinned-strip-current cycles through every pinned message on tap
       (photo and text share this one slot, since a pinned photo can carry
       its own caption that needs the same sender/text treatment); tapping
       it jumps to that message in the chat AND advances to the next pin
       for next time. The "View all" button opens #pinned-list-overlay for
       the full list, all at once. */
    .pinned-strip {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 2px 10px 8px;
    }

    /* The bubble itself - same tint .chat-msg-quote (the reply/quote chip)
       washes its own background with, rather than a separate one-off
       value, so a pinned comment or picture reads as "the same kind of
       thing" as a quoted reply. Wraps both a photo thumbnail (when the pin
       has one) and the sender/text block in one shared bubble, rather than
       giving each its own. min-height matches the photo thumbnail (its
       own tallest case) so cycling between a photo pin and a text-only one
       doesn't change the bubble's height from one tap to the next. */
    .pinned-strip-current {
      flex: 1 1 auto;
      min-width: 0;
      min-height: 44px;
      display: flex;
      align-items: center;
      gap: 6px;
      border: none;
      background: rgba(var(--chrome-rgb), 0.05);
      border-radius: 10px;
      padding: 6px 9px;
      cursor: pointer;
      text-align: left;
    }

    .pinned-strip-current-thumb {
      flex: 0 0 auto;
      width: 36px;
      height: 44px;
      border-radius: 8px;
      object-fit: cover;
    }

    .pinned-strip-current-textblock {
      flex: 1 1 auto;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 1px;
    }

    .pinned-strip-current-sender {
      font-size: 12px;
      font-weight: 700;
      color: var(--muted);
    }

    .pinned-strip-current-text {
      font-size: 12px;
      font-weight: 500;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Icon-only now (used to be a "View all" text label) - the eye reads
       as "see everything" without needing its own words, matching the
       outline style every other icon in this app uses. */
    .pinned-view-all-btn {
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 28px;
      height: 28px;
      border: none;
      background: none;
      padding: 0;
      color: var(--accent-stronger);
      cursor: pointer;
    }

    .pinned-view-all-btn svg {
      width: 18px;
      height: 18px;
    }

    /* Stacks on top of the chat room view rather than replacing it - an
       opaque background (the same radial gradient .shell itself paints,
       not a flat fill - this is the one real themed background every
       other full-screen panel shows through to, see .shell-main's own
       comment) + a z-index above .story-editor-overlay's own 15 (instead
       of that class's usual transparent trick) is enough to fully cover
       the chat room without needing setPageHiddenBehindOverlay(). Written
       as the compound .story-editor-overlay.pinned-list-overlay (not just
       .pinned-list-overlay) so it outranks .story-editor-overlay's own
       "background: transparent" regardless of which rule happens to come
       first in this file - two same-specificity single-class selectors
       would otherwise just fall to source order, and this one needs to
       win unconditionally. */
    .story-editor-overlay.pinned-list-overlay {
      background: radial-gradient(circle at top, var(--bg-shell-top) 0, var(--bg-shell) 48%);
      z-index: 20;
    }

    /* This page has no topbar of its own (see the HTML comment on
       #pinned-list-overlay) - the real chat room gets its clearance under
       the header from that topbar plus the pinned-messages strip sitting
       above its message list, neither of which exist here, so the shared
       .chat-message-list padding-top:4px alone left the first bubble
       sitting right under (visually touching) the header's avatar. ID
       selector so it only overrides padding-top, leaving the shared
       left/right/bottom values from .chat-message-list as they are. */
    #pinned-list {
      padding-top: 20px;
    }

    /* Same reasoning (and same compound-selector fix) as
       .story-editor-overlay.pinned-list-overlay just above - opaque
       themed gradient + a z-index above both it and the room view's own
       (this can stack on top of the pinned list too, if reached from a
       long-press while it's open) instead of the usual transparent
       trick, since this overlay isn't guaranteed to have anything
       consistently hiding what's behind it. */
    .story-editor-overlay.chat-room-media-overlay {
      background: radial-gradient(circle at top, var(--bg-shell-top) 0, var(--bg-shell) 48%);
      z-index: 22;
    }

    /* No topbar above these tabs (see the overlay's own HTML comment) -
       same "sitting right under the header" clearance problem
       #pinned-list solves with its own padding-top, here on the tab bar
       itself instead since it's the first thing in the overlay. */
    #chat-room-media-tabs {
      margin: 20px 10px 8px;
    }

    .chat-room-media-body {
      padding: 4px 10px 16px;
    }

    /* One per date the room's photos span - same idea as .chat-date-sep,
       just left-aligned above its own grid instead of centered inline
       with messages. */
    .chat-room-media-date-label {
      font-size: 11px;
      font-weight: 600;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin: 14px 2px 8px;
    }

    .chat-room-media-date-label:first-child {
      margin-top: 2px;
    }

    /* Briefly flashes a message that was jumped to (from a pin/reply/
       forward tap) so it's obvious which one it is. Used to fill the
       background of just the .chat-msg bubble (and, separately, the raw
       <img>) - but a reply/forward/photo quote renders as its own flush-
       joined piece above the real bubble (.chat-msg-quote/
       .chat-story-reply-row - see .chat-content-stack above), which that
       background-fill never touched, so jumping to a quoted message left
       its quote chip looking un-flashed while only the bubble below it lit
       up - disjointed, like two separate messages instead of one. A single
       outline ring around the whole .chat-content-stack (quote chip, photo,
       text bubble together) always flashes the complete joined shape as
       one piece instead. */
    @keyframes chatMsgJumpFlash {
      0%, 100% { box-shadow: 0 0 0 0 transparent; }
      30% { box-shadow: 0 0 0 3px var(--accent-stronger); }
    }

    .chat-msg-wrap.jump-flash .chat-content-stack {
      animation: chatMsgJumpFlash 1.1s ease-out;
    }

    /* Quote chip - shown above a reply's (or forward's) own content inside
       the same bubble area. Tappable: jumps to the original if it's still
       loaded in this room, otherwise just sits there as read-only context
       (a forward's original lives in a different room entirely). */
    .chat-msg-quote {
      display: flex;
      flex-direction: column;
      gap: 1px;
      /* Lets it shrink below its own ellipsized text's full un-truncated
         width - flex items default to min-width:auto, which would
         otherwise size the whole .chat-content-stack to fit a long quoted
         message in full before truncating it, rather than respecting
         whatever width the stack's other pieces (or the ancestor
         .chat-msg-wrap's 78% cap) actually settle on. */
      min-width: 0;
      max-width: 100%;
      padding: 5px 9px;
      border-radius: 10px;
      border-left: 2px solid var(--border-accent-soft);
      background: rgba(var(--chrome-rgb), 0.05);
      cursor: pointer;
    }

    /* Story reply - its own flush-joined piece of .chat-content-stack
       sitting right above the real reply bubble (see buildChatMessageElement
       in app.js), same role .chat-msg-quote plays for a reply to a message/
       photo: a faint, sender-agnostic quote chip, not colored per mine/
       theirs - the bubble below it is what carries that split, exactly
       like any other reply. Reuses .chat-msg-quote's own tint/accent-border
       recipe so both kinds of quoted reply read as the same visual
       language. */
    .chat-story-reply-row {
      display: flex;
      padding: 5px 9px;
      border-radius: 10px;
      border-left: 2px solid var(--border-accent-soft);
      background: rgba(var(--chrome-rgb), 0.05);
    }

    /* Label + (optional big reaction emoji) + preview card, all one row -
       align-items:center is what puts the label at the card's own mid-
       height, next to it rather than stacked above it. A tapped-emoji
       reaction's big copy (.chat-story-reply-emoji) joins this same row
       rather than stacking a whole extra block below it - the row is
       already as tall as the card, so a big emoji sized to roughly match
       needs little to no extra height to fit. */
    .chat-story-reply-toprow {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .chat-story-reply-emoji {
      flex: 0 0 auto;
      font-size: 44px;
      line-height: 1;
    }

    .chat-story-reply-label {
      display: flex;
      flex-direction: column;
      flex: 1 1 auto;
      min-width: 0;
      font-size: 11.5px;
      line-height: 1.3;
      opacity: 0.85;
    }

    .chat-story-reply-label-name {
      font-weight: 600;
    }

    .chat-story-mini-card {
      flex: 0 0 auto;
      width: 40px;
      /* Taller than it is wide (closer to the real story's own portrait
         shape) rather than the plain square it used to be - a thumbnail
         this size otherwise reads as "an attached photo", not "a story".
         Sized down from an earlier 48x80 - that drove the whole chip (and
         so the whole message) a lot taller than it needed to be, pushing
         the trailing time well below the preview with a lot of empty
         space in between. */
      height: 64px;
      border-radius: 7px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      /* The row around it is only a faint 5% wash (see .chat-story-reply-
         row) - this border/shadow is what makes the actual preview read as
         its own distinct card inset inside that row, rather than just a
         photo floating on the quote chip's background. */
      border: 1px solid rgba(var(--chrome-rgb), 0.18);
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
      cursor: pointer;
    }

    .chat-story-mini-card img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      cursor: pointer;
    }

    /* Text story's own bgColor as the background - same recipe
       .story-editor-bg uses in the real viewer/editor, just capped down to
       this thumbnail instead of full-bleed. The text itself is more
       texture than prose at this size, but still the actual words (not a
       blank swatch) - clamped so a long story can't overflow the box. */
    .chat-story-mini-card-text {
      /* .chat-story-mini-card (its flex parent) centers this both ways -
         auto width/height here (not 100%) is what lets that centering
         actually apply instead of this filling the box edge to edge. */
      width: 100%;
      padding: 0 4px;
      box-sizing: border-box;
      font-size: 7px;
      line-height: 1.15;
      text-align: center;
      color: #1a1a1a;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 5;
      -webkit-box-orient: vertical;
    }

    .chat-msg-quote-sender {
      font-size: 11px;
      font-weight: 600;
      color: var(--accent-stronger);
    }

    .chat-msg-quote-text {
      font-size: 12px;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Pending-reply chip shown above the composer while replying - cleared
       on send or explicit cancel. */
    .chat-reply-preview {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border-radius: 10px;
      background: var(--bg-input);
      border-left: 2px solid var(--border-accent-soft);
    }

    .chat-reply-preview-body {
      flex: 1 1 auto;
      min-width: 0;
    }

    .chat-reply-preview-sender {
      font-size: 11px;
      font-weight: 600;
      color: var(--accent-stronger);
    }

    .chat-reply-preview-text {
      font-size: 12px;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Small poster for the staged attachment (see #chat-attachment-preview
       in app.html) - a real thumbnail for photo/video (muted <video>, same
       poster-frame trick the chat bubble/gallery grid already use), a
       plain file glyph on a neutral fill otherwise, so the three kinds
       read differently from each other at a glance. */
    .chat-attachment-preview-thumb {
      flex: 0 0 auto;
      width: 36px;
      height: 36px;
      border-radius: 8px;
      overflow: hidden;
      background: var(--bg-card);
      border: 1px solid var(--border-subtle);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--muted);
    }

    .chat-attachment-preview-thumb img,
    .chat-attachment-preview-thumb video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .chat-attachment-preview-thumb svg {
      width: 16px;
      height: 16px;
    }

    /* Real byte progress for the upload in flight (see sendChatMessage's
       XHR path in app.js) - a thin bar rather than reusing the chip's own
       chrome, since by the time this shows the chip above has already
       gone back to hidden (the input/staged file are cleared the instant
       Send is tapped). */
    .chat-upload-progress {
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .chat-upload-progress-label {
      font-size: 11px;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .chat-upload-progress-track {
      height: 3px;
      border-radius: 999px;
      background: var(--bg-input);
      overflow: hidden;
    }

    .chat-upload-progress-fill {
      height: 100%;
      width: 0%;
      border-radius: 999px;
      background: var(--accent-stronger);
      transition: width 0.15s linear;
    }

    /* Same strip chrome as .chat-reply-preview (border-left + bg-input
       pill), occupying the same slot above the composer - the two never
       show at once (see cancelReplyPreview() inside startEditChatMessage
       and vice versa). Just a label, not interactive - cancel/save live
       inside the input itself, not here. */
    .chat-edit-label {
      padding: 6px 8px;
      border-radius: 10px;
      background: var(--bg-input);
      border-left: 2px solid var(--border-accent-soft);
      font-size: 11px;
      font-weight: 600;
      color: var(--accent-stronger);
    }

    /* Forward room picker - a simplified single-line version of
       .chat-room-row (no preview/timestamp, just "which room"). */
    .forward-room-row {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      padding: 8px;
      border-radius: 10px;
      border: none;
      background: transparent;
      cursor: pointer;
      text-align: left;
      color: var(--text-main);
      font-size: 13px;
    }

    .forward-room-row:active {
      background: var(--bg-input);
    }

    /* CHAT ROOM LIST - one row per room (icon tile, name + last-message
       preview, timestamp + chevron), modeled on .story-row's recipe for
       the same reason: a consistent "tap this row to open it full screen"
       pattern across tabs instead of each one inventing its own list. */
    .chat-room-row {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      padding: 8px 6px;
      border-radius: 14px;
      border: none;
      background: transparent;
      cursor: pointer;
      text-align: left;
      margin-bottom: 2px;
    }

    .chat-room-row:active {
      background: var(--bg-input);
    }

    .chat-room-icon-wrap {
      position: relative;
      flex-shrink: 0;
    }

    .chat-room-icon {
      width: 40px;
      height: 40px;
      min-width: 40px;
      border-radius: 13px;
      background: var(--accent-soft);
      color: var(--accent-stronger);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .chat-room-icon svg {
      width: 19px;
      height: 19px;
    }

    /* Small persistent "this room has a PIN" marker, overlaid on the icon
       tile's corner - independent of whether it happens to be unlocked for
       this page session right now (see .chat-room-icon-wrap in app.js). */
    .chat-room-lock-badge {
      position: absolute;
      bottom: -3px;
      right: -3px;
      width: 16px;
      height: 16px;
      border-radius: 999px;
      background: var(--bg-sheet-solid);
      border: 1.5px solid var(--bg-shell);
      color: var(--muted);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .chat-room-lock-badge svg {
      width: 9px;
      height: 9px;
    }

    .chat-room-row-info {
      flex: 1 1 auto;
      min-width: 0;
    }

    .chat-room-row-name {
      font-size: 14px;
      font-weight: 600;
      color: var(--text-main);
    }

    .chat-room-row-preview {
      font-size: 12px;
      color: var(--muted);
      margin-top: 1px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .chat-room-row-meta {
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .chat-room-row-time {
      font-size: 11px;
      color: var(--muted-softer);
      white-space: nowrap;
    }

    .chat-room-row-chevron {
      display: flex;
      color: var(--muted-softer);
    }

    .chat-room-row-chevron svg {
      width: 14px;
      height: 14px;
    }

    /* CHAT ROOM - full screen (reuses .story-editor-overlay/-topbar, the
       same shell as the story editor/viewer, for one consistent "full
       screen panel" convention across tabs). */
    /* .story-editor-topbar's own bottom padding (8px) is sized for the
       story editor/call screens, which have nothing directly under them -
       here the pinned-messages strip sits right below, so trim it down to
       pull that divider up tight against the back/title row above it. */
    .chat-room-view-header {
      padding-bottom: 2px;
    }

    .chat-room-view-titlewrap {
      /* Deliberately NOT position:relative - #chat-room-switch-dropdown
         (anchored "top:100%" below it) needs .app-header itself as its
         containing block, not this narrow title column, so it can reach
         all the way to just before the call button and render above
         every full-screen panel (chat room, pinned list) rather than
         getting stacked under their own z-index. See .app-header's own
         comment. */
      flex: 1 1 auto;
      min-width: 0;
    }

    /* A button, not a div - tapping it opens the room-switch dropdown
       below it (see renderChatRoomSwitchDropdown in app.js). Reset to
       plain block chrome since it's standing in for the old
       .chat-room-view-title div. */
    .chat-room-view-titlebtn {
      display: block;
      width: 100%;
      border: none;
      background: transparent;
      cursor: pointer;
      text-align: left;
      padding: 0 8px;
    }

    .chat-room-view-header .chat-room-view-title {
      min-width: 0;
      font-size: 14px;
      font-weight: 600;
      color: var(--text-main);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .chat-room-view-subtitle {
      min-width: 0;
      font-size: 11px;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Reuses .date-pill-dropdown's chrome (border/bg/shadow/sizing),
       centered (left:50%/translateX(-50%), same centering technique the
       base rule uses) against .app-header as a whole (see
       .chat-room-view-titlewrap's own comment) rather than that narrow
       title column - the 88px taken off the width is 44px of clearance on
       each side, matching the call button's own 36px width plus a little
       breathing room on the right, mirrored on the left for a centered
       (not lopsided) box. z-index raised well past every full-screen
       panel's own (.story-editor-overlay's 15, the pinned list's 20) -
       living in the persistent header, this needs to render above all of
       them, not get stacked underneath like a same-level sibling. */
    .chat-room-switch-dropdown {
      left: 50%;
      transform: translateX(-50%);
      width: calc(100% - 88px);
      max-width: none;
      z-index: 25;
    }

    .chat-room-switch-option {
      padding: 6px;
      border-radius: 8px;
      font-size: 13px;
      color: var(--text-subtle);
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .chat-room-switch-option:hover {
      background: rgba(var(--chrome-rgb), 0.04);
    }

    .chat-room-switch-option.active {
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    .chat-room-switch-option-icon {
      width: 26px;
      height: 26px;
      min-width: 26px;
      border-radius: 9px;
      background: var(--accent-soft);
      color: var(--accent-stronger);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .chat-room-switch-option.active .chat-room-switch-option-icon {
      background: var(--bg-input);
    }

    .chat-room-switch-option-icon svg {
      width: 13px;
      height: 13px;
    }

    .chat-room-switch-option-name {
      flex: 1 1 auto;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .chat-room-switch-option-lock {
      flex: 0 0 auto;
      color: var(--muted);
    }

    .chat-room-switch-option-lock svg {
      width: 12px;
      height: 12px;
    }

    /* Composer shares the room view's bottom row - the "new room" action
       now lives on the room LIST page instead (its own .gem-fab-wrap).
       Deliberately tight padding, not matched to other bottom rows'
       breathing room (.story-editor-toolbar, the FAB wrap's 12px) - the
       composer sits lower/tighter than that on purpose, and #app-root's
       own env(safe-area-inset-bottom) already keeps it clear of a
       notch/home-indicator, so there's nothing else holding this up off
       the screen edge. */
    /* Stacked (not a row) - the reply preview is its own full-width strip
       above the composer, not a sibling squeezed in beside it. It used to
       share this as a horizontal flex row with .chat-composer, which
       meant showing a reply visibly shoved the attach/emoji/input/send
       buttons sideways to make room instead of adding a row above them,
       the way every other messenger does it. */
    .chat-bottom-row {
      position: relative;
      display: flex;
      flex-direction: column;
      gap: 6px;
      padding: 1px 2px 1px;
      flex: 0 0 auto;
    }

    /* bottom:100% of .chat-bottom-row (its positioned ancestor) keeps this
       flush just above the composer regardless of the row's own height
       (reply preview/edit label showing or not, textarea grown or not) -
       floats over the message list rather than taking its own layout
       space, same as any other chat app's "jump to latest" button. */
    .chat-scroll-bottom-btn {
      position: absolute;
      bottom: 100%;
      left: 4px;
      margin-bottom: 8px;
      width: 34px;
      height: 34px;
      min-width: 34px;
      border-radius: 50%;
      border: 1px solid var(--border-subtle);
      background: var(--bg-sheet-solid);
      color: var(--muted);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      opacity: 0;
      visibility: hidden;
      transform: translateY(4px);
      transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
    }

    .chat-scroll-bottom-btn.visible {
      opacity: 1;
      visibility: visible;
      transform: translateY(0);
      transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0s;
    }

    .chat-scroll-bottom-btn svg {
      width: 16px;
      height: 16px;
    }

    /* Anchored dropdown, not a scrim overlay (unlike #room-action-overlay
       it borrowed its inner row markup from) - bottom:100% of
       .chat-bottom-row (its positioned ancestor), same technique
       .chat-scroll-bottom-btn above uses, so it pops up flush above
       #chat-fab-btn regardless of the row's own height (reply preview/
       link chip showing or not). right:2px roughly matches .chat-bottom-
       row's own 2px horizontal padding, so its right edge lines up under
       the FAB rather than the composer's. Shown/hidden via plain .hidden
       (see app.js) - same mechanism #chat-room-switch-dropdown already
       uses, not the openSheet()/closeSheet() singleton every full-screen
       sheet in this app goes through. */
    .chat-fab-menu {
      position: absolute;
      bottom: 100%;
      right: 2px;
      margin-bottom: 8px;
      /* Without this, a link-preview card on a message near the bottom
         of #chat-message-list (.story-link-preview-card sets z-index:2 on
         itself) can paint over this despite being geometrically behind it -
         neither the message list nor this row establishes its own
         stacking context, so that z-index:2 is compared directly against
         this element's z-index:auto and wins regardless of DOM order or
         actual on-screen position. */
      z-index: 6;
    }

    /* Overrides the box-shadow .message-action-list carries for its other
       use (the message long-press action sheet, which floats free over
       the message list and needs it for separation) - this menu instead
       pops up right off #chat-fab-btn with a visible anchor, so the drop
       shadow just reads as a dark smudge under it rather than helping. */
    .chat-fab-menu .message-action-list {
      box-shadow: none;
    }

    .chat-composer {
      flex: 1 1 auto;
      min-width: 0;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .chat-icon-btn {
      flex: 0 0 auto;
      width: 34px;
      height: 34px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      padding: 0;
      cursor: pointer;
    }

    .chat-icon-btn svg {
      width: 18px;
      height: 18px;
    }

    .chat-input-wrap {
      position: relative;
      flex: 1 1 auto;
      min-width: 0;
      display: flex;
      align-items: center;
    }

    .chat-text-input {
      flex: 1 1 auto;
      min-width: 0;
    }

    /* #chat-text-input, not .chat-text-input - the shared .text-input base
       rule's own `padding: 7px 8px` shorthand sits later in this file, so
       at equal (class-only) specificity it was winning the cascade and
       silently resetting this padding back to 8px each side, which is why
       the placeholder was sitting underneath the emoji icon instead of
       clear of it. An ID selector always outranks that regardless of
       source order. A textarea now, not a plain input (see app.html) -
       resize:none/the max-height+overflow-y pair replace .text-input's own
       resize:vertical/min-height so it grows with content (see
       autoGrowChatInput in app.js) up to a cap, then scrolls internally,
       rather than offering a manual drag-resize handle. */
    #chat-text-input {
      padding-left: 40px;
      padding-right: 40px;
      resize: none;
      max-height: 120px;
      overflow-y: auto;
      line-height: 1.3;
    }

    /* Two icon slots reserved instead of one while editing - tick sits
       one slot in from the edge, x takes over attach's usual spot at the
       very edge (see .chat-inline-icon-right2/-right and
       startEditChatMessage in app.js). */
    #chat-text-input.editing {
      padding-right: 74px;
    }

    /* Overrides the shared .text-input:focus rule's border-color swap +
       ring (box-shadow: 0 0 0 1px ...) - fine on a standalone field
       elsewhere, but here it sits right inside the already-visible
       composer pill, so focusing it just added a redundant highlighted
       outline around chrome that was already obviously "the input". An
       ID selector beats that rule regardless of theme or source order. */
    #chat-text-input:focus {
      border-color: var(--border-subtle);
      box-shadow: none;
    }

    /* Whisper themes separately re-add a real `outline` (not box-shadow)
       on :focus-visible for every input/textarea/select, as a deliberate
       keyboard-accessibility visible-focus ring - see
       [data-theme^="whisper-"] :is(input,textarea,select):focus-visible
       further down this file. The box-shadow override above doesn't
       touch that property, so on a Whisper theme the ring above was
       gone but this one still showed. Same reasoning as above for why
       it's unwanted here specifically (the composer pill is already
       obviously "the input"); an ID selector beats that attribute+:is()
       one regardless of order. */
    #chat-text-input:focus-visible {
      outline: none;
    }

    /* Emoji/attach sit inside the input pill itself rather than as
       separate button boxes beside it - no visible background/border of
       their own (the input's own pill is chrome enough), but the tap
       target is still a full box, just not drawn, so it stays easy to hit
       without adding visual clutter back in. */
    .chat-inline-icon-btn {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      width: 34px;
      height: 34px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      background: none;
      padding: 0;
      color: var(--muted);
      cursor: pointer;
      z-index: 1;
    }

    .chat-inline-icon-btn svg {
      width: 20px;
      height: 20px;
    }

    .chat-inline-icon-left { left: 0; }
    .chat-inline-icon-right { right: 0; }
    /* Tick (save), one slot in from the edge - x (cancel) takes the edge
       slot itself via the plain .chat-inline-icon-right above, same spot
       attach normally occupies. */
    .chat-inline-icon-right2 { right: 34px; }

    .chat-send-btn {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    /* STORIES - the feed list is one row per author (at most 2 in this
       pair-scoped app), each with a small preview thumbnail at the right;
       tapping a row opens that author's stories in the full-screen viewer
       below, rather than every story rendering inline in the list. */

    /* Pushes the whole row list down from the header, rather than
       starting flush under it like every other tab's list does. */
    #stories-feed-list {
      margin-top: 50px;
    }

    .story-row {
      position: relative;
      display: flex;
      align-items: center;
      gap: 9px;
      width: 100%;
      padding: 10px 8px;
      border-radius: 14px;
      border: none;
      background: transparent;
      cursor: pointer;
      text-align: left;
      margin-bottom: 2px;
    }

    .story-row:active {
      background: var(--bg-input);
    }

    /* A visible divider between authors, not just the 2px margin above -
       a straight ::after bar, not an actual border (which would bend
       around .story-row's own border-radius at each end instead of
       reading as one flat line), inset well clear of both edges rather
       than running edge to edge.
       Visually centering the line is NOT just "equal padding-bottom and
       margin-bottom" - the gap below the line also picks up the *next*
       row's own padding-top (10px, from .story-row's base padding
       shorthand) before that row's content actually starts, which the
       gap above the line has no equivalent of. So margin-bottom is set
       10px short of padding-bottom here - margin-bottom(10) + the next
       row's padding-top(10) = 20, matching padding-bottom(20) exactly -
       rather than making the two properties equal and leaving the line
       sitting 10px closer to the row above. Only between two actual
       rows, never trailing the last one. */
    .story-row:not(:last-child) {
      padding-bottom: 20px;
      margin-bottom: 10px;
    }

    .story-row:not(:last-child)::after {
      content: "";
      position: absolute;
      left: 28px;
      right: 28px;
      bottom: 0;
      height: 1px;
      background: rgba(var(--chrome-rgb), 0.1);
    }

    /* Sized up from an earlier 40px - this page is at most 2 rows (you
       and your partner), with a lot of empty space below them otherwise,
       so there's no reason to keep either this or .story-row-preview at
       a size chosen for a long scrolling list. */
    .story-row-avi {
      width: 54px;
      height: 54px;
      min-width: 54px;
      border-radius: 17px;
      --avi-inner-radius: 15px;
      background: var(--gem-conic);
      padding: 2px;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .story-row-avi::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 15px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
    }

    .story-row-avi span {
      position: relative;
      z-index: 1;
      font-size: 17px;
      font-weight: 700;
      color: var(--accent-stronger);
      letter-spacing: -0.02em;
    }

    .story-row-info {
      flex: 1 1 auto;
      min-width: 0;
    }

    .story-row-name {
      font-size: 14px;
      font-weight: 600;
      color: var(--text-main);
    }

    .story-row-meta {
      font-size: 11px;
      color: var(--muted);
      margin-top: 1px;
    }

    /* Same ~0.74 width/height ratio as before, just sized up from 46x62 -
       see .story-row-avi's own comment on why this page can afford it. */
    .story-row-preview {
      flex: 0 0 auto;
      width: 62px;
      height: 84px;
      border-radius: 13px;
      box-shadow: 0 0 0 1px rgba(var(--chrome-rgb), 0.1);
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 5px;
    }

    /* Only matters for a photo story - a text story's "background" is a
       flat colour fill, not an image, so there's nothing to letterbox. */
    .story-row-preview.has-photo {
      background-color: var(--bg-deep);
    }

    .story-row-preview span {
      font-size: 9px;
      line-height: 1.25;
      color: #1a1a1a;
      text-align: center;
      display: -webkit-box;
      -webkit-line-clamp: 6;
      -webkit-box-orient: vertical;
      overflow: hidden;
      word-break: break-word;
    }

    /* More than one story - see buildStoryRowPreview() in app.js, which
       only produces this wrapper (vs. a bare .story-row-preview) in that
       case. Same footprint as a single card; the back one is real content
       (the next story back), not a placeholder, rotated out from behind
       the front one as a "there's more here" cue. */
    .story-row-preview-wrap {
      position: relative;
      flex: 0 0 auto;
      width: 62px;
      height: 84px;
    }

    .story-row-preview-wrap .story-row-preview {
      position: absolute;
      inset: 0;
    }

    .story-row-preview-back {
      z-index: 0;
      transform: rotate(-8deg) translate(-5px, -3px);
      filter: brightness(0.78) saturate(0.85);
    }

    .story-row-preview-front {
      z-index: 1;
    }

    .story-row-preview.has-photo span {
      display: none;
    }

    /* Lives inside .story-viewer-footer now, right above the author/time
       row - normal document flow (not absolutely positioned over the
       photo), so it shares the footer's one scrim and fades with it on
       hold instead of needing its own background/positioning. */
    .story-photo-caption {
      padding: 0 12px 10px;
      color: rgb(var(--chrome-rgb));
      font-size: 13px;
      line-height: 1.3;
    }

    /* STORY VIEWER - full screen, tap-to-advance. Text slides reuse the
       composer's own .story-editor-bg/.story-editor-card (full-height,
       flex-centered, card auto-sized to content via padding - no fixed
       height) so the card naturally expands to fit longer text. */

    /* Footer: caption (if any) above the author/time row above the progress
       segments - floats over the stage (not its own row squeezing the
       stage smaller), same as .story-viewer-header below. Taller
       padding-top than the header's equivalent scrim since this one now
       also has to carry the caption, not just the thin author row. Delete
       moved up into the header instead (top-right, next to close) - see
       that element's own comment in app.html. */
    .story-viewer-footer {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 2;
      padding-top: 56px;
      background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.45) 50%, rgba(0, 0, 0, 0) 100%);
    }

    .story-viewer-bottom-bar {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px 6px;
      flex: 0 0 auto;
    }

    /* Centered under the progress segments, not inline with the name - a
       row of its own so centering doesn't fight the name/time's own flex
       layout above it. */
    .story-reply-trigger-row {
      display: flex;
      justify-content: center;
      padding: 6px 12px 0;
      flex: 0 0 auto;
    }

    /* Same chrome recipe as .story-editor-icon-btn (the close/delete
       buttons above) - rounded square via var(--radius-btn), not a pill -
       just auto-width with a label instead of that class's fixed 34x34
       icon-only box. */
    .story-reply-pill {
      display: flex;
      align-items: center;
      gap: 6px;
      height: 34px;
      padding: 0 12px;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      font-size: 13px;
      cursor: pointer;
    }

    .story-reply-pill svg {
      width: 16px;
      height: 16px;
      flex: 0 0 auto;
    }

    /* Composer - collapsed (both the chiprow and the input/send row
       together) until the pill above opens it, so idle it adds nothing
       below the progress segments. */
    .story-reply-composer {
      flex: 0 0 auto;
      max-height: 0;
      opacity: 0;
      overflow: hidden;
      padding: 0 12px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      transition: max-height 0.22s ease, opacity 0.16s ease, padding 0.22s ease;
    }

    .story-reply-composer.open {
      max-height: 100px;
      opacity: 1;
      padding: 2px 12px 10px;
    }

    /* One strip (the extended scrim), not one pill per emoji - same idea
       as chat's own .message-action-list card behind its reaction row.
       Chips themselves stay transparent at rest (see .story-reply-chip
       below), same as chat's .msg-action-reaction-btn. */
    .story-reply-chiprow {
      display: flex;
      align-items: center;
      gap: 2px;
      background: rgba(0, 0, 0, 0.35);
      border-radius: var(--radius-card);
      padding: 3px;
    }

    .story-reply-chip {
      flex: 1 1 auto;
      border: none;
      background: transparent;
      font-size: 17px;
      line-height: 1;
      padding: 6px 0;
      cursor: pointer;
    }

    .story-reply-chip-more {
      flex: 0 0 auto;
      width: 30px;
      font-size: 14px;
      color: rgba(var(--chrome-rgb), 0.85);
    }

    .story-reply-input-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    #story-reply-text-input {
      flex: 1 1 auto;
      min-width: 0;
    }

    .story-viewer-progress {
      display: flex;
      gap: 4px;
      padding: 0 12px 10px;
      flex: 0 0 auto;
    }

    /* Reaction feedback - a handful of copies of the tapped emoji rising
       from the stage's own center and fading out (spawnStoryEmojiBurst in
       app.js), standing in for the "Sent" toast on an emoji tap (a typed
       reply still gets the plain toast - there's no single emoji to
       animate there). --dx/--dur/--delay are set per-particle in JS for
       a bit of natural spread instead of every copy flying identically. */
    .story-emoji-particle {
      position: absolute;
      left: 50%;
      top: 50%;
      font-size: 30px;
      line-height: 1;
      pointer-events: none;
      z-index: 3;
      animation: story-emoji-burst var(--dur, 1s) ease-out var(--delay, 0s) both;
    }

    @keyframes story-emoji-burst {
      0% {
        transform: translate(-50%, -50%) scale(0.6);
        opacity: 0;
      }
      15% {
        transform: translate(calc(-50% + var(--dx, 0px)), -50%) scale(1.15);
        opacity: 1;
      }
      100% {
        transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% - 180px)) scale(0.85);
        opacity: 0;
      }
    }

    .story-viewer-progress-seg {
      flex: 1 1 auto;
      height: 2.5px;
      border-radius: 999px;
      background: rgba(var(--chrome-rgb), 0.25);
    }

    .story-viewer-progress-seg.filled {
      background: rgba(var(--chrome-rgb), 0.9);
    }

    .story-viewer-author-info {
      flex: 1 1 auto;
      min-width: 0;
      display: flex;
      flex-direction: column;
      padding: 0 4px;
    }

    .story-viewer-author-info #story-viewer-author {
      font-size: 13px;
      font-weight: 600;
      color: rgb(var(--chrome-rgb));
    }

    .story-viewer-author-info #story-viewer-time {
      font-size: 11px;
      color: rgba(var(--chrome-rgb), 0.65);
    }

    /* Fixed, not absolute: .story-editor-overlay's own position:absolute
       sizes it against .shell's box, which is only ever the real device
       viewport at the mobile (base) breakpoint - at the >=600px desktop
       breakpoint .shell becomes a rounded, max-height "phone in a frame"
       preview card (see that media query), and an absolutely-positioned
       viewer inherited that card's bounds and rounded corners instead of
       actually covering the screen. Stories are meant to be an immersive
       full-bleed takeover at any viewport size, so this one overlay (ID
       beats the shared class, so this wins with no !important) escapes
       .shell entirely and sizes against the real browser viewport instead -
       .shell has no transform/filter of its own to re-trap it. */
    #story-viewer-overlay {
      position: fixed;
      /* Above the chat room's swapped-in header (.app-header.app-header-
         swap-open, 21) - reachable by tapping a story-reply quote inside an
         open chat room (see openStoryViewer's own comment), where this and
         the room view share the plain .story-editor-overlay 15 and DOM
         order alone puts this overlay's content on top of the room's, but
         the header sits outside both overlays and stayed visible over the
         story underneath it. Same escape .story-editor-overlay.chat-room-
         media-overlay already uses for the same reason, one step higher so
         it isn't accidentally covered by that either. ID beats the shared
         class, so this wins with no !important. */
      z-index: 23;
    }

    .story-viewer-stage {
      position: absolute;
      inset: 0;
      display: flex;
    }

    /* Close floats over the stage too, with the same gradient-scrim
       treatment as the footer below - legible against any story
       background instead of squeezing the stage into a smaller rectangle.
       #story-viewer-overlay-scoped so this wins over .story-editor-topbar's
       own padding shorthand regardless of stylesheet order. */
    #story-viewer-overlay .story-viewer-header {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      z-index: 2;
      padding-bottom: 40px;
      /* Same recipe as .story-viewer-footer's scrim below - one standard
         fade used top and bottom instead of the header's old flatter,
         lower-opacity one-stop version. */
      background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.45) 50%, rgba(0, 0, 0, 0) 100%);
      /* Was flex-end, from back when close was this row's only button -
         that clustered close+delete together at the right once delete
         moved in here too (see #story-viewer-delete's own comment in
         app.html). space-between puts close on the left like every other
         full-screen panel's close button in this app, delete on the
         right. */
      justify-content: space-between;
    }

    .story-viewer-stage > .story-editor-bg {
      flex: 1 1 auto;
    }

    .story-viewer-stage > .story-editor-bg > .story-link-preview-card {
      width: 100%;
      max-width: 280px;
      margin: 10px auto 0;
    }

    .story-viewer-text {
      width: 100%;
      font-size: 22px;
      text-align: center;
      line-height: 1.4;
      word-break: break-word;
      white-space: pre-wrap;
    }

    /* Same 16px radius as the text story's .story-editor-bg canvas (also
       flush/full-bleed against the stage, no inset) - unifies the two
       story kinds' shape instead of text being rounded and photo sharp. */
    .story-viewer-photo-wrap {
      position: relative;
      flex: 1 1 auto;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--bg-shell);
      border-radius: 16px;
      overflow: hidden;
    }

    .story-viewer-photo-wrap img {
      display: block;
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
    }

    .story-viewer-photo-wrap .story-link-preview-card {
      position: absolute;
      left: 14px;
      right: 14px;
      bottom: 14px;
      margin-top: 0;
    }

    /* Spans the full stage now that the header/footer float on top with
       their own z-index - a direct tap on the close/delete button still
       reaches it first, same stacking-context rule as everywhere else. */
    .story-viewer-tap-zone {
      /* top/bottom only here (not inset:0) - setting left AND right both
         explicitly on the base rule left no "auto" side for the left/right
         modifiers below to position against, so both zones collapsed onto
         the same left half. */
      position: absolute;
      top: 0;
      bottom: 0;
      z-index: 1;
      border: none;
      background: transparent;
      padding: 0;
      cursor: pointer;
    }

    .story-viewer-tap-zone-left {
      left: 0;
      width: 50%;
    }

    .story-viewer-tap-zone-right {
      right: 0;
      width: 50%;
    }

    /* Held down (see attachLongPress's onLongPressEnd below) - the
       floating chrome fades out so the story is visible unobstructed,
       and fades back in on release. */
    .story-viewer-header,
    .story-viewer-footer {
      transition: opacity 0.15s ease-out;
    }

    .story-viewer-header.chrome-hidden,
    .story-viewer-footer.chrome-hidden {
      opacity: 0;
      pointer-events: none;
    }

    /* CALLING - #call-overlay reuses .story-editor-overlay for the same
       full-bleed/transparent-backdrop treatment as the story viewer, so it
       only needs its own content positioned on top. */

    /* Shared base for every in-call button (the back arrow, hang-up, and
       the bottom controls-bar icons) - same size/shape the header's call
       button uses (36px, 12px corners), not the perfect circles these
       used to be, so the whole call screen reads as one button family.
       The preview's flip/expand buttons intentionally scale this down
       rather than use it directly - see .call-local-flip-btn/-expand-btn. */
    .call-icon-btn {
      width: 36px;
      height: 36px;
      min-width: 36px;
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      display: flex;
      align-items: center;
      justify-content: center;
      /* Solid, not translucent - a translucent fill looks fine over the
         pure-black preview backdrop (it blends into a charcoal-ish grey)
         but falls apart over actual video, where it just lets the feed's
         colour/brightness show straight through. An opaque fill can't
         bleed regardless of what's behind it. */
      background: #2a2a2e;
      color: #fff;
      cursor: pointer;
      padding: 0;
    }

    .call-icon-btn svg {
      width: 17px;
      height: 17px;
    }

    /* Used to be a faint full-width top-to-transparent gradient scrim
       behind .call-topbar/.call-hangup-top-btn instead of this - removed
       outright rather than replaced with anything: the back button and
       hang-up already carry their own opaque .call-icon-btn chrome, and
       the status text reads fine straight over video without needing a
       backdrop of its own. See .call-controls-bar below for where the
       "full surround" pill treatment (matching .call-more-row, the
       expanded button set) actually belongs instead. */
    .call-topbar {
      position: absolute;
      top: 14px;
      left: 14px;
      right: 60px;
      z-index: 4;
      display: flex;
      align-items: center;
      gap: 10px;
      transition: opacity 0.2s ease;
    }

    /* Same chrome as .call-icon-btn's other instance (the back arrow beside
       it) - no red border/standout treatment any more. The red icon colour
       alone is what marks this as the end-call action. */
    .call-hangup-top-btn {
      position: absolute;
      top: 14px;
      right: 14px;
      color: var(--danger);
      z-index: 4;
      transition: opacity 0.2s ease;
    }

    /* Idle-hide alongside .call-controls-bar (see showCallControls() in
       app.js) - the back/status row and hang-up fade with the rest of the
       in-call chrome instead of staying permanently pinned over the
       video. */
    .call-topbar.chrome-hidden,
    .call-hangup-top-btn.chrome-hidden {
      opacity: 0;
      pointer-events: none;
    }

    /* "Who you're calling" - centered top, below the back/hang-up row.
       Shown from openCallOverlay (ringing/dialing, when your own camera
       is standing in full-screen for the feed - see
       .call-local-wrap.fullscreen) and explicitly hidden again right as
       callState flips to "connected" (see hideCallPartnerAvatar in
       app.js) - once their real video is the feed, floating a static
       photo of them over their own face is redundant, not reassuring.
       Same gem-conic ring recipe as every other avatar in the app. */
    .call-partner-avi {
      position: absolute;
      top: 64px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 2;
      width: 60px;
      height: 60px;
      border-radius: 18px;
      --avi-inner-radius: 16px;
      background: var(--gem-conic);
      padding: 2px;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
    }

    .call-partner-avi::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 16px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
    }

    .call-partner-avi span {
      position: relative;
      z-index: 1;
      font-size: 20px;
      font-weight: 700;
      color: var(--accent-stronger);
    }

    .call-partner-avi.has-avatar > span {
      opacity: 0;
    }

    .call-remote-wrap {
      position: absolute;
      inset: 0;
      background: #000;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .call-remote-video {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    /* Partner's mic/cam-off status - always visible (not part of
       callChromeElements()'s idle-hide, unlike every other piece of call
       chrome) since it's ongoing state worth knowing at a glance, not a
       control to tuck away. */
    .call-partner-media-badges {
      position: absolute;
      bottom: 14px;
      left: 14px;
      z-index: 2;
      display: flex;
      gap: 6px;
      pointer-events: none;
    }

    /* Same rounded-square family as .call-icon-btn, but translucent rather
       than opaque - unlike the buttons sized up earlier this session
       (.call-local-flip-btn/-expand-btn), these are a passive status
       readout, not a tap target that needs its icon to stay crisp against
       the live feed, so a lighter wash reads as "info", not "control". */
    .call-media-badge {
      width: 24px;
      height: 24px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: rgba(0, 0, 0, 0.55);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .call-media-badge svg {
      width: 13px;
      height: 13px;
    }

    /* Left-aligned beside the back arrow in .call-topbar now, not centered
       over the video - name on top, call duration (or a transient state
       like "Calling..."/"Reconnecting...") stacked under it. See the
       duration ticker in app.js (startCallDurationTimer()). */
    .call-status-wrap {
      color: rgb(var(--chrome-rgb));
      min-width: 0;
    }

    .call-status-name {
      font-size: 15px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .call-status-text {
      font-size: 12px;
      color: rgba(var(--chrome-rgb), 0.7);
      font-variant-numeric: tabular-nums;
    }

    /* Floating self-view. Toggled via #call-self-preview-btn using the
       shared .hidden utility - that just stops rendering it, it doesn't
       touch the camera track, so the partner keeps receiving video either
       way. Position is top/left (not right/bottom) because
       initCallLocalPreviewDrag() in app.js drives both drag-to-corner and
       tap-to-enlarge by writing those two properties directly - mixing in
       CSS-anchored right/bottom would fight that. transition is suppressed
       during an active drag (see .dragging) so the preview tracks the
       finger/cursor 1:1, then re-enabled for the snap/grow animation. */
    .call-local-wrap {
      position: absolute;
      top: 0;
      left: 0;
      width: 72px;
      height: 118px;
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid rgba(var(--chrome-rgb), 0.15);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
      z-index: 2;
      background: #111;
      touch-action: none;
      cursor: grab;
      transition: top 0.22s ease, left 0.22s ease, width 0.22s ease, height 0.22s ease;
    }

    .call-local-wrap.dragging {
      transition: none;
      cursor: grabbing;
    }

    /* Tap-to-enlarge target size - near-fullscreen but leaves the status
       text and controls bar reachable rather than covering them edge to
       edge. Width/height are set alongside top/left in JS (not here) since
       the enlarged box's position still has to stay inside the overlay
       bounds depending on which corner it grew from. */
    .call-local-wrap.enlarged {
      z-index: 3;
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    }

    /* Stands in for the (still-empty) remote feed before the call's
       answered - see setLocalPreviewFullscreen in app.js, which toggles
       this and clears the inline dock position so neither fights the
       other. Same inset:0 treatment as .call-remote-wrap, square corners/
       no border/no drag cursor instead of the small floating preview's
       chrome, so it genuinely reads as "the current main feed," not an
       oversized version of the little bubble. */
    .call-local-wrap.fullscreen {
      inset: 0;
      width: auto;
      height: auto;
      border-radius: 0;
      border: none;
      box-shadow: none;
      cursor: default;
      z-index: 1;
    }

    .call-local-video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      /* Mirrored, like every other front-camera self-preview - seeing
         yourself un-mirrored reads as subtly "wrong" to most people. Only
         the front camera gets this treatment - see flipCamera() in app.js,
         which adds .call-local-video-unmirrored for the rear camera. */
      transform: scaleX(-1);
    }

    .call-local-video.call-local-video-unmirrored {
      transform: none;
    }

    /* object-fit: cover (the normal default below, in each of these three
       elements' own rules) is right for a camera feed, where filling the
       frame and losing some edge is the whole point - wrong for a screen
       share, where the content is usually a wide desktop display way off
       a phone screen's own aspect ratio, so cover was cropping real
       content off both sides instead of just losing unimportant margin.
       contain letterboxes it instead - nothing gets cut off, just some
       black bars. Driven by screenSharing locally for the sharer's own
       preview (#call-local-video), and by the call-screenshare-state
       signaling message for whoever's watching (#call-remote-video, and
       #call-minimized-video if they minimize mid-share) - see
       toggleScreenShare()/handleRemoteScreenshareState() in app.js. */
    .call-remote-video.screensharing,
    .call-local-video.screensharing,
    .call-minimized-video.screensharing {
      object-fit: contain;
      background: #000;
    }

    /* Same rounded-square family as .call-icon-btn, scaled down to fit the
       preview thumbnail - not a circle - and now the same opaque chrome
       too (fill/border/icon colour all match exactly), not just the shape.
       These used to keep a translucent rgba(0,0,0,0.45) fill, which is
       exactly the thing .call-icon-btn's own comment already explains is
       the problem: fine over the pure-black preview backdrop, but sitting
       directly on the live camera feed here, a translucent fill let the
       feed's own colour/brightness bleed straight through and wash the
       icon out. min-height override is required: the global
       `button { min-height: 36px; }` reset otherwise floors this at 36px
       tall while width stays 24px, rendering an oblong pill instead of a
       small square. Sized up a few px from the original 18px/10px-icon -
       fine against even the smallest preview size (72x118, see
       LOCAL_PREVIEW_SMALL_SIZE in app.js) but was genuinely fiddly to tap
       at the old size. */
    .call-local-flip-btn,
    .call-local-expand-btn {
      position: absolute;
      right: 4px;
      width: 24px;
      height: 24px;
      min-height: 24px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      display: flex;
      align-items: center;
      justify-content: center;
      background: #2a2a2e;
      color: #fff;
      cursor: pointer;
      z-index: 1;
      transition: opacity 0.2s ease;
    }

    .call-local-flip-btn { bottom: 4px; }
    .call-local-expand-btn { top: 4px; }

    .call-local-flip-btn svg,
    .call-local-expand-btn svg {
      width: 13px;
      height: 13px;
    }

    /* Idle-hide alongside the rest of the in-call chrome (see
       callChromeElements() in app.js) - these used to stay permanently
       opaque over the video regardless of idle state, the only call
       controls that didn't fade with everything else. */
    .call-local-flip-btn.chrome-hidden,
    .call-local-expand-btn.chrome-hidden {
      opacity: 0;
      pointer-events: none;
    }

    /* Preview-stage dial button. Docked above .call-more-row rather than
       directly above .call-controls-bar, since the more-row can also be
       open at this stage (tapping #call-more-btn to check mic/cam/etc.
       before dialing) and the two shouldn't overlap. Same muted green as
       .call-accept-btn - both mean "go", kept semantic and independent of
       the selected palette rather than using the theme accent (see
       newstyle.md's Semantic colours note). Rounded-square corners, same
       12px family as .call-icon-btn - this used to be a full pill
       (border-radius:999px), the one call control that didn't match the
       rest of the screen's "rounded square, not a circle" language. */
    .call-start-btn {
      position: absolute;
      left: 50%;
      bottom: 130px;
      transform: translateX(-50%);
      z-index: 3;
      display: flex;
      align-items: center;
      gap: 7px;
      border: none;
      border-radius: 12px;
      padding: 10px 22px;
      background: #5fa97d;
      color: #0c2016;
      font-family: inherit;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
    }

    .call-start-btn svg {
      width: 17px;
      height: 17px;
    }

    /* Full-width edge-to-edge gradient used to sit here, same idea as
       .call-top-scrim (removed above) - replaced with the same "full
       surround" pill chrome .call-more-row (the expanded button set,
       directly below) already uses: one solid rounded background the
       buttons actually sit inside, centered and sized to its content
       rather than smeared across the whole bottom edge. */
    .call-controls-bar {
      position: absolute;
      left: 50%;
      bottom: 14px;
      transform: translateX(-50%);
      z-index: 2;
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      gap: 8px;
      padding: 8px;
      border-radius: 16px;
      background: rgba(0, 0, 0, 0.35);
      transition: opacity 0.2s ease;
    }

    /* Self-preview/partner-mute/screen-share/PiP - tucked behind
       #call-more-btn instead of sitting in the always-visible bar. Docked
       close above .call-controls-bar (~52px tall, now inset 14px off the
       edge rather than flush with it - see above); .call-start-btn sits
       higher still (see below) specifically to clear this row during the
       preview stage, when both can be showing at once. Toggled via
       toggleCallMoreRow() in app.js. */
    .call-more-row {
      position: absolute;
      left: 50%;
      bottom: 70px;
      transform: translateX(-50%);
      z-index: 3;
      display: flex;
      gap: 8px;
      padding: 8px;
      border-radius: 16px;
      /* Faint, not solid - the buttons inside are opaque charcoal now, so
         this doesn't need to carry the contrast any more, just a light
         wash for a touch of separation from the video. */
      background: rgba(0, 0, 0, 0.35);
      transition: opacity 0.2s ease;
    }

    .call-more-row.chrome-hidden {
      opacity: 0;
      pointer-events: none;
    }

    /* Matches .call-icon-btn's size/shape (36px, 12px corners) rather than
       the shared .story-editor-icon-btn base (34px, 10px corners) that the
       story editor/chat room headers use unchanged elsewhere - every
       in-call button, bottom bar and more-row included, should read as the
       same family. */
    /* Generic/matte on purpose, same reasoning as .call-accept-btn above -
       this screen's backdrop is always dark video regardless of the
       selected theme/palette (newstyle.md exempts calls from normal
       theming), so the controls stay a fixed neutral look too instead of
       inheriting --bg-input/--muted/--accent-soft, which used to make the
       same button look different per theme/palette combo. Solid fill, not
       translucent - see .call-icon-btn's comment for why (a translucent
       fill reads fine over the pure-black preview but lets real video
       bleed straight through once connected). */
    .call-controls-bar .story-editor-icon-btn,
    .call-more-row .story-editor-icon-btn {
      width: 36px;
      height: 36px;
      border-radius: 12px;
      background: #2a2a2e;
      border-color: rgba(255, 255, 255, 0.08);
      color: #fff;
    }

    .call-controls-bar .story-editor-icon-btn svg,
    .call-more-row .story-editor-icon-btn svg {
      width: 17px;
      height: 17px;
    }

    /* Idle-hide once connected (see scheduleCallControlsAutoHide() in
       app.js) - any tap on the call screen brings it back and restarts the
       timer, same "out of the way until needed" treatment the story
       viewer's header/footer use. */
    .call-controls-bar.chrome-hidden {
      opacity: 0;
      pointer-events: none;
    }

    /* A toggled-on control (mic/cam/screen-share/partner-mute while active,
       or #call-more-btn itself while its row is open) gets the same fixed
       "engaged" look. */
    .call-controls-bar .story-editor-icon-btn.active,
    .call-more-row .story-editor-icon-btn.active {
      background: #fff;
      color: #111;
      border-color: #fff;
    }

    /* Docked at the same height as .call-start-btn (130px), not directly
       above .call-controls-bar (70px) - the mic/cam controls stay live
       while ringing now too (see startIncomingCallPreview() in app.js), so
       this needs the same clearance above .call-more-row that the outgoing
       dial button already has, for the same reason. */
    .call-incoming-panel {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 130px;
      z-index: 3;
      display: flex;
      justify-content: center;
      gap: 48px;
    }

    .call-ring-btn {
      width: 56px;
      height: 56px;
      border-radius: 999px;
      border: none;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }

    .call-ring-btn svg {
      width: 24px;
      height: 24px;
    }

    .call-decline-btn {
      background: var(--danger);
      color: rgb(var(--chrome-rgb));
    }

    /* Muted/matte on purpose, not the usual bright "success" green - this
       sits on a video feed, not UI chrome, and should read as a call-app
       convention (fixed, independent of the selected theme/palette) rather
       than a vivid accent. .call-start-btn below shares this exact value -
       same action (start/join a call), should match. */
    .call-accept-btn {
      background: #5fa97d;
      color: #0c2016;
    }

    /* Persists across every page of the app while a call is minimized -
       deliberately NOT nested under #call-overlay (see the HTML comment
       above it for why) and uses position: fixed rather than absolute so
       it's anchored to the viewport regardless of which page is showing
       underneath. top/left/width/height are driven by initMinimizedBubbleDrag()
       in app.js (same dock model the self-preview uses), not by this rule -
       this just sets what doesn't change: shape, chrome, stacking. */
    .call-minimized-bubble {
      position: fixed;
      top: 0;
      left: 0;
      z-index: 20;
      /* Same corner radius as .call-local-wrap - its starting size now
         matches that too (see MINIMIZED_BUBBLE_SIZE in app.js), so the
         two read as the same shape, not just a similar one. */
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid rgba(var(--chrome-rgb), 0.15);
      box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
      background: #111;
      touch-action: none;
      cursor: grab;
      transition: top 0.22s ease, left 0.22s ease;
    }

    .call-minimized-bubble.dragging {
      transition: none;
      cursor: grabbing;
    }

    .call-minimized-video {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    /* Same rounded-square family/chrome as .call-icon-btn's own hangup
       instance (.call-hangup-top-btn) - this predated that button's
       redesign away from a plain red-filled circle and was never updated
       to match: no red fill/standout treatment any more, the red icon
       colour alone marks this as end-call, same as everywhere else on the
       call screen. */
    .call-minimized-hangup-btn {
      position: absolute;
      top: 4px;
      right: 4px;
      width: 20px;
      height: 20px;
      min-height: 20px;
      border-radius: 7px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      display: flex;
      align-items: center;
      justify-content: center;
      background: #2a2a2e;
      color: var(--danger);
      cursor: pointer;
    }

    .call-minimized-hangup-btn svg {
      width: 11px;
      height: 11px;
    }

    /* Drag-to-dismiss target for the bubble above - see
       initMinimizedBubbleDrag() in app.js. Hidden until a drag actually
       starts (.visible), then turns "armed" (ready to release) once the
       bubble is held over it. Matte, not themed, same reasoning as the
       rest of the call UI's generic controls. */
    .call-minimized-close-zone {
      position: fixed;
      left: 50%;
      bottom: 28px;
      transform: translateX(-50%) scale(0.85);
      z-index: 21;
      width: 52px;
      height: 52px;
      border-radius: 999px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(20, 20, 20, 0.7);
      border: 1px solid rgba(255, 255, 255, 0.18);
      color: #fff;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
    }

    .call-minimized-close-zone svg {
      width: 20px;
      height: 20px;
    }

    .call-minimized-close-zone.visible {
      opacity: 1;
      transform: translateX(-50%) scale(1);
    }

    .call-minimized-close-zone.armed {
      background: var(--danger);
      border-color: var(--danger);
      transform: translateX(-50%) scale(1.15);
    }

    /* STORY COMPOSER - full-screen editor (Instagram/Snapchat-style: close
       top-left, Post top-right - deliberately not the app's usual sheet-
       with-close-top-right pattern, to read as a distinct, immersive mode). */

    .story-editor-overlay {
      position: absolute;
      inset: 0;
      /* Transparent on purpose - the page it sits on top of is hidden
         while this is open (see setPageHiddenBehindOverlay() in app.js),
         so the shell's one real background gradient shows through with no
         seam, instead of this painting its own flat, mismatched panel. */
      background: transparent;
      z-index: 15;
      display: flex;
      flex-direction: column;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity 0.18s ease-out, visibility 0s linear 0.18s;
    }

    .story-editor-overlay.active {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transition: opacity 0.18s ease-out, visibility 0s linear 0s;
    }

    .story-editor-topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 12px 8px;
      flex: 0 0 auto;
    }

    /* .task-type-toggle's own button rule is flex:1 (it fills a full-width
       row elsewhere, e.g. the task editor's Checkbox/Quantity switch) -
       here the toggle sits in a compact 3-up topbar with nothing to
       stretch against, so each button needs to size to its own label
       instead. */
    #story-type-toggle button,
    #profile-post-type-toggle button {
      flex: 0 0 auto;
      width: 64px;
      padding: 6px 0;
      text-align: center;
    }

    /* Same icon-button recipe as .chat-icon-btn (Chat tab's composer) -
       shared look across tabs instead of each inventing its own chrome. */
    .story-editor-icon-btn {
      width: 34px;
      height: 34px;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      padding: 0;
    }

    .story-editor-icon-btn svg {
      width: 18px;
      height: 18px;
    }

    /* The caption toggle starts life like this - disabled until a photo
       actually exists to caption (see setPhotoCaptionUi in app.js) -
       rather than hidden, so it reads as "not yet available" in its
       fixed spot among the other controls instead of the row visibly
       reflowing as it comes and goes. */
    .story-editor-icon-btn:disabled {
      opacity: 0.35;
      cursor: default;
    }

    /* Static - the expiry is fixed, there's nothing to tap here. Sits where
       the old labeled "Post" button used to, now that posting moved down
       into the toolbar as an icon button (.story-editor-send-btn). */
    .story-editor-expiry-label {
      flex: 0 0 auto;
      padding: 0 4px;
      font-size: 12px;
      color: var(--muted);
    }

    .story-editor-canvas {
      flex: 1 1 auto;
      position: relative;
      display: flex;
      flex-direction: column;
      min-height: 0;
      padding: 8px 14px;
    }

    .story-editor-bg {
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      border-radius: 16px;
      padding: 20px;
      overflow-y: auto;
    }

    .story-editor-card {
      width: 100%;
      border-radius: 14px;
      transition: background 0.15s ease-out;
    }

    .story-editor-card.has-card {
      padding: 18px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    }

    /* Positioning context for the caption toggle/banner below, which are
       its siblings, not its children - see app.html's own comment on why
       they can't live inside the picker <label>. */
    .story-photo-frame {
      position: relative;
      flex: 1 1 auto;
      display: flex;
      min-height: 0;
    }

    .story-editor-photo-picker {
      flex: 1 1 auto;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 16px;
      border: 1.5px dashed var(--border-subtle);
      color: var(--muted);
      font-size: 14px;
      cursor: pointer;
      overflow: hidden;
      position: relative;
    }

    .story-editor-photo-picker img {
      width: 100%;
      height: 100%;
      object-fit: contain;
    }

    /* A banner laid over the bottom of the photo now, not a field below
       it - the scrim keeps the typed caption legible against any image
       underneath, Instagram/Snapchat-style, rather than a plain input box
       bolted on underneath the canvas. */
    .story-editor-caption-row {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 1;
      display: flex;
      align-items: center;
      padding: 18px 10px 10px;
      background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);
    }

    .story-editor-caption-row .text-input {
      flex: 1 1 auto;
      background: transparent;
      border: none;
      color: #fff;
      padding: 4px 2px;
    }

    .story-editor-caption-row .text-input::placeholder {
      color: rgba(255, 255, 255, 0.7);
    }

    .story-editor-caption-row .text-input:focus {
      outline: none;
      box-shadow: none;
    }

    /* Each control is a single button you tap repeatedly to cycle through
       its options (background color / card style / font), rather than a
       row showing every option at once - see cycleStoryBg()/
       cycleStoryCardColor()/cycleStoryFont() in app.js. */
    .story-editor-toolbar {
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 10px;
      padding: 10px 14px 14px;
    }

    /* Same square recipe as the other toolbar icon buttons, just filled
       with the current background color instead of an icon. */
    .story-swatch {
      width: 34px;
      height: 34px;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      cursor: pointer;
      padding: 0;
      flex-shrink: 0;
    }

    /* Posting moved here from the old top-right pill button - same
       soft-accent-fill treatment as .chat-send-btn, pinned to the far
       right of the row away from the other (left-clustered) controls. */
    .story-editor-send-btn {
      margin-left: auto;
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    /* Topbar is a 3-part space-between row (close | toggle | remove) so the
       toggle lands dead centre, same as the real story editor's close |
       toggle | "24h" row. Remove only actually applies to an existing
       post, but still needs to occupy this third slot even when inactive -
       otherwise the toggle would re-center across just close+toggle and
       visibly drift left whenever remove shows/hides. visibility (not the
       generic .hidden's display:none) keeps its layout box reserved while
       inactive - an ID selector to outrank .hidden's own !important. */
    #profile-post-remove-btn.hidden {
      display: flex !important;
      visibility: hidden;
      pointer-events: none;
    }
    /* Separate from the FAB's own "hidden" (managed by renderProfileGallery
       based on gallery state - full, or someone else's profile) so forcing
       it out of the way while the transparent post editor sits over it
       doesn't clobber that unrelated state when the editor closes again. */
    .gem-fab-wrap.editor-open {
      display: none;
    }
    /* Tap-again-to-confirm arm for the Remove button, same idea as the
       icon-action-btn danger/confirming pattern used elsewhere. */
    #profile-post-remove-btn.confirming {
      border-color: rgba(255, 75, 129, 0.7);
      background: var(--danger-soft);
      color: var(--danger);
    }

    /* Same 34x34 square as every other toolbar control (.story-swatch,
       .story-editor-icon-btn) - both the card-style icon and the "Aa" font
       label sit in this one uniform size rather than the label getting its
       own wider pill. */
    .story-editor-cycle-btn {
      width: 34px;
      height: 34px;
      border-radius: var(--radius-btn);
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--text-main);
      font-size: 13px;
      cursor: pointer;
    }

    .story-editor-cycle-btn svg {
      width: 18px;
      height: 18px;
    }

    .story-text-card {
      width: 100%;
      min-height: 140px;
      border: none;
      background: transparent;
      padding: 0;
      font-size: 18px;
      text-align: center;
      line-height: 1.4;
      resize: none;
      color: #1a1a1a;
    }

    .story-text-card:focus {
      outline: none;
    }

    .story-text-card::placeholder {
      color: rgba(26, 26, 26, 0.45);
    }

    /* The browser's own default text-selection highlight is a bright
       blue box - fine on an ordinary form field, jarring against these
       soft matte pastel cards. A plain dark translucent wash instead,
       same idea as every dark-on-light selection in a polished app. */
    .story-text-card::selection {
      background: rgba(26, 26, 26, 0.2);
    }

    /* LINK PREVIEW - shared between the composer's attached-link chip and
       the posted-story feed card. position+z-index here (not just in the
       viewer-specific placement rules below) because .story-viewer-stage
       has no z-index of its own to contain it - without this, the real
       bug: a tap anywhere on the card inside the viewer was landing on
       .story-viewer-tap-zone instead (z-index:1, spanning the full stage
       as a sibling of it, specifically so it still reaches above
       ordinary story content) and just advancing/rewinding the story
       instead of opening the link, since a plain in-flow <a> with no
       stacking order of its own loses to any explicitly-stacked sibling
       regardless of DOM nesting depth. */
    .story-link-preview-card {
      position: relative;
      z-index: 2;
      display: block;
      border-radius: 12px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-sheet-solid);
      overflow: hidden;
      text-decoration: none;
      color: var(--text-main);
      margin-top: 8px;
    }

    .story-link-preview-card img {
      display: block;
      width: 100%;
      max-height: 160px;
      object-fit: cover;
    }

    .story-link-preview-body {
      padding: 8px 10px;
    }

    .story-link-preview-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-main);
      line-height: 1.3;
    }

    .story-link-preview-desc {
      font-size: 12px;
      color: var(--muted);
      margin-top: 2px;
      line-height: 1.3;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .story-link-preview-domain {
      font-size: 11px;
      color: var(--muted-softer);
      text-transform: uppercase;
      letter-spacing: 0.04em;
      margin-top: 4px;
    }

    #story-link-chip,
    #story-link-chip-photo {
      position: relative;
      width: 100%;
      max-width: 280px;
      margin: 10px auto 0;
    }

    .story-link-chip-remove {
      position: absolute;
      /* .story-link-preview-card (its own parent AND its sibling - the
         chip container itself carries that class too) sets
         overflow:hidden, which was clipping away the negative offsets
         this used to have (-8px/-8px sits outside the card's own box,
         so the part sticking out past the edge never painted at all).
         Inset a few px instead - fully inside the clipped box, still
         reading as a corner badge. */
      top: 4px;
      right: 4px;
      /* Its sibling .story-link-preview-card sets z-index:2 on itself -
         without an explicit z-index here that beats it, this stacked
         below the card instead of floating on top of its corner despite
         coming later in the DOM (a positioned sibling with z-index:auto
         always loses to one with an explicit stacking value). */
      z-index: 3;
      width: 22px;
      height: 22px;
      border-radius: var(--radius-btn-sm);
      border: none;
      background: #1a1a1a;
      color: rgb(var(--chrome-rgb));
      font-size: 14px;
      line-height: 1;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .story-link-popup-status {
      font-size: 12px;
      color: var(--muted);
      margin-top: 4px;
    }

    .field {
      margin-bottom: 6px;
    }

    .field-label {
      font-size: 10px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted-softer);
      margin-bottom: 3px;
    }

    .text-input,
    .textarea-input {
      width: 100%;
      border-radius: 12px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-deep);
      padding: 7px 8px;
      font-size: 13px;
      color: var(--text-main);
      outline: none;
      resize: vertical;
      min-height: 34px;
      font-family: inherit;
    }

    .textarea-input {
      min-height: 60px;
      max-height: 120px;
    }

    .text-input::placeholder,
    .textarea-input::placeholder {
      color: var(--muted-softer);
    }

    .text-input:focus,
    .textarea-input:focus {
      border-color: var(--border-accent-soft);
      box-shadow: 0 0 0 1px var(--border-accent-soft);
    }

    .pill-row {
      display: flex;
      gap: 4px;
      justify-content: center;
      margin-top: 2px;
      margin-bottom: 2px;
      flex-wrap: nowrap;
    }

    .weekday-pill {
      font-size: 11px;
      border-radius: var(--radius-btn);
      padding: 3px 0;
      border: 1px solid var(--border-subtle);
      background: var(--bg-card);
      color: var(--muted);
      cursor: pointer;
      flex: 1 1 0;
      min-width: 0;
      text-align: center;
    }

    .weekday-pill.active {
      border-color: var(--border-accent-strong);
      background: var(--accent-soft);
      color: var(--accent-stronger);
      font-weight: 600;
    }

    .repeat-mode-label {
      margin-top: 3px;
      font-size: 11px;
      text-align: center;
      color: var(--muted);
    }

    .primary-btn {
      width: 100%;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-accent-strong);
      background: radial-gradient(circle at top, var(--btn-primary-top), var(--btn-primary-bot));
      color: #fefbff;
      padding: 7px 10px;
      font-size: 13px;
      cursor: pointer;
      margin-top: 6px;
      box-shadow: var(--shadow-card);
    }

    .primary-btn:disabled {
      opacity: 0.5;
      cursor: default;
      box-shadow: none;
    }
	
    /* Gem FAB - new task button */
    .gem-fab-wrap {
      align-self: flex-end;
      padding: 12px;
      flex-shrink: 0;
    }
    .gem-fab {
      width: 40px;
      height: 40px;
      min-width: 40px;
      border-radius: 12px;
      padding: 0;
      border: none;
      cursor: pointer;
      position: relative;
      background: var(--gem-conic);
      box-shadow:
        0 0 0 1px rgba(var(--chrome-rgb), 0.09),
        0 4px 16px rgba(0, 0, 0, 0.7);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.12s ease-out;
    }
    .gem-fab::before {
      content: "";
      position: absolute;
      inset: 3px;
      border-radius: 9px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
      border: 1px solid rgba(var(--chrome-rgb), 0.06);
      box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.9);
      pointer-events: none;
    }
    .gem-fab:active {
      transform: scale(0.93);
    }
    .gem-fab-icon {
      position: relative;
      z-index: 1;
      font-size: 20px;
      line-height: 1;
      margin-top: -4px;
      color: var(--accent-stronger);
      pointer-events: none;
    }

    .secondary-btn {
      width: 100%;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      padding: 6px 10px;
      font-size: 12px;
      cursor: pointer;
      margin-top: 4px;
    }

    .danger-btn {
      width: 100%;
      border-radius: var(--radius-btn);
      border: 1px solid rgba(255, 75, 129, 0.7);
      background: var(--danger-soft);
      color: var(--danger);
      padding: 6px 10px;
      font-size: 12px;
      cursor: pointer;
      margin-top: 4px;
    }

    /* display:none can't be transitioned - there's no "before" state for the
       browser to animate from, so a display:none/flex toggle always jumps
       instantly no matter what transition is declared on a child. Using
       opacity/visibility/pointer-events instead keeps the element in the
       render tree (harmless - it's position:absolute and inert while hidden)
       so the card's own transform+opacity can actually animate in and out. */
    /* Same flat scrim + blur every other overlay in the app uses now
       (.rail-overlay, .side-menu-overlay, .mini-popup-overlay,
       .lightbox-overlay) - was its own gradient with no blur, the one
       remaining backdrop that looked different from the rest.
       position: fixed (not absolute) is also load-bearing here, not just
       cosmetic: these sheets sit nested inside .shell-main, which is
       deliberately position:relative so full-screen TAKEOVER panels
       (.story-editor-overlay - the story editor, chat room view) stop at
       the header's edge instead of covering it. A dialog-over-content
       sheet is a different case - its scrim is supposed to dim literally
       everything behind it, header included, the same as the rail flyout
       and the mini-popups already do (both already fixed) - so this needs
       to escape that same containing block via fixed positioning instead
       of inheriting it via absolute. */
    .sheet-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.82);
      backdrop-filter: blur(3px);
      -webkit-backdrop-filter: blur(3px);
      display: flex;
      align-items: flex-end;
      justify-content: center;
      padding: 0;
      z-index: 10;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity 0.18s ease-out, visibility 0s linear 0.18s;
    }

    /* The emoji picker is opened ON TOP of other open overlays (the story
       editor, the message-action mini-popup, the gallery lightbox's own
       reaction rail, etc - see openEmojiPicker() in app.js, which
       deliberately bypasses the single-overlay-at-a-time helper so it
       doesn't close whatever's behind it). Needs to out-rank every z-index
       it can be opened over, including the lightbox's 500 - picking a
       gallery-post reaction from its "..." button used to open this
       invisible behind the (opaque) lightbox, only appearing once the
       lightbox itself closed. */
    #emoji-picker-overlay {
      z-index: 510;
      /* Floating centered card, not the bottom-docked sheet the base
         .sheet-overlay gives every other sheet - picking an emoji is a
         quick, self-contained action, closer in kind to a popup dialog
         than a page-like sheet (settings, task detail, etc). */
      align-items: center;
      padding: 20px;
    }

    /* No drag handle - that's a bottom-sheet affordance (nothing to drag
       down on a centered floating card), and it was just leaving dead
       space above the title with nothing using it. */
    #emoji-picker-overlay .sheet-card::before {
      display: none;
    }

    #emoji-picker-overlay .sheet-card {
      position: relative;
      max-width: 380px;
      border-radius: 16px;
      border: 1px solid var(--border-subtle);
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    }

    .sheet-overlay.active {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transition: opacity 0.18s ease-out, visibility 0s linear 0s;
    }

    .sheet-card {
      width: 100%;
      max-width: 480px;
      background: var(--bg-sheet-solid);
      border-radius: 14px 14px 0 0;
      border-top: 1px solid var(--border-subtle);
      border-left: 1px solid var(--border-subtle);
      border-right: 1px solid var(--border-subtle);
      padding: 10px 10px 14px;
      box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.8);
      max-height: 85vh;
      display: flex;
      flex-direction: column;
      transform: translateY(24px) scale(0.98);
      opacity: 0;
      transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.18s ease-out;
    }

    .sheet-overlay.active .sheet-card {
      transform: translateY(0) scale(1);
      opacity: 1;
    }

    /* Data & Storage is the one true bottom sheet (keeps its drag handle and
       top-only rounding below) - it slides fully from off-screen instead of
       the scale+fade used by the centered dialogs everything else uses. */
    #data-storage-overlay .sheet-card {
      transform: translateY(100%);
      opacity: 1;
    }

    #data-storage-overlay.active .sheet-card {
      transform: translateY(0);
    }

    .sheet-card::before {
      content: "";
      display: block;
      width: 42px;
      height: 5px;
      background: rgba(var(--chrome-rgb), 0.12);
      border-radius: 999px;
      margin: 2px auto 8px;
    }

    .sheet-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 6px;
    }

    .sheet-title {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.14em;
      color: var(--muted);
    }

    .sheet-close-btn {
      border-radius: var(--radius-btn-sm);
      border: 1px solid var(--border-subtle);
      background: var(--bg-sheet);
      color: var(--muted);
      font-size: 14px;
      width: 24px;
      height: 24px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
    }

    .sheet-close-btn svg,
    .mini-popup-btn svg {
      width: 13px;
      height: 13px;
    }

    .sheet-body {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding-right: 2px;
      scrollbar-width: thin;
    }

    .sheet-body::-webkit-scrollbar {
      width: 4px;
    }

    .sheet-body::-webkit-scrollbar-thumb {
      background: var(--accent-muted);
      border-radius: 999px;
    }

    .picker-pill-row {
      display: flex;
      gap: 6px;
    }

    .picker-pill {
      flex: 1;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      padding: 5px 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 11px;
      color: var(--text-subtle);
      cursor: pointer;
    }

    .picker-pill-label {
      max-width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .picker-pill-muted {
      color: var(--muted-softer);
    }

    .picker-pill-chevron {
      font-size: 12px;
      color: var(--muted-softer);
      margin-left: 6px;
    }

    .picker-pin-btn {
      flex-shrink: 0;
      width: 32px;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      cursor: pointer;
      opacity: 0.5;
    }

    .picker-pin-btn.active {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      opacity: 1;
    }

    .wheel-column {
      max-height: 210px;
      overflow-y: auto;
      border-radius: 10px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      padding: 4px 0;
      scrollbar-width: thin;
      width: 68px;
      scroll-snap-type: y mandatory;
      mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
      -webkit-mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
    }

    .wheel-column::-webkit-scrollbar {
      width: 4px;
    }

    .wheel-column::-webkit-scrollbar-thumb {
      background: var(--accent-muted);
      border-radius: 999px;
    }

    .wheel-option {
      padding: 5px 10px;
      font-size: 13px;
      color: var(--text-subtle);
      cursor: pointer;
      text-align: center;
      scroll-snap-align: center;
      opacity: 0.6;
    }

    .wheel-option.active {
      color: var(--accent-stronger);
      background: var(--accent-soft);
      font-weight: 500;
      opacity: 1;
    }

    .wheel-row {
      display: flex;
      justify-content: center;
      gap: 10px;
      margin-bottom: 12px;
    }

    /* date wheel: wider and centered */
    #date-wheel {
      width: 120px;
      margin: 0 auto 12px;
    }

    .sheet-actions-row {
      display: flex;
      gap: 6px;
      margin-top: 8px;
    }

    .sheet-actions-row .primary-btn,
    .sheet-actions-row .secondary-btn {
      flex: 1;
      margin-top: 0;
    }


    .inline-meta {
      font-size: 11px;
      color: var(--muted);
      margin-bottom: 4px;
    }

    .inline-meta span + span::before {
      content: "·";
      margin: 0 4px;
      color: var(--muted-softer);
    }

    button {
      font-family: inherit;
      min-height: 36px;
      -webkit-tap-highlight-color: transparent;
    }

    .clickable-row {
      cursor: pointer;
    }

    .clickable-row:active {
      transform: translateY(1px);
    }

    .hidden {
      display: none !important;
    }

    .task-row-compact {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 5px 7px;
      border-radius: 12px;
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      background: var(--bg-card);
      font-size: 12px;
      margin-bottom: 8px;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
    }

    .task-row-compact-title {
      font-size: 12px;
    }

    /* Room media gallery's Files tab (see renderRoomMediaFiles in app.js) -
       a <button>, same .chat-file-chip-icon/-info/-name/-meta classes the
       chat bubble's own file chip uses, just laid out full-width in a
       plain list instead of the bubble's own max-width/padding. */
    .chat-room-media-file-row {
      width: 100%;
      gap: 10px;
      font: inherit;
      text-align: left;
      color: inherit;
      cursor: pointer;
    }

    .task-row-compact.quantity-mode {
      display: block;
    }

    .pill-toggle-small {
      font-size: 11px;
      border-radius: var(--radius-btn);
      padding: 3px 7px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-card);
      color: var(--muted);
      cursor: pointer;
    }

    .pill-toggle-small.active {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    .pill-toggle-small.done {
      border-color: var(--border-accent-soft);
    }

    .pill-toggle-small.missed {
      border-color: rgba(var(--chrome-rgb), 0.03);
      background: var(--bg-deep-98);
      color: var(--muted);
      opacity: 0.9;
    }

    .role-pref-row .pill-toggle-small {
      min-width: 64px;
      text-align: center;
    }

    /* JOURNAL PAGE */

    .journal-body {
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      margin-top: 6px;
    }

    .journal-textarea {
      flex: 1 1 auto;
      min-height: 0;
      border-radius: 10px;
      border: 1px solid transparent;
      background: var(--bg-deep);
      padding: 14px;
      font-size: 14px;
      line-height: 1.6;
      color: var(--text-main);
      resize: none;
      outline: none;
      font-family: inherit;
    }

    .journal-textarea:focus {
      border-color: var(--border-subtle);
    }

    .journal-textarea::placeholder {
      color: var(--muted-softer);
    }

    .notes-textarea {
      width: 100%;
      min-height: 55vh;
      border-radius: 10px;
      border: 1px solid transparent;
      background: var(--bg-deep);
      padding: 14px;
      font-size: 14px;
      line-height: 1.6;
      color: var(--text-main);
      resize: none;
      outline: none;
      font-family: inherit;
    }

    .notes-textarea:focus {
      border-color: var(--border-subtle);
    }

    .notes-textarea::placeholder {
      color: var(--muted-softer);
    }

    /* editor main actions row */

    .editor-actions-row {
      display: flex;
      gap: 6px;
      margin-top: 10px;
    }

    .editor-actions-row .primary-btn,
    .editor-actions-row .secondary-btn,
    .editor-actions-row .danger-btn {
      flex: 1;
      margin-top: 0;
      min-height: 34px;
    }

    /* Icon-based action row (Save / Save to library / Archive / Delete) -
       repeatable, secondary-ish actions read better as a compact icon row
       than as a stack of full-width text buttons. Save keeps top billing
       via color and position (leftmost) even though it's icon-only too. */
    .icon-action-row {
      display: flex;
      justify-content: center;
      gap: 14px;
      margin-top: 12px;
    }

    .icon-action-btn {
      width: 44px;
      height: 44px;
      min-height: 44px;
      border-radius: 14px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-card);
      color: var(--muted);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
      transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out, transform 0.1s ease-out;
    }

    .icon-action-btn svg {
      width: 20px;
      height: 20px;
    }

    .icon-action-btn:active {
      transform: scale(0.92);
    }

    .icon-action-btn.save {
      border-color: rgba(var(--success-rgb), 0.4);
      background: rgba(var(--success-rgb), 0.12);
      color: var(--success);
    }

    .icon-action-btn.library {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    .icon-action-btn.danger {
      border-color: rgba(var(--danger-rgb), 0.4);
      background: var(--danger-soft);
      color: var(--danger);
    }

    .icon-action-btn.danger.confirming {
      background: var(--danger);
      border-color: var(--danger);
      color: rgb(var(--chrome-rgb));
      animation: dangerActionPulse 0.9s ease-in-out infinite;
    }

    @keyframes dangerActionPulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(var(--danger-rgb), 0.55); }
      50% { box-shadow: 0 0 0 7px rgba(var(--danger-rgb), 0); }
    }

    /* Task detail + editor sheet tweaks */
    #rules-overlay .sheet-card,
    #scheduled-overlay .sheet-card,
    #library-overlay .sheet-card,
    #notes-overlay .sheet-card,
    #user-penalty-overlay .sheet-card {
      max-height: 96vh;
      border-radius: 16px 16px 0 0;
      border-bottom: none;
    }

    #rules-overlay .sheet-card::before,
    #scheduled-overlay .sheet-card::before,
    #library-overlay .sheet-card::before,
    #notes-overlay .sheet-card::before,
    #user-penalty-overlay .sheet-card::before {
      display: none;
    }

    /* Pairing holds at most a short code/role form or a single Unpair
       button - nowhere near enough content to earn the tall, bottom-
       anchored sheet chrome above (96vh cap, flat bottom edge, heavy
       sheet shadow). Small floating card instead, sized to its content and
       matching the same matte-card recipe as Home's tiles (bg-card, 1px
       border, no heavy shadow) rather than looking like a different kind
       of surface bolted onto the same overlay pattern. */
    #pairing-overlay .sheet-card {
      max-width: 360px;
      border-radius: 16px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-card);
      box-shadow: none;
      padding: 14px 16px 16px;
    }
    #pairing-overlay .sheet-card::before {
      display: none;
    }

    /* Theme/appearance picker is Appearance + a 3-wide palette row + a
       3-wide text-size row - short, fixed content like Pairing above, not
       the tall scrolling list the Rules/Scheduled/Library/Notes/Penalty
       group was built for. It used to share THAT group's flat-bottom,
       96vh-tall chrome, which looked clipped/unfinished floating centered
       on screen with room below it instead of actually reaching the
       viewport edge - flat bottom reads as "docked", and this never was.
       Pairing's small-floating-card shape instead (full round, matte, no
       heavy shadow), just wider for the 3-across swatch/size grids. */
    #theme-overlay .sheet-card {
      border-radius: 16px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-card);
      box-shadow: none;
    }
    #theme-overlay .sheet-card::before {
      display: none;
    }

    /* The post editor is now a full-screen .story-editor-overlay (copied
       structure, not a .sheet-card dialog) - it opens ON TOP of the
       profile view it was tapped from (a gallery tile is edited in place,
       not navigated away from), and both share that class's z-index 15,
       so this one needs to actually outrank it or it paints underneath
       instead of over it. See openProfilePostEditor in app.js for the
       matching setPageHiddenBehindOverlay call that hides the profile
       view's own content while this sits over it. */
    #profile-post-editor-overlay {
      z-index: 16;
    }

    #task-detail-overlay,
    #task-editor-overlay,
    #penalty-editor-overlay,
    #date-picker-overlay,
    #time-picker-overlay,
    #rules-overlay,
    #pairing-overlay,
    #theme-overlay,
    #scheduled-overlay,
    #library-overlay,
    #notes-overlay,
    #user-penalty-overlay,
    #coin-settings-overlay,
    #dice-settings-overlay,
    #wheel-settings-overlay {
      align-items: center;
    }

    #task-detail-overlay .sheet-card,
    #task-editor-overlay .sheet-card,
    #penalty-editor-overlay .sheet-card,
    #coin-settings-overlay .sheet-card,
    #dice-settings-overlay .sheet-card,
    #wheel-settings-overlay .sheet-card {
      border-radius: 16px;
      max-height: 80vh;
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9);
      border-bottom: 1px solid var(--border-subtle);
    }

    #task-detail-overlay .sheet-card::before,
    #task-editor-overlay .sheet-card::before,
    #penalty-editor-overlay .sheet-card::before,
    #coin-settings-overlay .sheet-card::before,
    #dice-settings-overlay .sheet-card::before,
    #wheel-settings-overlay .sheet-card::before {
      display: none;
    }

    #task-detail-overlay .sheet-card {
      max-height: 70vh;
    }

    #date-picker-overlay .sheet-card,
    #time-picker-overlay .sheet-card {
      border-radius: 16px;
      max-height: 70vh;
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9);
      border-bottom: 1px solid var(--border-subtle);
    }
    #date-picker-overlay .sheet-card::before,
    #time-picker-overlay .sheet-card::before { display: none; }

    #rules-overlay .sheet-card::before {
      display: none;
    }

    .task-detail-title {
      font-size: 13px;
      font-weight: 500;
      letter-spacing: 0.04em;
      text-transform: none;
      color: var(--text-subtle);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .task-detail-description {
      font-size: 13px;
      color: var(--text-subtle);
      white-space: pre-wrap;
      word-wrap: break-word;
      line-height: 1.4;
    }

    .task-detail-quantity {
      margin-top: 14px;
    }

    .task-detail-quantity .quantity-size-pill {
      font-size: 12px;
      padding: 6px 16px;
    }

    /* Picker button sizing */

    /* DATE PICKER: button same width as wheel, directly under it */
    #date-picker-overlay .sheet-body {
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    #date-picker-overlay #date-wheel {
      width: 120px;
      margin: 0 auto 8px;
    }

    #date-picker-overlay #date-picker-set {
      width: 120px;
      align-self: center;
      margin-top: 0;
    }

    /* TIME PICKER BUTTONS */

    #time-picker-overlay .sheet-body {
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    #time-picker-overlay .wheel-row {
      margin-bottom: 8px;
    }

    #time-picker-overlay .sheet-actions-row {
      width: 220px;
      display: flex;
      justify-content: center;
      gap: 6px;
      margin-top: 0;
    }

    #time-picker-overlay .sheet-actions-row .primary-btn,
    #time-picker-overlay .sheet-actions-row .secondary-btn {
      flex: 1;
      margin: 0;
      min-width: 0;
    }

    /* BRAND SIDE MENU */


    /* RULES SHEET */

    .rules-list {
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .rule-item {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      padding: 7px 10px;
      border-radius: 10px;
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      background: var(--bg-card);
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
      margin-bottom: 6px;
    }

    .rule-item-text {
      flex: 1;
      font-size: 13px;
      color: var(--text-main);
      line-height: 1.45;
      padding-top: 1px;
    }

    .rule-item-actions {
      display: flex;
      gap: 2px;
      flex-shrink: 0;
    }

    .rule-edit-btn, .rule-delete-btn {
      width: 20px;
      height: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
      border: none;
      background: none;
      font-size: 12px;
      cursor: pointer;
      color: var(--muted-softer);
      padding: 0;
    }

    .rule-delete-btn {
      color: var(--danger);
    }

    .rule-edit-btn svg,
    .rule-delete-btn svg {
      width: 14px;
      height: 14px;
    }

    .rule-add-new-btn {
      width: 100%;
      border-radius: 10px;
      border: 1px dashed var(--border-subtle);
      background: transparent;
      color: var(--muted);
      font-size: 12px;
      padding: 8px;
      cursor: pointer;
      margin-bottom: 8px;
    }

    .rules-agree-section {
      margin-top: 16px;
      padding-top: 14px;
      border-top: 1px solid rgba(var(--chrome-rgb), 0.08);
      text-align: center;
    }

    .rules-agree-caption {
      font-size: 11px;
      color: var(--muted);
      margin-bottom: 10px;
    }

    .mini-popup-overlay {
      position: fixed;
      inset: 0;
      /* Same flat scrim + blur as every other backdrop in the app now. */
      background: rgba(0, 0, 0, 0.82);
      backdrop-filter: blur(3px);
      -webkit-backdrop-filter: blur(3px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 30;
      padding: 20px;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity 0.16s ease-out, visibility 0s linear 0.16s;
    }

    .mini-popup-overlay.active {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transition: opacity 0.16s ease-out, visibility 0s linear 0s;
    }

    .mini-popup-card {
      width: 100%;
      max-width: 320px;
      background: var(--bg-sheet-solid);
      border-radius: 12px;
      padding: 10px;
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
      transform: scale(0.96);
      opacity: 0;
      transition: transform 0.18s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.16s ease-out;
    }

    .mini-popup-overlay.active .mini-popup-card {
      transform: scale(1);
      opacity: 1;
    }

    .mini-popup-textarea {
      width: 100%;
      background: var(--bg-elevated);
      border: 1px solid var(--border-subtle);
      border-radius: 10px;
      color: var(--text-main);
      font-size: 13px;
      padding: 8px 10px;
      resize: vertical;
      min-height: 90px;
      font-family: inherit;
      outline: none;
    }

    .mini-popup-textarea:focus {
      border-color: var(--border-accent-soft);
    }

    .mini-popup-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 8px;
    }

    /* Same 34px/10px-radius chip as every other icon button in the app
       (.chat-icon-btn/.story-editor-icon-btn) - the standard, applied here
       too instead of a bare colored glyph with no chip at all. */
    .mini-popup-btn {
      width: 34px;
      height: 34px;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
    }

    .mini-popup-btn svg {
      width: 18px;
      height: 18px;
    }

    .mini-popup-cancel {
      border-color: rgba(255, 75, 129, 0.4);
      background: var(--danger-soft);
      color: var(--danger);
    }

    .mini-popup-save {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    /* Room icon picker - a grid of the app's own monochrome stroke icons
       (ROOM_ICONS in app.js, same currentColor/viewBox convention as the
       top-of-file ICONS set), shown under the name field in the chat room
       create/rename popup. Tapping the active one again clears it back to
       the default speech-bubble glyph. */
    .icon-picker-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 6px;
      margin-top: 8px;
    }

    .icon-picker-btn {
      aspect-ratio: 1;
      border-radius: 10px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
    }

    .icon-picker-btn svg {
      width: 18px;
      height: 18px;
    }

    .icon-picker-btn.active {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    /* EMOJI PICKER */

    .emoji-toolbar-row {
      position: relative;
      display: flex;
      justify-content: flex-end;
      margin-bottom: 4px;
    }

    .emoji-tone-toggle-btn {
      width: 28px;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      background: transparent;
      border-radius: 8px;
      color: var(--muted);
      cursor: pointer;
      opacity: 0.7;
    }

    .emoji-tone-toggle-btn svg {
      width: 16px;
      height: 16px;
    }

    /* Pops out over the grid instead of pushing it down - absolutely
       positioned off .emoji-toolbar-row (not part of the normal flex flow
       any more), so opening/closing it never changes the picker's height.
       Own background/shadow since it's now floating over content rather
       than sitting flush as an inline row. */
    .emoji-tone-row {
      position: absolute;
      top: calc(100% + 4px);
      right: 0;
      z-index: 5;
      display: flex;
      gap: 8px;
      margin: 0;
      padding: 8px 10px;
      background: var(--bg-elevated);
      border: 1px solid var(--border-subtle);
      border-radius: 12px;
    }

    /* Squared-with-rounded-corners, matching the app's button shape
       language (.story-editor-icon-btn/.call-icon-btn etc.) instead of a
       full circle. min-height override required: the global
       `button { min-height: 36px; }` reset otherwise floors this at 36px
       tall while width stays 24px, rendering an oblong pill instead of a
       square (same issue .call-local-flip-btn's comment already covers). */
    .emoji-tone-swatch {
      width: 24px;
      height: 24px;
      min-height: 24px;
      border-radius: 8px;
      border: 2px solid transparent;
      background: #ffcc4d;
      padding: 0;
      cursor: pointer;
    }

    .emoji-tone-swatch.selected {
      border-color: var(--accent-stronger);
    }

    /* Recently-used emoji - a pinned row above the main grid so your last
       picks are reachable without switching category/tab at all. */
    .emoji-recent-row {
      display: flex;
      flex-wrap: wrap;
      gap: 2px;
      padding-bottom: 6px;
      margin-bottom: 6px;
      border-bottom: 1px solid var(--border-subtle);
    }

    .emoji-recent-row .emoji-picker-btn {
      flex: 0 0 auto;
    }

    /* Category tabs sit at the bottom of the picker, under the grid - more
       reachable with a thumb, and keeps the grid itself as the first thing
       you see rather than a row of tabs. */
    .emoji-picker-tabs {
      display: flex;
      gap: 2px;
      overflow-x: auto;
      padding-top: 6px;
      margin-top: 4px;
      border-top: 1px solid var(--border-subtle);
    }

    .emoji-picker-tab {
      flex: 0 0 auto;
      width: 34px;
      height: 34px;
      border: none;
      background: transparent;
      border-radius: 8px;
      font-size: 17px;
      cursor: pointer;
      opacity: 0.55;
    }

    .emoji-picker-tab.active {
      opacity: 1;
      background: var(--accent-soft);
    }

    .emoji-picker-grid {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 4px;
      max-height: 280px;
      overflow-y: auto;
    }

    .emoji-picker-btn {
      border: none;
      background: transparent;
      font-size: 20px;
      padding: 6px 0;
      border-radius: 8px;
      cursor: pointer;
    }

    .emoji-picker-btn:active {
      background: var(--accent-soft);
    }

    /* FULLSCREEN IMAGE VIEWER */

    /* Deliberately NOT the shared dialog scrim (.sheet-overlay/
       .mini-popup-overlay/etc - see the comment there) - like the story
       viewer and call screen, this is a full-screen takeover of a single
       photo, not a dialog floating over other content. A blurred,
       partially-see-through backdrop plus a padded, rounded-corner image
       read as "a popup showing a photo", the opposite of "fullscreen" -
       solid black, zero padding, square corners is what every real photo
       viewer (Photos, Instagram, WhatsApp) actually looks like. */
    .lightbox-overlay {
      position: fixed;
      inset: 0;
      background: #000;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 500;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.15s ease;
      /* Scrolling/paging a gallery post (wheel handler in app.js) was
         chaining past this overlay into the page body underneath once a
         post hit its scroll edge - on this app's PWA shell that read as
         "scrolling reloads the page". Containing it here stops that chain
         regardless of what's actually scrollable behind the overlay. */
      overscroll-behavior: contain;
    }

    .lightbox-overlay.active {
      opacity: 1;
      visibility: visible;
    }

    .lightbox-overlay img {
      max-width: 100%;
      max-height: 100%;
      cursor: zoom-out;
    }

    /* No cursor:zoom-out here - unlike the img rule above, a tap on this
       is a native <video controls> interaction (play/scrub/fullscreen),
       not "close the viewer" (see the stopPropagation wiring in app.js). */
    .lightbox-overlay video {
      max-width: 100%;
      max-height: 100%;
    }

    /* Gallery text post - same role as the img rule above (the thing being
       viewed, centered on the shared black backdrop) but it's a colored
       card, not a photo, so it gets an intrinsic size instead of scaling to
       fill - same square shape as its own gallery tile, just life-size.
       cursor:zoom-out matches the img rule for the same reason (tap closes). */
    /* overflow-y:auto (not align-items/justify-content centering, which
       clips the top of overflowing content in a centered flex container)
       lets a caption longer than the box can show scroll inside it -
       margin:auto on the span below still centers it when the text is
       short enough to fit. */
    .lightbox-text {
      width: min(84vw, 420px);
      aspect-ratio: 1 / 1;
      border-radius: 16px;
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      padding: 28px;
      box-sizing: border-box;
      cursor: zoom-out;
    }

    .lightbox-text span {
      margin: auto 0;
      font-size: 20px;
      line-height: 1.4;
      text-align: center;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .lightbox-caption {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      padding: 28px 20px 20px;
      background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
      color: #fff;
      font-size: 14px;
      line-height: 1.4;
      text-align: center;
      pointer-events: none;
    }

    /* Gallery post prev/next (see scheduleLightboxNavReveal in app.js) - an
       explicit tap alternative to wheel/swipe paging, left-center rather
       than stacked with the bottom caption gradient. .hidden (display:none)
       is set/cleared based on whether a gallery post list is even open at
       all (lightboxNavPosts); .lightbox-nav-visible is the separate fade-in
       toggled ~1.5s after the post settles - two different states because
       display:none can't transition, so going straight from "not in a
       gallery" to "visible" would skip the fade every time. */
    .lightbox-nav {
      position: absolute;
      left: 16px;
      top: 50%;
      transform: translateY(-50%);
      display: flex;
      flex-direction: column;
      gap: 14px;
      opacity: 0;
      transition: opacity 0.25s ease;
    }
    .lightbox-nav.lightbox-nav-visible {
      opacity: 1;
    }
    .lightbox-nav-btn {
      width: 40px;
      height: 40px;
      border-radius: var(--radius-btn);
      border: 1px solid rgba(255, 255, 255, 0.18);
      background: rgba(20, 20, 20, 0.55);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      padding: 0;
    }
    .lightbox-nav-btn:disabled {
      opacity: 0.3;
      cursor: default;
    }
    .lightbox-nav-btn svg {
      width: 20px;
      height: 20px;
    }

    /* Gallery post reactions (see renderLightboxReactions in app.js) -
       right-center rail, mirroring .lightbox-nav's left-center placement
       but always visible once a gallery post is open (no fade-in delay -
       unlike paging, there's no "first glance" reason to hide it a beat).
       Hidden outright (display:none via .hidden) for every other lightbox
       use (chat/room media, story photos), which never set lightboxNavPosts. */
    .lightbox-reactions {
      position: absolute;
      right: 16px;
      top: 50%;
      transform: translateY(-50%);
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .lightbox-reaction-btn {
      width: 40px;
      height: 40px;
      border-radius: var(--radius-btn);
      border: 1px solid rgba(255, 255, 255, 0.18);
      background: rgba(20, 20, 20, 0.55);
      color: #fff;
      font-size: 20px;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      padding: 0;
    }

    .lightbox-reaction-btn.mine {
      background: var(--accent-stronger);
      border-color: transparent;
    }

    .lightbox-reaction-more-btn {
      font-size: 20px;
      color: rgba(255, 255, 255, 0.75);
    }

    /* Aggregate chips (count + whether it's one of mine) for whatever's
       already been reacted with on this post - bottom-left, clear of the
       rail above and of .lightbox-nav's own left-center paging buttons.
       Reuses .msg-reaction-chip's shape (same tap-to-toggle chip chat
       messages already use) but needs its own color/background here since
       that one assumes a bubble's own light/dark theme background, not this
       viewer's permanent black backdrop. */
    .lightbox-reaction-summary {
      position: absolute;
      left: 16px;
      bottom: 20px;
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      max-width: 60vw;
    }

    .lightbox-reaction-chip {
      height: 24px;
      padding: 0 8px;
      font-size: 13px;
      color: #fff;
      background: rgba(20, 20, 20, 0.55);
      border-radius: 999px;
    }

    .lightbox-reaction-chip.mine {
      background: var(--accent-stronger);
    }

    /* On your own post this renders as a plain <span>, not a <button> (see
       renderLightboxReactions in app.js) - nothing to toggle there, just
       showing what your partner reacted with, so it shouldn't look
       clickable either. */
    .lightbox-reaction-chip:not(button) {
      cursor: default;
    }

    /* MESSAGE ACTION SHEET (and ROOM ACTION SHEET, which reuses
       .message-action-card/.message-action-list/.message-action-row-* -
       same small context-menu pattern, just without a reactions row). Both
       are .mini-popup-overlay/.mini-popup-card instances, but overridden
       here (compound selector beats the shared single-class rule) to drop
       that shared chrome's full-width card and fixed max-width - both read
       as a small floating menu, not a centered dialog, so the "card" should
       fit its contents instead of stretching to 320px. Only the message
       sheet also drops the scrim - the room sheet (rename/PIN/delete,
       actions on the room itself rather than one message) keeps it. */
    #message-action-overlay {
      background: transparent;
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
    }

    .mini-popup-card.message-action-card {
      width: auto;
      max-width: 260px;
      background: none;
      box-shadow: none;
      padding: 0;
    }

    /* Whisper themes re-style the shared .mini-popup-card elsewhere in this
       file (background + its own shadow token) at equal specificity to the
       rule above but later in source order, which would win the tie and
       quietly bring back the card chrome just removed. One extra class in
       the selector beats that regardless of order. */
    [data-theme^="whisper-"] .mini-popup-card.message-action-card {
      background: none;
      box-shadow: none;
    }

    .message-action-card {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    /* One rounded bar holding all the quick-reaction emoji plus a "more"
       button at the end - matches Signal's long-press reaction bar. Its own
       background, separate from .message-action-list below (no longer
       sharing one outer card with it). */
    .msg-action-reactions {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 2px;
      background: var(--bg-input);
      border-radius: 999px;
      padding: 6px 8px;
    }

    .msg-action-reaction-btn {
      flex: 1;
      border: none;
      background: transparent;
      border-radius: 999px;
      font-size: 20px;
      line-height: 1;
      padding: 4px 0;
      cursor: pointer;
    }

    .msg-action-reaction-btn.mine {
      background: var(--accent-soft);
    }

    .msg-action-more-btn {
      color: var(--muted);
      font-size: 16px;
    }

    /* Own background here now, sized to its own content (via
       .message-action-card's width:auto override above) rather than
       inheriting the shared .mini-popup-card box both this and
       .msg-action-reactions used to sit inside together. */
    .message-action-list {
      display: flex;
      flex-direction: column;
      gap: 2px;
      background: var(--bg-sheet-solid);
      border-radius: 12px;
      padding: 6px;
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    }

    .message-action-row-btn {
      display: flex;
      align-items: center;
      gap: 12px;
      width: 100%;
      text-align: left;
      border-radius: 10px;
      border: none;
      background: transparent;
      color: var(--text-main);
      font-size: 14px;
      padding: 10px 6px;
      cursor: pointer;
    }

    /* Plain stroke icons now (matches the rest of the app's icon language)
       instead of emoji glyphs - sized to the icon itself, no background
       chip, colour inherited via currentColor so .danger/.confirming below
       recolour it automatically along with the label. */
    .message-action-row-icon {
      width: 18px;
      height: 18px;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .message-action-row-icon svg {
      width: 100%;
      height: 100%;
    }

    .message-action-row-btn.danger {
      color: var(--danger);
    }

    .message-action-row-btn.danger.confirming {
      background: var(--danger);
      color: rgb(var(--chrome-rgb));
      border-radius: 10px;
    }

    /* AVATAR CROP */

    .avatar-crop-card {
      width: auto;
      max-width: none;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 14px;
    }

    /* Rounded-square, not a circle - matches the actual avatar ring shape
       (.identity-card-avi etc.) so the crop preview is a true WYSIWYG of
       what gets saved, not a differently-shaped mask. */
    .avatar-crop-viewport {
      position: relative;
      width: 240px;
      height: 240px;
      max-width: 100%;
      border-radius: 16px;
      overflow: hidden;
      background: #000;
      touch-action: none;
      cursor: grab;
    }

    .avatar-crop-viewport.dragging {
      cursor: grabbing;
    }

    /* Sized/positioned entirely via JS (initAvatarCropper()) to always
       cover the viewport, then panned by dragging - left/top driven
       directly, not through a transform, same pattern the call screen's
       draggable elements already use. */
    .avatar-crop-viewport img {
      position: absolute;
      top: 0;
      left: 0;
      max-width: none;
      pointer-events: none;
      -webkit-user-drag: none;
      user-select: none;
    }

    /* Native range input - respects platform conventions (works with touch
       drag, arrow keys, etc. for free) rather than a custom-built track. */
    .avatar-crop-zoom {
      width: 240px;
      max-width: 100%;
      accent-color: var(--accent-strong);
    }

    .avatar-crop-hint {
      font-size: 12px;
      color: var(--muted);
      text-align: center;
    }

    .avatar-crop-actions {
      display: flex;
      gap: 10px;
      width: 240px;
      max-width: 100%;
    }

    .avatar-crop-cancel-btn {
      flex: 1;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--text-main);
      padding: 7px 10px;
      font-size: 13px;
      cursor: pointer;
    }

    .avatar-crop-save-btn {
      flex: 1;
      width: auto;
      margin-top: 0;
    }

    .rules-empty {
      font-size: 12px;
      color: var(--muted);
      text-align: center;
      padding: 24px 0;
    }

    .rules-acknowledged-note {
      font-size: 11px;
      color: var(--muted);
      margin-top: 6px;
      text-align: right;
    }

    /* THEME PICKER */
    .theme-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      padding: 4px 0 8px;
    }

    .font-size-row {
      display: flex;
      gap: 8px;
      margin-top: 8px;
    }

    .font-size-btn {
      flex: 1;
      border-radius: 10px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--muted);
      padding: 10px 0;
      cursor: pointer;
      font-family: inherit;
    }

    .font-size-btn:nth-child(1) { font-size: 13px; }
    .font-size-btn:nth-child(2) { font-size: 16px; }
    .font-size-btn:nth-child(3) { font-size: 19px; }

    .font-size-btn.active {
      border-color: var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
    }

    /* PENALTY SYSTEM */

    .penalty-list {
      list-style: none;
      margin: 0;
      padding: 4px 0 8px;
    }
    .penalty-card {
      border-radius: 12px;
      border: 1px solid rgba(var(--danger-rgb), 0.15);
      background: var(--bg-card);
      padding: 8px 10px;
      margin-bottom: 8px;
      cursor: pointer;
      transition: border-color 0.12s;
    }
    .penalty-card:hover { border-color: rgba(var(--danger-rgb), 0.4); }
    .penalty-card-reason {
      font-size: 12px;
      font-weight: 500;
      color: var(--text-main);
      margin-bottom: 3px;
    }
    .penalty-card-desc {
      font-size: 11px;
      color: var(--text-subtle);
      margin-bottom: 4px;
    }
    .penalty-card-meta {
      font-size: 10px;
      color: var(--muted);
    }
    .penalty-card-bottom {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .penalty-completed-toggle {
      list-style: none;
      font-size: 11px;
      color: var(--muted);
      padding: 6px 4px;
      cursor: pointer;
      user-select: none;
    }
    .penalty-completed-toggle.expanded {
      color: var(--text-subtle);
    }
    .penalty-completed-list {
      list-style: none;
      margin: 0;
      padding: 0;
      opacity: 0.7;
    }
    .penalty-flags {
      margin-bottom: 10px;
    }
    .penalty-flag-card {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 8px 10px;
      border-radius: 10px;
      border: 1px solid rgba(var(--danger-rgb), 0.2);
      background: var(--danger-soft);
      margin-bottom: 6px;
      cursor: pointer;
    }
    .penalty-flag-card.selected {
      border-color: rgba(var(--danger-rgb), 0.6);
      background: rgba(var(--danger-rgb), 0.16);
    }
    .penalty-flag-card-text {
      font-size: 11px;
      color: var(--danger);
    }
    .penalty-flag-actions {
      display: flex;
      gap: 8px;
    }
    .penalty-flag-action-btn {
      flex: 1 1 auto;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-accent-soft);
      background: var(--accent-soft);
      color: var(--accent-stronger);
      font-size: 12px;
      padding: 8px;
      cursor: pointer;
    }
    .penalty-flag-action-btn.secondary {
      border-color: var(--border-subtle);
      background: transparent;
      color: var(--text-subtle);
    }
    .penalty-flag-action-btn:disabled {
      border-color: var(--border-subtle);
      background: transparent;
      color: var(--muted-softer);
      cursor: default;
    }

    /* partner-facing punishment row (read-only + acknowledge) */
    .user-penalty-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 10px 0;
      border-bottom: 1px solid rgba(var(--chrome-rgb),0.05);
    }
    .user-penalty-item:last-child { border-bottom: none; }
    .user-penalty-text { flex: 1; }
    .user-penalty-reason {
      font-size: 12px;
      font-weight: 500;
      color: var(--text-main);
      margin-bottom: 3px;
    }
    .user-penalty-desc {
      font-size: 11px;
      color: var(--text-subtle);
    }

    /* JOURNAL PROMPT */
    .journal-prompt-card {
      margin-bottom: 4px;
    }
    .journal-prompt-card-head {
      display: block;
      width: 100%;
      text-align: center;
      appearance: none;
      border: none;
      background: none;
      padding: 2px 0 6px;
      font-size: 10px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--muted-softer);
      cursor: pointer;
      user-select: none;
    }
    .journal-prompt-card.expanded .journal-prompt-card-head {
      color: var(--accent-strong);
    }
    .journal-prompt-card-body {
      padding: 0 0 10px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .journal-prompt-textarea {
      width: 100%;
      background: var(--bg-elevated);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      color: var(--text-main);
      font-size: 12px;
      padding: 7px 9px;
      font-family: inherit;
      resize: none;
      min-height: 60px;
      box-sizing: border-box;
    }
    .journal-prompt-textarea:focus {
      outline: none;
      border-color: var(--border-accent-soft);
    }
    .journal-prompt-save-btn {
      align-self: flex-end;
      font-size: 11px;
      color: var(--accent-strong);
      background: none;
      border: none;
      cursor: pointer;
      padding: 0;
      letter-spacing: 0.06em;
    }

    /* HEADER IDENTITY AVATAR */

    /* Same gem-ring recipe as .identity-avi (conic-gradient ring + radial
       inner fill via ::before) - the app's one signature button treatment,
       not a plain bordered icon button, since this now sits where the
       avatar used to and should read as part of the same family. */
    .app-header-call-btn {
      justify-self: end;
      position: relative;
      width: 36px;
      height: 36px;
      min-width: 36px;
      border-radius: 12px;
      background: var(--gem-conic);
      padding: 2px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      cursor: pointer;
      box-shadow: 0 0 0 1px rgba(var(--chrome-rgb), 0.09), 0 0 18px rgba(0, 0, 0, 0.75);
    }

    .app-header-call-btn::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 10px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
    }

    .app-header-call-btn svg {
      position: relative;
      z-index: 1;
      width: 16px;
      height: 16px;
      color: var(--accent-stronger);
    }

    .call-live-dot {
      display: none;
      position: absolute;
      bottom: -3px;
      right: -3px;
      width: 10px;
      height: 10px;
      border-radius: 999px;
      background: var(--success);
      border: 2px solid var(--bg-shell);
      z-index: 2;
    }

    .app-header-call-btn.in-call .call-live-dot {
      display: block;
    }

    /* HOME TASK-STATUS HUD - shares the call button's own header column
       (see app.html's own comment); never visible alongside it, since the
       call button already hides itself on Home. Same gem-ring recipe as
       the call button/avatar, just wide enough to also fit the "0/3"
       count next to the icon. */
    .home-tasks-hud-btn {
      justify-self: end;
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      height: 36px;
      min-width: 36px;
      padding: 2px 10px 2px 2px;
      border-radius: 12px;
      border: none;
      background: var(--gem-conic);
      cursor: pointer;
      box-shadow: 0 0 0 1px rgba(var(--chrome-rgb), 0.09), 0 0 18px rgba(0, 0, 0, 0.75);
    }
    .home-tasks-hud-btn::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 10px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
    }
    .home-tasks-hud-icon {
      position: relative;
      z-index: 1;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .home-tasks-hud-icon svg {
      width: 15px;
      height: 15px;
      color: var(--accent-stronger);
    }
    .home-tasks-hud-count {
      position: relative;
      z-index: 1;
      font-size: 12px;
      font-weight: 700;
      color: var(--accent-stronger);
      white-space: nowrap;
    }

    .identity-avi {
      justify-self: center;
      width: 36px;
      height: 36px;
      min-width: 36px;
      border-radius: 12px;
      --avi-inner-radius: 10px;
      background: var(--gem-conic);
      padding: 2px;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      cursor: pointer;
      box-shadow: 0 0 0 1px rgba(var(--chrome-rgb), 0.09), 0 0 18px rgba(0, 0, 0, 0.75);
    }
    .identity-avi::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 10px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
    }
    .identity-avi span#identity-avi-initials {
      position: relative;
      z-index: 1;
      font-size: 13px;
      font-weight: 700;
      color: var(--accent-stronger);
      letter-spacing: -0.02em;
    }
    .identity-avi-dot {
      position: absolute;
      bottom: -2px;
      right: -2px;
      width: 11px;
      height: 11px;
      border-radius: 999px;
      background: var(--bg-shell);
      border: 2px solid var(--bg-shell);
      z-index: 2;
    }
    .identity-avi-dot::after {
      content: "";
      display: block;
      width: 100%;
      height: 100%;
      border-radius: 999px;
      background: var(--muted-softer);
    }
    .identity-avi-dot.paired::after {
      background: var(--accent-strong);
      box-shadow: 0 0 4px var(--gem-glow);
    }

    /* PROFILE CARD (used by the full-screen profile view) */

    /* Centered hero layout (avatar/name/role/title/stat-chips stacked,
       not the old side-by-side avatar+text row) - position:relative so
       the edit/save/pairing control in the corner (see
       .identity-card-edit-btn below, reused for all three - pencil, tick,
       and link icon alike) can sit top-right of the whole card without
       disturbing the centered flow. */
    .identity-card-row {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      gap: 4px;
      margin-bottom: 6px;
    }
    /* Bigger than the header's own .identity-avi (this is the hero, not a
       nav icon) - same rounded-square ring/shape otherwise, incl. the
       crop tool's WYSIWYG match (see .avatar-crop-viewport's own comment).
       Always a real <button> now (view-only opens the lightbox, editable
       opens the file picker - see buildProfileCard in app.js), so the
       button resets live here unconditionally rather than only under
       .editable below. */
    .identity-card-avi {
      appearance: none;
      border: 0;
      font: inherit;
      color: inherit;
      cursor: pointer;
      width: 84px;
      height: 84px;
      min-width: 84px;
      border-radius: 24px;
      --avi-inner-radius: 22px;
      background: var(--gem-conic);
      padding: 2px;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 4px;
      box-shadow: 0 0 0 1px rgba(var(--chrome-rgb), 0.08), 0 4px 16px rgba(0, 0, 0, 0.6);
    }
    .identity-card-avi::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 22px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
    }
    .identity-card-avi span {
      position: relative;
      z-index: 1;
      font-size: 28px;
      font-weight: 700;
      color: var(--accent-stronger);
    }
    .identity-card-meta {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      min-width: 0;
    }
    .identity-card-name {
      font-size: 21px;
      font-weight: 700;
      color: var(--text-main);
    }
    .identity-card-name-input {
      display: block;
      width: 100%;
      max-width: 220px;
      margin: 0 auto;
      box-sizing: border-box;
      font: inherit;
      font-size: 18px;
      font-weight: 700;
      text-align: center;
      color: var(--text-main);
      background: var(--bg-deep);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      padding: 3px 7px;
    }
    .identity-card-name-input::placeholder {
      font-weight: 400;
      color: var(--muted-softer);
    }
    .identity-card-name-input:focus {
      outline: none;
      border-color: var(--border-accent-soft);
      box-shadow: 0 0 0 1px var(--border-accent-soft);
    }
    /* Title now takes the Dom/Sub role label's old spot directly under the
       name, and its theme-accent coloring (--accent-strong) along with it -
       the role itself is still tracked everywhere else (pairing, permission
       checks), it's just not worth repeating on your own card when every
       profile here already is one or the other. */
    .identity-card-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--accent-strong);
      margin-top: 2px;
    }
    .identity-card-title-input {
      display: block;
      width: 100%;
      max-width: 220px;
      margin: 4px auto 0;
      box-sizing: border-box;
      font: inherit;
      font-size: 13px;
      font-weight: 600;
      text-align: center;
      color: var(--accent-strong);
      background: var(--bg-deep);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      padding: 3px 7px;
    }
    /* Age/star-sign/birthday - each its own pill, same recipe as any other
       small info chip in this app (e.g. .pinned-strip-current): border +
       .bg-input, not a filled accent badge, so they read as info, not
       controls. */
    .identity-card-chips {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 6px;
      margin-top: 8px;
    }
    .identity-card-chip {
      flex: 0 0 auto;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      padding: 4px 12px;
      font-size: 11px;
      color: var(--muted);
      white-space: nowrap;
    }
    /* Editing swaps the 3 read-only chips above for this one real date
       input, styled as the same pill, in the same spot - so there's no
       separate "Date of birth" form field elsewhere on the card. */
    .identity-card-dob-input {
      font: inherit;
      font-size: 11px;
      color: var(--muted);
      cursor: pointer;
    }
    .identity-card-dob-input:focus {
      outline: none;
      border-color: var(--border-accent-soft);
    }
    .identity-card-title-input::placeholder {
      font-style: normal;
      color: var(--muted-softer);
    }
    .identity-card-title-input:focus {
      outline: none;
      border-color: var(--border-accent-soft);
      box-shadow: 0 0 0 1px var(--border-accent-soft);
    }
    /* Top-right corner of the card, not inline in the centered column -
       .identity-card-row is the positioning context (see its own comment).
       top is (avatar height - this button's own height) / 2 = (84-30)/2 =
       27px, so it sits level with the avatar's vertical midpoint instead
       of the row's bare top edge. */
    .identity-card-edit-btn {
      position: absolute;
      top: 27px;
      right: 0;
      flex-shrink: 0;
      width: 30px;
      height: 30px;
      min-height: 0;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-sheet);
      color: var(--muted);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
    }
    .identity-card-edit-btn svg {
      width: 14px;
      height: 14px;
    }
    /* Banner control - mirrors .identity-card-edit-btn's corner on the
       opposite (left) side of the card, same top/size, so it reads as a
       paired control rather than competing with the pencil/save/pairing
       icon for the same corner. Only ever rendered alongside the save tick
       (editable) - see buildProfileCard in app.js. */
    .identity-card-banner-btn {
      position: absolute;
      top: 27px;
      left: 0;
      flex-shrink: 0;
      width: 30px;
      height: 30px;
      min-height: 0;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-sheet);
      color: var(--muted);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
      z-index: 1;
    }
    .identity-card-banner-btn svg {
      width: 14px;
      height: 14px;
    }
    /* A plain full-width block, not positioned/offset at all - it's the
       first child of .profile-view-body (see openProfilePage in app.js),
       which has no padding of its own specifically so this can sit flush
       with the page edges with zero bleed trickery, and reach all the way
       up behind the now-floating .app-header (see
       .shell:has(#profile-view-overlay.active) .app-header.app-header-
       swap-open / .shell-main above) since body itself already starts
       there. An earlier version tried bleeding this past
       .profile-view-body's own padding with negative offsets instead -
       don't reintroduce that: .profile-view-body scrolls (overflow-y:auto),
       which forces overflow-x to compute as auto too (an explicit non-
       "visible" overflow-y makes a "visible" overflow-x resolve to "auto"
       instead, per spec), and an auto/hidden overflow box clips negative-
       offset content regardless of scroll position - the bleed was
       silently cut off on both axes. The avatar below (see
       .profile-view-inner's own comment) overlaps this element's bottom by
       63px via its own negative margin instead of this one reaching down
       into it, so this element's painting order (plain static flow, before
       everything else) is all that's needed to make it look like a
       backdrop - nothing here needs z-index or absolute positioning to
       paint behind the avatar. The bottom ~60% eases to fully transparent
       via mask rather than a hard edge, so it blends gradually into
       whatever's actually behind it (the overlay's own background is
       deliberately transparent - see .story-editor-overlay's comment - so
       this reveals .shell's real gradient, which already matches whichever
       theme is active instead of guessing a color that would only match
       one) - a short, sharp fade read as a clipped edge rather than a
       blend, so this starts easing well above the bottom instead of
       holding solid until the last few px. */
    /* No background-color while there's no photo (editing before anything's
       been uploaded still creates this element - see buildProfileCard in
       app.js - so the upload flow has something to paint into once a file
       is picked) - .identity-card-banner-btn already shows there's a slot
       to fill here, so a flat placeholder fill on top of that was just a
       second, redundant "something's here" signal, not information on its
       own. */
    .identity-card-banner {
      height: 125px;
      background-size: cover;
      background-position: center;
      mask-image: linear-gradient(to bottom, #000 0%, #000 40%, transparent 100%);
      -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 40%, transparent 100%);
    }
    .identity-invite-code {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 26px;
      letter-spacing: 0.14em;
      text-align: center;
      font-weight: 600;
      color: var(--accent-stronger);
      padding: 14px 44px;
      border-radius: 12px;
      background: var(--bg-deep);
      border: 1px solid var(--border-subtle);
      margin: 8px 0;
    }
    .identity-invite-regen {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      width: 28px;
      height: 28px;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-sheet);
      color: var(--muted);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
    }
    .identity-invite-regen svg {
      width: 14px;
      height: 14px;
    }
    .identity-join-row {
      display: flex;
      gap: 6px;
      margin-top: 8px;
    }
    .identity-join-row input {
      text-transform: uppercase;
      letter-spacing: 0.14em;
      text-align: center;
    }
    .identity-join-btn {
      flex-shrink: 0;
      width: 34px;
      height: 34px;
      min-height: 34px;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-accent-strong);
      background: radial-gradient(circle at top, var(--btn-primary-top), var(--btn-primary-bot));
      color: #fefbff;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
      box-shadow: var(--shadow-card);
    }
    .identity-join-btn svg {
      width: 16px;
      height: 16px;
    }
    .identity-inline-error {
      font-size: 12px;
      color: var(--danger);
      margin-top: 6px;
      min-height: 16px;
    }

    /* PROFILE FIELDS (used inside the identity sheet) */

    .profile-fields {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    /* Edit mode used to swap this for a labeled, boxed .profile-input - a
       real admin-style form field, which read as a separate settings
       screen bolted on under the card instead of "the bio, now editable".
       This is deliberately the opposite choice: same font/color/padding/
       border-bottom as the read-mode text directly below (border-color
       is the only inert-vs-editable tell), auto-growing with content via
       the input listener in makeProfileBioField rather than a fixed
       min-height box. */
    .profile-bio-input {
      display: block;
      width: 100%;
      box-sizing: border-box;
      font: inherit;
      font-size: 13px;
      color: var(--text-subtle);
      background: transparent;
      border: none;
      border-bottom: 1px solid var(--border-subtle);
      padding: 6px 0;
      resize: none;
      overflow: hidden;
    }
    .profile-bio-input::placeholder {
      color: var(--muted-softer);
    }
    .profile-bio-input:focus {
      outline: none;
      border-color: var(--border-accent-soft);
    }
    .profile-read-field {
      font-size: 13px;
      color: var(--text-subtle);
      padding: 6px 0;
      border-bottom: 1px solid var(--border-subtle);
    }
    .profile-empty {
      text-align: center;
      color: var(--muted);
      font-size: 12px;
      padding: 32px 0;
    }
    /* HOME PAGE - the app's front door (see renderHomePage() in app.js).
       Needs-attention/recent-activity rows reuse .chat-room-row wholesale
       (see that class's own comment on why - one shared "tap to open" list
       recipe), so only the hero and section wrappers need new rules here. */
    .home-hero {
      border-radius: 16px;
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      background: var(--bg-card);
      padding: 18px 14px 14px;
      margin-bottom: 14px;
      display: flex;
      flex-direction: column;
      align-items: stretch;
    }
    .home-hero-avatars {
      display: flex;
      align-items: flex-start;
      justify-content: center;
      gap: 14px;
    }
    .home-hero-person {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      min-width: 0;
      max-width: 120px;
    }
    .home-hero-avi {
      width: 64px;
      height: 64px;
      min-width: 64px;
      border-radius: 20px;
      --avi-inner-radius: 18px;
      background: var(--gem-conic);
      padding: 2px;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      cursor: pointer;
      box-shadow: 0 0 0 1px rgba(var(--chrome-rgb), 0.08), 0 4px 16px rgba(0, 0, 0, 0.6);
    }
    .home-hero-avi::before {
      content: "";
      position: absolute;
      inset: 2px;
      border-radius: 18px;
      background: radial-gradient(circle at top, var(--gem-inner-top) 0, var(--gem-inner-bot) 65%);
    }
    .home-hero-avi span {
      position: relative;
      z-index: 1;
      font-size: 22px;
      font-weight: 700;
      color: var(--accent-stronger);
    }
    /* Unpaired state: the partner slot stays visible (not hidden) as an
       empty "add partner" tap target, rather than disappearing entirely -
       muted so it reads as "nothing here yet", not a real photo/initials. */
    .home-hero-avi.placeholder {
      opacity: 0.5;
    }
    /* Instagram-style "unseen story" ring - see authorHasUnviewedActiveStory/
       renderHomeHero in app.js. A small gap (matching .home-hero's own
       background, not the page's) between the avatar and the ring itself,
       same as every status-ring convention, then the ring in the theme's
       own accent (not a fixed colour - this is meant to read as "yours",
       consistent with every other accent-coloured control) plus a soft
       glow. Replaces the base shadow rather than stacking onto it, so the
       ring reads as the one thing drawing the eye instead of competing
       with it. */
    .home-hero-avi.has-unviewed-story {
      box-shadow:
        0 0 0 3px var(--bg-card),
        0 0 0 5px var(--accent-strong),
        0 0 14px 2px var(--accent-strong);
    }
    .home-hero-avi.placeholder span {
      font-weight: 400;
      font-size: 24px;
    }
    .home-hero-name {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-main);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
    }
    /* A real button now (opens the icon picker - see renderHomeHero/
       openHomeIconPicker in app.js), so it needs its own chrome reset -
       same recipe as #brand-rail-toggle's. */
    .home-hero-together {
      appearance: none;
      border: 0;
      background: none;
      font: inherit;
      color: inherit;
      cursor: pointer;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      /* (avatar height 64 - icon height 26) / 2, so this sits level with
         the avatars' vertical center rather than their top edge. */
      padding-top: 19px;
      flex-shrink: 0;
    }
    /* Outline, not a solid-filled glyph - same stroke recipe as every
       other icon in the app. Sized up to actually read at a glance between
       two 64px avatars instead of disappearing as a tiny filled dot.
       Targets any svg renderHomeHero() drops in here (from ROOM_ICONS, per
       ME.home_icon) rather than a fixed class on one specific markup
       element, since which icon it is can change at runtime. */
    #home-hero-together svg {
      width: 26px;
      height: 26px;
      color: var(--accent-strong);
    }
    /* Icon-only now (see app.html) - centered, fixed-size squares, same
       shape/size tier as every other toolbar icon button, rather than a
       pair of full-width pill buttons with a text label each. */
    .home-hero-actions {
      display: flex;
      justify-content: center;
      gap: 18px;
      margin-top: 16px;
    }
    .home-action-btn {
      flex: 0 0 auto;
      width: 42px;
      height: 42px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: var(--radius-btn);
      border: 1px solid var(--border-subtle);
      background: var(--bg-input);
      color: var(--text-main);
      padding: 0;
      cursor: pointer;
    }
    .home-action-btn svg {
      width: 17px;
      height: 17px;
    }
    .home-hero-pair-cta {
      margin-top: 14px;
    }
    .home-hero-pair-cta .primary-btn {
      margin-top: 0;
    }
    /* "A NOTE FOR YOU" - see renderHomePartnerNote() in app.js. Quote marks
       are pure CSS (content on ::before/::after) rather than typed into the
       text itself, so the stored note stays plain text. Italic serif is a
       deliberate zero-dependency "fancier font" - no web-font load, just a
       style already available everywhere. */
    .home-partner-note {
      border-radius: 16px;
      background: var(--bg-card);
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      padding: 14px 16px 12px;
      margin-bottom: 14px;
    }
    .home-partner-note-head {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      font-weight: 600;
      color: var(--muted);
      margin-bottom: 8px;
    }
    .home-partner-note-head svg {
      width: 14px;
      height: 14px;
      color: var(--accent-strong);
      flex-shrink: 0;
    }
    .home-partner-note-text {
      font-family: Georgia, 'Times New Roman', serif;
      font-style: italic;
      font-size: 15px;
      line-height: 1.45;
      color: var(--text-main);
      white-space: pre-wrap;
      word-break: break-word;
    }
    .home-partner-note-text::before {
      content: "\201C";
    }
    .home-partner-note-text::after {
      content: "\201D";
    }
    /* Empty state (no note left yet - card stays visible either way, see
       renderHomePartnerNote()) - no quote marks around a plain prompt. */
    .home-partner-note-text.empty {
      color: var(--muted);
    }
    .home-partner-note-text.empty::before,
    .home-partner-note-text.empty::after {
      content: none;
    }
    .home-partner-note-foot {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 10px;
    }
    .home-partner-note-foot span {
      font-size: 11px;
      color: var(--muted-softer);
    }
    .home-partner-note-foot svg {
      width: 15px;
      height: 15px;
      color: var(--muted-softer);
      flex-shrink: 0;
    }
    .home-partner-note-readview {
      cursor: pointer;
    }
    /* The WYSIWYG edit field (see openNoteEditMode() in app.js) - same
       typography as .home-partner-note-text above so composing your own
       outgoing note reads as editing that exact spot in place, not a
       generic form field dropped into the card. */
    .home-partner-note-edit {
      display: block;
      width: 100%;
      font-family: Georgia, 'Times New Roman', serif;
      font-style: italic;
      font-size: 15px;
      line-height: 1.45;
      color: var(--text-main);
      background: transparent;
      border: none;
      outline: none;
      resize: none;
      padding: 0;
      min-height: 60px;
    }
    .home-partner-note-edit-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 10px;
    }

    .home-section {
      margin-bottom: 14px;
    }
    .home-activity-label {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted-softer);
      margin-bottom: 4px;
      padding: 0 2px;
    }
    .home-activity-conversation {
      border-radius: 14px;
      background: var(--bg-card);
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      padding: 8px 6px 4px;
      margin-bottom: 10px;
    }
    .home-activity-conversation .chat-room-row {
      margin-bottom: 0;
    }

    /* Shared swipe-carousel shell for both of Home's swipe surfaces (recent
       conversations, remaining-activity pages) - a plain horizontal
       scroll-snap strip, one full-width slide per child, native touch/
       trackpad swipe rather than a JS drag handler. Scrollbar hidden since
       the dot row below is the position indicator. See wireSwipeDots() in
       app.js for the dot-tracking half of this. */
    .home-swipe-track {
      display: flex;
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      scrollbar-width: none;
      -ms-overflow-style: none;
    }
    .home-swipe-track::-webkit-scrollbar {
      display: none;
    }
    .home-swipe-track > * {
      flex: 0 0 100%;
      min-width: 0;
      scroll-snap-align: start;
    }
    .home-swipe-dots {
      display: flex;
      justify-content: center;
      gap: 6px;
      padding: 6px 0 2px;
    }
    /* A plain <button> needs this app's standard chrome reset (same recipe
       as #brand-rail-toggle's) or the browser's native control shape -
       padding, min size, platform theming - shows through instead of the
       flat round dot the width/height/border-radius below actually ask
       for; appearance:none is the part that was missing here. */
    .home-swipe-dot {
      appearance: none;
      -webkit-appearance: none;
      display: block;
      box-sizing: border-box;
      width: 6px;
      height: 6px;
      min-width: 6px;
      min-height: 0;
      margin: 0;
      padding: 0;
      border: 0;
      border-radius: 999px;
      background: rgba(var(--chrome-rgb), 0.22);
      font: inherit;
      color: inherit;
      cursor: pointer;
      transition: background 0.15s ease-out, width 0.15s ease-out;
    }
    .home-swipe-dot.active {
      width: 16px;
      background: var(--accent-strong);
    }

    .home-activity-carousel {
      margin-bottom: 10px;
    }
    /* One page per swipe, a single row of up to 2 tiles - see
       renderHomeActivity() chunking tiles into these in app.js. */
    .home-activity-grid-page {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
      align-content: start;
    }
    .home-activity-tile {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 3px;
      text-align: left;
      border-radius: 14px;
      background: var(--bg-card);
      border: 1px solid rgba(var(--chrome-rgb), 0.05);
      padding: 12px 12px 13px;
      cursor: pointer;
      font-family: inherit;
      min-height: 0;
    }
    .home-activity-tile-header {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-main);
      margin-bottom: 2px;
    }
    .home-activity-tile-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 20px;
      height: 20px;
      min-width: 20px;
      border-radius: 7px;
      background: var(--accent-soft);
      color: var(--accent-strong);
    }
    .home-activity-tile-icon svg {
      position: relative;
      z-index: 1;
      width: 14px;
      height: 14px;
    }
    .home-activity-tile-main {
      font-size: 11px;
      font-weight: 400;
      color: var(--muted);
    }

    /* FROSTED MEDIA THUMBNAILS - any Home card/tile whose activity surfaced
       an actual photo (a chat room's last image message, a gallery post,
       partner's changed avatar, a story) gets a soft mini preview of it IN
       PLACE of its icon glyph (hidden below, not layered under it - a
       flat-colour icon sitting on top of the photo was hiding most of the
       already-tiny preview), via a --thumb-url custom property set inline
       by buildHomeRow()/buildHomeTile() in app.js. Deliberately light-touch
       now - blur down to 1.5px and tint down to 0.06 (was 5px/0.32, then
       4px/0.14) - the goal is "recognisably a photo at a glance", not an
       abstracted colour blob; too much of either flattened real test
       photos down to something indistinguishable from the plain icon tile
       this replaces. overflow:hidden + position:relative live on the base
       class itself (not a wrapper) so the ::before is clipped to this
       element's own border-radius regardless of which element ends up as
       its absolute-positioning ancestor. */
    :is(.chat-room-icon, .home-activity-tile-icon).has-photo {
      position: relative;
      overflow: hidden;
      background: var(--bg-input);
    }
    :is(.chat-room-icon, .home-activity-tile-icon).has-photo::before {
      content: "";
      position: absolute;
      inset: -10%;
      background-image: var(--thumb-url);
      background-size: cover;
      background-position: center;
      filter: blur(1.5px) saturate(1.15);
    }
    :is(.chat-room-icon, .home-activity-tile-icon).has-photo::after {
      content: "";
      position: absolute;
      inset: 0;
      background: rgba(var(--chrome-rgb), 0.06);
    }
    :is(.chat-room-icon, .home-activity-tile-icon).has-photo svg {
      display: none;
    }
    .side-menu-overlay {
      position: absolute;
      /* Starts past the rail's own 68px width (not inset:0) - .rail-overlay
         stays active underneath (see openBrandMenu()), so the rail icons
         render through here instead of this backdrop painting over them;
         the panel below then extends out from the rail rather than
         replacing it. Minus --shell-inset-x because THIS overlay's own
         containing block is .shell-main (a normal-flow child of .shell,
         inset by .shell's padding+border), while .rail-overlay is an
         absolutely-positioned child of .shell itself and ignores that
         inset entirely - without subtracting it back out, 68px here would
         land --shell-inset-x too far right of the rail's actual edge (see
         .shell's own comment on that variable, and #brand-menu-overlay's
         in app.html for why this lives in .shell-main at all instead of
         just moving it out next to .rail-overlay). */
      top: 0;
      right: 0;
      bottom: 0;
      left: calc(68px - var(--shell-inset-x));
      /* No background/blur of its own - .rail-overlay (always active
         underneath, see openBrandMenu()) already paints that same flat
         scrim + blur across the FULL viewport, rail strip included, so
         this stacking its own identical layer on top would just double
         the darkness/blur over the panel's portion instead of matching
         it. This element exists to position .side-menu and catch
         backdrop clicks past the rail, not to paint anything itself. */
      background: transparent;
      display: flex;
      align-items: stretch;
      justify-content: flex-start;
      padding: 0;
      z-index: 20;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity 0.2s ease-out, visibility 0s linear 0.2s;
    }

    .side-menu-overlay.active {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transition: opacity 0.2s ease-out, visibility 0s linear 0s;
    }

    .side-menu {
      /* Almost the full remaining width, leaving 60px of backdrop visible
         on the right rather than the old 70%/280px cap (which left a wide
         strip of backdrop beside a fairly narrow drawer). Not a plain
         "100% - 60px": .side-menu-overlay's own right:0 lands at
         .shell-main's right edge, which is itself already inset from
         .shell's TRUE right edge by --shell-inset-x (same padding/border
         inset .side-menu-overlay's left comment above works around) - that
         strip reads as backdrop too (.rail-overlay's blur ignores the
         padding and covers it same as everywhere else), so leaving it out
         of this calc would make the visible gap --shell-inset-x bigger
         than 60px. */
      width: calc(100% - 60px + var(--shell-inset-x));
      height: 100%;
      background: var(--bg-sheet-solid);
      border-radius: 0 18px 18px 0;
      border-right: 1px solid var(--border-subtle);
      /* Offset-x == blur radius, rather than the plain centered
         "0 0 40px" every other flyout/sheet uses - .side-menu paints on
         top of .rail (its own stacking context, via #brand-menu-overlay's
         z-index, ends up later than .rail-overlay's in the shared .shell
         stacking order - see #brand-menu-overlay's own comment in
         app.html), so a centered blur bled 40px of this shadow leftward
         directly onto the rail's own surface, visible as a dark smudge
         right where the two panels meet (it reads worse here than a normal
         floating sheet's shadow because the rail sits immediately flush
         against this left edge, not open backdrop). Shifting the shadow's
         virtual box fully past its own left edge before blurring it means
         none of it extends left of that edge at all, while the top/bottom/
         right glow (unaffected by a horizontal offset) looks the same as
         before. */
      box-shadow: 40px 0 40px rgba(0, 0, 0, 0.85);
      padding: 12px 12px 16px;
      display: flex;
      flex-direction: column;
      /* Reveals left-to-right via clip-path rather than physically sliding
         the whole box in with translateX. This panel paints above .rail
         (see the box-shadow comment just above), so a translateX slide -
         starting from fully off past the LEFT edge of the screen - swept
         this entire solid card across the rail's own column on its way to
         its resting position, visibly painting over the rail's icons/
         buttons/text for most of the animation instead of the two reading
         as separate layers the whole time. clip-path never moves the box
         itself (it stays at its final, already-flush position throughout)
         - it only grows how much of it is painted, so there's no instant
         where this card's content can render on top of the rail at all. */
      clip-path: inset(0 100% 0 0);
      transition: clip-path 0.22s ease-out;
    }

    .side-menu-overlay.active .side-menu {
      clip-path: inset(0 0 0 0);
    }

    .side-menu-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 8px;
    }

    .side-menu-title {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.14em;
      color: var(--muted);
    }

    /* No .side-menu-close rule here - the drawer's close button uses the
       shared .sheet-close-btn class (app.html) so it automatically picks
       up every theme override that class gets (e.g. the whisper themes'
       borderless tinted "round square" look - see their own :is(...) rule
       near the whisper overrides below), instead of needing its own copy
       kept in sync by hand. */

    .side-menu-body {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding-right: 2px;
      scrollbar-width: thin;
    }

    .side-menu-body::-webkit-scrollbar {
      width: 4px;
    }

    .side-menu-body::-webkit-scrollbar-thumb {
      background: var(--accent-muted);
      border-radius: 999px;
    }

    .side-menu-section-label {
      font-size: 10px;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--muted-softer);
      margin: 14px 2px 6px;
    }

    .side-menu-section-label:first-child {
      margin-top: 2px;
    }

    /* Grouped native-list style: one rounded card per section, flat rows
       divided by hairlines, rather than each item as its own floating pill. */
    .side-menu-group {
      border-radius: 14px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-card);
      overflow: hidden;
    }

    .side-menu-group-danger {
      margin-top: 18px;
    }

    .side-menu-item {
      width: 100%;
      text-align: left;
      border: none;
      border-bottom: 1px solid var(--border-subtle);
      background: none;
      color: var(--text-subtle);
      font-size: 13px;
      padding: 10px 12px;
      margin: 0;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .side-menu-item:last-child {
      border-bottom: none;
    }

    .side-menu-item:active {
      background: rgba(var(--chrome-rgb), 0.04);
    }

    .side-menu-icon {
      width: 20px;
      height: 20px;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--muted);
      opacity: 0.85;
    }

    .side-menu-icon svg {
      width: 18px;
      height: 18px;
    }

    .side-menu-item-label {
      flex: 1;
      min-width: 0;
      opacity: 0.9;
    }

    .side-menu-item.danger {
      color: var(--danger);
    }

    .side-menu-item.danger .side-menu-icon {
      color: var(--danger);
      opacity: 1;
    }

    .side-menu-footer {
      margin-top: 8px;
      font-size: 10px;
      color: var(--muted-softer);
    }

    /* GAMES */
    .game-settings-section { margin-bottom: 16px; }
    .game-settings-label {
      display: block;
      font-size: 11px;
      font-weight: 600;
      color: var(--muted-softer);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin-bottom: 6px;
    }
    #game-settings-coin-save-btn,
    #game-settings-dice-save-btn,
    #game-settings-wheel-save-btn { width: 100%; }

    .game-card {
      border-radius: 12px;
      border: 1px solid rgba(var(--chrome-rgb),0.05);
      background: var(--bg-card);
      box-shadow: 0 3px 8px rgba(0,0,0,0.45);
      margin-bottom: 10px;
      overflow: hidden;
      transition: border-color 0.2s ease;
    }
    .game-card.expanded {
      border-color: var(--border-accent-soft);
    }
    .game-card-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 12px;
      cursor: pointer;
      user-select: none;
    }
    .game-card-title {
      font-size: 13px;
      font-weight: 500;
      color: var(--text-main);
      display: flex;
      align-items: center;
      gap: 8px;
      transition: color 0.2s ease;
    }
    .game-card.expanded .game-card-title {
      color: var(--accent-stronger);
    }
    .game-card-icon {
      font-size: 15px;
      filter: drop-shadow(0 0 4px var(--gem-glow));
    }
    .game-card-chevron {
      font-size: 12px;
      color: var(--muted-softer);
      transition: transform 0.15s;
    }
    .game-card.expanded .game-card-chevron { transform: rotate(90deg); }
    .game-card-body {
      padding: 0 12px 12px;
      display: none;
    }
    .game-card.expanded .game-card-body { display: block; }

    /* COIN */
    .coin-wrap {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      padding: 8px 0;
      perspective: 500px;
    }
    .coin-btn {
      width: 110px;
      height: 110px;
      cursor: pointer;
      filter: drop-shadow(0 4px 14px rgba(0,0,0,0.6));
      transition: transform 0.1s;
      user-select: none;
    }
    .coin-btn:active { transform: scale(0.94); }
    .coin3d {
      position: relative;
      width: 100%;
      height: 100%;
      transform-style: preserve-3d;
      transition: transform 1.1s cubic-bezier(0.3, 0.9, 0.4, 1);
    }
    .coin-face {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
      -webkit-backface-visibility: hidden;
      user-select: none;
      -webkit-user-drag: none;
      pointer-events: none;
    }
    .coin-face-back { transform: rotateX(180deg); }
    .coin-result {
      font-size: 16px;
      font-weight: 600;
      color: var(--accent-stronger);
      min-height: 24px;
    }
    .coin-weight-row {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 4px;
    }
    .coin-weight-label {
      font-size: 10px;
      color: var(--muted-softer);
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }
    .coin-weight-input {
      flex: 1;
      accent-color: var(--accent-strong);
    }

    /* DICE */
    .dice-face-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
      margin-bottom: 10px;
    }
    .dice-face-row {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .dice-face-num {
      font-size: 11px;
      color: var(--muted);
      width: 16px;
      flex-shrink: 0;
    }
    .dice-face-input {
      flex: 1;
      background: var(--bg-elevated);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      color: var(--text-main);
      font-size: 12px;
      padding: 5px 8px;
      font-family: inherit;
    }
    .dice-face-input:focus { outline: none; border-color: var(--border-accent-soft); }
    .dice-stage {
      display: flex;
      justify-content: center;
      padding: 8px 0 4px;
    }
    .dice-die {
      width: 90px;
      height: 90px;
      filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5));
      user-select: none;
      -webkit-user-drag: none;
      pointer-events: none;
    }
    .dice-die.rolling { animation: diceRoll 0.9s cubic-bezier(0.3, 0.9, 0.4, 1); }
    @keyframes diceRoll {
      0%   { transform: rotate(0deg) scale(1); }
      20%  { transform: rotate(-18deg) scale(1.05); }
      40%  { transform: rotate(14deg) scale(0.98); }
      60%  { transform: rotate(-10deg) scale(1.04); }
      80%  { transform: rotate(6deg) scale(1); }
      100% { transform: rotate(0deg) scale(1); }
    }
    .dice-result {
      text-align: center;
      font-size: 13px;
      color: var(--accent-stronger);
      font-weight: 500;
      min-height: 20px;
      margin-bottom: 8px;
    }

    /* Tap-to-play surface shared by the dice/wheel stage - same affordance
       as .coin-btn (cursor + a slight press-down scale), replacing the
       separate Roll/Spin buttons that used to sit below each one. */
    .tappable { cursor: pointer; transition: transform 0.1s; user-select: none; }
    .tappable:active { transform: scale(0.96); }

    /* WHEEL */
    .wheel-canvas-wrap {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      margin-bottom: 10px;
    }
    /* wheel-ring.png's transparent inner hole is sized to exactly fit a
       184px circle at this 230px display size - see WHEEL_CANVAS_SIZE in
       app.js. Keep the two in sync if either image or size changes. */
    .wheel-stage {
      position: relative;
      width: 230px;
      height: 230px;
    }
    .wheel-canvas {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      border-radius: 50%;
    }
    .wheel-ring-img {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      user-select: none;
      -webkit-user-drag: none;
      pointer-events: none;
      z-index: 2;
    }
    .wheel-hub-img {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 68px;
      height: 68px;
      transform: translate(-50%, -50%);
      user-select: none;
      -webkit-user-drag: none;
      pointer-events: none;
      z-index: 3;
    }
    .wheel-pointer {
      position: absolute;
      top: 50%;
      right: -30px;
      width: auto;
      height: 26px;
      transform: translateY(-50%);
      filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
      user-select: none;
      -webkit-user-drag: none;
      pointer-events: none;
      z-index: 4;
    }
    .wheel-result {
      font-size: 13px;
      font-weight: 500;
      color: var(--accent-stronger);
      text-align: center;
      min-height: 20px;
    }
    .wheel-slot-list {
      display: flex;
      flex-direction: column;
      gap: 5px;
      margin-bottom: 8px;
    }
    .wheel-slot-row {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .wheel-slot-input {
      flex: 1;
      background: var(--bg-elevated);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      color: var(--text-main);
      font-size: 12px;
      padding: 5px 8px;
      font-family: inherit;
    }
    .wheel-slot-input:focus { outline: none; border-color: var(--border-accent-soft); }
    .wheel-slot-del {
      font-size: 14px;
      color: var(--danger);
      background: none;
      border: none;
      cursor: pointer;
      padding: 0 2px;
      flex-shrink: 0;
    }
    .wheel-add-btn {
      font-size: 11px;
      color: var(--accent-strong);
      background: none;
      border: none;
      cursor: pointer;
      padding: 0;
      margin-bottom: 8px;
    }


    /* TOAST NOTIFICATIONS - surfaces failures that used to only go to the
       console, which nobody but a developer would ever see. */
    .toast-container {
      position: absolute;
      left: 50%;
      bottom: max(70px, calc(70px + env(safe-area-inset-bottom)));
      transform: translateX(-50%);
      z-index: 50;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      width: calc(100% - 24px);
      max-width: 420px;
      pointer-events: none;
    }

    /* While the call screen is open (see showToast() in app.js), anchor
       near the top instead of the bottom - .call-controls-bar occupies the
       same bottom-of-viewport band the default position uses, so a
       reconnecting/unstable toast fired mid-call would otherwise land
       squeezed behind or under the mic/camera/hang-up buttons. Clears
       .call-topbar (back arrow + name/status, ~14px to ~70px tall). */
    .toast-container.toast-container-in-call {
      top: max(90px, calc(90px + env(safe-area-inset-top)));
      bottom: auto;
    }

    .toast {
      background: var(--bg-sheet-solid);
      border: 1px solid var(--border-subtle);
      border-radius: 12px;
      padding: 10px 14px;
      font-size: 12px;
      line-height: 1.4;
      color: var(--text-main);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
      display: flex;
      align-items: center;
      gap: 8px;
      opacity: 0;
      transform: translateY(8px) scale(0.98);
      transition: opacity 0.2s ease-out, transform 0.2s ease-out;
      pointer-events: auto;
      max-width: 100%;
    }

    .toast.show {
      opacity: 1;
      transform: translateY(0) scale(1);
    }

    .toast.error {
      border-color: rgba(255, 75, 129, 0.35);
    }

    .toast-icon {
      flex-shrink: 0;
      width: 16px;
      height: 16px;
      color: var(--danger);
    }

    .toast-text {
      flex: 1;
      min-width: 0;
    }

/* Composed appearance controls: style, lighting and palette. */
#theme-grid { display: flex; flex-direction: column; gap: 22px; }
.appearance-section { border: 0; padding: 0; margin: 0; min-width: 0; }
.appearance-section legend { padding: 0; color: var(--text-main); font-size: 14px; font-weight: 600; }
.appearance-hint { margin: 5px 0 12px; font-size: 12px; line-height: 1.5; color: var(--text-subtle); }
.appearance-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.appearance-palettes { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.appearance-option { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; border: 0; position: relative; border-radius: 12px; padding: 13px 12px; background: var(--bg-card); color: var(--text-main); font: inherit; font-size: 13px; min-width: 0; cursor: pointer; }
.appearance-option small { font-size: 11px; line-height: 1.5; color: var(--text-subtle); }
.appearance-option[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-stronger); }
.appearance-option:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 4px; }
.appearance-palettes .appearance-option { align-items: center; font-size: 11px; padding: 12px 4px; gap: 8px; }
.appearance-swatch { width: 26px; height: 26px; border-radius: 50%; display: block; }
.appearance-option[aria-pressed="true"] .appearance-swatch { outline: none; }






#theme-overlay .sheet-card { max-height: calc(100dvh - 32px); }
#theme-overlay .sheet-body { overflow-y: auto; min-height: 0; }

/* Whisper: shared materials and independent palette tokens. */
[data-theme^="whisper-charcoal"] {
  color-scheme: dark;
  --bg-root: #19191C;
  --bg-shell: #19191C;
  --bg-body-top: #19191C;
  --bg-shell-top: #19191C;
  --bg-card: #252529;
  --bg-elevated: #2B2A2E;
  --bg-elevated-soft: #252529;
  --bg-chip: #252529;
  --bg-deep: #202024;
  --bg-deep-98: #202024;
  --bg-sheet: #2B2A2E;
  --bg-sheet-solid: #2B2A2E;
  --bg-expanded-top: #252529;
  --bg-toggle: #202024;
  --bg-chip-dark: #252529;
  --bg-input: #202024;
  --text-main: #F0EDEF;
  --text-subtle: #A6A2A9;
  --muted: #A6A2A9;
  --muted-softer: #A6A2A9;
  --border-subtle: #353439;
  --border-strong: #353439;
  --chrome-rgb: 240, 237, 239;
  --shadow-card: none;
  --whisper-shadow: 0 8px 28px rgb(0 0 0 / 18%);
  --danger: #F3A2B5;
  --danger-soft: #443039;
  --success: #94B19E;
  --warning: #C9B18A;
}
[data-theme="whisper-charcoal-amethyst"], [data-theme="whisper-charcoal"] {
  --accent-strong: #AB94BE; --accent-stronger: #AE97C0; --accent-muted: #AB94BE;
  --accent-soft: #3D3444; --border-accent-soft: #353439; --border-accent-strong: #AE97C0;
  --whisper-secondary: #B8B3C7; --whisper-secondary-fill: #3D3A45; --whisper-secondary-ink: #BBB6C9;
}
[data-theme="whisper-charcoal-forest"] {
  --accent-strong: #93B29E; --accent-stronger: #95B4A0; --accent-muted: #93B29E;
  --accent-soft: #36443D; --border-accent-soft: #353439; --border-accent-strong: #95B4A0;
  --whisper-secondary: #BBC2A3; --whisper-secondary-fill: #444739; --whisper-secondary-ink: #BDC4A6;
}
[data-theme="whisper-charcoal-daydream"] {
  --accent-strong: #A2BDD8; --accent-stronger: #A2BDD8; --accent-muted: #A2BDD8;
  --accent-soft: #384452; --border-accent-soft: #353439; --border-accent-strong: #A2BDD8;
  --whisper-secondary: #C8A2BE; --whisper-secondary-fill: #493744; --whisper-secondary-ink: #CAA5C0;
}
[data-theme^="whisper-cloud"] {
  color-scheme: light;
  --bg-root: #DEDDDB;
  --bg-shell: #DEDDDB;
  --bg-body-top: #DEDDDB;
  --bg-shell-top: #DEDDDB;
  --bg-card: #FAF9F7;
  --bg-elevated: #E5E2E2;
  --bg-elevated-soft: #FAF9F7;
  --bg-chip: #FAF9F7;
  --bg-deep: #EAE7E5;
  --bg-deep-98: #EAE7E5;
  --bg-sheet: #E5E2E2;
  --bg-sheet-solid: #E5E2E2;
  --bg-expanded-top: #FAF9F7;
  --bg-toggle: #EAE7E5;
  --bg-chip-dark: #FAF9F7;
  --bg-input: #EAE7E5;
  --text-main: #38343A;
  --text-subtle: #827C83;
  --muted: #827C83;
  --muted-softer: #827C83;
  --border-subtle: #DDD9D8;
  --border-strong: #DDD9D8;
  --chrome-rgb: 56, 52, 58;
  --shadow-card: none;
  --whisper-shadow: 0 8px 28px rgb(0 0 0 / 9%);
  --danger: #98344D;
  --danger-soft: #F0DEDF;
  --success: #42684F;
  --warning: #765D32;
}
[data-theme="whisper-cloud-amethyst"], [data-theme="whisper-cloud"] {
  --accent-strong: #8C72A2; --accent-stronger: #473A52; --accent-muted: #8C72A2;
  --accent-soft: #BFAFCB; --border-accent-soft: #DDD9D8; --border-accent-strong: #473A52;
  --whisper-secondary: #8C859E; --whisper-secondary-fill: #CBC9CF; --whisper-secondary-ink: #423D4C;
  --whisper-selection-fill: var(--accent-soft); --whisper-selection-ink: var(--accent-stronger);
  --whisper-completion-fill: #B6A4C4;
}
[data-theme="whisper-cloud-forest"] {
  --accent-strong: #6D927D; --accent-stronger: #384B40; --accent-muted: #6D927D;
  --accent-soft: #ADC3B5; --border-accent-soft: #DDD9D8; --border-accent-strong: #384B40;
  --whisper-secondary: #818C61; --whisper-secondary-fill: #CED1C7; --whisper-secondary-ink: #4B5139;
  --whisper-selection-fill: var(--accent-soft); --whisper-selection-ink: var(--accent-stronger);
  --whisper-completion-fill: #A2BAAB;
}
[data-theme="whisper-cloud-daydream"] {
  --accent-strong: #7D9DBB; --accent-stronger: #3E4E5E; --accent-muted: #7D9DBB;
  --accent-soft: #B2C6D7; --border-accent-soft: #DDD9D8; --border-accent-strong: #3E4E5E;
  --whisper-secondary: #D886B2; --whisper-secondary-fill: #D9BFCD; --whisper-secondary-ink: #662347;
  --whisper-selection-fill: var(--accent-soft); --whisper-selection-ink: var(--accent-stronger);
  --whisper-completion-fill: #AABFD2;
}
[data-theme^="whisper-"] {
  --gem-conic: var(--accent-soft); --gem-inner-top: var(--accent-soft); --gem-inner-bot: var(--accent-soft);
  --gem-fill-from: var(--accent-stronger); --gem-fill-via: var(--accent-stronger); --gem-fill-to: var(--accent-stronger); --gem-fill-end: var(--accent-stronger);
  --gem-glow: transparent;
  --btn-primary-top: var(--accent-soft); --btn-primary-bot: var(--accent-soft);
  --btn-active-top: var(--accent-soft); --btn-active-bot: var(--accent-soft); --btn-active-border: var(--border-subtle);
}

/* Shared matte component treatment; media and call stages keep their scrims. */
[data-theme^="whisper-"],
[data-theme^="whisper-"] body { background: var(--bg-body-top); }
[data-theme^="whisper-"] .shell { box-shadow: none; }
[data-theme^="whisper-"] .rail { box-shadow: none; }
[data-theme^="whisper-"] .date-pill-dropdown { box-shadow: none; }
[data-theme^="whisper-"] .section { box-shadow: none; }
[data-theme^="whisper-"] .task-card { box-shadow: none; }
[data-theme^="whisper-"] .task-checkbox { box-shadow: none; }
[data-theme^="whisper-"] .task-checkbox::before { background: var(--gem-inner-top); box-shadow: none; }
[data-theme^="whisper-"] .task-checkbox-icon { background: var(--gem-fill-from); box-shadow: none; }
[data-theme^="whisper-"] .history-row.expanded { background: var(--bg-expanded-top); }
[data-theme^="whisper-"] .scheduled-task-row { box-shadow: none; }
[data-theme^="whisper-"] .scheduled-task-row:hover { background: var(--bg-expanded-top); }
[data-theme^="whisper-"] .scheduled-trigger { box-shadow: none; }
[data-theme^="whisper-"] .scheduled-trigger:hover { background: var(--bg-expanded-top); }
[data-theme^="whisper-"] .quantity-bar-track.complete { box-shadow: none; }
[data-theme^="whisper-"] .quantity-bar-fill { background: var(--gem-fill-from); box-shadow: none; }
[data-theme^="whisper-"] .task-type-toggle button.active { background: var(--btn-active-top); }
[data-theme^="whisper-"] .admin-tabs button.active { background: var(--btn-active-top); box-shadow: none; }
[data-theme^="whisper-"] .archive-badge { box-shadow: none; }
[data-theme^="whisper-"] .story-row-avi::before { background: var(--gem-inner-top); }
[data-theme^="whisper-"] .text-input:focus,
[data-theme^="whisper-"] .textarea-input:focus { box-shadow: none; }
[data-theme^="whisper-"] .primary-btn { background: var(--btn-primary-top); box-shadow: none; }
[data-theme^="whisper-"] .primary-btn:disabled { box-shadow: none; }
[data-theme^="whisper-"] .gem-fab { box-shadow: none; }
[data-theme^="whisper-"] .gem-fab::before { background: var(--gem-inner-top); box-shadow: none; }
[data-theme^="whisper-"] .sheet-card { box-shadow: none; }
[data-theme^="whisper-"] .task-row-compact { box-shadow: none; }
[data-theme^="whisper-"] #task-detail-overlay .sheet-card,
[data-theme^="whisper-"] #task-editor-overlay .sheet-card,
[data-theme^="whisper-"] #penalty-editor-overlay .sheet-card { box-shadow: none; }
[data-theme^="whisper-"] #date-picker-overlay .sheet-card,
[data-theme^="whisper-"] #time-picker-overlay .sheet-card { box-shadow: none; }
[data-theme^="whisper-"] .rule-item { box-shadow: none; }
[data-theme^="whisper-"] .mini-popup-card { box-shadow: none; }
[data-theme^="whisper-"] :is(.app-header-call-btn,.home-tasks-hud-btn)::before { background: var(--gem-inner-top); }
[data-theme^="whisper-"] .identity-avi { box-shadow: none; }
[data-theme^="whisper-"] .identity-avi::before { background: var(--gem-inner-top); }
[data-theme^="whisper-"] .identity-avi-dot.paired::after { box-shadow: none; }
[data-theme^="whisper-"] .identity-card-avi { box-shadow: none; }
[data-theme^="whisper-"] .identity-card-avi::before { background: var(--gem-inner-top); }
[data-theme^="whisper-"] .identity-join-btn { background: var(--btn-primary-top); box-shadow: none; }
[data-theme^="whisper-"] .side-menu { box-shadow: none; }
[data-theme^="whisper-"] .game-card { box-shadow: none; }
[data-theme^="whisper-"] .toast { box-shadow: none; }

[data-theme^="whisper-"] :is(.primary-btn,.identity-join-btn) { background: var(--accent-soft); color: var(--accent-stronger); border-color: var(--border-subtle); }
[data-theme^="whisper-"] :is(.rail-item.active,.weekday-pill.active) { background: var(--accent-soft); color: var(--accent-stronger); border-color: transparent; box-shadow: none; }
[data-theme^="whisper-"] .task-checkbox-icon { background: var(--gem-fill-from); box-shadow: none; }
[data-theme^="whisper-"] .task-checkbox { animation: none; border: 1px solid var(--accent-stronger); }
[data-theme^="whisper-"] .chat-msg-wrap.theirs .chat-msg:not(.emoji-only) { background: var(--bg-card); color: var(--text-main); border-color: var(--border-subtle); }
[data-theme^="whisper-"] .chat-msg-wrap.mine .chat-msg:not(.emoji-only) { background: var(--accent-soft); color: var(--text-main); border-color: var(--border-subtle); }
/* Charcoal's near-white --chrome-rgb at the shared .chat-msg-quote/
   .chat-story-reply-row recipe's 0.05 opacity reads almost flush against
   the solid accent-soft reply bubble sitting right below it (both land as
   similarly dark, low-contrast greys) - Cloud doesn't need this, its light
   --bg-card/accent-soft bubble already contrasts plenty against a dark-ink
   wash. A touch more opacity is enough to read as two distinct pieces.
   .pinned-strip-current deliberately reuses that same base 0.05 wash
   (see its own comment) so it needs the identical Charcoal boost to
   actually read as "the same color" there too, not just on Cloud. */
[data-theme^="whisper-charcoal"] :is(.chat-msg-quote, .chat-story-reply-row, .pinned-strip-current) { background: rgba(var(--chrome-rgb), 0.09); }
[data-theme^="whisper-"] :is(.sheet-card,.mini-popup,.side-menu,.brand-menu) { background: var(--bg-elevated); box-shadow: var(--whisper-shadow); }
[data-theme^="whisper-"] :is(.journal-textarea,.notes-textarea,.journal-prompt-textarea) { background: var(--bg-input); color: var(--text-main); }
[data-theme^="whisper-"] :is(input,textarea,select):focus-visible { outline: 1px solid var(--accent-stronger); outline-offset: 2px; }

[data-theme^="whisper-"] .appearance-hint { color: var(--text-main); opacity: .8; }
[data-theme^="whisper-"] .appearance-option small { color: var(--text-main); }
[data-theme^="whisper-"] :is(.journal-prompt-card-head,.history-journal-dot,.gem-fab-icon) { color: var(--whisper-secondary-ink); }
[data-theme^="whisper-"] .journal-prompt-card { background: var(--whisper-secondary-fill); }
[data-theme^="whisper-"] .identity-avi { background: var(--whisper-secondary); }
/* Keep the supplied secondary token; use a readable ink for small labels. */
[data-theme^="whisper-cloud"] { --whisper-reading-secondary: #676169; }
[data-theme^="whisper-charcoal"] { --whisper-reading-secondary: #B8B4BC; }
[data-theme^="whisper-"] :where(.rail-item) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.date-nav-arrow) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.date-nav-label) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.date-pill-option) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.date-pill-option-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.task-empty) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.task-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.task-note) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.history-penalty-status.done) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.history-row-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.scheduled-date-heading) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.scheduled-task-badge) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.scheduled-trigger-label) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.scheduled-trigger-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.quantity-edit-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.quantity-size-pill) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.task-type-toggle button) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.quantity-cap-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.archive-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.archive-actions button) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.admin-tabs button) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-date-sep span) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-msg-time) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.msg-hover-action-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.pinned-strip-current-sender) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.pinned-strip-current-text) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-msg-quote-text) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-reply-preview-text) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-room-lock-badge) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-room-row-preview) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-room-row-time) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-room-row-chevron) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-room-view-subtitle) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-room-switch-option) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-room-switch-option-lock) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.chat-icon-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.story-row-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.story-editor-icon-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.story-editor-expiry-label) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.story-editor-photo-picker) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.story-link-preview-desc) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.story-link-preview-domain) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.story-link-popup-status) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.field-label) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.text-input)::placeholder,
[data-theme^="whisper-"] :where(.textarea-input)::placeholder { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.weekday-pill) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.repeat-mode-label) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.secondary-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.sheet-title) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.sheet-close-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.picker-pill) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.picker-pill-muted) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.picker-pill-chevron) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.wheel-option) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.inline-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.inline-meta span + span)::before { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.pill-toggle-small) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.pill-toggle-small.missed) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.journal-textarea)::placeholder { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.notes-textarea)::placeholder { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.icon-action-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.task-detail-title) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.task-detail-description) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.rule-edit-btn),
[data-theme^="whisper-"] :where(.rule-delete-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.rule-add-new-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.rules-agree-caption) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.icon-picker-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.msg-action-more-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.rules-empty) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.rules-acknowledged-note) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.font-size-btn) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.penalty-card-desc) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.penalty-card-meta) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.penalty-completed-toggle) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.penalty-completed-toggle.expanded) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.penalty-flag-action-btn.secondary) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.penalty-flag-action-btn:disabled) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.user-penalty-desc) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.journal-prompt-card-head) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.identity-invite-regen) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.profile-bio-input) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.profile-read-field) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.profile-empty) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.side-menu-title) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.side-menu-section-label) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.side-menu-item) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.side-menu-icon) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.side-menu-footer) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.game-card-chevron) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.coin-weight-label) { color: var(--whisper-reading-secondary); }
[data-theme^="whisper-"] :where(.dice-face-num) { color: var(--whisper-reading-secondary); }

[data-theme^="whisper-"] :is(.task-type-toggle button.active,.admin-tabs button.active) { color: var(--accent-stronger); border-color: transparent; }
[data-theme^="whisper-"] .mini-popup-card { background: var(--bg-elevated); box-shadow: var(--whisper-shadow); }
[data-theme^="whisper-"] :is(#call-overlay,#story-viewer-overlay,#lightbox-overlay) {
  --chrome-rgb: 240, 237, 239; --text-main: #F0EDEF; --text-subtle: #A6A2A9; --muted: #A6A2A9; --muted-softer: #A6A2A9; --whisper-reading-secondary: #B8B4BC;
}
[data-theme^="whisper-"] .story-link-chip-remove { color: #F0EDEF; }

/* Idle date navigation stays readable; media auto-hide remains unchanged. */
[data-theme^="whisper-"] .date-nav-bar.idle { opacity: 1; }



/* Unified action and selection colours. Neutral labels never override states. */
.appearance-check { position: absolute; right: 10px; top: 9px; color: currentColor; font-size: 12px; }
#theme-grid .appearance-option { border: 0; box-shadow: none; }
#theme-grid .appearance-option:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 4px; }
#theme-grid .appearance-option[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-stronger); }
#theme-grid .appearance-option[aria-pressed="true"] small { color: inherit; }
#theme-grid .appearance-swatch { outline: none; box-shadow: none; }
[data-theme^="whisper-"] :is(.quantity-size-pill.active,.quantity-cap-btn.active,.pill-toggle-small.active,.picker-pin-btn.active,.wheel-option.active,.icon-picker-btn.active,.emoji-picker-tab.active,.font-size-btn.active,.chat-room-switch-option.active,.weekday-pill.active,.task-type-toggle button.active,.admin-tabs button.active,.rail-item.active) {
  background: var(--accent-soft); color: var(--accent-stronger); border-color: transparent; box-shadow: none;
}
[data-theme^="whisper-"] :is(.primary-btn,.identity-join-btn,.chat-send-btn,.story-editor-send-btn,.mini-popup-save,.icon-action-btn.save,.archive-actions button.primary,#home-call-btn,#home-story-btn) {
  background: var(--accent-soft); color: var(--accent-stronger); border-color: transparent; box-shadow: none;
}
[data-theme^="whisper-"] :is(.secondary-btn,.icon-action-btn.library,.journal-prompt-save-btn,#home-message-btn) {
  background: var(--whisper-secondary-fill); color: var(--whisper-secondary-ink); border-color: transparent; box-shadow: none;
}
/* Any paired/grouped toggle alternates primary, secondary, primary, secondary...
   by position - the first (and generic .active default above) stays primary,
   so only even positions need overriding here. Text/Photo use their own
   data-attribute instead of position since the two editors order them
   differently (post: Photo,Text - story: Text,Photo). Groups with many
   same-kind options (weekday-pill, emoji/icon pickers, quantity-size-pill,
   chat-room-switch-option's room list) aren't "paired" in this sense and are
   deliberately left out - alternating colour there would be arbitrary, not
   meaningful. */
[data-theme^="whisper-"] :is(
  #story-type-toggle button[data-story-type="photo"].active,
  #profile-post-type-toggle button[data-post-type="photo"].active,
  #task-type-toggle button:nth-of-type(2).active,
  #tasks-subtabs button:nth-of-type(2).active,
  #library-subtabs button:nth-of-type(2).active,
  #chat-room-media-tabs button:nth-of-type(2n).active,
  .role-pref-row .pill-toggle-small:nth-of-type(2).active
) {
  background: var(--whisper-secondary-fill); color: var(--whisper-secondary-ink);
}
/* Same alternation, applied to the home activity feed's tile icons (not a
   toggle - just a fixed-order list of distinct cards - so every even tile
   gets the secondary colour instead of only the active one). */
[data-theme^="whisper-"] .home-activity-grid-page .home-activity-tile:nth-child(2n) .home-activity-tile-icon {
  color: var(--whisper-secondary);
  background: var(--whisper-secondary-fill);
}
[data-theme^="whisper-"] :is(.chat-icon-btn:not(.chat-send-btn),.sheet-close-btn,.icon-action-btn:where(:not(.save):not(.library):not(.danger))) { background: var(--bg-card); color: var(--accent-stronger); border-color: transparent; }
[data-theme^="whisper-"] :is(.gem-fab,.app-header-call-btn,.home-tasks-hud-btn) { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
[data-theme^="whisper-"] :is(.gem-fab,.app-header-call-btn,.home-tasks-hud-btn)::before { background: var(--accent-soft); border: 0; box-shadow: none; }
[data-theme^="whisper-"] .gem-fab-icon { color: var(--accent-stronger); }
[data-theme^="whisper-"] .mini-popup-textarea { background: var(--bg-input); }
[data-theme^="whisper-"] .game-card.expanded .game-card-head { background: var(--accent-soft); }
[data-theme^="whisper-"] :is(.game-card.expanded .game-card-title,.game-card.expanded .game-card-chevron) { color: var(--accent-stronger); }
[data-theme^="whisper-cloud"] { --danger-ink: #F0EDEF; }
[data-theme^="whisper-charcoal"] { --danger-ink: #19191C; }
[data-theme^="whisper-"] :is(.icon-action-btn.danger.confirming,.message-action-row-btn.danger.confirming) { color: var(--danger-ink); }

/* Text-size controls belong to the same outline-free picker. */
#theme-overlay :is(.font-size-btn,.sheet-close-btn) { border: 0; box-shadow: none; }
#theme-overlay .font-size-btn:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 4px; }
#theme-overlay .sheet-close-btn:focus-visible { outline: none; background: var(--accent-soft); color: var(--accent-stronger); }


/* Profile view - full-screen (see #profile-view-overlay in app.html), so
   unlike the old dialog this needs no fixed card height of its own; it
   just scrolls inside whatever space is left under the topbar. Deliberately
   no padding of its own (unlike most scrolling sheet bodies in this app) -
   overflow-y:auto here forces overflow-x to compute as auto too (an
   explicit non-"visible" overflow-y makes a "visible" overflow-x resolve to
   "auto" instead, per spec), so padding here would clip .identity-card-
   banner's full-bleed edges instead of letting it reach them - see that
   rule's own comment. .profile-view-inner below carries the padding
   everything else needs instead. No scrollbar-gutter:stable either (unlike
   most other scrolling sheets in this app) - it reserves a permanent strip
   on one side for a scrollbar whether or not one is actually showing,
   which ate into .identity-card-banner's full-bleed width by that same
   amount every time, defeating the point of full-bleed. */
.profile-view-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* Carries the padding .profile-view-body itself can't (see its own comment)
   for everything except the banner - .identity-card-banner is the only
   direct child of body that comes before this. 54px base margin-top keeps
   the avatar/pencil clear of the now-floating back button even with no
   banner in the DOM at all (view mode, nothing set - see buildProfileCard
   in app.js) - .identity-card-banner is absent entirely then, so there's
   nothing to overlap and this is the only clearance there is, and nothing
   overrides the header's own normal solid background either (see the
   has-image-scoped scrim rule) - so anything short of the header's real
   bottom edge (measured 48px at the base/mobile breakpoint) renders
   partly behind solid, opaque chrome, not just unscrimmed. 54px clears
   that with a few px to spare for font-size settings nudging the header
   a little taller. The :has() rule below replaces it with the banner-
   overlap value instead, once there's actually a banner to overlap -
   that one already clears this with room to spare (62px). */
.profile-view-inner { padding: 0 16px 24px; margin-top: 54px; }

/* Only when .identity-card-banner actually exists (editing always renders
   one, even unset - see buildProfileCard). Pulls this wrapper up to
   overlap the banner's bottom by exactly 63px - the same constant
   .identity-card-banner's own comment derives (three-quarters of
   .identity-card-avi's 84px height stays over the banner, the bottom
   quarter overhangs past it) - rather than pushing the banner down to meet
   a fixed-position wrapper, since the banner's own height is otherwise
   free to change without this needing to track it. With the banner's own
   125px height this lands the avatar at 62px of clearance - more than the
   42px the base rule above guarantees for the no-banner case, which is
   fine, that 42px is only ever a minimum (enough to clear the back
   button), not a target this needs to land on exactly. */
.profile-view-body:has(.identity-card-banner) .profile-view-inner {
  margin-top: -63px;
}

/* PROFILE GALLERY - 6 fixed slots (see renderProfileGallery in app.js), a
   "pick your best" space rather than an open-ended feed. Square tiles,
   3 per row (wraps to two rows) - no carousel yet, each slot is a single
   photo + caption. */
.profile-gallery-section {
  margin-top: 20px;
}
.profile-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.profile-gallery-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
/* cover, not contain - a portrait photo in a square tile used to
   letterbox with blank bars on both sides to show the whole frame. This
   is a thumbnail, not the photo itself (tap always opens the real
   uncropped image via openLightbox - see renderProfileGallery), so an
   edge-to-edge crop here costs nothing. */
.profile-gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Room media gallery video tile (see renderRoomMediaPhotos in app.js) - no
   `controls` (too small to scrub at thumbnail size), just the browser's
   automatic poster frame once metadata loads, same crop as the img rule
   above plus the play badge below. */
.profile-gallery-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.chat-media-play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
/* Same rounded-square family as .call-icon-btn (36px, 12px corners, matte
   #2a2a2e fill, opaque white icon) rather than a bare drop-shadowed glyph
   floating over the thumbnail - reads as an actual button, and the solid
   fill can't bleed/wash out depending on what's in the poster frame behind
   it the way a translucent one would. */
.chat-media-play-badge-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #2a2a2e;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-media-play-badge-icon svg {
  width: 17px;
  height: 17px;
  color: #fff;
}
/* Text-kind post - same idea as .story-row-preview's text snippet, just
   sized for a full tile instead of a 46x62 sidebar thumbnail. */
.profile-gallery-tile-text {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
}
.profile-gallery-tile-text span {
  font-size: 12px;
  line-height: 1.35;
  color: #1a1a1a;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}
/* .gem-fab-wrap's own align-self:flex-end only does anything inside a flex
   parent (the full-height page column it's normally used in, e.g. Stories)
   - this section is just one block among others on the profile page, so
   it needs its own alignment instead. */
/* PROFILE POST EDITOR */
.identity-card-avi.editable::after { content: "+"; position: absolute; bottom: -4px; right: -4px; z-index: 3; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-stronger); font: 20px/26px system-ui; text-align: center; }
.identity-card-avi:focus-visible { outline: 2px solid var(--accent-stronger); outline-offset: 3px; }
/* Flush with the ring's own padding (2px) - the photo still shows its full
   intended crop, nothing trimmed off by the box itself. The "set into the
   ring" look comes from the inset box-shadow instead: a shadow drawn just
   inside the photo's own edge doesn't shrink its box or eat into the
   image, unlike inset/width/height would.
   border-radius uses --avi-inner-radius (set per avatar type alongside its
   own outer border-radius, 2px smaller to match the ::before inner face
   this sits over), NOT `inherit` - inherit pulls the OUTER ring's radius
   from the actual DOM parent, which is too gentle a curve for this
   smaller, 2px-inset box, leaving a small triangular gap in each corner
   where the curve doesn't reach the box's own corner. */
.avatar-photo { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); border-radius: var(--avi-inner-radius, inherit); object-fit: cover; z-index: 1; pointer-events: none; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.35); }
.identity-card-avi.has-avatar > span,
.identity-avi.has-avatar > #identity-avi-initials { opacity: 0; }
.identity-photo-status { color: var(--text-subtle); font-size: 12px; line-height: 1.4; }
.identity-photo-status:empty { display: none; }

/* Story author images use the same saved avatar and initials fallback. */
.story-row-avi.has-avatar > span { opacity: 0; }

/* Theme-coloured navigation glyph, with no Gem frame or open-state fill. */
#brand-rail-toggle { appearance: none; border: 0; padding: 0; min-height: 36px; background: none; box-shadow: none; font: inherit; color: inherit; text-align: left; }
.rail-menu-icon { width: 24px; height: 24px; flex-shrink: 0; color: var(--accent-stronger); }
#brand-rail-toggle:focus-visible { outline: none; }
#brand-rail-toggle:focus-visible .brand-text-main { text-decoration: underline; text-underline-offset: 4px; }

/* History date pills keep their fills without the dark shadow behind them. */
#admin-tab-history .history-row,
#admin-tab-history .history-row.expanded { box-shadow: none; }

/* A little richer colour and a restrained glow only on filled controls. */
[data-theme^="whisper-"] { --whisper-control-glow: color-mix(in srgb, var(--accent-strong) 28%, transparent); --whisper-done-fill: color-mix(in srgb, var(--accent-soft) 78%, var(--accent-strong)); --completion-fill: var(--whisper-done-fill); }
[data-theme^="whisper-"] .task-checkbox { padding: 0; background: var(--accent-soft); border-color: var(--accent-strong); }
[data-theme^="whisper-"] .task-checkbox::before { inset: 0; border: 0; border-radius: 5px; background: var(--bg-card); box-shadow: inset 0 1px 2px rgb(0 0 0 / 14%), inset 0 0 0 1px color-mix(in srgb, var(--accent-strong) 22%, transparent); }
[data-theme^="whisper-"] .task-checkbox-icon { inset: 1px; border-radius: 4px; background: var(--whisper-done-fill); box-shadow: none; }
[data-theme^="whisper-"] .task-checkbox.checked .task-checkbox-icon { transform: none; }
[data-theme^="whisper-"] .task-checkbox.checked { border-color: color-mix(in srgb, var(--accent-strong) 48%, var(--border-subtle)); box-shadow: 0 0 2px 0 color-mix(in srgb, var(--accent-strong) 20%, transparent); }
[data-theme^="whisper-"] .quantity-bar-fill { background: var(--whisper-done-fill); box-shadow: 0 0 5px var(--whisper-control-glow); }
[data-theme^="whisper-"] .quantity-bar-track.complete { box-shadow: 0 0 5px var(--whisper-control-glow); }
[data-theme^="whisper-"] .quantity-bar-label { color: var(--text-main); text-shadow: none; }

/* Cloud richness belongs to shared palette tokens, across every screen. */
[data-theme^="whisper-cloud"] { --whisper-done-fill: var(--whisper-completion-fill); }
[data-theme^="whisper-cloud"] :is(.admin-tabs button,.font-size-btn) { color: var(--text-main); font-weight: 500; }
[data-theme^="whisper-cloud"] .admin-tabs button { font-size: 12px; }
[data-theme^="whisper-cloud"] :is(.primary-btn,.chat-send-btn,.story-editor-send-btn,.admin-tabs button.active) { font-weight: 600; }

/* Every Whisper palette is a dual palette: primary/communication colour, secondary/personal colour.
   Semantic status and destructive controls retain their dedicated colours. */
[data-theme^="whisper-"] :is(.chat-icon-btn:not(.chat-send-btn),.secondary-btn,.icon-action-btn.library,.journal-prompt-save-btn,.story-editor-cycle-btn,.quantity-size-pill.active,.weekday-pill.active,.date-pill-option.active) {
  background: var(--whisper-secondary-fill); color: var(--whisper-secondary-ink); border-color: transparent;
}
[data-theme^="whisper-"] :is(.rail-item[data-rail-page="journal"].active,.rail-item[data-rail-page="notes"].active,.rail-item[data-rail-page="rules"].active) {
  background: var(--whisper-secondary-fill); color: var(--whisper-secondary-ink);
}
[data-theme^="whisper-"] #theme-grid .appearance-section:nth-of-type(2) .appearance-option[aria-pressed="true"] {
  background: var(--whisper-secondary-fill); color: var(--whisper-secondary-ink);
}
[data-theme^="whisper-"] :is(.identity-avi,.identity-card-avi,.story-row-avi) { background: var(--whisper-secondary); }
[data-theme^="whisper-"] :is(.identity-avi,.identity-card-avi,.story-row-avi)::before { background: var(--whisper-secondary-fill); }
[data-theme^="whisper-"] :is(.identity-card-avi span,.story-row-avi span) { color: var(--whisper-secondary-ink); }
[data-theme^="whisper-"] .identity-avi #identity-avi-initials { color: var(--whisper-secondary-ink); }

[data-theme^="whisper-"] .identity-card-avi.editable::after { background: var(--whisper-secondary-fill); color: var(--whisper-secondary-ink); }

/* Soft circular confirmation for tasks and rituals (including history).
   Theme-driven, not the fixed slate-grey these used to be - and matches
   the exact recipe every other "selected" control in the app already uses
   (.admin-tabs button.active, .rail-item.active, etc.) rather than a new
   value of its own: Gem's radial-gradient btn-active-top/bot pair + its
   #fefbff text colour by default, overridden below for Whisper themes to
   their flatter accent-soft fill + accent-stronger text, same as
   .admin-tabs button.active's own whisper override does. Outline reuses
   the existing soft-accent-border token (no direct "active button"
   equivalent for an unchecked resting state to mirror here). */
:root { --completion-outline: var(--border-accent-soft); --completion-fill: radial-gradient(circle at top, var(--btn-active-top), var(--btn-active-bot)); --completion-border: var(--btn-active-border); --completion-check: #fefbff; }
[data-theme^="whisper-"] { --completion-fill: var(--accent-soft); --completion-border: transparent; --completion-check: var(--accent-stronger); }
.task-checkbox.completion-control {
  width: 44px; height: 44px; min-height: 44px; flex-shrink: 0;
  padding: 0; border: 0; border-radius: 50%; background: transparent;
  box-shadow: none; animation: none;
}
.task-checkbox.completion-control::before {
  inset: 10px; border-radius: 50%; border: 1px solid var(--completion-outline);
  background: transparent; box-shadow: none;
  transition: background-color 180ms ease, border-color 180ms ease;
}
.task-checkbox.completion-control.checked { border: 0; box-shadow: none; }
.task-checkbox.completion-control.checked::before { background: var(--completion-fill); border-color: var(--completion-border); }
.task-checkbox.completion-control .task-checkbox-icon {
  inset: auto; width: 9px; height: 5px; margin-top: -3px;
  border: solid var(--completion-check); border-width: 0 0 2px 2px;
  border-radius: 0; background: transparent; box-shadow: none;
  transform: rotate(-45deg) scale(.8); opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}
.task-checkbox.completion-control.checked .task-checkbox-icon { opacity: 1; transform: rotate(-45deg) scale(1); }
.task-checkbox.completion-control:focus-visible {
  outline: 2px solid var(--completion-outline); outline-offset: 2px;
}
.task-checkbox.completion-control:disabled { cursor: default; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .task-checkbox.completion-control, .task-checkbox.completion-control::before,
  .task-checkbox.completion-control .task-checkbox-icon { transition: none; transform: none; }
  .task-checkbox.completion-control .task-checkbox-icon,
  .task-checkbox.completion-control.checked .task-checkbox-icon { transform: rotate(-45deg); }
  .task-card.card-pulse { animation: none; }
}
