:root {
    /* Theme 1: Telegram-inspired blue charcoal, intentionally not Telegram's
       own hex values. The extra luminance keeps analytics surfaces legible. */
    --bg-primary: #18232e;
    --bg-secondary: #222e3a;
    --bg-tertiary: #304050;
    --text-primary: #f3f6f8;
    --text-secondary: #aebbc7;
    /* Aliases, resolved on :root so they pick up each theme's values. Rules and
       inline styles ask for these names; without a definition the colour is
       invalid at computed-value time and silently falls back to the inherited
       colour, which does not follow the theme. */
    --text-muted: var(--text-secondary);
    --primary-color: var(--accent-color);
    --accent-light: var(--accent-color);
    /* Undefined, these made background invalid at computed-value time, which
       resolves to transparent: .detail-avatar lost its circle entirely and
       showed a white letter on the pane. */
    --accent-gradient: var(--accent-color);
    --accent-soft: color-mix(in srgb, var(--accent-color) 12%, transparent);
    --accent-color: #3f8df5;
    --accent-hover: #64a5ff;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --warning-color: #fbbf24;
    --border-color: #3a4a5b;
    /* The global neutral-hover standard's border/highlight colour: a step
       up from --border-color (so hover still reads as "interactive", not
       identical to the resting border) but dimmer than --text-secondary
       used on its own, which read as too bright/high-contrast for a border
       against this dark a background. Derived rather than a fourth flat hex
       per theme: it recomputes correctly under every [data-theme] block
       below since both inputs already do, without duplicating a value in
       each one. */
    --border-hover: color-mix(in srgb, var(--border-color), var(--text-secondary));
    /* Default corner radius: reach for this on any new rectangular control
       (button, pill, card, input, dropdown) unless it has a specific reason
       not to: a capsule/pill shape some other control in the app already
       established (the message composer, status badges), a circular avatar,
       or a brand mark that must stay pixel-exact. "Looks nicer more rounded"
       is not a reason on its own: see the Tasks/Progress/Cost pills this
       replaced a 999px capsule on, where full rounding read as less
       professional/more toy-like than a plain 6px corner. */
    --radius: 6px;
    --modal-radius: 12px;
    --msg-bg-me: #2b4054;
    --msg-bg-other: #202c38;
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --pop-green: #10b981;
    --me-accent: #f59e0b;
    /* Same values as design-system.css's --ds-motion-fast/--ds-ease: this
       page doesn't consume that file's tokens (separate system, see that
       file's Overview section), but the popover motion standard documented
       there (/design-system#popovers) should still look identical here. */
    --motion-fast: 120ms;
    /* For size/position changes that move a lot of pixels (a modal growing
       as its content loads, say). --motion-fast is tuned for small
       state flips: on a 200px+ height jump it reads as a snap rather than
       a movement, which is exactly the thing the animation is there to
       smooth over. */
    --motion-med: 220ms;
    --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Global scrollbar: thin, rounded, theme-colored, instead of the OS
   default. Uses the same --bg-tertiary/--text-secondary/--border-color
   tokens as everything else, so it follows whichever of the 7 themes
   (see the [data-theme] blocks below) is active rather than being pinned
   to one look. Firefox (scrollbar-color/-width) and Chromium/Safari
   (::-webkit-scrollbar) both covered: there's no unprefixed standard yet
   that works everywhere this app runs as a PWA.

   Auto-hide: the thumb is transparent at rest and only drawn while the
   element carries .scrolling-active (toggled by the capture-phase scroll
   listener in chat-kit.js) or is :hover/:focus-within, so it doesn't sit on
   screen as chrome when nothing is actually being scrolled, but is still
   reachable by mouse without scrolling first.

   scrollbar-gutter:stable (added next to every overflow-y/-x/overflow:
   auto|scroll declaration in this file, not here on `*`) reserves that
   space UNCONDITIONALLY: without it, a container's available width
   silently shifts by the scrollbar's own width the moment its content
   crosses from "fits" to "needs to scroll" (or back), since the space
   for the bar is only there when a scrollbar is actually drawn. A
   dialog.app-modal sliding open is the case that actually surfaced this:
   content finishing its async load could tip it into needing to scroll
   mid-animation, so the centered .modal-container inside it would
   visibly drift sideways by half that width in the same moment it was
   already sliding up - two different motions reading as one janky one.
   NOT on this `*` rule: tried that first, and it was wrong - the CSS
   spec has `scrollbar-gutter` apply to any element whose overflow isn't
   `visible`, which includes plain `overflow:hidden` (a value that can
   never actually show a scrollbar at all). Every `overflow:hidden`
   ancestor in this app's layout chain (body, the shell, the pane
   wrappers) started reserving dead space it would never use, and since
   several of those wrap each other, the waste compounded on its way
   down to a ~50px gap by the time it reached the actual chat pane -
   worse than the jitter it was meant to fix. Scoped to genuinely
   auto/scroll elements instead, it costs nothing on unrelated
   overflow:hidden boxes while still covering every real scroll
   container, not just the one modal that surfaced the bug. */
* {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

*:hover,
*:focus-within,
*.scrolling-active {
    scrollbar-color: var(--bg-tertiary) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background-color var(--motion-fast) var(--motion-ease);
}

:hover::-webkit-scrollbar-thumb,
:focus-within::-webkit-scrollbar-thumb,
.scrolling-active::-webkit-scrollbar-thumb {
    background-color: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* ONE global focus ring, not a per-component list. The browser's default
   outline-color is `currentcolor`, and this app paints text
   var(--text-primary) - a near-white on every dark theme - so ANY
   focusable element without its own rule draws a bright white ring that
   belongs to no theme. Patching that class by class never converges:
   .icon-btn, .btn and .form-select each got their own fix and the pills,
   theme swatches, and every future control still came out white. Setting
   it once here, at the lowest possible specificity, covers all of them
   and leaves any component free to override with a plain class selector.
   :focus-visible, not :focus - keyboard navigation gets the ring, a mouse
   click doesn't get one it never asked for. */
:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}
/* Containers that only ever take focus programmatically. showModal() falls
   back to focusing the <dialog> itself when nothing inside is autofocusable,
   and a ring drawn around an entire sheet points at nothing the user can
   act on - it just reads as the modal being outlined. */
dialog:focus-visible,
dialog:focus,
.modal-container:focus-visible,
.modal-container:focus {
    outline: none;
}

/* ---- Selectable themes (switched via [data-theme] on <html>) ----
   The default theme is :root above. Each block below overrides the tokens.
   Theme choice is stored per-origin in localStorage, so dev and prod
   installs keep independent themes. */

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --success-color: #16a34a;
    --border-color: #cbd5e1;
    --msg-bg-me: #3b82f6;
    --msg-bg-other: #e2e8f0;
    --pop-green: #10b981;
    --me-accent: #d97706;
}

[data-theme="emerald"] {
    --bg-primary: #0b1f1a;
    --bg-secondary: #12302a;
    --bg-tertiary: #1c4339;
    --text-primary: #ecfdf5;
    --text-secondary: #9cc9b6;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --border-color: #1c4339;
    --msg-bg-me: #10b981;
    --msg-bg-other: #12302a;
    --pop-green: #10b981;
    --me-accent: #f59e0b;
}

[data-theme="violet"] {
    --bg-primary: #160f24;
    --bg-secondary: #241a38;
    --bg-tertiary: #352a52;
    --text-primary: #f5f3ff;
    --text-secondary: #b8a9d9;
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --border-color: #352a52;
    --msg-bg-me: #8b5cf6;
    --msg-bg-other: #241a38;
    --pop-green: #10b981;
    --me-accent: #f59e0b;
}

[data-theme="amber"] {
    --bg-primary: #1f1403;
    --bg-secondary: #3a2606;
    --bg-tertiary: #52380c;
    --text-primary: #fffbeb;
    --text-secondary: #e0c89a;
    --accent-color: #f59e0b;
    --accent-hover: #d97706;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --border-color: #52380c;
    --msg-bg-me: #f59e0b;
    --msg-bg-other: #3a2606;
    --pop-green: #10b981;
    --me-accent: #f59e0b;
}

[data-theme="crimson"] {
    --bg-primary: #220a0e;
    --bg-secondary: #3a1118;
    --bg-tertiary: #521922;
    --text-primary: #fff1f2;
    --text-secondary: #e3a9b3;
    --accent-color: #f43f5e;
    --accent-hover: #e11d48;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --border-color: #521922;
    --msg-bg-me: #f43f5e;
    --msg-bg-other: #3a1118;
    --pop-green: #10b981;
    --me-accent: #f59e0b;
}

[data-theme="ocean"] {
    --bg-primary: #08192b;
    --bg-secondary: #0e2a44;
    --bg-tertiary: #143b5e;
    --text-primary: #f0f9ff;
    --text-secondary: #9bc4e0;
    --accent-color: #06b6d4;
    --accent-hover: #0891b2;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --border-color: #143b5e;
    --msg-bg-me: #06b6d4;
    --msg-bg-other: #0e2a44;
    --pop-green: #10b981;
    --me-accent: #f59e0b;
}

/* Theme picker swatches (Account tab, the one place these live now: see
   the HTML comment on .sidebar-nav-popover for why a second copy used to
   sit there too). Each button is a small card: a rounded-rectangle
   two-tone preview (background + accent, see the HTML comment on
   #theme-picker) with the theme's name underneath, rather than a bare
   color circle that only ever showed the accent and needed a hover
   tooltip to say which theme it even was. */
.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 64px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}

.theme-swatch-preview {
    width: 100%;
    height: 40px;
    box-sizing: border-box;
    border-radius: 10px;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px var(--border-color);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 6px;
    transition: transform 0.1s ease;
}

.theme-swatch-accent {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

.theme-swatch-name {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.theme-swatch:hover .theme-swatch-preview,
.theme-swatch:active .theme-swatch-preview {
    transform: scale(1.05);
}

.theme-swatch.active .theme-swatch-preview {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.theme-swatch.active .theme-swatch-name {
    color: var(--text-primary);
    font-weight: 600;
}

* {
    box-sizing: border-box;
    /* Chrome/Safari's own default tap feedback: a solid rectangle sized to
       the element's full bounding box, ignoring whatever border-radius it
       actually has. Every icon button in this app already has its own
       deliberate pressed/hover treatment (.icon-btn:hover, :active below),
       so left on, this flashed as a mismatched square box over an
       otherwise-circular button on every single tap - the exact "shape
       doesn't look right" moment the design already accounted for
       everywhere else, just not this one. */
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    height: 100%;
    overflow: hidden;
}

#app {
    height: 100%;
    width: 100%;
    background: var(--bg-secondary);

    /* Center on Desktop */
    display: grid;
    place-items: center;
}

/* Views Container - Mobile First: Full width/height */
/* Desktop: Centered card or split view */
.view {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);

    display: grid;
    grid-template-rows: auto 1fr auto;
    /* Header, Content, Footer */
    overflow: hidden;

    /* Transitions handled by JS class toggling, but we can add grid transition if needed */
}

/* Desktop Responsiveness */
@media (min-width: 768px) {
    #app {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    /* Only login view gets centered card treatment */
    #view-login {
        max-width: 480px;
        max-height: 900px;
        border-radius: 20px;
        box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
        border: 1px solid var(--border-color);
        margin: auto;
    }

    /* Main shell fills entire screen */
    #view-main-shell {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }
}

/* header, pills row, chat content filling the rest. #mobile-chat-search-home
   used to add a 4th direct child here (the relocated search bar's own row
   below .mobile-explore-row) needing a 4th "auto" track - now that the
   search bar relocates INSIDE .chat-header instead (see the HTML comment
   on #mobile-chat-search-home and the .chat-search-active rules in this
   file), #view-conversation is back to its original 3 direct children and
   doesn't need that track anymore. Leaving it in would silently cost
   #mobile-tab-chat its 1fr sizing again the same way it did before -
   see this repo's history for that bug if this ever needs re-deriving. */
#view-conversation {
    grid-template-rows: auto auto 1fr;
}

/* Mobile: project list -> conversation reads as a push (same idea as
   .side-panel's mobile full-screen mode / .pane-view-slide): the incoming
   screen slides in from the right over the outgoing one instead of an
   instant display:none/block swap. #view-main-shell stays mounted and
   visible underneath for the duration (the :has() override below lifts its
   own .hidden, which showView() always sets while conversation is the
   active view) so there's something to see through the transition rather
   than a blank frame. Desktop is untouched: .view still swaps via the
   plain .hidden{display:none} rule there. */
@media (max-width: 767px) {
    #view-conversation {
        position: fixed;
        inset: 0;
        z-index: 50;
        transform: translateX(100%);
        transition: transform var(--motion-med) var(--motion-ease);
    }
    #view-conversation.hidden {
        display: grid !important;
        transform: translateX(100%);
        pointer-events: none;
    }
    #view-conversation:not(.hidden) {
        transform: translateX(0);
    }
    #view-main-shell.hidden:has(~ #view-conversation:not(.hidden)) {
        display: grid !important;
    }
    @media (prefers-reduced-motion: reduce) {
        #view-conversation {
            transition: none;
        }
    }
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-color), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.version-tag {
    font-size: 0.4em;
    opacity: 0.5;
    font-weight: 500;
    margin-left: 8px;
    vertical-align: middle;
    -webkit-text-fill-color: var(--text-secondary);
    /* Override gradient for version */
}

.hidden {
    display: none !important;
}

/* Login View */
#view-login {
    grid-template-rows: 1fr;
    /* Center content */
    place-items: center;
}

.login-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Common Header Grid */
.app-header,
.chat-header {
    height: 60px;
    padding: 0 20px;
    /* Was a hardcoded slate rgba(), which stayed dark in every theme and left
       the title/buttons on top of it unreadable in the light one. */
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;

    display: grid;
    align-items: center;
}

.transparent-header {
    background: transparent;
    border: none;
    position: absolute;
    top: 0;
    width: 100%;
    backdrop-filter: none;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.chat-header {
    grid-template-columns: auto 1fr auto;
    /* Back ... Title/Status ... Invite */
    gap: 15px;
}

.chat-title {
    /* .chat-header is actually display:flex (a later rule at ~line 3612
       overrides the display:grid declared just above), so this fills the
       row the same way .chat-header-text already does for its own text:
       flex:1 + min-width:0 to grow into all the space between back-btn and
       invite-btn, height:100% to claim the header's full (definite) 60px
       so clicking anywhere in that band opens the modal, not just the text. */
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    height: 100%;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius);
}

.chat-title:hover {
    background: var(--hover-bg, rgba(0, 0, 0, 0.04));
}

.chat-title h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.chat-title .status {
    font-size: 12px;
    color: var(--success-color);
}

.chat-header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Plain descriptive text (a member/thread count), never independently
   clickable anywhere it's used: it always sits inside a larger clickable
   block (#project-header-text-btn, a panel header) that already owns the
   click and its own hover feedback. A hyperlink-style underline+dim on just
   this one line used to suggest it was its own, more specific link: two
   different affordances reading as one control, when hovering "4 members"
   did exactly the same thing as hovering "Intuise web" beside it. */
.chat-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    min-height: 13px;
    line-height: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.role-owner {
    background: #9333ea;
    color: white;
}

.role-admin {
    background: #2563eb;
    color: white;
}

/* Inline role picker in the project members list (admins only). Same
   reasoning as select.input-field above: a native <select> arrow is the one
   piece of un-styled browser chrome left next to the role badge it sits
   beside, which otherwise reads as fully custom. */
.member-role-select {
    appearance: none;
    -webkit-appearance: none;
    font-size: 11px;
    padding: 3px 22px 3px 6px;
    border-radius: 6px;
    background-color: var(--bg-tertiary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9L12 15L18 9' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 12px;
    color: var(--text-primary);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    cursor: pointer;
}

.member-role-select:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Remove-from-project button in the members list (admins only). */
.member-kick-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px 7px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1;
}

.member-kick-btn:hover {
    background: rgba(239, 68, 68, 0.12);
}


/* Scrollable Data Lists */
.scroll-content {
    overflow-y: auto;
    scrollbar-gutter: stable;
    /* Grid layout for list items if needed, or just block */
    display: flex;
    /* Flex is still good for vertical lists, but let's stick to user request if strictly grid */
    flex-direction: column;
}

.messages-scroll {
    flex: 1;
    min-height: 0;
}

/* Chat List: grouping, item grid, avatar palette */

/* Static single group today (see renderProjectList): a stand-in for a real
   client/internal/prospect category, built collapsible so more groups is a
   rendering change, not a markup one. */
.project-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px 8px;
    cursor: pointer;
    user-select: none;
}

.project-group-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.project-group-chevron {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.project-group.collapsed .project-group-chevron {
    transform: rotate(-90deg);
}

.project-group.collapsed .project-group-body {
    display: none;
}

/* Project Item & Avatar Styles */
/* Margin/padding/radius live here now, unconditionally: the same values
   for every row in every state: rather than only appearing on
   :hover/.active. Adding margin ONLY on hover used to shift that row's
   neighbours in the document flow (margin isn't paint, it's layout): the
   whole list visibly jumped by a few px every time the pointer entered or
   left a row, and again on select. A constant gap can't shift anything,
   since it's already accounted for before any state changes. This also
   means no divider is needed any more: the permanent gap plus each row's
   own rounded corners already separate them, Telegram/Discord/Slack-style,
   so there's nothing for a hairline to still be doing. */
.project-item {
    padding: 12px;
    margin: 2px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
}

/* filterProjectList (app.js) toggles this per-row rather than re-rendering
   the list, so scroll position and active-project state survive typing. */
.project-item.search-hidden {
    display: none;
}

/* Neutral fill only: same reasoning as the explore-pill/pane-resizer
   fixes: no accent-coloured border/outline for "you're about to open this"
   or "this is open", just a plain rounded highlight. .active is declared
   after :hover so it wins if the pointer happens to be sitting on the
   already-active row. */
.project-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.project-item.active {
    background: var(--bg-tertiary);
}

.avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Compact variant for tight rows (company switcher pill): same palette
   classes, just smaller. */
.avatar.avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    font-size: 0.7rem;
    box-shadow: none;
}

/* Deterministic blue-family palette (see getAvatarColorClass) so avatars read
   as distinct without a per-project color in the data model. */
.avatar.avatar-c1 { background: #3b82f6; }
.avatar.avatar-c2 { background: #2563eb; }
.avatar.avatar-c3 { background: #1d4ed8; }
.avatar.avatar-c4 { background: #0ea5e9; }
.avatar.avatar-c5 { background: #6366f1; }
.avatar.avatar-c6 { background: #0284c7; }

.chat-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-row-top {
    display: flex;
    align-items: center;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-last-msg {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lock-badge {
    font-size: 0.75em;
    color: var(--text-secondary);
}

/* Right-hand column: timestamp above, unread badge below: mirrors the
   name/preview column at a glance without needing its own width. */
.chat-meta-col {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    align-self: stretch;
    justify-content: space-between;
    padding: 1px 0;
}

.chat-timestamp {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Cost/schedule health chips shown in place of the last message when a project
   has valid EVM data. */
.chat-evm {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

/* Why CPI/SPI isn't shown: incomplete task data, or no tasks yet. */
.chat-evm-note {
    font-size: 0.8rem;
    color: #f59e0b;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-evm-note.muted {
    color: var(--text-secondary);
}

.evm-chip {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.evm-chip.evm-ok {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.evm-chip.evm-warn {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.evm-chip.evm-bad {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Unread message count on a project row. */
.unread-badge {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent-color, #3b82f6);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
}

.chat-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}


/* Messages Container */
.messages-scroll {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--bg-primary);
}

/* The outer scroll element: stays full pane width and owns overflow-y:auto
   (see .messages-scroll), so its scrollbar sits at the pane's actual right
   edge. The width cap lives one level deeper on .messages-inner instead of
   here: putting max-width on the SAME element as overflow-y:auto made the
   scrollbar hug the capped column's edge rather than the pane's, floating
   it in the middle of the screen on a wide pane: wrong, and not what any
   reference chat app does. */
#messages-container,
#project-messages-container {
    display: flex;
    flex-direction: column;
    /* NOTE: this does NOT give you a floating overlay. An absolutely-
       positioned child of an overflow:auto element resolves its offsets
       against the scrolled content box, so `bottom: 0` here means "the end
       of all the messages" and the child scrolls away with them: which is
       exactly how the scroll-to-bottom FAB ended up scrolling with the
       chat. Anything meant to float over the scrollport belongs in
       .messages-viewport (the non-scrolling wrapper), not in here. Kept
       only so descendants that opt into absolute positioning have a
       predictable context; every current one (.msg-avatar-slot,
       .msg-jumbo-emoji .msg-meta) resolves against its own .message. */
    position: relative;
}

/* Top-of-feed strip for backward pagination (see App#setOlderLoadingUi):
   a spinner while a page of older messages is in flight, then a one-line
   "Beginning of the conversation" once there's nothing older left. A flex
   sibling ABOVE .messages-inner (not inside it) so that element's
   innerHTML='' repaint on chat switch can't wipe it.

   Height is animated, not just opacity: this sits in normal flow at the
   top of the scrollport, so collapsing it to 0 height when idle keeps it
   from permanently eating space above the first message. Capped at the
   same max-width as .messages-inner so its centered text lines up with
   the message column instead of the full pane. */
.older-loader {
    flex: none;
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
    height: 0;
    opacity: 0;
    font-size: 12px;
    color: var(--text-secondary);
    transition: height var(--motion-fast) var(--motion-ease),
        opacity var(--motion-fast) var(--motion-ease);
}

.older-loader.visible {
    height: 36px;
    opacity: 1;
}

/* Terminal state reads as a quiet caption, not an active process. */
.older-loader.exhausted {
    font-size: 11px;
    opacity: 0.55;
}

.older-loader-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: older-loader-spin 0.7s linear infinite;
}

@keyframes older-loader-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .older-loader { transition: none; }
    .older-loader-spinner { animation-duration: 2s; }
}

/* Floating "jump to latest" button: hidden once the user is within ~150px
   of the bottom (see App#isNearBottom/updateScrollToBottomButton), shown
   otherwise so scrolling up to read history doesn't lose the way back down.
   Anchored to #messages-container/#project-messages-container's own
   position:relative (above) rather than the page, and sits ABOVE
   .messages-inner in source order so it isn't wiped out by that element's
   innerHTML='' repaint on chat switch. A scale+fade pop rather than the
   shared clip-path popover reveal (see that standard further down): this
   isn't anchored to a trigger at one edge, it just appears in place. */
/* Wraps the message scroller and owns the positioning context for the
   scroll-to-bottom FAB. The FAB used to live INSIDE .messages-scroll, but an
   absolutely-positioned child of an overflow:auto element resolves its
   offsets against that element's scrolled content box: so `bottom: 16px`
   meant "16px above the end of all the messages", and it scrolled out of
   view with them instead of floating. Anchoring it to this non-scrolling
   box (which occupies exactly the scrollport's area) is what makes it a
   real FAB. Takes over the scroller's former flex role; min-height:0 so it
   can actually shrink inside the column flex parent rather than being
   forced to its content height. */
.messages-viewport {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.messages-viewport > .messages-scroll {
    flex: 1;
    min-height: 0;
}

.scroll-to-bottom-btn {
    position: absolute;
    right: 16px;
    bottom: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 5;
    opacity: 0;
    visibility: hidden;
    /* Rises into place rather than only scaling up, matching the modal's
       own translateY entrance (.modal-container) so the app has one
       motion language. Was 120ms + scale(0.8) alone, which at that
       distance and duration was over before it registered and read as
       the button simply blinking on. */
    transform: translateY(8px) scale(0.85);
    transition: opacity var(--motion-med) var(--motion-ease),
        transform var(--motion-med) var(--motion-ease),
        /* Delayed to the END of the fade: visibility is a discrete
           property, so without the delay it would flip to hidden on frame
           one and the fade-out would never be seen. */
        visibility 0s linear var(--motion-med);
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    /* No visibility delay on the way IN: it has to be visible before the
       fade can be watched, not after. */
    transition: opacity var(--motion-med) var(--motion-ease),
        transform var(--motion-med) var(--motion-ease);
}

.scroll-to-bottom-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

@media (prefers-reduced-motion: reduce) {
    .scroll-to-bottom-btn {
        /* Opacity only: no travel: but still not an instant pop. */
        transform: none;
        transition: opacity var(--motion-fast) linear, visibility 0s linear var(--motion-fast);
    }
    .scroll-to-bottom-btn.visible {
        transition: opacity var(--motion-fast) linear;
    }
}

/* Width-capped, left-anchored message column: see the outer rule above for
   why this is a separate element from the scrollport rather than the same
   node max-width was originally applied to. On an ultra-wide pane
   .message's max-width:80% (below) would otherwise let a bubble grow to
   hundreds of px past a readable line length. width:100%/max-width caps it
   without needing align-self/flex-basis tricks: a block-level flex
   container's used width already resolves to "fill available space, up to
   max-width" and then sits flush at the inline-start (left) of its
   parent: auto margins would be needed to center it, and none are set. */
.messages-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 900px;
    /* Query container for the .msg-me flip below: deliberately measuring
       THIS element's own (already max-width-clamped) size, not the
       viewport. A @media breakpoint would react to window/screen width;
       this app has a resizable pane-splitter (pane-resizer.js) that can
       change the chat pane's width with the browser window untouched, so
       the trigger has to be this element's actual rendered width. Unlike
       when this lived on the scrollport, no padding sits on this element,
       so its content-box (what @container measures) equals max-width
       exactly: no 40px-of-padding correction needed here. */
    container-type: inline-size;
}


/* Project Details View */
.project-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Belt-and-suspenders clip: .pane-right (its parent) has its own
       overflow-y:auto, meant only for genuine cross-pane overflow. Every
       real scrollable region in here (.messages-scroll, .pane-side-body's
       lists) already clips itself; this stops anything that slips past one
       of those (a collapsed panel whose child didn't shrink as intended,
       say) from also giving .pane-right its own redundant scrollbar. */
    overflow: hidden;
}

.project-header {
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.project-header > div:first-child {
    display: flex;
    align-items: center;
}

/* The gap lives here, not on the row above, so it stops right before
   #chat-search-bar - see the HTML comment on this element for why: a
   gap between two flex siblings still applies in full even while one of
   them is collapsing toward zero width, which read as one final phantom
   jump the instant it actually left the flex flow (display:none). */
.project-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    /* flex:1 (not the outer row) is what actually grows to fill the row
       now - its own child #project-header-text-btn (flex:1, see its own
       rule) then grows to fill THIS. Without it, this wrapper would just
       size to its own content and leave #chat-search-bar's margin-left
       :auto to (wrongly) claim all the outer row's leftover space
       instead of the title. */
    flex: 1;
    min-width: 0;
}

.project-header .chat-header-text {
    flex: 1;
    min-width: 0;
    /* Desktop counterpart of .chat-title (mobile): the whole title+member
       block is the click target for the project modal, not just the
       member-count subtitle line. Only button-reset properties here:
       display/flex-direction/height/justify-content come from the shared
       .chat-header-text rule (it already centers h3 + subtitle inside a
       44px-tall flex column) and must stay untouched. */
    text-align: left;
    background: none;
    border: none;
    padding: 4px 8px;
    margin: -4px -8px;
    box-sizing: border-box;
    font: inherit;
    cursor: pointer;
    border-radius: 8px;
}
.project-header .chat-header-text:hover {
    background: var(--hover-bg, rgba(0, 0, 0, 0.04));
}
.project-header .chat-header-text h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.project-header .chat-header-text { min-height: 44px; }

.project-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.project-header .project-tabs {
    width: 100%;
    margin-top: 4px;
}

.project-tabs {
    display: flex;
    gap: 8px;
}

.project-tab-btn {
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.project-tab-btn:hover {
    color: var(--text-primary);
}

.project-tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

/* Message search bar: on desktop, a plain flex sibling of the title/pills
   (NOT hidden while this is open - see the .chat-search-active rules
   below for why); on mobile it overlays .chat-title inside
   .chat-header-swap instead, since a ~300-420px header can't fit both a
   title and a search bar at once (see that HTML comment). Toggled by
   #chat-search-toggle (see toggleChatSearch in app.js). Matches aren't
   filtered into their own list: every message stays where it is and hits
   just get a highlight, so the conversation's context around a match
   isn't stripped away the way it would be if non-matches disappeared. */
.chat-search-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 40px;
    padding: 4px 8px;
    box-sizing: border-box;
    /* flex-grow:0 caps this at its own flex-basis rather than stretching
       to fill the row on a wide desktop window. No margin-left:auto -
       .project-header-left (its only sibling in the outer row, see its
       own rule) already has flex:1 and absorbs every bit of leftover
       space itself, which pushes this flush against the row's trailing
       edge as a natural side effect, without needing its own auto margin
       to do the same job redundantly. That redundancy used to leave a
       tiny leftover auto-margin value even once flex-basis had all but
       reached 0 (an auto margin's resolved size and a flex-basis
       transitioning toward 0 aren't quite the same computation, and the
       gap between them showed up as one final few-pixel snap right as
       display:none finally applied). flex-shrink stays 1 so it still
       narrows to fit on mobile. flex-basis is what actually animates
       open/closed (see the transition below) - the title on desktop
       (flex:1, inside .project-header-left) recomputes every frame as
       this basis grows/shrinks, so the Tasks/Progress/Cost pills after
       it visibly slide over in step instead of snapping sideways the
       instant this bar's box appears. overflow:hidden keeps its own
       contents from wrapping/spilling out while the basis is still
       smaller than what icon+input+buttons naturally need, early in
       that animation. */
    flex: 0 1 420px;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    opacity: 1;
    /* Tried dropping display:none altogether (animate purely via opacity/
       flex-basis, element always a real flex participant) to rule out a
       display:none<->flex flip as the source of a small trailing snap -
       that removed the transition ENTIRELY instead (jumped straight to
       the end state, no animation at all, in this browser). Reverted:
       keep display:none + allow-discrete + @starting-style, which is
       confirmed to actually animate. */
    transition: opacity .18s ease, flex-basis .18s ease, display .18s allow-discrete;
}
.chat-search-bar.hidden {
    display: none;
    opacity: 0;
    flex-basis: 0;
}
@starting-style {
    .chat-search-bar:not(.hidden) {
        opacity: 0;
        flex-basis: 0;
    }
}
.chat-search-bar-icon {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
}
.chat-search-bar input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}
.chat-search-bar input::placeholder {
    color: var(--text-secondary);
}
.chat-search-count {
    color: var(--text-secondary);
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
}
/* Scoped under .chat-search-bar (not just the bare classes) so this beats
   .icon-btn/.icon-btn-muted on specificity rather than relying on source
   order - those are declared LATER in this file and, at the same 0-1-0
   specificity a bare .chat-search-nav rule would have, source order is
   what decides the tie. That was true even before this comment existed:
   the prev/next buttons were already rendering at .icon-btn-muted's 19px/
   8px (a ~35px box) instead of this rule's intended 13px/5px (~25px),
   pre-existing and unrelated to the header-overwrite-in-place change.
   #chat-search-close matches the same sizing - it's a plain .icon-btn
   otherwise, which defaults to a 24px glyph and 8px padding (~40px box):
   even further out of scale next to these chevrons. */
.chat-search-bar .chat-search-nav,
.chat-search-bar #chat-search-close {
    padding: 5px;
    font-size: 13px;
}

/* Tasks/Progress/Cost: pills instead of an underlined tab strip, on both
   breakpoints now (desktop keeps them inline in the header's title row via
   this class; mobile gets its own row below the header, see
   .mobile-explore-row). Reading as "open this" rather than "you are here"
   is the point: unlike Chat, none of these is a place you sit in, they're
   panes you pop open beside/over the conversation. */
.project-explore-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
/* Sits beside the explore pills, not styled as one itself: this opens an
   inline search row rather than a pane, so it stays a plain circular icon
   button (matching the paperclip/attach treatment) rather than adopting the
   pills' rectangular chrome. Padding trimmed from the .icon-btn default so
   its hit-circle doesn't overshoot the pill row's height. */
.chat-search-toggle {
    padding: 6px;
}
.chat-search-toggle[aria-pressed="true"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
/* The project name and Tasks/Progress/Cost pills stay put while
   searching - only the toggle button that opens search hides (redundant
   with #chat-search-close once the bar's open), so the title/pills never
   move, resize, or reflow anything else on the page. #chat-search-bar
   (see its own rule) just adds itself to the row's trailing edge instead
   of replacing anything here - desktop has the width for both.
   .chat-search-toggle-hidden, not body.chat-search-active, on purpose:
   openChatSearch adds this class instantly (the bar needs the toggle's
   spot right away), but closeChatSearch removes it on a timer matched to
   #chat-search-bar's own ~180ms collapse (see the JS comment there). If
   this button reappeared the instant body.chat-search-active came off
   instead, it would claim its width back WHILE the bar was still
   mid-shrink, fighting the bar's own flex-basis animation for the same
   space and reading as a snap right at the end instead of one continuous
   collapse. Scoped as #chat-search-toggle.chat-search-toggle-hidden (id
   + class), not a bare class selector, so it wins on specificity rather
   than depending on landing after .icon-btn's own `display: grid` in
   source order - the same tie-breaking trap .chat-search-nav's sizing
   rule fell into (see that rule's own comment). */
#chat-search-toggle.chat-search-toggle-hidden {
    display: none;
}
.project-tab-btn.explore-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    /* Rectangle, not a capsule: a fully-rounded pill on a hover/active
       control read as more toy-like than professional; the standard 6px
       corner (see --radius) is the default for controls like this unless
       something specific calls for full rounding. */
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
}
.project-tab-btn.explore-pill i {
    font-size: 0.85em;
}
/* Neutral hover, not an accent-coloured outline: a saturated border on
   every hover reads as loud/unpolished next to how sparingly this app's own
   accent colour is otherwise used (send button, links, active states). A
   plain lighter border + brighter text is the same "you're about to
   interact with this" signal without borrowing the brand colour for it. */
.project-tab-btn.explore-pill:hover,
.project-tab-btn.explore-pill:active {
    border-color: var(--border-hover);
    color: var(--text-primary);
}
/* Filled, not just a different border colour: this is the one currently
   open in the pane beside the chat, so it should read at a glance the same
   way an active nav item does elsewhere in the app: not merely "hovered".
   Neutral fill (--bg-tertiary), not an accent tint: an accent-mixed
   background read as too saturated/"full blue" next to the ghost pills
   beside it: the accent colour belongs to the text/icon (currentColor),
   same as .project-tab-btn.active's underline treatment above, not to a
   block of fill. */
.project-tab-btn.explore-pill.active {
    background: var(--bg-tertiary);
    border-color: transparent;
    color: var(--accent-color);
}

.project-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.project-tab-content.hidden {
    display: none;
}

/* Mobile row of Tasks/Progress/Cost pills, same .explore-pill look as the
   desktop title row (see .project-explore-actions above and the HTML
   comment where this is used): needs its own background/border/padding
   since on desktop those pills just sit inline in the title row, with no
   row of their own to style. */
.mobile-explore-row {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    /* Was left-aligned at each pill's own content width (inherited from
       .project-explore-actions, built for desktop's title row where the
       pills just sit inline next to other content). At 3 pills (Tasks,
       Progress, Cost - the admin case) they now grow evenly to actually
       use the row's full width instead of clumping left with dead space
       on the right; center is what that same rule falls back to for
       fewer pills (Cost hidden for non-admins), so 2 pills read as a
       centered pair at their own natural width instead of a still-clumped-
       left row with an obvious gap where the third one would be. */
    justify-content: center;
}
.mobile-explore-row .project-tab-btn.explore-pill {
    flex: 1 1 0;
    /* Caps how far a pill grows once there are few enough of them that
       flex:1 alone would stretch each one implausibly wide (2 pills each
       taking half the screen, say) - chosen so 3 pills' own equal share
       of a typical phone width already sits under this and are never
       actually clipped by it, only 1-2 pills are. */
    max-width: 140px;
    justify-content: center;
}

/* .chat-title, #mobile-chat-search-toggle-home, and #mobile-chat-search-home
   all overlay each other here instead of sitting side by side as flex
   siblings of .chat-header - see the HTML comment on .chat-header-swap for
   why (a crossfade between ordinary flex items squeezed the title text
   mid-transition; a ~300px mobile header can't fit the old and new content
   side by side even briefly - and #mobile-chat-search-toggle-home used to
   live OUTSIDE this wrapper as a separate flex sibling, so its own instant
   show/hide resized the wrapper's flex:1 width out from under whatever was
   crossfading inside it). height:100% relies on .chat-header's own explicit
   height:60px (see its rule) since making every child position:absolute
   leaves nothing in normal flow to size this box from otherwise. */
.chat-header-swap {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
}
.chat-header-swap .chat-title,
.chat-header-swap #mobile-chat-search-home {
    position: absolute;
    inset: 0;
}
/* Not inset:0 like the two above - this is a small icon button, not
   something that should stretch to fill the whole swap box. Pinned to the
   right edge, vertically centered, same corner .chat-search-toggle sits in
   on desktop's own title row. */
.chat-header-swap #mobile-chat-search-toggle-home {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}
/* pointer-events:none on the wrapper, auto on the bar itself: inset:0
   (see the shared rule above) gives this an explicit full-size box
   regardless of what's inside it, so even while #chat-search-bar is
   display:none (closed) the empty wrapper still sat there at full size,
   last in DOM order - meaning topmost in stacking - silently swallowing
   every click meant for .chat-title or #mobile-chat-search-toggle-home
   underneath it. The bar's own pointer-events:auto lets its input/buttons
   keep working normally once it's actually open. */
#mobile-chat-search-home {
    display: flex;
    align-items: center;
    pointer-events: none;
}
#mobile-chat-search-home .chat-search-bar {
    pointer-events: auto;
}
/* Right-aligned within this box, same as it used to be pinned to the row's
   trailing edge on desktop - but desktop dropped its own margin-left:auto
   (see the comment on .chat-search-bar) once .project-header-left's own
   flex:1 started doing that job instead. There's no such sibling inside
   THIS box (the bar is its only child - .chat-title overlays it from
   OUTSIDE, in the shared .chat-header-swap, not inside here), so nothing
   else absorbs the leftover space on a header wide enough that the bar's
   own max-width:420px doesn't already fill it (comfortably true well
   past the mobile/tablet breakpoint) - without this the bar reverted to
   flex-start, growing from the LEFT instead of the right it's meant to
   mirror the search icon it replaces from. */
#mobile-chat-search-home .chat-search-bar {
    margin-left: auto;
}
/* Search takes .chat-header over in place - the header itself has room
   for either the title OR the bar, never both, so .chat-title still hides
   while #chat-search-bar is open (see .chat-header-swap above). The
   Tasks/Progress/Cost row is a SEPARATE element below the header, though,
   with no width constraint forcing it to disappear too - hiding it used
   to collapse its grid row and shift the whole conversation up
   underneath it, so it now stays put like desktop's own pills do (see
   the .chat-search-active rule on #chat-search-toggle). back-btn is also
   untouched - closing search shouldn't also cost you the ability to
   leave the conversation; #chat-search-close is the dedicated way to
   close just the search. #mobile-chat-search-toggle-home isn't part of
   the fade below - it's a small icon pinned to the title's own corner
   (see its own rule), not the thing crossfading; it just pops, same as
   before, alongside whichever of .chat-title/#chat-search-bar is about
   to take over. */
body.chat-search-active #mobile-chat-search-toggle-home {
    display: none;
}
.chat-header .chat-title {
    opacity: 1;
    transition: opacity .15s ease, display .15s allow-discrete;
}
body.chat-search-active .chat-header .chat-title {
    display: none;
    opacity: 0;
}
@starting-style {
    body:not(.chat-search-active) .chat-header .chat-title {
        opacity: 0;
    }
}

/* Only .project-tab-content left in #view-conversation now that Tasks/
   Progress/Cost moved out to #pane-side (see its HTML comment): never
   toggled hidden/active, so it keeps that layout without the class. */
#mobile-tab-chat {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.message {
    max-width: 80%;
    padding: 6px 10px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;

    /* Plain block, not grid: a CSS Grid item's auto track sizing doesn't
       reliably include a floated descendant's width (the .msg-meta-inline
       timestamp below), so the bubble never grew to make room for it and it
       always wrapped onto its own line regardless of text length. Shrink-
       to-fit block layout does account for floats in its preferred-width
       calculation, which is what actually lets a short line's timestamp
       tuck in beside it. */
    display: block;
}

.message > * + * {
    /* Replaces the old grid `gap` now that rows (.msg-sender/.msg-reply-quote/
       .msg-text/.msg-reactions/.msg-meta) are plain stacked block children. */
    margin-top: 2px;
}

.msg-text {
    /* Establishes a block formatting context so the floated
       .msg-meta-inline timestamp (see below) is contained within the text
       block instead of poking into .msg-reactions/.msg-meta below it. */
    display: flow-root;
}

/* Delivery tick on an own-message (see App#messageTickHtml). There was no
   rule for this at all before: the glyph just inherited whatever it landed
   in. Sized in em so it tracks .msg-meta-inline's 10px rather than needing
   its own value kept in sync. */
.msg-tick-icon {
    font-size: 1.05em;
    line-height: 1;
    /* The double-check is a wide glyph; a hair of leading separates it from
       the timestamp without needing a gap on the flex parent. */
    margin-left: 1px;
    vertical-align: -0.05em;
}

/* The synced tick is an <svg> now, not an <i>: font-size above does
   nothing to it, so it needs its own em-based width/height to keep tracking
   .msg-meta-inline's 10px the same way the pending <i>/fa-clock still does. */
.msg-tick-double {
    width: 1.35em;
    height: 1.35em;
    display: inline-block;
    color: currentColor;
}

/* Not yet acknowledged by the server. Dimmed rather than a different colour:
   this is an in-between state, and colour here would compete with the
   read/unread signalling the ticks themselves carry. */
.msg-tick-pending {
    opacity: 0.7;
}

.msg-meta-inline {
    float: right;
    /* Floats align to the top of the line they land in by default, which
       reads as too high next to the text's baseline (a 21px text line vs.
       this ~12px-tall box): pushed down to sit at the bottom of the line
       instead, matching where the text itself visually sits. */
    margin: 8px 0 0 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
}

.msg-me {
    align-self: flex-end;
    background: var(--msg-bg-me);
    border-bottom-right-radius: 4px;
    /* position:relative unconditionally (cheap, no layout effect on its
       own) so the @container rule below only has to add margin-left: no
       need to also introduce position there once the column's wide enough
       for the avatar to appear. */
    position: relative;
}

.msg-other {
    align-self: flex-start;
    background: var(--msg-bg-other);
    border-bottom-left-radius: 4px;
    /* Room for .msg-avatar-slot (see below) without touching this bubble's
       own box model: the slot is position:absolute and so out of flow, so it
       doesn't need a flex-row wrapper around the existing bubble content
       (sender name/text/reactions/meta, and the report-balloon variant,
       all stay exactly as they already were). */
    position: relative;
    margin-left: 40px;
}

/* Message search hits (#chat-search-bar/runChatSearch in app.js). Declared
   after .msg-me/.msg-other so the highlight actually wins the cascade over
   their own `background` at equal specificity: every matching bubble gets a
   soft, persistent tint (not a hover state; same category as a .selected
   exception on the global neutral-hover standard), and the one currently
   focused via prev/next gets a stronger ring on top of it. */
.message.search-hit {
    background: var(--accent-soft);
}
.message.search-current {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Group-chat sender avatar. Reuses the same initials-square look as the
   project/profile avatars (getProjectInitials/getAvatarColorClass) rather
   than a separate visual language for "avatar" just for chat. Rendered for
   every message regardless of sender (see renderMessage): .msg-me's copy
   stays display:none until the @container rule below turns it on, rather
   than never being created, so there's nothing to retrofit once the column
   is wide enough that "which side" no longer tells own from others'. */
/* Holds the avatar in the 40px gutter .msg-other/.msg-me reserve to their
   left. This slot carries the absolute placement (out of flow, so the
   bubble's own block layout and its floated .msg-meta-inline timestamp are
   untouched) and stretches the FULL height of the message via top:0/bottom:0.
   That height is what gives the sticky avatar inside it something to travel
   within: sticky is constrained by its containing block, so a slot that only
   wrapped the glyph would have zero range and never move.
   align-items:flex-end is the "at rest" position: bottom-aligned with the
   last line of the bubble, the way a chat groups an avatar with the end of
   someone's turn, rather than floating beside its middle. */
.msg-avatar-slot {
    position: absolute;
    left: -40px;
    top: 0;
    bottom: 0;
    width: 32px;
    display: flex;
    align-items: flex-end;
    /* The slot is a tall invisible box sitting in the gutter; only the glyph
       inside it should be hittable (it opens the user's profile). */
    pointer-events: none;
}

.msg-avatar {
    /* Sticky, not absolute: on a message tall enough to exceed the viewport,
       a bottom-aligned avatar would scroll off below while the top of the
       message is still being read. Sticky keeps it on screen for as long as
       any part of its message is, then releases at the slot's top edge so it
       never drifts up beside somebody else's message. */
    position: sticky;
    bottom: 6px;
    pointer-events: auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.75rem;
    /* Fully self-contained centering: not relying on .avatar's own
       display:flex/align-items/justify-content still being in effect here,
       since a prior fix (line-height:1 alone) didn't resolve this in
       practice. line-height:1 avoids the inherited default (~1.2+) adding
       asymmetric space above/below the glyph that the box-level centering
       below can't compensate for. */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-align: center;
    /* align-items:center genuinely does center the LINE BOX (confirmed in
       DevTools: this rule wins, box is exactly 32x32, no padding): the
       remaining upward drift is the font's own metrics: most typefaces
       reserve descender space (for g/p/y) below the baseline that "RI"/"NI"
       never use, so the glyphs themselves sit visually above the line
       box's true center even though the box is centered correctly. A small
       manual nudge compensates; this is calibrated for the font stack in
       use here, not a generic fix that holds for every font. */
    padding-top: 2px;
    box-sizing: border-box;
}

.msg-me .msg-avatar-slot {
    display: none;
}

/* Once the message column (see .messages-inner's container-type above) is
   wide enough to have hit its own max-width cap, own messages drop the
   right-alignment that distinguishes them from everyone else's and join
   the same left edge, reading as one left-anchored conversation rather
   than a two-sided one. Below the cap (mobile, tablet, a narrowed pane:
   the overwhelmingly common case) .msg-me keeps flex-end from the base
   rule above. Placed AFTER .msg-me's base rule deliberately: equal
   specificity means source order decides the cascade, and a rule nested in
   @container doesn't win just for being conditional: it has to come
   later to actually override.
   Threshold is 900px, matching max-width exactly: .messages-inner carries
   no padding of its own (that stays on the outer .messages-scroll), so its
   content-box: what @container measures: equals its border-box here.
   (When max-width and container-type briefly lived on the same element as
   that padding, this had to be 860 instead; not the case anymore.)
   Once own messages join the left edge, color alone is a weaker signal for
   "whose message is this" in a group chat: everyone's bubbles are now on
   the same side: so the avatar comes on here too, matching .msg-other. */
@container (min-width: 900px) {
    .msg-me {
        align-self: flex-start;
        margin-left: 40px;
        /* The sharp corner is a speech-bubble tail substitute, pointing
           toward whichever side the avatar sits on: .msg-me's base rule
           hardcodes it bottom-right (correct while own messages sit on the
           right, avatar-less). Once this @container flips the bubble to
           the left edge to sit beside its own avatar, the tail has to flip
           with it: sharp corner moves to bottom-left (matching .msg-other),
           and the now-unused right corner rounds back to the base 16px. */
        border-bottom-right-radius: 16px;
        border-bottom-left-radius: 4px;
    }
    .msg-me .msg-avatar-slot {
        /* Toggling the SLOT rather than the avatar. This used to target
           .msg-avatar and had to restate display:flex, because that base
           rule uses flex to center the initials and a 2-class override
           silently replaced it: the old "RI looks uncentered" bug. The
           slot owns layout and the avatar owns its own centering, so
           neither has to know about the other's display value. */
        display: flex;
    }
}

.msg-meta {
    font-size: 10px;
    opacity: 0.8;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

/* A message that's nothing but one emoji (see ChatKit.isSingleEmoji): no
   bubble at all (background/padding/radius dropped), so it reads as a
   "sticker," not a text line. The timestamp isn't shown inline either:
   Telegram-style, it's an overlay chip on the emoji's bottom-right corner
   that only appears on hover, taken out of grid flow via position:absolute
   so it doesn't reserve any space while hidden. */
.msg-jumbo-emoji {
    background: none;
    padding: 0;
    border-radius: 0;
}

.msg-jumbo-emoji .msg-meta {
    position: absolute;
    right: 2px;
    bottom: 2px;
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-fast) var(--motion-ease);
}

.msg-jumbo-emoji:hover .msg-meta,
.msg-jumbo-emoji:focus-within .msg-meta {
    opacity: 1;
}

/* Inline emoji within normal text (renderBody): Telegram/WhatsApp-style:
   the same Noto image the picker uses, sized relative to the surrounding
   text instead of the OS's native emoji font glyph. */
.ck-inline-emoji {
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.2em;
    margin: 0 0.02em;
}

.ck-jumbo-emoji-img,
.ck-jumbo-emoji-lottie {
    width: 72px;
    height: 72px;
    justify-self: var(--jumbo-emoji-align, start);
    cursor: pointer;
}

.msg-me .ck-jumbo-emoji-img,
.msg-me .ck-jumbo-emoji-lottie {
    --jumbo-emoji-align: end;
}

/* System notice (role changes, etc.): centered, no balloon, muted. Overrides
   the .message balloon base so it reads as an event, not someone's message. */
.msg-system {
    align-self: center;
    max-width: 90%;
    padding: 2px 12px;
    background: none;
    justify-items: center;
}

.msg-system-text {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 12px;
    text-align: center;
}

/* Day marker between messages ("Today"/"August 12"): sticks to the top of
   the scroll area while its day's messages are in view, then is naturally
   displaced by the next day's separator once its flow position reaches the
   same spot (plain CSS sticky-siblings trick, no JS scroll listener). Needs
   its own opaque background + shadow since it overlays message bubbles
   while stuck, unlike .msg-system-text which never overlaps anything. */
.msg-date-separator {
    align-self: center;
    position: sticky;
    top: 8px;
    z-index: 3;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    /* --bg-tertiary, not --bg-primary: no border/outline draws the edge
       anymore, so the fill itself has to read as distinct from the scroll
       area's own background in every theme (it's a token specifically
       meant to contrast against --bg-primary everywhere, not a color
       picked to match one theme). Still deliberately lower visual weight
       than a message bubble (smaller, no shadow): a scroll aid, not
       content. No :hover state either: clickability is cursor-only here,
       not a color/border change. */
    background: var(--bg-tertiary);
    padding: 3px 12px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
}

/* Only a CURRENTLY-STUCK separator (see App#updateStuckDateSeparator: CSS
   sticky has no reliable ":stuck" selector across browsers, so that's a
   plain rect comparison, not this file) fades in: and only while actively
   scrolling UP into history (.scrolling-up-active, set in the container's
   scroll handler in app.js, not the generic page-wide .scrolling-active
   every scrollable element gets for its scrollbar). Scrolling down never
   forces it back off: see that handler's comment: it only ever fades out
   again once its own timer runs out. An inline separator sitting in normal
   flow between messages isn't overlaying anything either way, so it has no
   reason to hide: hiding it too would remove real date context from the
   message history itself, not just decorate a scroll affordance.
   --motion-med (220ms), not --motion-fast (120ms): this fade is the whole
   point of the interaction now that it's timer-driven rather than snapping
   off on the next down-scroll, so it needs to read as a deliberate fade in
   both directions, not a flash quick enough to half-miss. */
.msg-date-separator.is-stuck {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-med) var(--motion-ease);
}

#messages-container.scrolling-up-active .msg-date-separator.is-stuck,
#project-messages-container.scrolling-up-active .msg-date-separator.is-stuck {
    opacity: 1;
    pointer-events: auto;
}

/* The handoff leftover (see App#updateStuckDateSeparator): CSS
   position:sticky itself still floats this one at the same spot as the
   genuine .is-stuck separator for a frame or two, so it needs forcing off
   regardless of .scrolling-up-active, or it doubles up as a second pill
   sitting right on top of the real one. Not just opacity:0 like the resting
   .is-stuck state (which .scrolling-up-active can override): !important
   here specifically wins over that rule too, since this one must never
   show, not even while actively scrolling. */
.msg-date-separator.is-stuck-behind {
    opacity: 0 !important;
    pointer-events: none;
}

/* Jump-to-date calendar, opened by clicking a .msg-date-separator pill:
   a native <dialog class="app-modal date-jump-modal"> (#date-jump-modal in
   index.html), not a popover: dialog.app-modal already supplies the box/
   backdrop/sizing (see the shared rules further down), so nothing here
   needs its own position/background/shadow. ChatKit.renderDateJumpCalendar
   only fills #date-jump-modal-body with the header/weekdays/grid below. */
.date-jump-modal .modal-body {
    padding-top: 4px;
}

/* This dialog used to carry its own scoped pop animation, because at the
   time it was the only animated modal and retrofitting the rest was
   deferred. That retrofit has since happened (see .modal-container's own
   translateY transition), so the override is gone and this modal follows
   the global standard like every other: a scoped rule here would only
   serve to override it and drift again. */

.date-jump-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.date-jump-month {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95em;
}

.date-jump-nav {
    display: flex;
    gap: 4px;
}

.date-jump-nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
}

.date-jump-nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.date-jump-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.72em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.date-jump-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.date-jump-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.82em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.date-jump-cell.empty {
    background: none;
    cursor: default;
}

.date-jump-cell:not(.empty):hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
}

.date-jump-cell:disabled {
    color: var(--text-secondary);
    opacity: 0.35;
    cursor: default;
}

.date-jump-cell.is-today {
    background: var(--accent-color);
    color: #fff;
    font-weight: 700;
}

.date-jump-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.55);
}

/* Day number sits on top of the thumbnail image (see .date-jump-thumb's
   dimmed filter above, which exists purely so this stays legible). */
.date-jump-cell span {
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Input Area Flexbox */
.chat-input-area {
    padding: 12px 15px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);

    display: flex;
    gap: 12px;
    align-items: center;
}

.input-field {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
}

/* select.input-field only: a plain <input> has no arrow to replace, but a
   <select> falls back to the OS/browser's own dropdown chevron otherwise:
   the one control left rendering with none of this app's own styling next
   to everything else that's fully custom. A <select> can't take a ::after
   pseudo-element reliably, so the chevron is a background image instead of
   a real icon; hard-coded to a neutral slate rather than currentColor
   (background-image can't read CSS custom properties) since it has to look
   reasonable across all 7 accent themes, not just the default one. */
select.input-field {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9L12 15L18 9' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
}

.chat-input-area input {
    flex: 1;
    min-width: 0;
    padding: 8px 16px;
    border-radius: 25px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
}

.chat-input-area input:focus {
    box-shadow: 0 0 0 2px var(--accent-color);
}

.icon-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}


.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
/* Touch's own tactile feedback, now that the browser's mismatched default
   rectangle is suppressed (see the tap-highlight-color reset above):
   same circular fill as :hover, just a touch stronger so a tap still
   reads as "pressed" on a device with no hover state to fall back on. */
.icon-btn:active {
    background: rgba(255, 255, 255, 0.16);
}

/* Muted/outline-leaning treatment for action icons that aren't the primary
   send action (attach, emoji, mic): FA6 Free's regular/outline glyphs don't
   exist for several of these (paperclip, microphone: confirmed by rendering
   both weights and checking for a missing-glyph box), so solid icons in a
   lighter weight/color stand in for a true outline style instead. */
.icon-btn-muted {
    font-size: 19px;
    color: var(--text-secondary);
}

.icon-btn-muted:hover {
    color: var(--text-primary);
}

/* Same muted colour as .icon-btn-muted, but for a plain SVG child instead of
   an <i>: .icon-btn-muted's own font-size:19px rule does nothing to an
   <svg>, which is sized by width/height instead. Kept as its own class
   rather than folded into .icon-btn-muted so a button can mix an SVG icon
   with the rest of that muted-icon family without a no-op font-size rule
   riding along. */
.icon-btn-muted-svg {
    color: var(--text-secondary);
}
.icon-btn:hover .icon-btn-muted-svg {
    color: var(--text-primary);
}

/* A rounded-square hover shape instead of .icon-btn's usual full circle:
   for icons whose own subject is a rectangular/cornered thing (a panel, a
   frame), where a circular hit-area would hint at a roundness the glyph
   itself doesn't have. Paperclip-family icons (organically curved) keep the
   circle; this is the exception, not a new default. */
.icon-btn-cornered {
    border-radius: 6px;
}

.send-btn {
    color: var(--accent-color);
}

/* Pill input with the emoji button docked inside it, right edge: the input
   itself gets right-padding so typed text never runs under the icon. */
.msg-input-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
}

.msg-input-wrap input {
    padding-right: 42px !important;
}

.icon-btn-inline {
    position: absolute;
    right: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.icon-btn-inline:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

/* ═══════════════════════════════════════════════════════════════════════
 * Global popover animation standard
 *
 * Every toggle-by-.open popover in this app (attach menu, emoji picker,
 * sidebar nav, @-mention dropdown) shares this same appear/dismiss motion,
 * driven by a CSS transition on the .open class rather than a display:none/
 * flex swap. Documented as a reusable pattern at /design-system#popovers
 * (.ds-popover there: same values, mirrored here since this page doesn't
 * consume design-system.css's tokens).
 *
 * Deliberately NOT the same motion as .ds-modal's ds-modal-pop (scale from
 * center + drift up + fade: a surface "materializing" in place): a popover
 * is pinned to a trigger at one edge, so it reveals upward FROM that edge
 * instead, via an animated clip-path rather than transform. transform (a
 * uniform scale) would visibly squash the icons/text inside as it grows;
 * clip-path only moves the visible boundary, so content inside is never
 * distorted: it just gets uncovered top-down as the clip retreats.
 *
 * display:none can't transition (no intermediate frame to animate through),
 * so each popover now keeps its permanent display value (flex or block, set
 * in its own rule below) and toggles opacity/clip-path/visibility instead.
 * visibility is delayed on the way out (transition-delay on that property
 * only) so a closed popover still has pointer-events:none and isn't in the
 * accessibility tree, without cutting the reveal short.
 *
 * New popover checklist: add the selector to this list, keep display:none
 * OUT of its own rule, and don't touch opacity/clip-path there either.
 *
 * .sidebar-nav-popover is the one exception: it isn't in this shared list.
 * On mobile it's display:contents (an invisible layout wrapper, its children
 * sit directly in .bottom-nav's row), and opacity/visibility/clip-path on a
 * display:contents element is inconsistent across browsers since the element
 * has no box to apply them to. It gets the same values instead, scoped
 * inside the min-width:768px block where it actually becomes a popover. */
.ck-emoji-panel,
.ck-mention-dd,
.ck-msg-menu {
    opacity: 0;
    visibility: hidden;
    /* Fully clipped from the top down to the bottom edge: zero height
       visible, anchored at the bottom (where the trigger is). */
    clip-path: inset(100% 0 0 0);
    pointer-events: none;
    transition: opacity var(--motion-fast) var(--motion-ease),
        clip-path var(--motion-fast) var(--motion-ease),
        visibility 0s linear var(--motion-fast);
}

.ck-emoji-panel.open,
.ck-mention-dd.open,
.ck-msg-menu.open {
    opacity: 1;
    visibility: visible;
    clip-path: inset(0 0 0 0);
    pointer-events: auto;
    transition: opacity var(--motion-fast) var(--motion-ease),
        clip-path var(--motion-fast) var(--motion-ease);
}

@media (prefers-reduced-motion: reduce) {

    .ck-emoji-panel,
    .ck-mention-dd,
    .ck-msg-menu {
        transition: opacity var(--motion-fast) linear, visibility 0s linear var(--motion-fast);
    }

    .ck-emoji-panel.open,
    .ck-mention-dd.open,
    .ck-msg-menu.open {
        transition: opacity var(--motion-fast) linear;
    }
}






.btn-install {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
}

.btn-install:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-install:active {
    transform: scale(0.96);
}

/* Buttons */
.btn {
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-block {
    width: 100%;
}

/* Spinner */
.loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 50;
    display: grid;
    place-items: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Login Refactor Styles --- */

/* Auth Method Radio Switch */
.auth-method-switch {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.auth-flow {
    display: grid;
    gap: 15px;
    width: 100%;
}

.auth-flow>div {
    display: grid;
    gap: 15px;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-addon {
    padding: 16px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 16px;
    border: none;
    outline: none;
    cursor: pointer;
}

.radio-label {
    flex: 1;
    cursor: pointer;
    text-align: center;
}

.radio-label input {
    display: none;
}

.radio-btn {
    display: block;
    padding: 10px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.radio-label input:checked+.radio-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    padding: 0 10px;
}

/* Secondary Button */
.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

/* Text Button */
.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
    margin-top: 5px;
}

/* Register Overlay */
/* Unified under modal system (v2.4) */

.overlay-content {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 400px;
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    position: relative;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
}

/* PWA Install Overlay Specific Styles */
/* Unified under modal system */

#pwa-install-overlay .pwa-install-content {
    background: var(--bg-secondary);
    padding: 2.5rem;
    border-radius: 24px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    animation: slideUp 0.4s ease-out;
}

.pwa-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5em;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

#pwa-install-overlay h2 {
    margin: 0 0 0.5em;
    color: var(--text-primary);
    font-size: 1.75em;
}

#pwa-install-overlay p {
    color: var(--text-secondary);
    margin: 0 0 2em;
    line-height: 1.6;
}

.pwa-ios-instructions {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    padding: 1.5em;
    margin-top: 1.5em;
    text-align: left;
}

.pwa-ios-instructions h3 {
    margin: 0 0 0.75em;
    color: var(--accent-color);
    font-size: 1em;
}

.pwa-ios-instructions ol {
    margin: 0;
    padding-left: 1.5em;
    color: var(--text-secondary);
    line-height: 1.8;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Buttons */
.btn {
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-block {
    width: 100%;
}

/* Spinner */
.loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 50;
    display: grid;
    place-items: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Login Refactor Styles --- */

/* Auth Method Radio Switch */
.auth-method-switch {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.auth-flow {
    display: grid;
    gap: 15px;
    width: 100%;
}

.auth-flow>div {
    display: grid;
    gap: 15px;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-addon {
    padding: 16px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 16px;
    border: none;
    outline: none;
    cursor: pointer;
}

.radio-label {
    flex: 1;
    cursor: pointer;
    text-align: center;
}

.radio-label input {
    display: none;
}

.radio-btn {
    display: block;
    padding: 10px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.radio-label input:checked+.radio-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    padding: 0 10px;
}

/* Secondary Button */
.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

/* Text Button */
.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
    margin-top: 5px;
}

/* Register Overlay */
/* Unified under modal system (v2.4) */

.overlay-content {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 400px;
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    position: relative;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
}

/* Modal */
.modal-overlay,
.modal,
.overlay {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(4px) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    transition: opacity 0.3s ease;
    pointer-events: auto !important;
    border-radius: 0 !important;
}

.modal-overlay.hidden,
.modal.hidden,
.overlay.hidden {
    display: none !important;
    opacity: 0;
}

.modal-container {
    background: var(--bg-secondary);
    padding: 0px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    /* Use the larger of the two max-widths */
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    /* Slides up from below on entry, back down on exit - one motion
       language at every width, the global modal standard (every
       .modal-container in this app lives inside a dialog.app-modal, so
       this one rule IS that standard), not just the mobile bottom sheet
       shape it originally came from.
       transform+transition, not a keyframe @animation: a keyframe
       animation only ever plays on ENTRY (the moment an element starts
       being rendered) - it does not run in reverse when the element
       goes away, which is exactly why this used to have no slide-down
       on close at all, mobile's bottom sheet included. A transition on
       transform genuinely animates BOTH directions: out when [open] is
       removed (see the :not([open]) rule below), not just in when it's
       added (see @starting-style further down for that "before" value).
       Decelerating ease, no overshoot, both ways: a spring/bounce curve
       reads as elastic, not like paper settling into or lifting off a
       table. */
    transform: translateY(0);
    /* transform ONLY - deliberately not `margin` alongside it. An earlier
       pass added margin here on the theory that the mobile sheet's
       resting Y (margin:auto 0 0, see the 767px rule below) was being
       recomputed mid-slide and snapping. It cannot: that value is `auto`,
       and `auto` is not an interpolable margin value, so a transition on
       margin is a guaranteed no-op for exactly the case it was added for.
       The real cause of the reported open-bounce was the dialog's own
       scroll position, not this box's geometry - see openModal() in
       app.js and the overflow-anchor note on dialog.app-modal[open]. */
    transition: transform var(--motion-med) var(--motion-ease);
    pointer-events: auto;
    position: relative;
    /* For nested absolute elements if any */
}
/* The dialog itself keeps .is-closing laid out for exactly long enough
   for this transition to actually finish (see closeModal() and the CSS
   comment on dialog.app-modal[open], .is-closing) - without that, [open]
   would be gone and the dialog back to display:none before there was
   anything left to slide. */
dialog.app-modal:not([open]) .modal-container {
    transform: translateY(100%);
}
@starting-style {
    dialog.app-modal[open] .modal-container {
        transform: translateY(100%);
    }
}

.modal-container h3 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-container p {
    margin: 0 0 24px 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

@media (prefers-reduced-motion: reduce) {
    .modal-container {
        transition: none;
    }
}

/* ===== SYNC RESULTS UI ===== */
.sync-section {
    margin-bottom: 2rem;
}

.sync-section-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sync-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sync-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

.sync-item:hover:not(.disabled) {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.sync-item.disabled {
    opacity: 0.6;
    background: var(--bg-secondary);
    cursor: not-allowed;
}

.sync-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sync-item-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.sync-item-phone {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.sync-status-tag {
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--accent-soft);
    color: var(--accent-color);
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
}

.sync-check,
.sync-invite-check {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--accent-color);
    cursor: pointer;
}

/* ===== SPLIT-SCREEN LAYOUT ===== */

/* Main Shell - Full Height */
#view-main-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-area {
    flex: 1;
    overflow: hidden;
}

/* Tab Content */
.tab-content {
    height: 100%;
    width: 100%;
    display: none;
}

.tab-content.active {
    display: flex;
}

#tab-account.active {
    flex-direction: column;
    align-items: center;
    /* Top-aligned + scrollable: the Active Sessions list can be long, and a
       centered flex column clips its overflowing start/end unreachably. This
       keeps the whole tab (down to Logout) scroll-reachable. */
    justify-content: flex-start;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 24px 16px;
}

/* Desktop: Two-Pane Layout */
#tab-projects {
    display: flex;
}

.pane-left {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

/* Wraps everything above .bottom-nav (see the HTML comment). During the
   collapse/expand animation (togglePaneLeft in app.js) this gets an inline
   `width` pinned to .pane-left's OWN target width for the transition's
   duration: so while the OUTER .pane-left is animating narrower/wider,
   this inner box stays a constant size the whole time. Without that pin,
   every .chat-name/.chat-last-msg row (white-space:nowrap + ellipsis) would
   recompute its truncation against a shrinking/growing container on EVERY
   animation frame: real layout work, not just paint, and with more than a
   few projects in the list that's what turns a 220ms slide into visible
   stutter. Pinning the content's width and letting the outer pane's
   overflow-x:hidden do the reveal/hide instead means only the CLIP changes
   per frame, nothing here ever reflows mid-animation. */
.pane-left-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Contacts/Notifications routed inside .pane-left (see App#openLeftPaneMode):
   the anchor for #pane-left-chat-body (the static base, never hidden) and
   the two .pane-view-slide overlays that cover it. overflow:hidden clips
   an overlay while it's sitting off to the side mid-slide/at rest. */
.pane-left-body-stack {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
#pane-left-chat-body {
    display: flex;
    flex-direction: column;
    height: 100%;
}
#pane-left-contacts-body,
#pane-left-notifications-body,
#pane-left-analytics-body {
    display: flex;
    flex-direction: column;
}
/* Same header standard as every other one in the app (.chat-header,
   .side-panel-header, .pane-side-header): fixed 60px, horizontal-only
   padding with the content vertically centered inside it, border-bottom
   separating it from what's below. This one used to be sized by its own
   content instead (no height, padding only on the sides+bottom), which
   read as a cramped label sitting above the list rather than a header. */
.pane-left-mode-header {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 60px;
    flex-shrink: 0;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
/* Matches .pane-side-back/.pane-side-actions .icon-btn (#task-panel's own
   header controls): 1rem, not .icon-btn's 24px default, so this button
   doesn't read heavier than the title and mode icon sitting next to it.
   min-width/height: same 44px touch-target spec as #back-btn (see its own
   comment) - .icon-btn's 8px padding around a 1rem icon only gives ~32px,
   short of the accepted minimum tap target on a screen with plenty of
   room to spare for it. */
#pane-left-mode-back {
    font-size: 1rem;
    min-width: 44px;
    min-height: 44px;
    /* Same Material Design 3 top-app-bar reasoning as .chat-header
       .icon-btn#back-btn's own comment (4dp edge-inset for the touch
       target, scaled to this app's 44px target): margin:-12px pulls
       the 44px box's edge in to 16-12=4px from the header's true edge,
       landing the icon at ~16px - this header's own established inset -
       instead of the box's own extra padding pushing that outward. */
    margin: 0 -12px;
}
/* This icon toggles between fa-arrow-left (Contacts, "back to chats" - a
   real back) and fa-xmark (Notifications, "close" - not a back), see
   openLeftPaneMode in app.js. Both states now share the plain
   --text-primary .icon-btn default (see the long comment on .back-btn):
   no rule needed here any more, kept only as a note for why there isn't
   one where a reader would expect the accent-blue override to be. */
.pane-left-mode-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

/* Cross-fade content swap: /design-system#animation type 6 ("opacity-only
   fade"). Used for views that are peers of equal weight, neither one
   "deeper" than the other (project-details-view <-> project-empty-state:
   see .pane-right below): .hidden itself can't be reused here, since
   display:none !important gives the browser no intermediate frame to
   transition through, so a sibling swap using it always snaps regardless
   of any transition declared alongside it. */
.view-stack-layer {
    position: absolute;
    inset: 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--motion-med) var(--motion-ease);
}
.view-stack-layer.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* No transition on visibility itself (it can't be animated: it's a
       flip, not a range), it's just delayed until the opacity fade
       finishes, so a layer isn't still catching hover/click while it's
       mid-fade-out. Only the OUT direction needs this delay: fading IN
       should already be interactive at the very first frame. */
    transition: opacity var(--motion-med) var(--motion-ease),
                visibility 0s linear var(--motion-med);
}

/* The other case: a routed sub-view that IS a level deeper than what it
   covers (Contacts/Notifications over the chat body, a selected contact's
   detail over project-details-view/project-empty-state) gets the exact
   motion #task-panel already uses to slide over .pane-side-body's default
   content (see .side-panel's own transform/transition): push in from the
   right on the way in, slide back out the same way on the way out, rather
   than crossfading two views of equal weight. Opaque background: what it's
   covering stays mounted underneath the whole time, so it must not show
   through mid-slide. */
.pane-view-slide {
    position: absolute;
    inset: 0;
    background: var(--bg-secondary);
    visibility: visible;
    transform: translateX(0);
    transition: transform var(--motion-med) var(--motion-ease),
                visibility 0s linear 0s;
    z-index: 2;
}
/* visibility:hidden, not just pointer-events:none + an off-screen transform:
   pointer-events only blocks the MOUSE - it does nothing for keyboard Tab,
   which walks the DOM's focusable elements regardless of where a transform
   has visually moved them. Without this, tabbing through the sidebar could
   walk straight into a slid-away Contacts pane's search box, and focusing
   it makes the browser scroll/reveal it - showing a raw, never-activated
   copy of the view (no header, no rendered contacts) instead of the one
   actually reached through Contacts nav, because only the CSS moved, not
   the mode switch that populates it. Delayed until the slide-out transform
   finishes (matches .view-stack-layer.is-hidden's own delayed-visibility
   pattern above) so a pane isn't yanked from the tab order mid-slide while
   still visibly on screen; the way IN needs no delay; the moment [is-hidden]
   is removed it should already be focusable again. */
.pane-view-slide.is-hidden {
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--motion-med) var(--motion-ease),
                visibility 0s linear var(--motion-med);
}
/* Notifications specifically: same covering-overlay idea as .pane-view-slide,
   but its trigger (#sidebar-notif-btn) sits at the top of the sidebar, not
   off to the side, so it drops down from above instead of sliding in from
   the right. */
.pane-view-slide-top {
    position: absolute;
    inset: 0;
    background: var(--bg-secondary);
    visibility: visible;
    transform: translateY(0);
    transition: transform var(--motion-med) var(--motion-ease),
                visibility 0s linear 0s;
    z-index: 2;
}
/* Same keyboard-reachability fix as .pane-view-slide.is-hidden above. */
.pane-view-slide-top.is-hidden {
    transform: translateY(-100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--motion-med) var(--motion-ease),
                visibility 0s linear var(--motion-med);
}
@media (prefers-reduced-motion: reduce) {
    .view-stack-layer,
    .view-stack-layer.is-hidden,
    .pane-view-slide,
    .pane-view-slide.is-hidden,
    .pane-view-slide-top,
    .pane-view-slide-top.is-hidden {
        transition: none;
    }
}

.pane-right {
    display: none;
    /* Hidden on mobile */
    flex: 1;
    /* Not a scroll container at all any more, on either axis: every real
       child view now clips/scrolls itself (.messages-scroll,
       .company-list-body/.company-form-body, .details-content - all
       .scroll-content - plus .project-view's own overflow:hidden as a
       belt-and-suspenders catch-all, see its comment). This used to carry
       its own overflow-y:auto + scrollbar-gutter:stable "just in case",
       but nothing here ever actually overflowed THIS box - every child's
       own clip caught it first - so it was reserving real gutter width
       for a scrollbar that could never appear, right next to the resizer
       between this pane and Tasks/Progress/Cost, and the two together
       read as one oversized dead gap rather than a single clean seam.
       overflow-x:hidden alone still needs its own explicit overflow-y
       (hidden, not the visible default): contact-details-view sits at
       translateX(100%) while hidden (see .pane-view-slide), and per spec
       one axis set to non-visible while the other stays 'visible'
       silently redefines that other one to 'auto' - hidden on both sides
       here keeps it a plain, non-scrolling clip. */
    overflow: hidden;
    background: var(--bg-primary);
    /* Anchors the position:absolute children below: project-details-view/
       project-empty-state cross-fade (.view-stack-layer), contact-details-
       view slides over them (.pane-view-slide). #company-management-view
       stays a plain .hidden sibling, unaffected by either. */
    position: relative;
    /* The real constraint on how wide .pane-left/.pane-side may grow: below
       this the header's own controls (avatar+name+member-count, the invite
       icon, four tab buttons) start colliding rather than the chat simply
       looking cosy. Both splitters clamp against this in pane-resizer.js
       instead of each carrying its own independent cap: one number, read
       from the one place that actually needs it, rather than two guesses
       that can drift apart. */
    min-width: 360px;
}

/* Drag handle between .pane-left and .pane-right (desktop only: see
   pane-resizer.js). Hidden by default; the min-width:768px block below turns
   it on alongside the two-pane layout it resizes. */
.pane-resizer {
    display: none;
    flex-shrink: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    touch-action: none;
}

/* transparent at rest used to mean this 5px drag handle painted nothing at
   all until hovered - functionally fine, but with no border of its own on
   either side of it (.pane-right has none; .pane-side's own border-left is
   a separate 1px line past this box's far edge), it read as a stray dead
   gap rather than a deliberate splitter, especially next to .pane-side's
   own real border sitting right after it. var(--border-color) at rest
   makes it look like what it is: a slightly-thick continuation of the
   ordinary divider, not empty space, before hover/drag brightens it. */
.pane-resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 1px;
    width: 3px;
    border-radius: 2px;
    background: var(--border-color);
    transition: background 0.15s ease;
}

/* Neutral, not the accent colour: same reasoning as the explore-pill
   hover fix: a saturated accent highlight on every hover/drag reads as
   loud next to how sparingly this app's accent colour is used elsewhere
   (send button, links, active states). */
.pane-resizer:hover::after,
.pane-resizer.is-dragging::after {
    background: var(--border-hover);
}
/* Only the splitter actually being dragged lights up. This used to key off
   body.pane-resizing, which is document-wide, so grabbing either boundary lit
   BOTH of them: reading as though the whole layout were being resized rather
   than the one edge under the pointer. The body class stays for the global
   cursor/selection lock below, which genuinely is document-wide.
   Hover is suppressed on the others too: the pointer is captured mid-drag, but
   this keeps a stray hover from lighting a second edge. */
body.pane-resizing .pane-resizer:not(.is-dragging)::after {
    background: transparent;
}

body.pane-resizing {
    cursor: col-resize;
    user-select: none;
}

/* Sidebar brand: top of .pane-left, above the company switcher. The mark is
   a fixed brand color (not var(--accent-color)): it identifies the product
   itself, so it stays constant across all 7 accent themes rather than
   shifting with them. */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1rem 0.7rem 1rem;
    background: var(--bg-secondary);
}
.sidebar-brand-mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
}
.sidebar-brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--accent-color);
    letter-spacing: -0.01em;
    /* Pushes .sidebar-notif-btn to the row's right edge, matching the
       row's other end-aligned control (.company-selector-row's own
       Create Project icon sits the same way relative to the switcher). */
    margin-right: auto;
}
.sidebar-notif-btn {
    position: relative;
    flex-shrink: 0;
}
/* Mirrors .bottom-nav .connection-status's own desktop rule (display:none
   there past 768px): this copy exists so the dot still has somewhere to
   live once the FAB replaces mobile's bottom-nav entirely - see the HTML
   comment on .sidebar-connection-status. */
/* Compound selector, not a plain .sidebar-connection-status: the base
   .connection-status rule (declared later in this file) also sets its own
   unconditional display:inline-block, which at equal specificity wins on
   source order alone and silently overrode a plain class selector here. */
.connection-status.sidebar-connection-status {
    display: none;
    flex-shrink: 0;
}
@media (max-width: 767px) {
    .connection-status.sidebar-connection-status {
        display: inline-block;
    }
}
.sidebar-notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.2rem;
    border-radius: 999px;
    background: var(--danger-color);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg-secondary);
}
.sidebar-notif-badge.hidden {
    display: none;
}

/* Mobile: with Contacts/Notifications open, .pane-left-mode-header's own
   back button is the one and only way out - the brand row's logo and its
   own Contacts/Notifications buttons sitting above it just doubled up on
   that same "leave" affordance without doing anything a full-screen mode
   couldn't already do via the header below it, making the back button read
   as less than the whole story. Desktop keeps the brand row: Contacts/
   Notifications share the row with the chat list there instead of covering
   the whole pane, so there's no competing "back" to begin with. */
@media (max-width: 767px) {
    .pane-left-content:has(#pane-left-mode-header:not(.hidden)) .sidebar-brand,
    .pane-left-content:has(#pane-left-mode-header:not(.hidden)) .mobile-fab,
    .pane-left-content:has(#pane-left-mode-header:not(.hidden)) .mobile-fab-menu {
        display: none;
    }
}

/* Mobile-only avatar FAB, replacing the bottom-nav footer entirely on this
   breakpoint (see .bottom-nav's own max-width:767px rule and the HTML
   comment on #mobile-fab): floats over the project list, opens
   #mobile-fab-menu. Desktop is untouched - .bottom-nav still docks inside
   .pane-left there exactly as before. Hidden unconditionally by default: a
   <button>/<div> has no display:none of its own to fall back on past the
   media query below, so without this both rendered inline at desktop,
   pushed into the document flow whereever they happened to sit in the
   sidebar-brand markup instead of being invisible there. */
.mobile-fab,
.mobile-fab-menu {
    display: none;
}
@media (max-width: 767px) {
    /* A capsule carrying who you are, not a bare 56px avatar tile: the
       avatar alone said "an account" without saying whose, and read as a
       floating project tile (it even used the same 16px entity radius) on
       top of a list of project tiles. Now it's a pill - avatar plus name -
       which is both unmistakably a person and unmistakably a control. */
    .mobile-fab {
        display: flex;
        align-items: center;
        gap: 8px;
        position: fixed;
        right: 16px;
        /* env() falls back to 0px on browsers without the notch/home-
           indicator inset, so this is just 20px there - same as a plain
           fixed value would be, but correct on an iPhone too. */
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        z-index: 40;
        max-width: calc(100vw - 32px);
        height: 52px;
        /* Even inset now that the "+" is the trailing element rather than a
           badge pinned on the avatar: both ends hold a round 40/22px shape,
           so the extra right padding the bare label used to need is gone. */
        padding: 6px;
        border: 1px solid var(--border-color);
        border-radius: 999px;
        background: var(--bg-secondary);
        cursor: pointer;
        box-shadow: var(--shadow-md);
    }
    .mobile-fab-avatar {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
        font-size: 0.95rem;
        /* Round: a person, per the app-wide split (.msg-avatar, .detail-avatar
           and the members list are all 50%; the rounded square belongs to
           projects/entities). This was 16px, the entity radius. */
        border-radius: 50%;
    }
    .mobile-fab-name {
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--text-primary);
    }
    /* The "this opens a menu" affordance: sits half off the avatar's own
       top-left corner rather than centered on top of it, so it reads as a
       badge marking the button, not as covering part of the avatar image
       a real photo would show there later. */
    /* Trailing element in the capsule's own flex row, not absolutely pinned
       on the avatar: overlapping it covered the initials that say whose
       account this is (and would clip a photo avatar later). No separating
       ring needed any more either - that existed only to lift it off the
       avatar it used to sit on. */
    .mobile-fab-plus {
        flex-shrink: 0;
        width: 22px;
        height: 22px;
        margin-left: 2px;
        border-radius: 50%;
        background: var(--accent-color);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.65rem;
    }
    /* A stack of separate cards with real space between them, not one card
       subdivided by a rule. Same shape the message reaction bar and its
       context menu already use when they appear together: a gap says "these
       are different things" far more plainly than a hairline inside a single
       surface, where the CTA still reads as the first row of one list. The
       outer element carries no surface of its own any more - it only
       positions and spaces the blocks. */
    .mobile-fab-menu {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        right: 16px;
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
        z-index: 40;
        min-width: 190px;
        gap: 8px;
    }
    .mobile-fab-menu-group {
        display: flex;
        flex-direction: column;
        gap: 2px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        box-shadow: var(--shadow-md);
        padding: 6px;
    }
    .mobile-fab-menu.hidden {
        display: none;
    }
    .mobile-fab-menu-item {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        padding: 10px 12px;
        background: none;
        border: none;
        border-radius: 10px;
        color: var(--text-secondary);
        font-size: 0.9rem;
        text-align: left;
        cursor: pointer;
    }
    .mobile-fab-menu-item i {
        width: 20px;
        text-align: center;
        font-size: 1rem;
    }
    .mobile-fab-menu-item:hover,
    .mobile-fab-menu-item:active {
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.05);
    }
    /* The one action here that creates something, given the accent so it
       doesn't have to be found by reading three identical rows. Full-strength
       accent rather than a tint: this is the same primary weight .btn-primary
       carries everywhere else, so a CTA looks like a CTA app-wide. */
    /* Its own card now rather than a row inside one, so it carries the
       radius/shadow itself. Slightly taller than a plain row: it's the
       primary action, and it no longer has neighbours to match. */
    .mobile-fab-menu-cta {
        background: var(--accent-color);
        color: #fff;
        font-weight: 600;
        padding: 13px 14px;
        border-radius: 12px;
        box-shadow: var(--shadow-md);
    }
    .mobile-fab-menu-cta:hover,
    .mobile-fab-menu-cta:active {
        background: var(--accent-hover);
        color: #fff;
    }
    .mobile-fab:active .mobile-fab-avatar {
        filter: brightness(0.9);
    }
}

/* Company Selector Row */
.company-selector-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* Was "0 1rem 1rem 1rem" - zero top padding, relying entirely on
       .sidebar-brand's own bottom padding above it for separation. Every
       other header-like row in the sidebar/app settled on a real gap of
       its own (.pane-left-mode-header, .side-panel-header,
       .pane-side-header, .chat-header all use 16px padding on a 60px
       row) - this was the one row leaning on a neighbor's padding
       instead of having its own, which read as cramped next to them. */
    /* Symmetric top/bottom (was 1rem bottom, 0.5rem top - leftover from
       when the row still relied on internal padding, not the margin
       below, to separate itself from the search box; that made the
       colored padding BELOW the button noticeably taller than the
       actual transparent gap to the search box, unbalanced). */
    padding: 0.5rem 1rem 0.5rem 1rem;
    /* Keeps its own background (matches .sidebar-brand above it, same
       var(--bg-secondary)) - margin-bottom is what actually separates
       this row from the search box now, not internal padding that's
       the same color as the rest of the row. */
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
}

/* Filters the rendered .project-item rows client-side (see filterProjectList
   in app.js): there's no separate "search results" view, matching rows just
   stay in place and everything else hides. */
.project-search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem 0.75rem 1rem;
    /* Was 0.5rem (8px) vertical, matching .company-switcher-btn's own
       bump above for the same reason - the tightest padding in this
       part of the sidebar next to rows that settled on more. */
    padding: 10px 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.project-search-icon {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
}
.project-search-box input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}
.project-search-box input::placeholder {
    color: var(--text-secondary);
}
.project-search-clear {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: color var(--motion-fast) var(--motion-ease), background var(--motion-fast) var(--motion-ease);
}
.project-search-clear:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}
.project-search-clear.hidden {
    display: none;
}
/* The dropdown trigger: one control for every company count (1 or many),
   replacing the old bare label / native <select> split. See
   renderCompanySwitcherButton + openCompanySwitcherMenu in app.js. */
.company-switcher-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    /* Was 8px vertical - the tightest padding of any interactive row in
       the sidebar (the search box below it and every header-like row
       elsewhere in the app use 10-16px). 10px keeps this reading as a
       compact control (not a full 60px header) while no longer standing
       out as the cramped one next to its own neighbors. */
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    /* Standard global radius (--radius: 6px), not a capsule: same fix as
       the Tasks/Progress/Cost pills: full rounding on an active/selected
       control read as less professional than a plain corner. */
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}
.company-switcher-btn:hover {
    border-color: var(--border-hover);
}
.company-switcher-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.company-switcher-caret {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Company management: list + form sub-views */
#company-list-view,
#company-form-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.company-list-body,
.company-form-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 8px 0;
}

/* The footer row under the scrolling list/form above (+ Create Company /
   Save). Had no rule of its own at all - just an inline padding style - so
   it sat directly on the page's own background with nothing marking it as
   a footer, reading as a small button that had drifted loose rather than a
   deliberate action bar, exactly like .modal-footer already reads
   everywhere else in the app. flex-shrink:0 so the scrolling sibling above
   can never compress it. */
.form-actions {
    flex-shrink: 0;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* The form has padding all around, and clear separation between its
   sections (Company Name / Subscription Plan / Company Administrators). */
.company-form-body {
    padding: 16px;
}

.company-form-body .form-section+.form-section {
    margin-top: 1.5rem;
}

/* Company administrators editor */
.admins-add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.admins-add-row .input-field {
    flex: 1;
    min-width: 0;
}

.admins-add-row .btn {
    flex-shrink: 0;
}

.admins-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.admin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.admin-row:last-child {
    border-bottom: none;
}

.admin-row__info {
    min-width: 0;
}

.admin-row__name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-row__role {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 2px;
}

.admin-remove-btn {
    flex-shrink: 0;
    color: var(--danger-color, #e74c3c) !important;
}

.empty-admins {
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.9em;
    text-align: center;
}

.company-list {
    display: flex;
    flex-direction: column;
}

.company-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.company-row__info {
    min-width: 0;
    /* Grows to absorb the row's free space itself now, so .company-row__actions
       beside it (Web link + Edit) sits as one grouped cluster right after it
       instead of getting spread apart by the row's own justify-content:
       space-between - which, with those two buttons as separate direct
       children, was treating them as two independent items to push toward
       the far edge rather than one action group. */
    flex: 1;
}

.company-row__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.company-row__name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-row__plan {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 2px;
}

.company-row__expiry {
    font-size: 0.78em;
    color: var(--text-muted);
    margin-top: 2px;
}

.company-row__renew {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 6px;
}

.company-row__renew-text {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.company-edit-btn {
    flex-shrink: 0;
}

.close-app-btn {
    color: var(--text-secondary) !important;
    margin-right: 8px;
    font-size: 1.25rem !important;
}

.close-app-btn:hover {
    color: var(--text-primary) !important;
}

#company-display-area {
    flex: 1;
    min-width: 0;
}

/* Icon-only now, sitting beside the company switcher rather than its own
   full-width pill row below it: .icon-btn/.icon-btn-cornered/
   .icon-btn-muted-svg do the rest (see the "Custom SVG icons" criteria on
   /design-system#icons); a `title` attribute on the button carries the
   "Create Project" label as a native tooltip instead of always-visible text. */
.btn-create-project {
    flex-shrink: 0;
}
.btn-create-project-icon {
    width: 22px;
    height: 22px;
}

/* Project List */
.project-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* .project-item / .project-item:hover / .project-item.active are defined
   once, near .avatar/.chat-info above: this used to be a second,
   lower-specificity copy that only won on padding/background via source
   order. Consolidated to avoid the two drifting out of sync. */

/* Button Styles */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    /* Theme-aware surface + border. The old rgba(255,255,255,.1) was invisible
       on light themes (white on white). */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
}

/* Form Controls */
.form-select {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-primary);
    width: 100%;
    font-size: 0.875rem;
}

.form-select option,
.input-addon option,
.input-field option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.company-label {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
/* Replaced entirely by the avatar FAB on mobile (see .mobile-fab): this
   used to be Settings + the connection dot, both now off the FAB menu/
   brand row instead of a permanently-docked footer. Desktop's version (a
   real floating popover docked inside .pane-left via nav-dock.js, see the
   min-width:768px block below) is untouched - Contacts lives there again
   too now, see the HTML comment on #sidebar-nav-popover. */
@media (max-width: 767px) {
    .bottom-nav {
        display: none;
    }
}

.nav-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    border-top: 3px solid transparent;
    position: relative;
}

/* Unread badge on a bottom-nav tab (e.g. pending contact requests) */
.nav-badge {
    position: absolute;
    top: 0.35rem;
    right: 50%;
    transform: translateX(1.1rem);
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--danger-color);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.05rem;
    text-align: center;
}

.nav-btn.active {
    color: var(--accent-color);
    border-top-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

.nav-btn:hover:not(.active),
.nav-btn:active:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Four tabs plus the status dot get tight on narrow phones; trim the padding
   and label size so longer labels like "Notifications" stay on one line. */
@media (max-width: 480px) {
    .nav-btn {
        padding: 0.75rem 0.2rem;
    }

    .nav-label {
        font-size: 0.6rem;
    }
}

/* Connection status in bottom nav */
.bottom-nav .connection-status {
    /* Fixed 50px slot on the left (10px dot + 20px margins each side),
       with the dot centered in it. The tabs split the rest. */
    flex: 0 0 auto;
    margin: 0 10px;
    align-self: center;
}

/* Mobile: .sidebar-nav-popover is invisible to layout: its children
   (the 4 nav-btns + theme row) sit directly in .bottom-nav's flex row
   exactly as if it weren't there, so the existing mobile bar is unchanged. */
.sidebar-nav-popover {
    display: contents;
}

/* Desktop-only nav icon / profile card: hidden on mobile, where the emoji
   .nav-icon and the fuller Account tab already cover the same ground.
   Turned on in the min-width:768px block below alongside the rest of the
   bottom-nav restyle. */
.nav-icon-desktop,
.sidebar-profile-card {
    display: none;
}

/* Tablet/desktop: .bottom-nav shrinks to just the profile-card row (one
   compact bar) and: see nav-dock.js: is moved to be the last child of
   .pane-left instead of staying a page-level sibling of .content-area. Both
   used to be children of the same height:100vh flex column, so the nav's own
   height came out of that shared budget: a taller nav shrank .content-area
   and left a visible gap below the chat/message pane, which had nothing to
   do with the nav at all. As a true child of .pane-left (already
   flex-direction:column) it just takes its natural height at the bottom of
   that column instead, and .pane-right is no longer affected by it either
   way. Nav items + theme picker move into .sidebar-nav-popover, a floating
   popover opened by the profile card, rather than a permanently expanded
   block. */
@media (min-width: 768px) {
    .chat-input-area {
        height: 61px;
        min-height: 61px;
        padding: 0 16px;
        box-sizing: border-box;
    }

    .chat-input-area input {
        height: 40px;
        min-height: 40px;
        padding-top: 0;
        padding-bottom: 0;
        box-sizing: border-box;
    }

    .chat-input-area .report-btn {
        padding: 4px;
    }

    .bottom-nav {
        position: relative;
        border-top: 1px solid var(--border-color);
        border-radius: 0;
        padding: 0;
        /* Keep the account footer and the chat composer on the same
           baseline. Both are docked at the bottom of their pane, so their
           outer heights must be explicit rather than content-driven. */
        height: 61px;
        min-height: 61px;
        box-sizing: border-box;
    }

    .bottom-nav .connection-status {
        display: none;
    }

    /* Same appear/dismiss motion as the shared popover rule above this media
       query: duplicated rather than added to that rule's selector list
       because .sidebar-nav-popover is display:contents on mobile (see the
       comment there), and this block is the only place it's a real popover. */
    .sidebar-nav-popover {
        display: flex;
        flex-direction: column;
        position: absolute;
        /* An intrinsic width, not `left: 8px; right: 8px` stretching this to
           match whatever .pane-left's current (user-resizable) width happens
           to be: a floating overlay has no reason to track its anchor's
           width at all. */
        left: 8px;
        width: 260px;
        bottom: calc(100% + 6px);
        background: var(--bg-secondary, #1e293b);
        border: 1px solid var(--border-color, #334155);
        border-radius: 12px;
        box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
        padding: 6px;
        gap: 2px;
        max-height: 70vh;
        overflow-y: auto;
        scrollbar-gutter: stable;
        z-index: 60;
        opacity: 0;
        visibility: hidden;
        clip-path: inset(100% 0 0 0);
        pointer-events: none;
        transition: opacity var(--motion-fast) var(--motion-ease),
            clip-path var(--motion-fast) var(--motion-ease),
            visibility 0s linear var(--motion-fast);
    }

    .sidebar-nav-popover.open {
        opacity: 1;
        visibility: visible;
        clip-path: inset(0 0 0 0);
        pointer-events: auto;
        transition: opacity var(--motion-fast) var(--motion-ease),
            clip-path var(--motion-fast) var(--motion-ease);
    }

    @media (prefers-reduced-motion: reduce) {
        .sidebar-nav-popover {
            transition: opacity var(--motion-fast) linear, visibility 0s linear var(--motion-fast);
        }

        .sidebar-nav-popover.open {
            transition: opacity var(--motion-fast) linear;
        }
    }

    .nav-btn {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 10px 12px;
        border-top: none;
        border-radius: 10px;
    }

    .nav-btn.active {
        border-top-color: transparent;
    }

    .nav-icon {
        display: none;
    }

    .nav-icon-desktop {
        display: inline-flex;
        width: 20px;
        font-size: 1rem;
        text-align: center;
    }

    .nav-label {
        font-size: 0.9rem;
    }

    .nav-badge {
        position: static;
        transform: none;
        margin-left: auto;
    }

    .sidebar-profile-card {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 60px;
        min-height: 60px;
        padding: 12px;
        box-sizing: border-box;
        border: none;
        /* .bottom-nav is nested inside .pane-left now (nav-dock.js), not a
           page-corner element, so there's no outer corner to match anymore:
           flush/square keeps the hover fill simple and edge-to-edge. */
        border-radius: 0;
        background: none;
        color: var(--text-primary);
        cursor: pointer;
        text-align: left;
        width: 100%;
    }

    .sidebar-profile-card:hover,
    .sidebar-profile-card.open {
        background: rgba(255, 255, 255, 0.05);
    }

    .sidebar-profile-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        font-size: 0.85rem;
        flex-shrink: 0;
    }

    /* A row, not a column: the chevron is a sibling of .sidebar-profile-text
       (the name+email stack) spanning this row's full height, so
       align-items:center here centers it against BOTH lines together:
       which is what actually lines it up with the avatar next to it (also
       centered against this same two-line height by the outer row). Centering
       it only against the name line on its own, one line taller than the
       chevron needs, put it visibly above that true middle. */
    .sidebar-profile-info {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .sidebar-profile-text {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .sidebar-profile-name {
        min-width: 0;
        font-weight: 600;
        font-size: 0.88rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-profile-email {
        font-size: 0.75rem;
        color: var(--text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Icon-only: no chip/background. A fixed small frame so its own
       whitespace doesn't grow/shrink with the glyph, and flex centering
       (rather than relying on the icon's own line-height, which FA glyphs
       don't sit centered within) for true vertical alignment against the
       name text next to it. */
    .sidebar-profile-chevron {
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 18px;
        height: 18px;
        font-size: 0.7rem;
        line-height: 1;
        color: var(--text-secondary);
        transition: transform 0.15s ease;
    }

    .sidebar-profile-card.open .sidebar-profile-chevron {
        transform: rotate(180deg);
    }
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
}

/* Placeholder */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
}

.placeholder h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
}

.placeholder p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Account tab: name/phone/version carry their own colours rather than relying
   on an inherited one, so they follow the theme in every case. */
#account-name {
    color: var(--text-primary);
}

#account-phone,
.version-info {
    color: var(--text-secondary);
}

/* Desktop: Split Screen */
@media (min-width: 768px) {
    .pane-left {
        /* Set/persisted by pane-resizer.js as the pane is dragged; 360px until
           then or on a viewport too narrow for a saved value to fit. */
        width: var(--pane-left-width, 360px);
        flex-shrink: 0;
        /* -x only, not a full clip: .sidebar-nav-popover (the account menu)
           is an absolutely-positioned descendant that deliberately floats
           ABOVE this pane's own top edge (see its `bottom: calc(100% + 6px)`)
          : a plain `overflow: hidden` here would clip it away entirely
           whenever it's open. Horizontal clipping is all the width
           transition below actually needs, to keep row content from
           spilling past the shrinking edge while it animates. */
        overflow-x: hidden;
        transition: width var(--motion-med) var(--motion-ease);
    }

    .pane-resizer {
        display: block;
        transition: width var(--motion-med) var(--motion-ease),
                    opacity var(--motion-med) var(--motion-ease);
    }

    @media (prefers-reduced-motion: reduce) {
        .pane-left,
        .pane-resizer { transition: none; }
    }

    .pane-right {
        display: block;
    }

    .back-button {
        display: none;
    }

    .project-header .connection-status {
        display: none;
    }
}

/* Mobile: Single Pane with Navigation */
@media (max-width: 767px) {
    .pane-left.hidden-mobile {
        display: none;
    }

    .pane-right.show-mobile {
        display: block;
        width: 100%;
    }

    .back-button {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        color: var(--text-primary);
        cursor: pointer;
    }
}

/* ===== CREATE COMPANY MODAL ===== */

/* Consolidated styles applied above */

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-header .icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.modal-header .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-section {
    padding: 10px;
}

/* Subscription Plans */
.storage-meter {
    margin-top: 1em;
}

.storage-meter__label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 0.4em;
}

.storage-meter__track {
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    overflow: hidden;
}

.storage-meter__fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent-color);
    transition: width 0.2s;
}

.storage-meter__fill.storage-meter__fill--warn {
    background: var(--danger-color);
}

.subscription-plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1em;
    margin-top: 1em;
    /* No inner scroll: the whole company form (.company-form-body) scrolls, so
       the plan grid renders its cards fully. A capped, scrolling grid hid the
       Custom Plan card (appended last) below the fold. */
}

.plan-card {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5em;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
    /* Column layout + equal-height cards (grid stretches a row) let each card
       pin its price/duration section to the bottom, so prices line up across
       cards regardless of how many feature lines each has. */
    display: flex;
    flex-direction: column;
}

.plan-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.plan-card.selected {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

.plan-card h4 {
    margin: 0 0 0.5em;
    color: var(--text-primary);
    font-size: 1.2em;
}

.plan-card .price {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--accent-color);
    margin: 0.5em 0 0;
    /* Pin to the bottom so the Free card's price aligns with paid cards'
       duration/price sections. */
    margin-top: auto;
    padding-top: 1rem;
}

.plan-card .price small {
    font-size: 0.6em;
    color: var(--text-secondary);
}

.plan-card ul {
    list-style: none;
    padding: 0;
    margin: 1em 0 0;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.plan-card ul li {
    padding: 0.3em 0;
}

.plan-card ul li::before {
    content: "✓ ";
    color: var(--success-color);
    font-weight: bold;
    margin-right: 0.5em;
}

/* Tier-unlocked capabilities (Report approval, Sub-projects): accented so they
   read as the premium features the tier adds, not just another limit. */
.plan-card ul li.plan-cap {
    color: var(--accent-color);
    font-weight: 600;
}

/* A tier card with duration options isn't itself clickable - its buttons are. */
.plan-card:not([data-plan-id]) {
    cursor: default;
}
.plan-card:not([data-plan-id]):hover {
    transform: none;
    border-color: var(--border-color);
}
.plan-card.selected:not([data-plan-id]):hover {
    border-color: var(--accent-color);
}

/* Static "Custom Plan" contact card — not selectable, opens the contact-us modal. */
.plan-card--custom {
    cursor: default;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75em;
}
.plan-card--custom:hover {
    transform: none;
    border-color: var(--border-color);
}
.plan-card__custom-blurb {
    margin: 0;
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.4;
}
.plan-card--custom .btn {
    align-self: stretch;
    /* Pin the button to the bottom so it lines up with the other cards'
       price/duration sections. */
    margin-top: auto;
}

/* Inline status/error area inside the Custom Plan modal. */
.custom-plan-status {
    margin-top: 12px;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: .85rem;
    color: var(--text-secondary);
}
.custom-plan-status.hidden { display: none; }
.custom-plan-status--error {
    background: color-mix(in srgb, var(--danger-color) 12%, transparent);
    color: var(--text-primary);
    border: 1px solid color-mix(in srgb, var(--danger-color) 45%, transparent);
}

/* Duration options within a tier (Monthly / Annual / ...). */
.plan-durations {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Push the price/duration options to the bottom of the card so they align
       across cards of different feature-list lengths. */
    margin-top: auto;
    padding-top: 1rem;
}
.plan-duration {
    /* Stack the price under the Monthly/Annual label instead of beside it. */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: border-color 0.15s, background 0.15s;
}
.plan-duration:hover {
    border-color: var(--border-hover);
}
.plan-duration.selected {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.15);
}
.plan-duration__label {
    font-weight: 600;
}
.plan-duration__price {
    color: var(--text-primary);
    font-weight: 600;
}
.plan-duration__price small {
    color: var(--text-muted);
    margin-left: 2px;
}

.loading-plans {
    text-align: center;
    padding: 2em;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* The gap above a label (this margin) and the gap below it (the label's own
   margin) are kept equal so the label sits centred between the field above it
   and its own field. They used to be 1rem/0.5rem, which pushed every label
   towards its input and left a bigger gap on top. The total spacing between
   two fields is unchanged. */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.input-field::placeholder {
    color: var(--text-secondary);
}

/* --- Contact Management Styles --- */
.contacts-header {
    padding: 15px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contacts-header .search-container {
    width: 100%;
}

.contacts-header .search-container input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
/* Neither this input nor .quick-add input below carries .input-field (they
   predate it, or were just never switched over), so neither picked up its
   :focus rule - same browser-default-ring gap as .icon-btn/.btn/.form-select
   had, just on a class the earlier pass didn't know to look for. Same
   .input-field convention here: swap the border to the theme's accent
   instead of drawing a ring on top of it. */
.contacts-header .search-container input:focus,
.quick-add input:focus {
    outline: none;
    border-color: var(--accent-color);
}

#btn-sync-contacts {
    margin-top: 5px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 600;
}

.quick-add {
    display: flex;
    gap: 10px;
}

.quick-add input {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.contact-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.contact-item .avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-weight: 600;
    color: var(--text-primary);
}

.contact-phone {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Modal for Sync Results */
/* Unified Modal Overlay System applied */

/* Redundant Modal box rule removed */

/* Global modal standard: dialog.app-modal ITSELF is the ONLY scroller (see
   its rule further down) - header, body, and footer all move together as
   one sheet, the way sliding a physical piece of paper would, rather than
   .modal-body (or .modal-container) owning a second, independent scroll
   nested inside it. That used to give a tall modal a short, cramped inner
   scrollbar sitting inset from the card's own edge, with the header pinned
   outside it entirely. Header/footer are plain static content now, NOT
   sticky: sticky would hold them fixed on screen while the rest of the
   card scrolls underneath, which reads as content moving inside a window
   cut into the card rather than the whole sheet of paper sliding as one
   rigid piece - the header's own rounded top corner would scroll out from
   behind it while the header text itself stayed put, breaking the "one
   piece" look this is meant to have. Scrolling the dialog itself, not
   .modal-container, still means the native scrollbar renders flush
   against the dialog's own outer edge (there's nothing else outside
   .modal-container to inset it) instead of tucked inside the card with
   visible background peeking around it. */
.modal-header {
    padding: 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

/* Left-aligned, like every other form in the app. .modal-container sets
   text-align:center for the popup/confirm modals (a centred title + one
   sentence + one button, where that's right), and every form modal - report,
   task, cost, create-project - silently inherited it, so their .form-group
   labels rendered centred over left-aligned inputs. .form-group label is
   display:block precisely so a label sits on its own line above its field;
   centring it breaks the read down the left edge that makes a form scannable.
   Scoped to .modal-body, which only the form modals use: #popup-modal and
   #app-confirm put their content straight in .modal-container and stay
   centred. */
.modal-body,
/* .modal-section is the same thing under a different name - #create-project-
   modal wraps its form-groups in these instead of one .modal-body, so it kept
   inheriting the centring until it was named here too. */
.modal-section {
    text-align: left;
}
.modal-body {
    padding: 15px 20px;
}
/* A <textarea> does not inherit font-family from its ancestors - the UA
   stylesheet sets it to monospace - so the report's Description box rendered
   in a mono face while every other field in the same form was Inter. Every
   other control (input, select, button) is covered by their own rules; this
   was the one left on the browser default. */
textarea,
textarea.input-field {
    font-family: inherit;
}

.modal-footer {
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    text-align: right;
}

/* Size only, deliberately - no background/color/border here any more. This
   used to also set background:accent-color + color:white + border:none, and
   because it shares .btn-secondary's specificity (both single classes) while
   being declared LATER in this file, it silently won that tie on every
   .btn-secondary.btn-sm combo app-wide (Web link/Edit in Companies, Export
   report in the members modal's Project actions) - all rendered as solid
   accent blue with no border, indistinguishable from .btn-primary, no matter
   which variant class they actually carried. .btn-danger.btn-sm happened to
   escape it only because .btn-danger is declared even later still - luck of
   file position, not a rule anyone could see. Colour is exclusively
   .btn-primary/.btn-secondary/.btn-danger's job now; this only sets what's
   legitimately size. */
.btn-small,
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
}

.btn-small.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-small.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* --- Split View Layout (Dual Pane) --- */
.split-container {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
}

.split-left {
    flex: 0 0 350px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.split-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* Contacts Header Tuning */
.contacts-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contacts-header .search-container {
    margin-bottom: 0;
}

.quick-add {
    display: flex;
    gap: 8px;
}

.quick-add input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
}

/* Detail View Styles */
/* .scroll-content (see its own rule) makes this the real scroller: full
   pane width so its scrollbar/gutter hug the pane's true edge, same
   reasoning as .messages-scroll vs .messages-inner - max-width+centering
   lives one level deeper, on .contact-detail-card, instead of here, so
   the scrollbar doesn't end up floating in the middle of a wide pane.
   flex:1/min-height:0 is what actually lets it scroll at all: it sits
   inside #contact-details-view's own flex column (.project-view), and
   without an explicit min-height a flex item defaults to fitting its
   content instead of being capped by the column - which is exactly what
   used to let a long contact detail get silently clipped by .project-
   view's own overflow:hidden instead of ever reaching a scrollbar. */
.details-content {
    flex: 1;
    min-height: 0;
    padding: 30px;
}

.details-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    opacity: 0.5;
}

.details-placeholder i {
    font-size: 64px;
    margin-bottom: 15px;
}

.contact-detail-card {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.detail-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    color: white;
}

.detail-info {
    text-align: center;
}

.detail-name {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.detail-phone {
    color: var(--text-secondary);
    font-family: monospace;
}

.shared-projects {
    width: 100%;
    margin-top: 30px;
}

.shared-projects h4 {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.project-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.project-chip {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.project-chip:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

/* Sync Header Styles */
.sync-section-header {
    padding: 15px;
    background: var(--bg-tertiary);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

/* Mobile-only elements are hidden by default and revealed by the media query
   below. This must come BEFORE that block: both rules are !important with equal
   specificity, so source order decides, and having it after meant the desktop
   default won on mobile too and .mobile-only was hidden at every width. */
.mobile-only {
    display: none !important;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .split-left {
        flex: 1;
        border-right: none;
    }

    .split-right {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
    }

    .hidden-mobile {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    .details-header {
        padding: 15px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
    }
}

/* Font Awesome now, not a raw &#8592; character: every other back/close
   affordance in the app (#pane-side-close, #pane-left-mode-back,
   #thread-panel-close, #task-panel-close) draws fa-arrow-left, so a plain
   text-glyph arrow here rendered in a different weight/style than all of
   them despite meaning the same thing. Neutral --text-primary, matching
   every other header icon (search, close, etc): back/close/every other
   icon-btn in the app share one plain color, an accent-blue "back" is not
   a real color rule elsewhere, and singling it out read as a link rather
   than a plain navigation icon (see #pane-side-close/.panel-back-icon,
   #pane-left-mode-back-icon.fa-arrow-left, .pane-side-back,
   #btn-company-form-back below - all reverted the same way). */
.back-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    /* Centers the icon inside the enlarged 44px tap target (see
       .chat-header .icon-btn#back-btn) instead of it sitting flush against
       the box's left edge, which is where flex-start would otherwise
       leave it now that the box is wider than the glyph itself. */
    justify-content: center;
    cursor: pointer;
}

/* Create Company's own back-to-company-list step: plain --text-primary,
   same as every other icon-btn - see the long comment on .back-btn above
   for why this app no longer singles "back" out with accent-blue. */
#btn-company-form-back {
    color: var(--text-primary);
}


/* ===== CONNECTION STATUS INDICATOR ===== */
.connection-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

.me-label {
    color: var(--me-accent);
    font-weight: 600;
}

.chat-header {
    height: 60px;
    /* Was 0 10px: every other header in the app (.pane-side-header,
       .pane-left-mode-header) and the pill row directly below this one
       (.mobile-explore-row) all settled on 16px - this was the one
       holdout at a narrower inset, misaligning its back button/title
       against the Tasks/Progress/Cost row sitting flush underneath it. */
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

/* Touch-target spec for this app's "back to the previous screen" buttons
   (#back-btn here; #pane-left-mode-back and #pane-side-close get the same
   treatment, see their own rules): 44x44px minimum, the baseline every
   major guideline converges on for a primary tap target (Apple HIG's own
   44pt, Material Design's 48dp, WCAG 2.5.5's 44px). This one measured
   24x32 - roughly half that in both dimensions, from a leftover width:24px
   override dating back to when this button held a raw text character
   instead of an icon (see the HTML's own back-btn comment). The GLYPH
   stays the same visual size it already was (1rem via .back-btn, matching
   every other back icon in the app): min-width/min-height grow the
   invisible tappable box around it, not the icon itself, so a finger gets
   a fair target without the arrow suddenly reading heavier than its
   surrounding UI. */
.chat-header .icon-btn#back-btn {
    min-width: 44px;
    min-height: 44px;
    /* Material Design 3's top app bar spec: the leading navigation
       icon's touch target sits 4dp in from the bar's own edge, not
       flush against it and not centered under the header's full
       generic content padding either (the 24dp icon then centers
       inside that 48dp target, landing ~16dp from the true edge -
       which is also this app's own established content inset, see
       .chat-header's 16px padding). Scaled to this app's 44px target
       (WCAG 2.5.5's number, not MD's own 48dp): 4/48 of 44 ≈ 4px.
       Header padding is 16px, so margin:-12px pulls the touch target's
       edge in to 16-12=4px from the true edge - was -14px (2px edge
       inset), pulled in far enough to visually collide with the
       header's own rounded corner on desktop's card-framed layout.
       Symmetric on both sides: the same 4px logic applies to the gap
       toward the title as it does to the edge, so the icon sits at
       roughly the same 16dp/16px position content elsewhere in this
       header already uses, without the touch target's own edges
       pushing that inset outward by their own extra padding. */
    margin: 0 -12px;
}

.chat-header-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 44px;
    justify-content: center;
}

.chat-header-text h3 {
    /* Was flex:1: growing to fill .chat-header-text's own 44px column left
       an oversized box around a single line of text (its line-height only
       needs ~19px), pushing the subtitle down into what read as too big a
       gap under the title even though the subtitle's own margin-top is a
       tight 2px. 0 1 auto sizes this to its actual text instead, so the
       two lines sit close together and the pair centers as one block via
       .chat-header-text's own justify-content:center. overflow-y:auto
       stays for the rare title tall enough to actually need it - with no
       flex-grow forcing extra height, that's now the only thing that can
       trigger it. */
    flex: 0 1 auto;
    font-size: 1rem;
    margin: 0;
    line-height: 1.2;
    word-break: break-word;
    overflow-y: auto;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    /* Unconditional here (not transparent-at-rest like the global rule)
       would keep this one scrollbar always visible while every other one
       on the page auto-hides: kept conditional to match. */
    scrollbar-color: transparent transparent;
}

.chat-header-text h3:hover,
.chat-header-text h3:focus-within,
.chat-header-text h3.scrolling-active {
    scrollbar-color: var(--border-color) transparent;
}

.chat-header-text h3::-webkit-scrollbar {
    width: 3px;
}

.chat-header-text h3::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 10px;
    transition: background-color var(--motion-fast) var(--motion-ease);
}

.chat-header-text h3:hover::-webkit-scrollbar-thumb,
.chat-header-text h3:focus-within::-webkit-scrollbar-thumb,
.chat-header-text h3.scrolling-active::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

/* Was var(--pop-green): a bright accent color on a subtitle line reads as
   a status/highlight, competing with the title above it instead of
   supporting it - every other subtitle under a title in the app
   (.chat-header-text on desktop, .side-panel-title, .project-info-hero-
   text) stays on the plain .chat-subtitle base color (--text-secondary)
   for exactly that reason; this was the one place still pulling rank on
   the visual hierarchy with a color that has nothing to do with what the
   text actually says (a member count, not a status). */
.chat-header .chat-subtitle {
    font-weight: 600;
}

.status-connected {
    background-color: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-disconnected {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.status-connecting {
    background-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    animation: statusPulse 1.5s infinite ease-in-out;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* --- Tasks Tab & Modal --- */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
}

.task-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: default;
}

.task-item.admin-only:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    cursor: pointer;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.task-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.task-price {
    font-size: 14px;
    color: var(--accent-color);
    font-weight: 500;
}

.task-progress-container {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    margin: 12px 0;
    overflow: hidden;
}

.task-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #60a5fa);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.task-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.task-dates {
    display: flex;
    gap: 8px;
}

.task-amount {
    font-weight: 500;
}

.tab-actions {
    padding: 12px 15px;
    display: flex;
    justify-content: flex-end;
    border-bottom: 1px solid var(--border-color);
}

.admin-only.hidden {
    display: none !important;
}

/* Delete-project button: company owners/admins only (gated in JS). */
.company-admin-only.hidden {
    display: none !important;
}
.danger-icon-btn {
    color: var(--danger-color);
}
.danger-icon-btn:hover {
    background: color-mix(in srgb, var(--danger-color) 14%, transparent);
    color: var(--danger-color);
}

/* The delete-project confirm lists several warnings joined by blank lines;
   preserve those breaks (other confirm messages are single-line, unaffected). */
#app-confirm-message {
    white-space: pre-line;
}

/* Modal form row fix */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .modal .modal-container {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        flex: 1;
        overflow-y: auto;
        scrollbar-gutter: stable;
        padding: 20px;
    }

    .modal-header {
        border-radius: 0;
    }
}

.footer-right {
    display: flex;
    gap: 10px;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* --- Task Reporting Styles --- */

.msg-report {
    max-width: 85%;
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 12px;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    background: #1e293b;
    /* Dark slate */
    border: 1px solid #334155;
    color: #f1f5f9;
}

.msg-me.msg-report {
    background: #1e3a8a;
    /* Deep blue */
    border-color: #2563eb;
    margin-left: auto;
}

/* A flex item's CROSS-AXIS auto margin (margin-left above, since this column
   is flex-direction:column) wins over align-self: that's what auto margins
   are FOR: so the plain .msg-me { align-self: flex-start } flip earlier in
   this file (search "Once the message column") had no effect on report
   balloons specifically: every other own-message bubble uses align-self
   alone and flipped correctly, only this one had its own competing margin
   rule. Cancel it once the column's wide enough to have triggered that
   flip, so a report balloon joins the same left edge instead of being the
   one bubble type still stuck on the right. 40px, not 0: matches the
   avatar-reserving margin-left the plain @container (min-width: 900px)
   rule gives every other .msg-me bubble at this width; 0 would leave own
   report balloons the one bubble type with no room for its avatar. */
@container (min-width: 900px) {
    .msg-me.msg-report {
        margin-left: 40px;
    }
}

.msg-other.msg-report {
    background: #334155;
    /* Slate */
    border-color: #475569;
    margin-right: auto;
}

.report-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: #94a3b8;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.report-header i {
    color: #10b981;
    /* Emerald green icon */
}

.report-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-task-name {
    font-weight: 600;
    font-size: 1.05em;
    color: #fff;
}

.report-amount {
    font-size: 0.9em;
    color: #cbd5e1;
}

.report-amount strong {
    color: #3b82f6;
}

/* Progress reports show both the task total and the delta represented by
   this report. Keeping the two values in a compact metric row makes the
   report more prominent than a normal chat bubble without inventing a new
   attachment or message primitive. */
.report-progress-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 2px;
    padding: 9px 0;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.report-progress-summary > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.report-progress-summary > div + div {
    padding-left: 10px;
    border-left: 1px solid rgba(148, 163, 184, 0.2);
}
.report-progress-summary span {
    color: #94a3b8;
    font-size: 0.76rem;
}
.report-progress-summary strong {
    color: #f1f5f9;
    font-size: 1.05rem;
    line-height: 1.15;
}
.report-progress-addition strong {
    color: var(--accent-color);
}
.report-progress-bar {
    height: 7px;
    margin: 1px 0 2px;
    overflow: hidden;
    border-radius: 3px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(148, 163, 184, 0.25);
    display: flex;
}
.report-progress-bar span {
    display: block;
    height: 100%;
    border-radius: 2px;
    transition: width 180ms ease;
}
.report-progress-prior { background: var(--accent-color, #428cff); }
.report-progress-addition-fill { background: var(--accent-color); }

.report-desc {
    font-size: 0.9em;
    color: #94a3b8;
    font-style: italic;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px;
    border-radius: 8px;
    margin-top: 6px;
}

/* Edit/delete controls, pushed to the far end of the report header. */
.report-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.report-action-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.85em;
    line-height: 1;
}

.report-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* "Edited by X" note under a report someone other than the author changed. */
.report-edited-by {
    font-size: 0.78em;
    color: #94a3b8;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* "Approved by X" -- same shape as Edited-by, tinted with the approved color. */
.report-approved-by {
    font-size: 0.78em;
    color: var(--success-color, #22c55e);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* An offline/in-flight edit the server has not confirmed yet. */
.report-pending {
    font-size: 0.78em;
    color: #f59e0b;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* An earlier copy of a report that has since been re-posted after an edit. */
.report-superseded,
.report-tombstone {
    font-size: 0.85em;
    color: #94a3b8;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
}

.report-tombstone {
    color: #ef4444;
    font-style: normal;
}

.report-loading,
.report-error {
    font-size: 0.85em;
    color: #94a3b8;
    padding: 10px;
    text-align: center;
}

/* --- Report attachments: modal picker --- */
.report-attachments {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}
.report-attachments:empty {
    margin-bottom: 0;
}
/* The attachment is the subject of a report, not a footnote to it: the form
   deliberately puts it first (see the HTML comment on #report-attachments -
   a photo of finished work is usually what prompts the report at all), but a
   52px chip next to a caption box read as an afterthought and undercut that
   ordering. Given a real preview and room to breathe so what you're
   reporting is what you see. */
.attachment-row {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
}
.attachment-thumb {
    /* 52 -> 84: large enough to actually recognise the photo you just picked,
       which is the whole point of showing it back. */
    width: 84px;
    height: 84px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}
.attachment-thumb.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: var(--text-secondary);
}
.attachment-thumb.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    color: var(--text-muted);
}
.attachment-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.attachment-name {
    font-size: 0.78em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachment-caption {
    width: 100%;
    font-size: 0.85em;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
}
.attachment-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1em;
    flex-shrink: 0;
    padding: 2px 6px;
}
.attachment-remove:hover {
    color: var(--danger-color, #ef4444);
}
.btn-attach {
    font-size: 0.85em;
    padding: 8px 12px;
}

/* --- Report attachments: in the chat balloon (media-message style) --- */
.report-media-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.report-media {
    margin: 0;
    /* Positioning context for the video play badge below. */
    position: relative;
    width: fit-content;
}

/* Play badge over a video attachment. The native control bar already has a
   play button, but it sits in a strip at the bottom edge and reads as chrome:
   at a glance a video attachment was indistinguishable from a dark image. A
   centred badge is what makes "this is a video" legible before any
   interaction, the way every chat app shows it.
   :has() rather than a class on the figure, so this needs no markup change. */
.report-media:has(> video)::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    /* Sits above the frame's centre rather than dead-centre: the native
       control bar occupies the bottom ~40px, so true centring reads as low. */
    transform: translate(-50%, calc(-50% - 18px));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.62) no-repeat center;
    /* Triangle drawn as a mask so it inherits one flat colour and needs no
       second element. */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    /* The badge must never swallow a click meant for the video or its
       controls: it is a label, not a button. */
    pointer-events: none;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMiIgdmlld0JveD0iMCAwIDIwIDIyIj48cGF0aCBkPSJNMTggOS4yNjhhMiAyIDAgMCAxIDAgMy40NjRMMyAyMS4zOTVhMiAyIDAgMCAxLTMtMS43MzJWMi4zMzdhMiAyIDAgMCAxIDMtMS43MzJ6IiBmaWxsPSIjZmZmIi8+PC9zdmc+");
    background-size: 20px 22px;
    background-position: 53% 50%;
    transition: opacity var(--motion-fast) var(--motion-ease);
}
/* Hidden while the clip actually plays: see wireVideoPlayState in app.js.
   CSS alone cannot ask whether a video is paused. */
.report-media.is-playing::after {
    opacity: 0;
}
.report-media-img {
    display: block;
    width: 100%;
    max-width: 260px;
    max-height: 320px;
    height: auto;
    /* Matches .message/.msg-report's 16px: the bubble and the media inside
       it read as one uniform rounding language, not two different corner
       radii on the same visual object. */
    border-radius: 16px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
}
/* Video reuses .report-media-img for sizing, but three of those rules are
   written for a still image and are wrong for a video: together they produced
   the "black hole with a white pill floating in it" look:

     object-fit: cover  crops a video to fill the box. An image can be cropped
                        because the full thing is one tap away; a video's cut
                        edges are simply lost.
     cursor: pointer    on an image means "tap to open full size". A video's own
                        controls own the click, so the pointer promised
                        something that does not happen.
     height: auto       collapses to nothing before metadata arrives, since a
                        video has no intrinsic size until then: which is why it
                        rendered as a squat black strip barely taller than its
                        control bar.

   Element-qualified rather than a new class so the fix needs no markup change
   (and the design-system specimens pick it up as-is). */
video.report-media-img {
    object-fit: contain;
    cursor: default;
    /* Holds a sensible shape before metadata lands, then the real intrinsic
       ratio takes over: min-height rather than aspect-ratio precisely so a
       portrait clip is not forced into a landscape box. */
    min-height: 150px;
    /* Plain black. A film glyph used to sit here as a "this is a video"
       hint, but .report-media's play badge now does that job properly and
       in front of the frame: two stacked affordances just read as
       clutter (visible as a faint square behind the play circle). */
    background: #000;
    /* A pure-black rectangle on the blue bubble reads as a hole punched in it.
       A hairline edge makes it read as a framed object instead. */
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-sizing: border-box;
}

/* Native media controls follow the element's declared colour scheme. Nothing
   declared one, so Chromium used its LIGHT control set: the white pill. Both
   players sit on dark bubbles in every theme this app ships, so both declare
   dark and get the matching dark controls. */
video.report-media-img,
.report-media.audio audio {
    color-scheme: dark;
}

.report-media.audio audio {
    width: 240px;
    max-width: 100%;
    display: block;
    /* Matches the 16px used by images, the document chip and the bubble
       itself, so an audio player is not the one attachment with square ends. */
    border-radius: 16px;
}
.report-file-doc {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.22);
    /* Matches .report-media-img/.message/.msg-report's 16px: see that
       comment; a document chip is still "an attachment in the bubble". */
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 0.85em;
    text-decoration: none;
    max-width: 260px;
}
.report-file-doc span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.report-media-caption {
    font-size: 0.8em;
    color: #94a3b8;
    margin-top: 4px;
    white-space: normal;
    word-break: break-word;
    max-width: 260px;
}
.report-media.pending .report-media-img {
    opacity: 0.65;
}

/* The report launcher uses FA Free's regular clipboard, matching the
   neutral composer icons while its label explains the specialised action. */
.report-btn {
    color: var(--text-secondary) !important;
    font-size: 19px !important;
}

.report-btn:hover {
    color: var(--text-primary) !important;
}

/* Launcher View */
.launcher-view {
    padding: 24px;
    height: 100%;
}

.launcher-view.hidden {
    display: none !important;
}

.launcher-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 20px;
    justify-items: center;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s;
}

.app-icon:active {
    transform: scale(0.9);
}

.icon-wrap {
    width: 64px;
    height: 64px;
    background: var(--bg-secondary);
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.app-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.app-container {
    height: 100%;
    width: 100%;
    overflow: hidden;
    display: flex;
}

.app-container.hidden {
    display: none !important;
}

/* PWA Install Overlay */
.pwa-install-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.pwa-install-modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.pwa-install-content h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 20px;
    font-weight: 600;
}

.pwa-install-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.pwa-install-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.pwa-install-buttons button {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.pwa-install-buttons .btn-primary {
    background: var(--accent-color);
    color: white;
}

.pwa-install-buttons .btn-primary:hover {
    background: var(--accent-hover);
}

.pwa-install-buttons .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.pwa-install-buttons .btn-secondary:hover {
    background: var(--bg-secondary);
}
/* ---- Notifications tab ------------------------------------------------- */
/* .tab-content.active is a flex row by default, which would sit the header
   beside the list. Stack them, and let the list own the remaining height so
   an empty-state message has something to centre itself in. */
#tab-notifications.active {
    flex-direction: column;
}
/* Fixed header: centred title, separated from the list below it. */
.notifications-header {
    flex: 0 0 auto;
    padding: 0.9rem 1rem;
    text-align: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.notifications-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}
/* The list takes the remaining height and scrolls on its own.
   min-height:0 is what actually lets it shrink and scroll inside the
   flex column instead of pushing the header off-screen. */
.notifications-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
/* Centre the empty / offline / loading message both ways in the leftover
   space. margin:auto does the centring; height:auto gives it room to work
   (.empty-state is height:100% by default, which would fill instead). */
.notifications-list > .empty-state,
.notifications-list > .loading {
    margin: auto;
    height: auto;
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
}
.notif-item {
    /* flex:0 0 auto so rows keep their natural height and the list scrolls,
       rather than the rows squashing to fit. */
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}
.notif-item.notif-resolved {
    opacity: 0.6;
}
.notif-avatar {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.notif-avatar-system {
    background: var(--bg-tertiary);
}
.notif-body {
    flex: 1;
    min-width: 0;
}
.notif-text {
    color: var(--text-primary);
    font-size: 0.9rem;
}
.notif-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 0.15rem;
}
.notif-actions {
    display: flex;
    gap: 0.4rem;
    flex: 0 0 auto;
}
.btn-notif-accept,
.btn-notif-decline {
    padding: 0.4rem 0.7rem;
    border-radius: 0.4rem;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-notif-accept {
    background: var(--accent-color);
    color: #fff;
}
.btn-notif-accept:hover:not(:disabled) {
    background: var(--accent-hover);
}
.btn-notif-decline {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.btn-notif-accept:disabled,
.btn-notif-decline:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Contact-request icon in the project members list. A quiet ghost icon
   button, not a bordered/colored pill (see the HTML comment on contactAction
   in renderProjectMembers): it's a personal-contacts nicety, and the role
   control beside it is the thing actually worth drawing the eye to. */
/* Both row icons carry .icon-btn now (see the member row template in
   app.js), so the circular hit area, hover/active tint and the global
   focus ring all come from that one standard instead of each of these
   re-inventing a 6px-radius square with no states at all. Only the size
   is local: .icon-btn's own 24px glyph would dwarf a 40px avatar row. */
#project-members-list .member-contact-btn,
#project-members-list .member-kick-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 0.85rem;
    border-radius: 50%;
}
/* Destructive actions stay quiet until interaction; their accessible labels
   and the existing confirmation retain the meaning without a red icon row. */
#project-members-list .member-kick-btn { color: var(--text-secondary); }
#project-members-list .member-kick-btn:hover { color: var(--danger-color); }
.member-contact-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
}
.member-contact-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.member-contact-btn:disabled {
    opacity: 0.6;
    cursor: default;
}
.member-contact-btn.is-done {
    color: var(--success-color, #22c55e);
    cursor: default;
}
.contact-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--success-color);
    white-space: nowrap;
}

/* ---- Native <dialog> for lightweight confirmations --------------------- */
.app-dialog {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    max-width: 90vw;
    width: 320px;
    box-shadow: var(--shadow-md);
    /* Fades the whole box + its ::backdrop together on close (open already
       reads fine via .modal-container's own translateY transition). display/overlay need
       allow-discrete so the browser keeps rendering through the close()
       transition instead of yanking the dialog out of the top layer on
       frame one: unsupported browsers just ignore it and close instantly,
       same as before. */
    opacity: 1;
    transition: opacity var(--motion-med) var(--motion-ease),
                display var(--motion-med) allow-discrete,
                overlay var(--motion-med) allow-discrete;
}
.app-dialog:not([open]) {
    opacity: 0;
}
/* Same three-part setup as dialog.app-modal::backdrop: see the long note
   there for why the base rule has to hold the hidden value, why ::backdrop
   needs its own display/overlay allow-discrete, and why @starting-style is
   still required on top of both. */
.app-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--motion-med) var(--motion-ease),
                display var(--motion-med) allow-discrete,
                overlay var(--motion-med) allow-discrete;
}
.app-dialog[open]::backdrop {
    opacity: 1;
}
@starting-style {
    .app-dialog[open]::backdrop {
        opacity: 0;
    }
}
@media (prefers-reduced-motion: reduce) {
    .app-dialog {
        transition: none;
    }
    .app-dialog::backdrop {
        transition: none;
    }
}
.app-dialog-content {
    padding: 1.25rem;
    margin: 0;
}
.app-dialog-content h3 {
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}
.app-dialog-content p {
    margin: 0 0 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.app-dialog-actions {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.app-dialog-actions .btn {
    min-width: 5rem;
}

/* ---- Modals as native <dialog> ---------------------------------------- */
/* Properties that must survive unconditionally, applying whether the
   dialog is open, closed, or was never opened at all: the entrance/exit
   slide is already covered by .modal-container's own translateY
   transition, but the backdrop still appeared instantly and nothing
   faded on close.
   display/overlay need allow-discrete so closeModal()'s close() doesn't
   yank the dialog (and its ::backdrop) out of the top layer before the
   fade finishes; unsupported browsers just ignore those two and close
   instantly, same as before this change. */
dialog.app-modal {
    border: none;
    padding: 0;
    background: transparent;
    color: var(--text-primary);
    opacity: 1;
    transition: opacity var(--motion-med) var(--motion-ease),
                display var(--motion-med) allow-discrete,
                overlay var(--motion-med) allow-discrete;
}
/* The dialog itself is the ONE scroller, full-viewport, at every width -
   not just the mobile bottom sheet. .modal-container (the visible card)
   is a centered flex child inside it, its own width/max-width capping how
   wide it gets without capping the DIALOG's scroll region to that same
   narrow box. Two things this fixes over just centering .modal-container
   itself with margin:auto on a dialog sized to its content:
     1. The native scrollbar renders at the actual edge of the viewport
        (this box's own outer edge, full-bleed), not inset next to a
        narrower centered card with backdrop still visible past it.
     2. margin-block:auto on .modal-container (not justify-content:center
        here) is what lets a short modal sit vertically centered while a
        tall one naturally starts from the top instead of having its own
        top clipped by centering an overflowing flex item - a scrolled-to
        item centered via justify-content loses whatever grew past either
        edge; margin:auto collapses to 0 once there's no slack left,
        leaving the overflowing case to just start at the top and scroll,
        same as a plain block would.
   [open], PLUS .is-closing - not a bare dialog.app-modal applying this
   unconditionally. Unconditional was tried first and traded one bug for
   another: [open] is removed the instant close() is called, synchronously,
   before the opacity fade even starts, so gating this behind [open] alone
   snapped the dialog back to plain undecorated sizing for the whole fade
   (a visible shrink/jump on every dismiss); applying it unconditionally
   instead fixed that, but meant EVERY dialog.app-modal on the page sat
   fully laid out - full-viewport, overflow-y:auto, flex - all the time,
   open or not, which is real, constant layout cost for however many
   modals happen to exist on the page, not just the one actually in use.
   .is-closing is what actually threads the needle: closeModal() adds it
   right before calling close(), and removes it once the dialog's own
   `close` event fires... but that event fires the SAME instant [open] is
   removed, before any fade - so what keeps this rule matching for the
   fade's actual duration is closeModal() waiting on the dialog's opacity
   transitionend (with a timeout fallback) before removing the class. A
   dialog that's genuinely idle - closed and not mid-dismiss, or never
   opened - matches neither condition and falls back to the UA's own
   display:none default, so it costs nothing to have sitting around. */
dialog.app-modal[open],
dialog.app-modal.is-closing {
    position: fixed;
    inset: 0;
    margin: 0;
    width: 100%;
    /* svh, not dvh: dvh tracks the mobile browser's toolbar as it
       actually is, which is right for something that stays open a
       while (see .side-panel/.pane-side's own dvh, further down, for
       that case) - but this dialog opens with an animated slide EVERY
       time, and a mobile browser's toolbar visibility is exactly the
       kind of thing that can still be settling in the first few frames
       right as a modal opens (a scroll-lock or focus change is enough
       to trigger it). Recalculating dvh mid-transition changes the
       dialog's own height WHILE .modal-container's margin:auto is
       centering inside it - not the slide transform's own doing (that
       curve has no overshoot, see the CSS comment two rules down), but
       the box it's centering within genuinely resizing under it reads
       exactly like one: the container appears to overshoot then settle
       back. svh is pinned to the smallest the viewport ever gets, so it
       never recalculates - stable through the one animation that
       actually matters here, at the cost of not re-expanding into
       extra space if the toolbar later collapses while already open
       (an acceptable trade for something meant to be dismissed quickly,
       unlike the persistent panels dvh is kept for). */
    height: 100svh;
    max-width: 100%;
    max-height: 100svh;
    overflow-y: auto;
    /* The entry slide starts .modal-container at translateY(100%), and a
       transform DOES contribute to scrollable overflow (unlike layout
       offsets) - so for the duration of the animation this dialog really
       is scrollable, by exactly the height of the card hanging below its
       bottom edge. Chrome's scroll anchoring would then treat every frame
       of that shrinking overflow as "content moved" and compensate by
       adjusting scrollTop, fighting the very transform that's driving it.
       Off here: the only thing that should move during entry/exit is the
       transform. (The other half of that same problem - showModal()'s own
       focus scroll - is handled in openModal(), see app.js.) */
    overflow-anchor: none;
    /* Nothing above a modal should move because of a gesture inside it: a
       downward swipe at scrollTop 0 (exactly how a drag-to-dismiss starts)
       otherwise chains to the page behind, or triggers the browser's own
       pull-to-refresh, either of which steals the gesture mid-drag. */
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    display: flex;
    flex-direction: column;
    align-items: center;
}
/* A <dialog> with no `open` attribute is display:none by the UA
   stylesheet's own default; the rule above has enough specificity to
   override that while [open] or .is-closing match, which is why a dialog
   that was never opened at all - matching neither - correctly stays
   display:none and costs nothing, addressing the concern the rest of
   this comment used to be about directly instead of via pointer-events.
   pointer-events:none here still matters for the brief .is-closing
   window itself though: the dialog IS laid out and fading during that
   time, and shouldn't be clickable while it's on its way out. */
dialog.app-modal:not([open]) {
    opacity: 0;
    pointer-events: none;
}

/* Backdrop fade, in and out. Three things all have to line up for a
   ::backdrop to animate BOTH ways, and missing any one of them silently
   gives you an instant appear/disappear with no error anywhere:
     1. The base rule must hold the HIDDEN value and [open] the visible one.
        Putting `opacity: 1` on the base (as this did) means closing changes
        nothing to transition: the backdrop just blinks out.
     2. ::backdrop needs its OWN display/overlay allow-discrete transitions.
        It's a separate box in the top layer, so the ones on the dialog
        element don't cover it: without them it's yanked from the top layer
        on frame one, cutting the fade before it can run.
     3. @starting-style supplies the "before" value for the entry, since
        [open] already matches at the moment the backdrop starts rendering.
   Only opacity is animated, never background-color/backdrop-filter: the
   blur is per-pixel expensive, and animating its RADIUS re-runs that blur
   every frame instead of once. Opacity is compositor-only, so fading a
   backdrop that's already fully blurred looks the same and costs a
   fraction: animated, and still cheap. */
dialog.app-modal::backdrop {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--motion-med) var(--motion-ease),
                display var(--motion-med) allow-discrete,
                overlay var(--motion-med) allow-discrete;
}
dialog.app-modal[open]::backdrop {
    opacity: 1;
}
@starting-style {
    dialog.app-modal[open]::backdrop {
        opacity: 0;
    }
}
@media (prefers-reduced-motion: reduce) {
    dialog.app-modal {
        transition: none;
    }
    dialog.app-modal::backdrop {
        transition: none;
    }
}
/* The visible box: a centered flex child of the full-viewport dialog
   above (width/max-width capped here, on the CARD, not on the dialog
   that actually scrolls), free to grow to whatever height its content
   needs - no cap, no scroll of its own. dialog.app-modal is the one that
   scrolls once that height exceeds the viewport, so the whole card (this
   box, rounded corners included) is what moves, the way sliding a
   physical sheet of paper across a table would, not just its content
   shifting inside a window cut into it.
   margin-top a fixed offset, margin-bottom:auto - not margin-block:auto
   on both sides. Auto on both perfectly vertically centers a short modal,
   which reads as floaty/adrift rather than anchored; a fixed top offset
   with the leftover space collected below instead gives every modal the
   same settled distance from the top regardless of how short its content
   is. Still not justify-content:center on the dialog itself: an auto
   BOTTOM margin (unlike a fixed one) still collapses to 0 once content
   is tall enough to need scrolling, so the top offset is what you see
   scrolled past first, never clipped off. */
dialog.app-modal .modal-container {
    width: 90%;
    max-width: 500px;
    max-height: none;
    overflow: visible;
    flex-shrink: 0;
    /* Auto margins center short dialogs. Once content exceeds the viewport,
       the dialog's top padding becomes the authored resting offset and the
       overflowing sheet naturally starts at that top edge. */
    margin: auto;
    border-radius: var(--modal-radius);
}

@media (min-width: 768px) {
    dialog.app-modal[open], dialog.app-modal.is-closing {
        padding-top: 48px;
        padding-bottom: 48px;
        box-sizing: border-box;
    }
}

/* Mobile (<768px): bottom sheet instead of a centered dialog: full width,
   anchored to the bottom, rounded top corners only. Matches the responsive
   half of the .ds-modal spec documented at /design-system#modal (the
   desktop "materialize" half was already covered by .modal-container's
   own animation above; this was the genuinely missing piece: see that
   page's "Reality check" section). Every dialog.app-modal picks this up
   automatically; nothing to opt into per-modal. The dialog being the
   full-viewport scroller is already the global rule above - only the
   CARD's own sizing/resting position within it is mobile-specific. */
@media (max-width: 767px) {
    dialog.app-modal .modal-container {
        width: 100%;
        max-width: 100%;
        /* The actual "sits near the bottom, mostly-empty backdrop above
           it" resting look for a short modal: overrides the base rule's
           margin-block:auto (which centers vertically) with a bottom-only
           anchor instead - this margin eats all the spare space in the
           flex column above the card, the same way centering a single
           flex item with margin:auto does, just on one side. A modal
           tall enough to need the full screen has no spare space left
           for this to consume, so it naturally starts from the very top
           instead - nothing else has to change for that case. */
        margin: auto 0 0;
        border-radius: 16px 16px 0 0;
        /* Keep the device inset inside the painted sheet, never under it. */
        padding-bottom: env(safe-area-inset-bottom, 0px);
        /* No animation/transition override here any more: the base
           .modal-container rule's transform transition already slides
           this up on entry and down on exit (see its own comment) - the
           same motion this sheet always had, now just the global
           standard instead of a mobile-only keyframe duplicating it. */
    }
    /* A sheet that reaches the very top edge stops reading as a sheet:
       with no backdrop left above it there's nothing to show it's resting
       ON something, and it looks like the app simply navigated to a new
       screen. Padding on the DIALOG, not a max-height on the card, keeps
       the single-scroller rule intact (see the structure diagram at
       /design-system#modal): the card is still free to be as tall as its
       content, this just means the column it lives in starts lower, so
       the gap is a floor the resting position can never eat into. A modal
       tall enough to scroll still scrolls - the gap is simply the first
       thing that scrolls away, exactly like the top offset on desktop. */
    dialog.app-modal[open],
    dialog.app-modal.is-closing {
        padding-top: calc(28px + env(safe-area-inset-top, 0px));
        padding-bottom: 0;
    }
    /* Drag-to-dismiss needs the browser to hand the gesture to JS, and
       touch-action is the only thing that decides that - it's resolved at
       touchstart, long before any listener could preventDefault. Default
       (auto) means a downward swipe is claimed for scrolling and the
       pointermove stream dies with a pointercancel, which is why dragging
       from the body "didn't take" while the thin grip (already
       touch-action:none) worked.
       Granted only where it costs nothing: a modal whose content fits has
       no scrolling to give up, so the whole card becomes the drag surface.
       .is-scrollable (set from JS, see syncModalScrollable) marks the ones
       that DO need to scroll; those keep native scrolling everywhere
       except the grip and header. */
    dialog.app-modal:not(.is-scrollable) .modal-container {
        touch-action: none;
    }
    /* The header is a grab area on every modal, scrollable or not: it's the
       big, obvious, always-visible target the 36x4px grip alone was never
       going to be. Swiping the header no longer scrolls a long modal - the
       standard bottom-sheet trade, and its body is still fully scrollable. */
    .modal-header {
        touch-action: none;
    }
}

/* Drag-to-dismiss (mobile sheets only: see wireModalDrag in
   app.js, wired once per dialog.app-modal at init). Dragging the handle, or
   the sheet itself once it's scrolled to its own top (checks the dialog's
   scrollTop, the actual scroller now - see the max-width:767px rule on
   dialog.app-modal above), moves the WHOLE sheet with the finger: box and
   backdrop together, like pulling a physical sheet of paper off the
   screen, not just an inner list scrolling in place. */
.modal-drag-handle {
    display: none;
    justify-content: center;
    padding: 10px 0 6px;
    cursor: grab;
    touch-action: none;
}
.modal-drag-handle::after {
    content: '';
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-color);
}
@media (max-width: 767px) {
    .modal-drag-handle {
        display: flex;
    }
    /* JS sets this on .modal-container mid-drag and clears it on
       release: with a transition active, the sheet would lag a frame
       behind the finger instead of tracking it 1:1. */
    dialog.app-modal.dragging .modal-container {
        transition: none !important;
        animation: none !important;
    }
    /* --modal-drag-progress (0..1) is set on the dialog element itself by
       the drag handler; a custom property set on an element is visible to
       that element's own ::backdrop, which is otherwise unreachable from
       JS/inline styles. Scoped to [open] deliberately: it has to match the
       specificity of the [open]::backdrop opacity rule above (and win by
       coming later) or the drag would have no effect on the backdrop at
       all. Resolves to 1 when no drag is in progress, so this is also the
       plain open state on mobile. */
    dialog.app-modal[open]::backdrop {
        opacity: calc(1 - (var(--modal-drag-progress, 0) * 0.7));
    }
    /* Kills the transition only WHILE dragging, so the backdrop tracks the
       finger 1:1. Deliberately not the inverse (`:not(.dragging)` re-
       declaring the transition): that wins on specificity and replaces the
       whole shorthand, dropping the display/overlay allow-discrete parts
       the exit fade depends on: which silently cost mobile its close
       animation. Overriding to `none` in the narrow case leaves the real
       transition intact everywhere else. */
    dialog.app-modal.dragging::backdrop {
        transition: none;
    }
}

/* The register/PWA overlays keep their own box width; just let them scroll. */
dialog.app-modal .overlay-content,
dialog.app-modal .pwa-install-content {
    max-height: 90dvh;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* The popup modal (showPopup) puts its title/message/OK straight into
   .modal-container, which has no padding of its own (the big modals pad via
   their header/body). Give it its own padding and a normal-width, centered OK
   button instead of the full-width btn-block. */
#popup-modal .modal-container {
    padding: 1.5rem;
}
#popup-modal #popup-close-btn {
    display: inline-block;
    width: auto;
    min-width: 6rem;
    margin-top: 0.75rem;
}

/* ---- Collapsible contact groups ---------------------------------------- */
.contact-group {
    border-bottom: 1px solid var(--border-color);
}
.contact-group__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    user-select: none;
    background: var(--bg-primary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    list-style: none;
    position: sticky;
    top: 0;
    z-index: 1;
}
/* Replace the default marker with our own caret that rotates when open. */
.contact-group__header::-webkit-details-marker {
    display: none;
}
.contact-group__header::before {
    content: '▸';
    font-size: 0.8rem;
    line-height: 1;
    transition: transform 0.15s ease;
}
.contact-group[open] > .contact-group__header::before {
    transform: rotate(90deg);
}
.contact-group__header:hover {
    color: var(--text-primary);
}
.contact-group__title {
    flex: 1;
    min-width: 0;
}
.contact-group__count {
    flex: 0 0 auto;
    min-width: 1.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
}
.contact-group__empty {
    padding: 0.75rem 0.9rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* One-tap Telegram login: the candidate numbers the user picks from. */
.tg-numbers {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.tg-number {
    flex: 1;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 14px 0;
    letter-spacing: 1px;
}

.tg-manual {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tg-manual summary {
    cursor: pointer;
    padding: 4px 0;
}

/* chat-kit: shared emoji picker + @-mention (added for both chat PWAs) */
.chat-input-area { position: relative; }

/* Emoji popover: category tabs + search + a grid for the active tab/search
   results. Anchored above the emoji button (bottom-right of the input bar),
   not full-width, to match a Telegram-style floating popover rather than a
   full-bleed sheet. */
.ck-emoji-panel {
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 60px;
    right: 8px;
    width: min(340px, calc(100vw - 32px));
    height: 360px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 14px;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
    overflow: hidden;
    z-index: 50;
}

.ck-emoji-tabs {
    flex-shrink: 0;
    display: flex;
    overflow-x: auto;
    scrollbar-gutter: stable;
    border-bottom: 1px solid var(--border-color, #334155);
    padding: 6px 6px 0;
    gap: 2px;
}
.ck-emoji-tab {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
}
.ck-emoji-tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.ck-emoji-tab.active { color: var(--accent-color); border-bottom-color: var(--accent-color); }

.ck-emoji-search {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 10px;
    padding: 7px 12px;
    background: var(--bg-tertiary, #334155);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.ck-emoji-search input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
}
.ck-emoji-search input::placeholder { color: var(--text-secondary); }

.ck-emoji-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 4px 10px 10px;
}

.ck-emoji-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 8px 2px 4px;
}

.ck-emoji-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.ck-emoji {
    width: auto;
    aspect-ratio: 1;
    background: transparent;
    border: none;
    padding: 4px;
    margin: 0;
    cursor: pointer;
    line-height: 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ck-emoji:hover { background: var(--bg-primary, #0f172a); }

.ck-emoji img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Continuous-scroll picker (see attachEmoji/renderAll in chat-kit.js):
   every category's section stacked in one scroll, not a filtered single
   category: the first section shouldn't repeat the top padding .ck-emoji-body
   already provides. */
.ck-emoji-body > div + div {
    margin-top: 4px;
}

.ck-emoji-empty {
    padding: 24px 8px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.ck-mention-dd { display: block; position: absolute; bottom: 60px; left: 8px; right: 8px;
    background: var(--bg-secondary, #1e293b); border: 1px solid var(--border-color, #334155);
    border-radius: 10px; overflow: hidden; z-index: 51; max-height: 200px; overflow-y: auto; scrollbar-gutter: stable; }
.ck-mention-item { padding: 10px 12px; cursor: pointer; font-size: .9rem; color: var(--text-primary, #e2e8f0); }
.ck-mention-item.active { background: var(--accent-color, #14b8a6); color: #fff; }
.ck-mention { color: var(--accent-color, #14b8a6); font-weight: 600; }

/* ---- Project Cost tab (admin only) ---- */
#project-tab-cost { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#project-tab-cost.hidden { display: none; }
.cost-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--border-color); flex: none; }
.cost-total-lbl { font-weight: 600; color: var(--text-primary); }
.cost-total-lbl span { color: var(--accent-color); }
.cost-table-wrap { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
.cost-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.cost-table th, .cost-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-color);
    text-align: left; white-space: nowrap; color: var(--text-primary); }
.cost-table thead th { position: sticky; top: 0; background: var(--bg-tertiary); color: var(--text-secondary);
    font-weight: 700; font-size: .8rem; z-index: 1; }
.cost-table .ta-right { text-align: right; }
.cost-table tbody tr:hover { background: rgba(255, 255, 255, 0.05); }
.cost-table .cost-name { font-weight: 600; }
.cost-row-actions { display: flex; gap: 10px; }
.cost-row-actions a { cursor: pointer; font-size: .82rem; }
.cost-act-edit { color: var(--accent-color); }
.cost-act-del { color: var(--danger-color); }
.cost-evi img { max-width: 46px; max-height: 46px; border-radius: 4px; border: 1px solid var(--border-color); vertical-align: middle; }
.cost-evi a { color: var(--accent-color); }
.cost-empty { text-align: center; color: var(--text-secondary); padding: 22px; }

/* Transfer-ownership (crown) button in the company admins list */
.admin-makeowner-btn { color: var(--me-accent, #f59e0b); }
.admin-makeowner-btn:hover { color: var(--me-accent, #f59e0b); filter: brightness(1.15); }

/* Toast (ChatKit.showToast):
   generic enough for any future one-off confirmation/error. */
.ck-toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translate(-50%, 12px);
    background: var(--bg-tertiary, #334155);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 200;
}

/* ═══════════════════════════════════════════════════════════════════════
 * Message context menu (right-click / long-press): see
 * ChatKit.attachMessageActions in shared/chat-kit.js.
 * ═══════════════════════════════════════════════════════════════════════ */

/* A plain positioning wrapper now, not a card of its own: the reaction
   row and the item list below are two visually separate floating cards
   (see their own background/border/shadow further down), not one fused
   box with an internal divider line. */
.ck-msg-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: fixed;
    /* left/top set inline by attachMessageActions.position(): this popover
       opens wherever the user clicked/pressed, not anchored to a fixed
       corner like the others. */
    width: 260px;
    max-width: calc(100vw - 16px);
    z-index: 200;
}

.ck-msg-menu-reactions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 10px;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
    /* Anchors .ck-msg-menu-picker (position:absolute) below this row when
       expanded, so it overlays the item list beneath rather than pushing
       it down the page. */
    position: relative;
}

.ck-msg-menu-react,
.ck-msg-menu-expand {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 8px;
    padding: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--motion-fast) var(--motion-ease), transform var(--motion-fast) var(--motion-ease);
}

.ck-msg-menu-react img {
    width: 22px;
    height: 22px;
}

.ck-msg-menu-react:hover,
.ck-msg-menu-expand:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.15);
}

.ck-msg-menu-expand {
    flex: 0 0 auto;
    width: 28px;
    font-size: 0.8rem;
}

.ck-msg-menu-items {
    display: flex;
    flex-direction: column;
    padding: 6px;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-gutter: stable;
    /* Its own card, separate from .ck-msg-menu-reactions above (see that
       rule's comment): same look, own box. */
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 10px;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
}

.ck-msg-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
}

.ck-msg-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Marks a row that doesn't belong to the pattern above it - e.g. the
   company switcher's per-company entries vs. its trailing "Manage
   companies" settings action - without splitting the menu into a second
   card (see .mobile-fab-menu-group for that heavier treatment; this list
   is one continuous choice, just with one settings row tacked on, not two
   different categories of action). Margin, not the item's own padding,
   so it reads as space BETWEEN rows rather than a wider row. */
.ck-msg-menu-separator {
    height: 1px;
    margin: 4px 4px;
    background: var(--border-color);
    flex-shrink: 0;
}

.ck-msg-menu-item i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.ck-msg-menu-item.danger {
    color: var(--danger-color, #ef4444);
}

.ck-msg-menu-item.danger i {
    color: var(--danger-color, #ef4444);
}

/* The full emoji picker, expanded from the quick-react row's chevron (see
   openPicker in chat-kit.js): a child of .ck-msg-menu-reactions (its
   position:relative anchor), absolutely positioned to OVERLAY the item
   list below rather than push it down the page. Its own floating card,
   same look as the reaction bar/item list, not fused flat into either. */
.ck-msg-menu-picker.ck-emoji-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    height: 300px;
    z-index: 5;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1));
    background: var(--bg-tertiary, #334155);
    /* Overrides the shared .ck-emoji-panel checklist's clip-path direction
       (inset(100% 0 0 0), bottom-anchored: reveals upward, meant for a
       popover anchored at a trigger below it). This panel grows DOWNWARD
       from the reactions row above it, so it's clipped from the bottom
       edge instead, revealing top-down: the growth direction matches
       where it visually emerges from, reading as an expansion of the row
       rather than a separate popover snapping into place. (A stale
       clip-path/transition:none !important used to live here from when
       this was inserted inline into an already-open menu, which needed no
       reveal of its own: not the case anymore now that it's an overlay.) */
    clip-path: inset(0 0 100% 0);
}

.ck-msg-menu-picker.ck-emoji-panel.open {
    clip-path: inset(0 0 0 0);
}

/* ═══════════════════════════════════════════════════════════════════════
 * Message reactions: badges under a bubble, "N Reactions" breakdown popover.
 * ═══════════════════════════════════════════════════════════════════════ */

.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.msg-reaction-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.msg-reaction-badge:hover {
    background: rgba(255, 255, 255, 0.14);
}

.msg-reaction-badge.mine {
    background: var(--accent-soft, rgba(59, 130, 246, 0.18));
    border-color: var(--accent-color);
}

.msg-reaction-badge img {
    width: 14px;
    height: 14px;
}

.msg-reaction-badge .count {
    font-weight: 600;
    font-size: 0.7rem;
}

/* "N Reactions" breakdown: who reacted with what. Reuses .ck-msg-menu's
   popover shell/animation via the same class, so it needs no styling of
   its own beyond the row layout inside it. */
.ck-reactions-detail-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
}

.ck-reactions-detail-row img {
    width: 20px;
    height: 20px;
}

.ck-reactions-detail-name {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════════════
 * Reply: the preview bar above the composer while replying, and the
 * quoted block inside a message bubble that's a reply to another one.
 * ═══════════════════════════════════════════════════════════════════════ */

.reply-preview-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
}

.reply-preview-bar.open {
    display: flex;
}

.reply-preview-bar i.reply-preview-icon {
    color: var(--accent-color);
    font-size: 0.95rem;
}

.reply-preview-body {
    flex: 1;
    min-width: 0;
}

.reply-preview-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-color);
}

.reply-preview-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
}

.reply-preview-close:hover {
    color: var(--text-primary);
}

/* Smaller font + a muted snippet line keep this visually subordinate to the
   message's own text below it: a preview, not a second message. */
.msg-reply-quote {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 8px;
    margin-bottom: 4px;
    border-left: 3px solid var(--accent-color);
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.msg-reply-quote-name {
    font-weight: 600;
    color: var(--accent-color);
}

.msg-reply-quote-text {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

/* Every theme sets --msg-bg-me equal to --accent-color (verified across all
   7 theme blocks, not assumed): so .msg-reply-quote-name rendered in
   --accent-color was invisible on an own-message bubble, same color on
   same color. Swap to the bubble's own (white-ish) text family instead,
   with a darkening overlay since a lightening one barely shows on an
   already-saturated accent color. */
.msg-me .msg-reply-quote {
    background: rgba(0, 0, 0, 0.22);
    border-left-color: rgba(255, 255, 255, 0.85);
}

.msg-me .msg-reply-quote-name {
    color: #fff;
}

.msg-me .msg-reply-quote-text {
    color: rgba(255, 255, 255, 0.75);
}

.msg-deleted-text {
    color: var(--text-secondary);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Highlight when jumping to a message via its reply-quote or the jump-to-
   date calendar (see scrollToMessage/jumpToDate): a soft blurred glow, not
   a color swap or a hard-edged ring, so it doesn't clash with .msg-me/
   .msg-other's own background and reads as gentle rather than a snap-flash.
   A brief hold at full glow (0%→15%) before the fade gives it a moment to
   register as "you arrived here" instead of an instant flash. */
.msg-flash {
    animation: msg-flash-glow 1.6s ease-out;
}
@keyframes msg-flash-glow {
    0% {
        box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-color) 55%, transparent),
            0 0 20px 4px color-mix(in srgb, var(--accent-color) 40%, transparent);
    }
    15% {
        box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-color) 55%, transparent),
            0 0 20px 4px color-mix(in srgb, var(--accent-color) 40%, transparent);
    }
    100% {
        box-shadow: 0 0 0 1px transparent, 0 0 20px 4px transparent;
    }
}

.ck-toast.open { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   Approval + sub-projects (P3 / P5)
   ============================================================ */

/* Create-project form: checkboxes + hints */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95em;
}
.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
}
.form-hint {
    font-size: 0.8em;
    color: #94a3b8;
    margin-top: 4px;
    line-height: 1.4;
}

/* Report status chips on a report bubble */
.report-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72em;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.report-status-chip.status-pending {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
}
.report-status-chip.status-rejected {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.report-reject-reason {
    font-size: 0.82em;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    padding: 6px 10px;
    margin-top: 6px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.report-approval-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.btn-approve {
    background: #10b981;
    color: #fff;
    border: none;
}
.btn-approve:hover { background: #059669; }
.btn-reject {
    background: transparent;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.5);
}
.btn-reject:hover { background: rgba(239, 68, 68, 0.12); }

/* Project profile hero (replaces the old bordered .modal-header strip:
   see the HTML comment on #project-members-modal). Sits inside .modal-body,
   which #project-members-modal .modal-body zeroes out (invite.css) so the
   full-bleed member list below can go edge-to-edge; this section restores
   its own horizontal padding to match. */
/* .modal-container sets text-align:center for the small popup/confirm
   modals that genuinely want it. This one is a settings surface: labels,
   hints and list rows all read as left-aligned copy, and inheriting the
   centering was what made it look half-finished (a centered "Project name"
   label above a left-aligned input, a centered hint above a left-aligned
   list). Reset once here rather than per-child. */
.project-info-modal .modal-container {
    text-align: left;
}

.project-info-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    /* Right padding clears .modal-floating-close. */
    padding: var(--pm-inset) 56px 18px var(--pm-inset);
}
.project-info-hero .avatar {
    width: 52px;
    height: 52px;
    font-size: 1.15rem;
    border-radius: 14px;
    flex-shrink: 0;
}
.project-info-hero-text {
    min-width: 0;
}
.project-info-hero-text h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: var(--text-primary);
    word-break: break-word;
}
.project-info-hero-text .chat-subtitle {
    display: block;
    margin-top: 3px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Floating close (no more .modal-header bar to hold it): a plain circular
   icon over the corner instead, since a bordered title strip read as stiff
   for what's really the project's own profile. */
.project-info-modal .modal-container {
    position: relative;
    /* One inset for every edge in this modal. It used to be four separate
       hardcoded 22px (hero, sections, members heading, member rows) plus
       .modal-footer's own inherited 1.5rem, so the footer button sat 2px
       off from the dividers above it and any future row was a guess. */
    --pm-inset: 22px;
    --pm-section-gap: 18px;
}
.project-info-modal .modal-footer {
    padding-left: var(--pm-inset);
    padding-right: var(--pm-inset);
}
/* Matches the 22px gutter the hero and every section below it use. */
.project-info-modal .modal-footer {
    padding: 14px 22px;
}
.modal-floating-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    line-height: 1;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.15);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    z-index: 1;
    transition: background var(--motion-fast) var(--motion-ease),
                color var(--motion-fast) var(--motion-ease);
}
.modal-floating-close:hover {
    background: rgba(0, 0, 0, 0.28);
    color: var(--text-primary);
}

/* Project settings sections in the members modal. Horizontal inset is
   margin, not padding, on purpose: the modal itself is padding:0 (a
   deliberate full-bleed surface for #project-members-list below), so a
   section's own border-top - drawn on ITS box edge - would span the full
   modal width edge-to-edge while padding only inset the CONTENT inside
   it, leaving the divider line touching both sides while everything else
   sat 22px in from them. Margin shrinks the section's own box (border
   included), so the line lines up with the content above/below it
   instead of running past it. */
.project-settings-section {
    margin: 0 var(--pm-inset);
    padding: 16px 0 18px;
    border-top: 1px solid var(--border-color);
}
/* Only the standalone "Members" heading needs its own margin/padding: the
   "Report approvers" one reuses this same class but sits inside
   .project-settings-section, which already insets itself. */
#project-members-heading {
    margin: 0 var(--pm-inset);
    padding: 16px 0 10px;
    border-top: 1px solid var(--border-color);
}
.project-settings-heading {
    /* display:block matters for the rename <label>, which carries this
       class too: an inline label would ignore the margin below and sit on
       the same line as its input. */
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
/* The hint sits directly under its heading, so the heading's own bottom
   margin would double up the gap. */
.project-settings-section .project-settings-heading + .form-hint {
    margin-top: -4px;
    margin-bottom: 10px;
}

/* ---- Member rows in the project modal --------------------------------
   The .picker-contact-* classes are shared with the contact-picker modal,
   so everything here is scoped to #project-members-list. The id also buys
   the specificity needed to beat invite.css, which defines the same
   classes and loads AFTER this file: a plain class override here would
   lose on source order no matter how it's written. */
#project-members-list {
    /* invite.css caps this list at 400px with its own scrollbar. Inside a
       .modal-body that already scrolls, that's two nested scrollers for
       one list: let the modal body own the scrolling instead. */
    max-height: none;
    overflow: visible;
}
#project-members-list .picker-contact-item {
    gap: 12px;
    /* Paint hover across the row, with breathing room around its content.
       The separator is inset independently so it never defines the hit area. */
    position: relative;
    margin: 0;
    padding: 10px var(--pm-inset);
    border-bottom: 0;
    border-radius: 0;
    /* Rows here aren't clickable (unlike the picker's, where the row IS the
       control): a pointer cursor promises an interaction that isn't there.
       The hover tint below is only to help the eye track a row across a wide
       modal, same reasoning a table row gets one without being a link. */
    cursor: default;
}
#project-members-list .picker-contact-item:hover,
#project-members-list .picker-contact-item:focus-within {
    background: var(--surface-hover);
}
#project-members-list .picker-contact-item:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: 0;
    inset-inline: var(--pm-inset);
    border-bottom: 1px solid var(--border-color);
    pointer-events: none;
}
#project-members-list .picker-contact-avatar {
    /* Overrides invite.css's grey circle + size/shape (its own 40px circle),
       for the same rounded-square silhouette every other avatar in the app
       uses. No background here, on purpose: this ID-scoped selector would
       otherwise beat .avatar.avatar-cN's own background on specificity
       alone (1 id + 1 class > 2 classes) and flatten every member's colour
       to nothing: which is exactly the bug this comment used to describe
       fixing while actually causing it. Leave background unset so the
       lower-specificity palette rule can win. */
    width: 40px;
    height: 40px;
    /* Round, per the app-wide split: a PERSON is a circle (.msg-avatar,
       .detail-avatar, and invite.css's own .picker-contact-avatar all 50%),
       a project/entity is the rounded square (.avatar, 10px - which is why
       the hero above this list keeps its corners). This rule used to force
       11px here and claimed it matched "every other avatar in the app",
       which was only ever true of the entity ones - it made the members
       read as four little projects. */
    border-radius: 50%;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 700;
}
/* invite.css gives .picker-contact-info flex:1 with no min-width:0, so a
   flex item's auto minimum kept it from ever shrinking below its text and
   the name wrapped onto a second line instead of the row staying one line
   tall ("Rindra-demo (Me)" and "Kamil-demo" both broke at 390px). With the
   floor removed the name can shrink, and ellipsis is the honest overflow
   for a proper noun - a mid-word wrap reads as a layout bug. */
#project-members-list .picker-contact-info {
    min-width: 0;
}
#project-members-list .picker-contact-name {
    font-weight: 600;
    font-size: 0.94rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#project-members-list .picker-contact-phone {
    font-size: 0.78rem;
    color: var(--text-secondary);
}
#project-members-list .picker-contact-actions {
    /* 8px, matching the app's usual control gap and freeing 2px for the
       name column: the role and icon slots either side of it are both
       fixed, so this gap is the only other slack in the row. */
    gap: 8px;
}
/* One shared FIXED width for whichever control occupies the role column:
   a <select> for editable roles, a static badge otherwise. min-width was
   only a floor, so "COMPANY-ADMIN" - the one label wider than 104px - grew
   past it and, because this cluster is right-aligned (margin-left:auto),
   pushed its whole row's controls left of every other row's. Sized to hold
   the longest label outright so the column is a column. */
#project-members-list .member-role-select,
#project-members-list .role-badge {
    /* .role-badge is a <span>, i.e. inline: width is ignored on an inline
       box, so it has to become inline-block for the column to hold at all. */
    display: inline-block;
    box-sizing: border-box;
    flex: 0 0 124px;
    width: 124px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#project-members-list .role-badge {
    font-size: 0.65rem;
    /* 999px, not the base rule's 4px: /design-system's radius scale puts
       pills and badges at fully round, and this is the one badge in the app
       still on a soft-rectangle radius. */
    border-radius: 999px;
    padding: 5px 8px;
    letter-spacing: 0.04em;
}
#project-members-list .member-role-select {
    font-size: 0.78rem;
    /* Right side keeps room for the chevron background image (see the base
       .member-role-select rule): a plain padding:5px 8px here would
       silently override that and swallow the icon into the text. */
    padding: 5px 20px 5px 8px;
    background-position: right 4px center;
    background-size: 11px;
}
/* Narrow sheets: the role control moves under the name instead of beside it.
   Measured, not guessed - one row needs 40(avatar) + 12 + ~153(longest name)
   + 12 + 124(role) + 8 + 62(icons) = 411px of content, so it fits the 500px
   desktop card (456px of content) but not a 390px phone (346px), where every
   single name was being cut: "Rindra-demo (Me)" had 86px for 153px of text.
   Truncating four names to hold a one-line layout is the worse trade - a
   member list exists to tell you who the members are.
   Grid rather than flex-wrap so the avatar can span both rows and the name
   and role still start on the same left edge; both slots either side of the
   name stay fixed-width, so the role and icon columns remain aligned down
   the list exactly as they are on desktop. 520px, because at that width the
   one-line layout still has 476px of content and fits. */
@media (max-width: 520px) {
    #project-members-list .picker-contact-item {
        display: grid;
        grid-template-columns: 40px 1fr;
        grid-template-areas:
            "avatar info"
            "avatar actions";
        align-items: center;
        column-gap: 12px;
        row-gap: 8px;
    }
    #project-members-list .picker-contact-avatar {
        grid-area: avatar;
        align-self: start;
    }
    #project-members-list .picker-contact-info {
        grid-area: info;
    }
    #project-members-list .picker-contact-actions {
        grid-area: actions;
        /* invite.css pushes this cluster right with margin-left:auto, which
           in its own grid cell would strand it against the far edge away
           from the name it describes. */
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* A fixed-width slot for the trailing icon actions (contact/kick), right-
   aligned within it: so that edge stays flush down the whole list whether
   a row has both icons, one, or (like your own row) neither, instead of
   whichever icons ARE present shifting the visible cluster left or right. */
.member-icon-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    /* Fixed, not a floor: a row with one icon (or none, like your own) would
       otherwise pull the fixed role column above out of alignment again.
       62px is exactly two 30px .icon-btns plus the 2px gap - measured, not
       rounded up, because every px reserved here is a px taken from the
       member's name, which is the one thing in the row that can't be
       shortened without losing information. */
    flex: 0 0 62px;
    width: 62px;
}
.project-rename-row,
.project-approver-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}
.project-rename-row .input-field,
.project-approver-add-row .input-field {
    flex: 1;
    min-width: 0;
}
/* Project actions section (Export report / Delete project), merged in from
   origin/main's per-header icon-btn pair - see the HTML comment on
   #project-actions-group. Buttons here are full .btn/.btn-danger, not
   .icon-btn: this row has the width a header's icon cluster never did. */
.project-actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.project-actions-row .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.approver-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}
.approver-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}
.approver-name { font-size: 0.9em; }
.approver-remove-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
}
.approver-remove-btn:hover { background: rgba(239, 68, 68, 0.12); }

/* Nested sub-project list rows */
.project-item--child {
    padding-left: 44px;
    position: relative;
}
.project-item--child::before {
    content: "";
    position: absolute;
    left: 26px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}
.project-item--child .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.8em;
}
.project-item--parent .chat-name { font-weight: 700; }

/* Parent rollup indicator */
.chat-rollup {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 4px;
}
.rollup-label {
    font-size: 0.75em;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.rollup-bar {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}
.rollup-bar > span {
    display: block;
    height: 100%;
    background: var(--accent-color);
    border-radius: 999px;
}

/* "Add sub-project" action on a parent row */
.project-subproject-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: #94a3b8;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 0.75em;
    line-height: 1;
    margin-top: 4px;
}
.project-subproject-btn:hover {
    color: #fff;
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

/* Text-prompt dialog input */
#app-prompt .input-field {
    width: 100%;
    margin: 10px 0;
}

/* ---- Thread panel (right-click "View thread" / hover hint) ------------
   A fixed drawer, not a modal: no backdrop, main chat stays usable next
   to it (the one thing this borrows from Slack; see the HTML comment on
   #thread-panel for why it otherwise isn't a Slack-style thread). */
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(400px, 92vw);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.25);
    z-index: 500;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--motion-fast) var(--motion-ease);
}
.side-panel.open {
    transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
    .side-panel {
        transition: none;
    }
}
.side-panel.hidden {
    display: none;
}

/* ---- Embedded variant: #task-panel moved inside .pane-side-body -------
   Only #task-panel ever gets this (see relocateTaskPanel in app.js): the
   thread panel stays the ordinary viewport drawer. .pane-side-body
   is the positioning parent (relative + overflow:hidden already), so inset:0
   here fills exactly the pane's current width, resizer-dragged or not,
   instead of the drawer's own fixed min(400px, 92vw). No box-shadow: floating
   above the pane read as a card dropped on top; flush against the pane's own
   background reads as the pane's content, which is the point. */
.side-panel--embedded {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    box-shadow: none;
    border-left: none;
}
/* Its own header would stack a second "Task detail" bar directly under
   .pane-side-header's "Tasks" bar: two headers for one pane. #pane-side-header
   takes over the back/edit controls instead while this is open (see
   setSidePaneHeaderForTaskDetail in app.js), so the panel contributes only
   its body here. */
.side-panel--embedded .side-panel-header { display: none; }

/* Mobile: a full-screen step, not a drawer. At phone widths
   min(400px, 92vw) left an ~30px sliver of chat down the left edge: too
   narrow to read or tap, so it read as a rendering fault rather than
   deliberate layering. Full-bleed also matches how it now behaves in
   history: on mobile the panel is its own back-navigable step (see
   openThreadPanel), so it should look like a screen, not an overlay. */
@media (max-width: 767px) {
    .side-panel {
        width: 100%;
        border-left: none;
        box-shadow: none;
        /* dvh, not %: a fixed 100% resolves against the largest viewport, so
           the bottom of the panel sits under the mobile URL bar until it
           collapses. dvh tracks the viewport as it actually is. */
        height: 100dvh;
        /* index.html sets viewport-fit=cover, which means the page paints
           under the notch and the home indicator. Every other surface here
           is inset by app chrome, but this one is full-bleed, so it has to
           inset itself or its header lands under the notch and the last
           reply under the home bar. */
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
    }
    .side-panel-header {
        /* Matches .chat-header's height so the two screens line up when the
           panel slides over the conversation. */
        height: 60px;
        padding: 0 8px 0 4px;
    }
    /* The close control reads as "back" on a full-screen step. Ordered
       before the title so it lands on the left like every other back
       affordance in the app, without reordering the markup. */
    .side-panel-header {
        flex-direction: row-reverse;
        justify-content: flex-end;
        gap: 4px;
    }
    .side-panel-title {
        flex: 1;
        min-width: 0;
    }
}

/* Glyph swap for #thread-panel-close (see its markup comment). Default is
   the desktop "close"; the mobile block below flips to "back". Plain
   --text-primary on the back variant, same as .panel-close-icon and
   #back-btn: this app's icons share one neutral color regardless of
   back vs. close, or which specific button it's on (see the long comment
   on .back-btn). */
.panel-back-icon { display: none; color: var(--text-primary); }
.panel-close-icon { display: inline-block; }
@media (max-width: 767px) {
    .panel-back-icon { display: inline-block; }
    .panel-close-icon { display: none; }
}
.side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 60px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}
.side-panel-title h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}
.side-panel-title .chat-subtitle {
    display: block;
    font-size: 0.8rem;
}
.side-panel-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 12px;
}
/* Bubbles in here are narrower than the main feed's, so let them use more
   of the panel's own width instead of the feed's max-width:80%-ish rules. */
.side-panel-body .message {
    max-width: 100%;
}
/* The message that anchors this thread: visually set apart from its
   replies below it (a thin rule + a small caption), not restyled: still
   the exact same bubble renderMessage always produces. */
.side-panel-body .msg-thread-anchor {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.thread-panel-anchor-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 8px;
}

/* Hover hint on a message that has replies: the alternative to the
   right-click "View thread" menu item. Hidden entirely for a message with
   no replies (no .msg-has-thread class), only visible on hover otherwise. */
.msg-thread-hint {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 4px 10px;
    width: fit-content;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-color);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--motion-fast) var(--motion-ease);
}
.message.msg-has-thread .msg-thread-hint {
    display: flex;
}
.message.msg-has-thread:hover .msg-thread-hint {
    opacity: 1;
}
@media (hover: none) {
    /* No hover on touch: the hint has to just be visible whenever it
       applies, or a touch-only user would have no way to reach it besides
       the long-press context menu item. */
    .message.msg-has-thread .msg-thread-hint {
        opacity: 1;
    }
}

/* ---- Task detail panel (#task-panel) ---------------------------------
   Layout/animation/mobile behaviour all come from .side-panel, shared with
   the thread panel. Only the content styling lives here. */
.task-panel-body {
    padding: 16px;
    gap: 12px;
}
.task-panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.task-panel-heading h4 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    word-break: break-word;
}
/* Progress state, not a workflow label: the tasks table has no status
   column, so inventing "In Design"-style stages here would be fiction.
   This reports what the data actually knows: how much of the task's
   amount has been reported and approved. */
.task-panel-status {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    white-space: nowrap;
}
.task-panel-status.is-done {
    background: rgba(34, 197, 94, 0.15);
    color: var(--pop-green, #22c55e);
}
.task-panel-status.is-active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-color);
}

/* Native <details>: see the markup comment for why. */
.task-panel-section {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    overflow: hidden;
}
.task-panel-section > summary {
    padding: 10px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    /* The default triangle sits inconsistently across browsers; a rotating
       chevron via ::after matches the rest of the app's disclosure UI. */
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.task-panel-section > summary::-webkit-details-marker { display: none; }
.task-panel-section > summary::after {
    content: '\f078'; /* fa-chevron-down */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7em;
    color: var(--text-secondary);
    transition: transform var(--motion-fast) var(--motion-ease);
}
.task-panel-section[open] > summary::after { transform: rotate(180deg); }
.task-panel-section-static {
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-primary) 88%, var(--bg-secondary));
}
.task-panel-section-static > h5 {
    margin: 0;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.task-panel-section-static .task-panel-section-body {
    min-height: 42px;
    display: flex;
    align-items: center;
}
.task-panel-section-static .task-panel-section-body.empty-state {
    justify-content: center;
    text-align: center;
}
.task-panel-section-body {
    padding: 0 12px 12px;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-secondary);
    word-break: break-word;
}
.task-panel-details {
    margin: 0;
    padding: 0 12px 12px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    font-size: 0.85rem;
}
.task-panel-details dt { color: var(--text-secondary); }
.task-panel-details dd { margin: 0; color: var(--text-primary); font-weight: 500; }

.task-panel-activity-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-top: 4px;
}
.task-panel-activity {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.task-activity-item {
    display: flex;
    gap: 10px;
}
.task-activity-item .avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 0.72rem;
    flex-shrink: 0;
}
.task-activity-main { min-width: 0; flex: 1; }
.task-activity-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.task-activity-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
    word-break: break-word;
}
.task-activity-meta {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 3px;
}
.task-activity-thumbs {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.task-activity-thumbs img {
    width: 56px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
/* "+N" for images beyond the first few, so a report with many attachments
   doesn't turn the feed into a gallery. */
.task-activity-more {
    width: 56px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
}

/* Day-off dot on a calendar cell (see markersByDate in chat-kit.js): a
   generic capability of the shared date-jump calendar, not tied to any one
   caller. */
.date-jump-cell.has-marker { position: relative; }
.date-jump-marker {
    position: absolute;
    left: 50%;
    bottom: 5px;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f59e0b;
}

/* ---- "Soon" marker for unbuilt interactions ---------------------------
   See .agent/rules/rules.md: anything that looks operable but isn't must
   say so BEFORE it is used, not in a toast afterwards.

   Deliberately quiet: same muted colour as secondary text, no border, no
   accent. A loud badge would pull the eye toward precisely the items that
   cannot help, turning every menu into a list of things you cannot do. The
   parent is also dimmed slightly, so the real items are what read first and
   the marker is only found by someone already looking at that row. */
.ck-menu-soon {
    margin-left: auto;
    padding-left: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.7;
    white-space: nowrap;
}
.ck-msg-menu-item.is-soon {
    opacity: 0.72;
}
/* Still fully operable on hover: these do respond (with an explanation), so
   they must not read as disabled. */
.ck-msg-menu-item.is-soon:hover {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════
 * THIRD PANE: Tasks / Progress / Cost beside the chat
 *
 * These used to be .project-tab-content panels INSIDE .pane-right, swapped
 * in place of the chat: opening Tasks hid the conversation the task came
 * from. They now live in .pane-side, a sibling of .pane-right, so the chat
 * stays on screen: and only gets covered when the user explicitly
 * maximises this pane.
 *
 * Desktop only. Below 768px .pane-right is hidden entirely and the mobile
 * #mobile-tab-* panels handle these views full-screen, so a side pane there
 * would be a third competing layer on a phone screen.
 * ═══════════════════════════════════════════════════════════════════════ */
.pane-side {
    display: none;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    /* Open/close slides the width in/out rather than snapping: see
       openSidePane/closeSidePane in app.js, which briefly overrides
       flex-basis with an inline style so there's a concrete start/end value
       to animate between (display:none has no width to transition FROM,
       and this pane's real open width is a resizable var()/clamp(), not a
       fixed number transition could target directly). Unconditional here,
       not scoped to .is-open, so both the opening and closing leg use it. */
    transition: flex-basis var(--motion-med) var(--motion-ease);
    /* Pairs with pinSidePaneBodyWidth (app.js): while that pins
       .pane-side-body to a constant width for the slide's duration, THIS is
       what turns the outer flex-basis change into a reveal/hide of that
       fixed-size content instead of squeezing it. No menu/dropdown inside
       this pane needs to escape past its edge: every one of them
       (ChatKit.showSimpleMenu) is appended to <body> and fixed-positioned,
       not a descendant relying on overflow to render outside this box. */
    overflow-x: hidden;
}
@media (prefers-reduced-motion: reduce) {
    .pane-side {
        transition: none;
    }
}
@media (min-width: 768px) {
    /* flex-basis rather than width: the pane shares the row with .pane-right
       and must give space back when the window narrows, instead of pushing
       the chat to zero.
       No upper bound of its own: clamp(...,560px) used to cap it
       arbitrarily. The real limit is how far .pane-right can shrink before
       its header controls collide (.pane-right's own min-width), and flex
       already enforces that: .pane-right cannot be squeezed past its
       min-width, so past that point THIS pane simply stops growing even
       though nothing here says a number. pane-resizer.js's clamp on the
       dragged value is the same story from the pointer's side.
       clamp(320px, 34%,) still gives the FLOOR and the fluid default:
       double-clicking the splitter clears --pane-side-width and falls back
       to exactly this. */
    .pane-side.is-open {
        display: flex;
        flex: 0 0 var(--pane-side-width, clamp(320px, 34%, 100%));
    }
    /* The splitter between the chat and this pane. Only meaningful while the
       pane is open and sharing the row: maximised, there is no chat left
       beside it to trade width with. */
    #pane-side-resizer { display: none; }
    .app-container:has(.pane-side.is-open):not(:has(.pane-side.is-max)) #pane-side-resizer {
        display: block;
    }
    /* Maximised: takes the chat's space as well. .pane-right is not hidden:
       it keeps its DOM and scroll position, so closing the pane returns the
       conversation exactly as it was rather than re-rendering it. */
    .pane-side.is-open.is-max {
        flex: 1 1 auto;
    }
    .pane-side.is-open.is-max ~ .pane-right,
    .app-container:has(.pane-side.is-max) .pane-right {
        display: none;
    }
    /* The resizer belongs between the project list and the chat; with the
       chat hidden it would sit against nothing. */
    .app-container:has(.pane-side.is-max) .pane-resizer {
        display: none;
    }
}

/* Mobile: Tasks/Progress/Cost push over the conversation full-screen instead
   of sharing the row beside it (there's no room beside anything on a phone).
   Same push-slide mechanic as .side-panel's own mobile mode and
   #view-conversation's above: mounted at all times (never display:none, so
   the transform actually has something to animate), translateX(100%) at
   rest, is-open slides it to 0. z-index above #view-conversation's 50 so it
   lands on top of the conversation screen it's opened from. */
@media (max-width: 767px) {
    .pane-side {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 60;
        width: 100%;
        height: 100dvh;
        border-left: none;
        transform: translateX(100%);
        transition: transform var(--motion-med) var(--motion-ease);
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
        pointer-events: none;
    }
    .pane-side.is-open {
        transform: translateX(0);
        pointer-events: auto;
    }
    /* Maximize and the desktop splitter are both meaningless full-screen. */
    #pane-side-max,
    #pane-side-resizer {
        display: none !important;
    }
    /* Row-reverse, not a markup reorder (same trick .side-panel-header
       already uses for #thread-panel-close/#task-panel-close, see its own
       max-width:767px rule): #pane-side-close is the header's last DOM
       child, so this lands it on the left, matching every other back
       affordance in the app (#back-btn included) instead of sitting after
       the title on the right, which only ever made sense next to the
       edit/maximize cluster it shares a desktop header row with. */
    .pane-side-header {
        flex-direction: row-reverse;
        justify-content: flex-end;
    }
    /* 44px touch-target spec (see #back-btn's own comment), mobile only:
       .pane-side-actions .icon-btn's shared 1rem/8px-padding sizing stays
       untouched at desktop, where #pane-side-close shares this same row
       with edit/maximize and a mouse pointer doesn't need a 44px target
       to begin with - inflating every icon in that cluster there would
       just crowd the header for no benefit. Mobile only ever shows this
       one button in the row (max is hidden, edit only appears in task
       detail), so the room this needs is already there. */
    #pane-side-close {
        min-width: 44px;
        min-height: 44px;
        /* Same Material Design 3 top-app-bar reasoning as .chat-header
           .icon-btn#back-btn's own comment: margin:-12px pulls the 44px
           box's edge in to this header's own 16px inset minus 12,
           landing the icon ~16px from the true edge like every other
           back affordance instead of the box's own padding pushing it
           further in. row-reverse (see .pane-side-header above) means
           this is the LEFT margin doing the work here, not both sides
           symmetrically: the right side of this box faces the title
           gap, which .pane-side-header's own 8px right padding + gap
           already sizes correctly on its own. */
        margin-left: -12px;
    }
    @media (prefers-reduced-motion: reduce) {
        .pane-side { transition: none; }
    }
}

.pane-side-header {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    flex-shrink: 0;
    padding: 0 8px 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.pane-side-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}
.pane-side-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.pane-side-actions .icon-btn { font-size: 1rem; }
/* Shown only while a task is routed open (see setSidePaneHeaderForTaskDetail);
   sits before the title so it reads left-to-right as "back, then where you are".
   Plain --text-primary, same as every other icon-btn (see the long comment
   on .back-btn for why this app no longer singles "back" out with color). */
.pane-side-back { font-size: 1rem; flex-shrink: 0; color: var(--text-primary); }

.pane-side-body {
    position: relative; /* anchors #task-panel.side-panel--embedded's inset:0 */
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* The moved panels were sized for the full .pane-right; in here they fill
   the pane's body instead. `.active` is still what switchProjectTab toggles,
   so the panel-swapping logic is unchanged. */
/* Capped and centered, not full-bleed: this pane can be maximized (see
   .pane-side.is-open.is-max) to the width of the whole window, and a list
   of cards with a handful of words and a date range each doesn't gain
   anything from stretching that wide - each row just gets harder to scan
   left-to-right, and empty rows read as unfinished rather than spacious.
   980px matches /design-system's own main-content column (see its `main`
   rule): established already as this app's own answer to "how wide before
   a content column stops helping," not a new number invented here. Still
   full flex width (align-self stays the flex default, stretch) below that
   cap - only actually kicks in once the pane is wide enough to matter,
   e.g. maximized or dragged past it. */
.pane-side-body > .project-tab-content {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
}
/* Progress is exempt from that cap. The reasoning behind it - a list of cards
   with a few words and a date each gains nothing from more width, and gets
   harder to scan left-to-right - is true of Tasks and Cost and is the exact
   opposite of true for a Gantt: its horizontal axis IS the data, so every
   extra pixel is more of the timeline visible at once. Capped and centred, a
   maximised pane left dead margin on BOTH sides of the chart while the chart
   itself had to be scrolled to see days it had room to show.
   ID beats the two-class selector above it, so this needs no !important. */
.pane-side-body > #project-tab-progress {
    max-width: none;
}

/* Double-click reset on a splitter animates the pane back to its default
   instead of jumping (see the dblclick handler in pane-resizer.js). Scoped to
   .pane-snapping so a drag stays pinned to the pointer with no transition
   lagging behind it. */
.pane-snapping > .pane-left,
.pane-snapping > .pane-side {
    transition: flex-basis var(--motion-med) var(--motion-ease),
                width var(--motion-med) var(--motion-ease);
}
@media (prefers-reduced-motion: reduce) {
    .pane-snapping > .pane-left,
    .pane-snapping > .pane-side { transition: none; }
}

/* ---- Collapse the project list ---------------------------------------
   Desktop only: below 768px .pane-left IS the whole screen (the chat is a
   separate pushed view), so collapsing it there would leave nothing. */
.pane-left-toggle {
    position: relative;
    flex-shrink: 0;
    font-size: 1.05rem;
}
/* 22px, not 20: the drawn shape only fills part of its own 24-unit viewBox
   (see the criteria on /design-system#icons), so a slightly larger render
   size is what actually closes the gap to the button edge: matching FA
   glyphs, which fill most of their own em box. */
.pane-left-toggle-icon {
    width: 22px;
    height: 22px;
    /* No `color` here (was `currentColor`, redundant: that's the default
       inherited behavior anyway): it's the same specificity as
       .icon-btn-muted-svg and declared later in the file, so it was quietly
       winning the cascade and overriding the muted colour back to
       .icon-btn's own text-primary. */
    display: block;
}
/* The unread dot. Deliberately a dot and not a count: the exact number is
   already on each project row, and this only has to answer "is there
   anything waiting behind the collapsed list". */
.pane-left-toggle-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-color);
    /* Ring in the header's own colour so the dot reads as separate from the
       glyph underneath rather than merging into it. */
    box-shadow: 0 0 0 2px var(--bg-secondary);
    pointer-events: none;
}
.pane-left-toggle-badge[hidden] { display: none; }

@media (min-width: 768px) {
    .app-container.pane-left-hidden > .pane-left {
        width: 0;
        border-right: none;
    }
    /* The splitter sized .pane-left; with the pane gone it has nothing to
       drag, so it would be a dead 5px hit target against the chat edge.
       Shrunk to 0 (not display:none) so it animates alongside the pane
       instead of vanishing a frame early. */
    .app-container.pane-left-hidden > .pane-resizer {
        width: 0;
        opacity: 0;
        pointer-events: none;
    }
}

/* ===== Shared fullscreen media viewer =====
   Report attachments in chat used to open with window.open(url) - a raw
   browser tab showing a bare file, which loses the conversation, has no way
   back, and is blocked outright as a popup on some mobile browsers. Video
   didn't open at all. This is the in-app viewer they open into instead, the
   way tapping media in any chat app behaves.
   A native <dialog>, so Esc, the top layer and focus trapping come from the
   platform rather than being re-implemented (same reasoning as the app's
   modals - see /design-system#modal); it deliberately does NOT carry
   .app-modal, because none of that sheet-on-a-table treatment applies to a
   lightbox: no card, no rounded panel, no slide-up. */
dialog.media-viewer {
    padding: 0;
    border: none;
    max-width: none;
    max-height: none;
    background: transparent;
    overflow: hidden;
}
dialog.media-viewer[open] {
    position: fixed;
    inset: 0;
    margin: 0;
    width: 100%;
    height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Near-black on every theme, on purpose: a lightbox's job is to get out
       of the way of the image, and a themed surface tints what you came to
       look at. The one place in the app that ignores the palette. */
    background: rgba(0, 0, 0, 0.94);
}
dialog.media-viewer::backdrop {
    background: rgba(0, 0, 0, 0.94);
}
.media-viewer-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 96vw;
    max-height: 84svh;
}
.media-viewer-stage img,
.media-viewer-stage video {
    max-width: 96vw;
    max-height: 84svh;
    object-fit: contain;
    /* The image is the one thing here that should still respond to a pinch. */
    touch-action: pinch-zoom;
}
.media-viewer-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
    color: #fff;
    /* Gradient, not a solid bar: keeps the filename legible over a light
       image without drawing a hard edge across it. */
    background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}
.media-viewer-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.82rem;
}
/* .icon-btn for the close control, like every other close in the app, so its
   hit area, hover and focus ring come from that one standard. Only the colour
   is local: --text-primary would be theme-dependent, and this sits on black. */
.media-viewer-close {
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
}
.media-viewer-close:hover {
    background: rgba(255, 255, 255, 0.15);
}
.media-viewer-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    color: #fff;
    font-size: 0.8rem;
    opacity: 0.9;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}
.media-viewer-caption:empty {
    display: none;
}

/* Report media in a chat bubble: now a real thumbnail you tap, so it needs to
   say so. Video loses its inline controls and gets a play badge instead - the
   same "tap the thumbnail, it opens" contract as an image, rather than two
   different interactions for two media types sitting side by side. */
.report-media-openable {
    cursor: pointer;
}
.report-media-video {
    position: relative;
    display: inline-flex;
}
.report-media-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.95rem;
    pointer-events: none;
}
/* ---- Report export modal (admin only) ---- */
#report-export-modal .modal-container {
    width: min(92vw, 560px);
    max-width: 560px;
    text-align: left;
}
.report-export-notice {
    background: color-mix(in srgb, var(--danger-color) 12%, transparent);
    color: var(--text-primary);
    border: 1px solid color-mix(in srgb, var(--danger-color) 45%, transparent);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: .85rem;
}
.report-export-notice.hidden { display: none; }
.report-export-loading,
.report-export-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 18px;
    font-size: .9rem;
}
.report-export-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border-color);
}
.report-export-row:last-child { border-bottom: none; }
.report-export-row__main { flex: 1; min-width: 0; }
.report-export-row__label { font-weight: 600; color: var(--text-primary); }
.report-export-row__when { font-size: .8rem; color: var(--text-secondary); margin-top: 2px; }
.report-export-row__actions { display: flex; align-items: center; gap: 12px; }
.report-export-dl { color: var(--accent-color); font-weight: 600; font-size: .85rem; }
.report-export-muted { color: var(--text-secondary); font-size: .85rem; }
.report-export-row__msg {
    flex-basis: 100%;
    font-size: .8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.report-export-row__msg.hidden { display: none; }
.report-export-row__msg--error { color: var(--danger-color); }

/* ---- Company report branding (Edit Company form, admin only) ---- */
#company-report-branding-section.hidden { display: none; }
/* Report branding is collapsed by default (a <details>) to keep the company
   form short. */
.brand-details > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    padding: 6px 0;
}
.brand-details[open] > summary { margin-bottom: 4px; }

/* Header + footer: stacked on mobile, side by side on desktop. */
.brand-assets { display: grid; gap: 12px; }
@media (min-width: 768px) {
    .brand-assets { grid-template-columns: 1fr 1fr; align-items: start; }
}
.brand-assets .brand-asset { margin-top: 0; } /* grid gap handles spacing */

.brand-asset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}
.brand-asset__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.brand-asset__title { font-weight: 600; color: var(--text-primary); }
.asset-preview-box {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    padding: 8px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.asset-preview-image { max-height: 100%; max-width: 100%; object-fit: contain; display: block; }
.asset-preview-empty { font-size: .85rem; color: var(--text-secondary); }
.brand-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.brand-control { flex: 1 1 150px; }
.brand-control label { display: block; font-size: .8rem; color: var(--text-secondary); margin-bottom: 4px; }
.brand-preview {
    margin-top: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    background: var(--bg-primary);
}
.brand-preview__title { font-size: .85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.brand-preview__img { width: 100%; border: 1px solid var(--border-color); border-radius: 6px; background: #fff; display: block; }
.brand-save-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.brand-status { font-size: .82rem; color: var(--text-secondary); }
.brand-status--ok { color: var(--accent-color); }
.brand-status--error { color: var(--danger-color); }

/* ===== Analytics (company-wide EVM / S-curve) =====
   Routed exactly like Contacts now (App#openLeftPaneMode/closeLeftPaneMode):
   the project list lives in #pane-left-analytics-body (.pane-left, alongside
   #pane-left-contacts-body), the selected project's detail in
   #analytics-detail-view (.pane-right, alongside #contact-details-view). Used
   to own a whole separate two-pane/mobile-swap system here
   (#tab-analytics/.analytics-container/.analytics-pane-left/-right/
   .analytics-back-btn, a full duplicate of what .pane-left/.pane-right +
   pane-resizer.js/nav-dock.js already do) - gone now that it's the genuine
   article instead of a parallel copy: resizing, the mobile single-pane swap,
   and the shared #pane-left-mode-back/#pane-left-mode-header all come from
   the SAME mechanism Contacts uses, not a second one to keep in sync. */
.analytics-detail-placeholder { padding: 40px 12px; text-align: center; }
/* Own header treatment, matching .contacts-header's: this used to inherit
   .analytics-pane-left's padding, which no longer exists now that this sits
   directly inside .pane-view-slide. */
.analytics-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 15px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
}
.analytics-toolbar h3 { margin: 0; font-size: 1.1rem; }
/* Colour/border/radius/padding/option styling all come from .form-select
   now (see the HTML) - the app's own established dropdown standard, not a
   bespoke one-off. This rule only keeps the width constraint that's
   genuinely specific to sitting in this toolbar row. */
.analytics-company-select {
    width: auto;
    min-width: 200px;
    max-width: 100%;
    padding-right: 44px;
}
/* flex:1/overflow-y/scrollbar-gutter is the scrolling job .analytics-pane-left
   used to do; padding is the horizontal/bottom inset that same element also
   used to provide (there's no card-level inset otherwise - .analytics-row
   would run edge to edge). */
.analytics-list {
    display: flex; flex-direction: column; gap: 10px;
    flex: 1; overflow-y: auto; scrollbar-gutter: stable;
    padding: 12px 16px 16px;
}
.analytics-empty, .analytics-note { color: var(--text-secondary); font-size: .9rem; padding: 14px 2px; }
.analytics-note { font-size: .82rem; opacity: .85; }

.analytics-row {
    display: flex; align-items: center; gap: 14px;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
    position: relative;
    transition: border-color .15s ease, transform .05s ease;
}
.analytics-row:hover { border-color: var(--accent-color); }
.analytics-row.is-active { border-color: transparent; background: var(--bg-tertiary); }
.analytics-row.is-active::before { content: ""; position: absolute; inset: 12px auto 12px 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-color); }
.analytics-row:active { transform: scale(.996); }
.analytics-row:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.analytics-row__main { flex: 1; min-width: 0; }
.analytics-row__name { font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.analytics-row__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.analytics-row__preview { width: 160px; height: 54px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
@media (max-width: 600px) { .analytics-row__preview { width: 110px; height: 46px; } }

.scurve-mini-svg { width: 100%; height: 100%; display: block; }
.scurve-mini-loading { width: 100%; height: 3px; border-radius: 3px; background:
    linear-gradient(90deg, transparent, var(--border-color), transparent);
    background-size: 200% 100%; animation: scurve-shimmer 1.1s linear infinite; }
@keyframes scurve-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.scurve-empty { color: var(--text-secondary); font-size: .85rem; text-align: center; padding: 30px 10px; }
.scurve-empty--mini { font-size: .72rem; padding: 0; }

.evm-chip {
    display: inline-block; font-size: .72rem; font-weight: 600; line-height: 1;
    padding: 4px 8px; border-radius: 999px;
    background: var(--bg-tertiary); color: var(--text-secondary);
}
.evm-chip--good { background: color-mix(in srgb, #22c55e 20%, transparent); color: #16a34a; }
.evm-chip--warn { background: color-mix(in srgb, #f59e0b 22%, transparent); color: #d97706; }
.evm-chip--bad  { background: color-mix(in srgb, #ef4444 20%, transparent); color: #dc2626; }

/* Detail view */
/* Own header bar now, matching .analytics-toolbar/.contacts-header: this used
   to inherit .analytics-pane-right's padding, which no longer exists now
   that #analytics-detail-view is a plain .project-view (see its own base
   rule - no padding of its own by design, same as #contact-details-view). */
.analytics-detail-head {
    display: flex; align-items: center; gap: 12px; flex-shrink: 0;
    padding: 15px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
}
.analytics-detail-head h3 { margin: 0; font-size: 1.1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* flex:1/overflow-y/scrollbar-gutter is .analytics-pane-right's old scrolling
   job; padding is the inset that same element used to provide. */
.analytics-detail-body {
    display: flex; flex-direction: column; gap: 16px;
    flex: 1; overflow-y: auto; scrollbar-gutter: stable;
    padding: 16px;
}

/* Analytics uses the same shell as chat, but its task is comparison first:
   give the chart a stable reading frame and keep the KPI hierarchy visible
   without introducing a second card language. */
.analytics-detail-body {
    gap: 12px;
    padding: 16px 18px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}
.analytics-detail-head {
    height: 68px;
    padding: 0 18px;
    background: var(--bg-primary);
}
.analytics-detail-head h3 { font-size: 1.05rem; font-weight: 700; }
.analytics-project-meta { min-width:0; flex:1; }
.analytics-project-title { display:flex; align-items:center; gap:9px; min-width:0; }
.analytics-project-title h3 { overflow:hidden; text-overflow:ellipsis; }
.analytics-status-pill { display:inline-flex; align-items:center; gap:6px; padding:4px 9px; border:1px solid var(--border-color); border-radius:999px; color:var(--text-secondary); font-size:11px; white-space:nowrap; }
.analytics-status-pill i { width:7px; height:7px; border-radius:50%; background:var(--success-color); }
.analytics-breadcrumb { color:var(--text-secondary); font-size:12px; margin-top:3px; }
.analytics-date-range { flex:0 0 auto; color:var(--text-secondary); font-size:12px; border:1px solid var(--border-color); border-radius:6px; padding:7px 10px; }
.analytics-health { display:flex; align-items:center; gap:10px; padding:12px 14px; border:1px solid var(--border-color); border-radius:8px; background:var(--bg-secondary); }
.analytics-health__dot { width:10px; height:10px; flex:0 0 10px; border-radius:50%; background:var(--text-secondary); }
.analytics-health.is-bad .analytics-health__dot { background:#ef4444; box-shadow:0 0 0 4px rgba(239,68,68,.12); }
.analytics-health.is-good .analytics-health__dot { background:#22c55e; box-shadow:0 0 0 4px rgba(34,197,94,.12); }
.analytics-health strong,.analytics-health span { display:block; }
.analytics-health strong { color:var(--text-primary); font-size:14px; }
.analytics-health > div > span { color:var(--text-secondary); font-size:12px; margin-top:2px; }
.analytics-health__quick { display:flex; gap:18px; margin-left:auto; }
.analytics-health__quick span { color:var(--text-secondary); font-size:11px; }
.analytics-health__quick b { color:var(--text-primary); font-size:14px; margin-left:4px; }
.analytics-chart-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:10px; }
.analytics-chart-heading > div { min-width:0; }
.analytics-chart-title { margin:0; line-height:1.25; }
.analytics-chart-subtitle { color:var(--text-secondary); font-size:12px; line-height:1.4; margin-top:6px; }
.analytics-chart-period { color:var(--text-secondary); font-size:11px; border:1px solid var(--border-color); border-radius:6px; padding:6px 9px; }
.evm-metric-groups { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.evm-metric-group { background:var(--bg-secondary); border:1px solid var(--border-color); border-radius:8px; padding:12px; }
.evm-metric-group h4 { margin:0 0 10px; color:var(--text-primary); font-size:13px; font-weight:700; }
.evm-metric-group .evm-metric-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.evm-metric-group .evm-metric { border:0; border-top:1px solid var(--border-color); border-radius:0; padding:9px 0 2px; }
.analytics-chart-card {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 16px 18px 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.analytics-chart-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.analytics-chart-host { width: 100%; overflow: hidden; flex: 1; min-height: 0; display: flex; align-items: center; }
.scurve-full-svg { min-width: 0; width: 100% !important; }

.evm-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.evm-metric {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 12px 14px;
}
.evm-metric__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
.evm-metric__val { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); margin-top: 4px; font-variant-numeric: tabular-nums; }
.evm-metric__hint { font-size: .72rem; color: var(--text-secondary); margin-top: 2px; }
.evm-metric.is-good .evm-metric__val { color: #16a34a; }
.evm-metric.is-warn .evm-metric__val { color: #d97706; }
.evm-metric.is-bad  .evm-metric__val { color: #dc2626; }
.evm-metric__val { font-variant-numeric: tabular-nums; }
@media (min-width: 1200px) {
    .evm-metric-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .evm-metric-groups { grid-template-columns:repeat(3,minmax(0,1fr)); }
    .evm-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .scurve-full-svg { min-width: 0; }
}
@media (max-width: 600px) {
    .analytics-health { align-items:flex-start; display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; padding:10px; }
    .analytics-health-copy { grid-column:1 / -1; }
    .analytics-health__quick { margin:8px 0 0; }
    .analytics-health-stat { min-width:0; }
    .analytics-health-stat small { display:block; line-height:1.25; }
    .analytics-detail-body { padding: 8px; gap: 8px; }
    .analytics-chart-card { padding: 12px 10px 8px; min-height: 250px; }
    .analytics-chart-title { font-size: .9rem; }
    .analytics-chart-subtitle { font-size: 11px; }
    .analytics-chart-period { display: none; }
    .analytics-detail-head { height: 60px; padding: 0 12px; }
    .analytics-status-pill { display:none; }
    .analytics-date-range { max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    .evm-metric-groups { grid-template-columns: 1fr 1fr; gap: 8px; }
    .evm-metric-group { padding: 8px; }
    .evm-metric-group:first-child { grid-column: 1 / -1; }
    .evm-metric-group .evm-metric-grid { grid-template-columns: 1fr; gap: 0; }
    .evm-metric-group h4 { font-size: 11px; margin-bottom: 5px; }
    .evm-metric-group .evm-metric-grid { grid-template-columns: 1fr; gap: 0; }
    .evm-metric-group .evm-metric { padding: 5px 0 1px; }
    .evm-metric-group .evm-metric__label { font-size: .68rem; }
    .evm-metric-group .evm-metric__val { margin-top: 2px; }
    .evm-metric-group .evm-metric__hint { margin-top: 1px; }
    .evm-metric__val { font-size: .95rem; }
    .evm-metric__hint { font-size: .62rem; }
}

/* Operational UI baseline. Keep these primitives together: earlier sections
   contain legacy component variants, but forms must share one density and
   state contract across the company, project, task, report and cost flows. */
:root {
    --control-height: 40px;
    --field-gap: 16px;
    --surface-input: color-mix(in srgb, var(--bg-primary) 65%, var(--bg-secondary));
    --surface-hover: color-mix(in srgb, var(--text-primary) 6%, var(--bg-secondary));
    --field-error-color: #fca5a5;
}
[data-theme="light"] { --field-error-color: #b42318; }
body { font-size: 14px; line-height: 1.5; }
button, input, textarea, select { font-family: inherit; }
.btn {
    min-height: var(--control-height);
    padding: 8px 14px;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 600;
    border-radius: var(--radius);
    transition: background-color var(--motion-fast), border-color var(--motion-fast), opacity var(--motion-fast);
}
.btn:active { transform: none; filter: brightness(.94); }
.btn:disabled, button[aria-busy="true"] { cursor: wait; opacity: .55; }
.btn-secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-hover); }
.btn-danger { background: transparent; color: var(--field-error-color); border: 1px solid var(--border-color); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger-color) 10%, transparent); }
.btn-sm, .btn-small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.icon-btn { min-width: 36px; min-height: 36px; font-size: 18px; }
.input-field, .form-select {
    min-height: var(--control-height);
    padding: 9px 12px;
    background-color: var(--surface-input);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    transition: border-color var(--motion-fast), background-color var(--motion-fast);
}
.form-select, select.input-field { padding-right: 38px; }
.input-field:focus, .form-select:focus {
    background-color: var(--surface-input);
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-color: var(--accent-color);
}
.input-field:disabled, .form-select:disabled { opacity: .6; cursor: not-allowed; }
.input-field[readonly] { background-color: var(--bg-secondary); color: var(--text-secondary); }
textarea.input-field { min-height: 88px; resize: vertical; }
.form-group { margin-bottom: var(--field-gap); min-width: 0; }
.form-group label, .field-label { display: block; margin-bottom: 6px; font-size: 13px; line-height: 1.5; font-weight: 500; color: var(--text-primary); }
.form-row { gap: 16px; margin-bottom: 0; }
.form-row > .form-group { min-width: 0; }
.form-hint, .input-help { color: var(--text-secondary); font-size: 13px; line-height: 1.5; margin-top: 6px; }
.field-error { color: var(--field-error-color); font-size: 13px; line-height: 1.5; margin: 6px 0 0; }
[aria-invalid="true"] { border-color: var(--field-error-color); }
.checkbox-row { min-height: 36px; align-items: center; gap: 10px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-color); }
.modal-header { padding: 16px 20px; gap: 12px; }
.modal-header h3 { font-size: 18px; font-weight: 600; line-height: 1.4; }
.modal-header .icon-btn { width: 36px; height: 36px; font-size: 22px; }
.modal-body, .modal-section { padding: 20px; }
.modal-footer { padding: 16px 20px; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border-color); }
.modal-footer .footer-right { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.modal-container { border-radius: 12px; box-shadow: 0 16px 48px rgb(0 0 0 / .18); }
dialog.app-modal .modal-container { max-width: 520px; }
.project-info-modal .modal-container { max-width: 600px; }
#pwa-install-overlay .pwa-install-content { border-radius: 12px; box-shadow: none; padding: 28px; }
#pwa-install-overlay .pwa-install-icon { background: var(--surface-input); box-shadow: none; }
#pwa-install-overlay h2 { font-size: 22px; }
.login-container { width: 100%; max-width: 420px; margin-inline: auto; padding: 32px 24px; }
.login-container h1 { font-size: 24px; line-height: 1.3; letter-spacing: -.4px; font-weight: 600; }
.login-container .logo { color: var(--text-primary); letter-spacing: 1.5px; font-size: 13px; }
.auth-method-switch { gap: 4px; padding: 4px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--surface-input); }
.auth-method-switch .radio-label { position: relative; }
/* Keep the existing native radio behavior, including arrow keys, in the
   accessibility tree. display:none removed keyboard access to all channels. */
.auth-method-switch input[type="radio"] { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; clip-path: inset(50%); }
.auth-method-switch .radio-btn { min-height: 40px; display: grid; place-items: center; border: 0; border-radius: 5px; font-size: 14px; }
.auth-method-switch input:checked + .radio-btn { color: var(--text-primary); background: var(--bg-secondary); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.auth-method-switch input:focus-visible + .radio-btn { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.company-form-body { padding: 24px; }
.company-form-body > .form-section { width: 100%; max-width: 960px; margin-inline: auto; }
.company-form-body .form-section { border-radius: 0; box-shadow: none; }
.plan-card { border-width: 1px; padding: 16px; border-radius: 8px; box-shadow: none; background: var(--bg-secondary); }
.plan-card:hover { transform: none; }
.plan-card.selected { background: var(--bg-secondary); box-shadow: inset 0 0 0 1px var(--accent-color); }
.plan-card h4 { font-size: 16px; }
.plan-card .price { font-size: 18px; color: var(--text-primary); }
.plan-card ul { font-size: 13px; line-height: 1.65; }
.plan-card ul li::before { color: var(--text-secondary); }
.plan-card ul li.plan-cap { color: var(--text-primary); }
.plan-card ul { margin-top: 4px; }
.plan-duration__label { font-weight: 400; color: var(--text-secondary); }
.quick-add { flex-wrap: wrap; }
.quick-add .field-error { flex-basis: 100%; order: 3; }
.msg-report, .msg-me.msg-report, .msg-other.msg-report {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    color: var(--text-primary); border-radius: 6px; box-shadow: none;
    width: 420px; max-width: calc(100% - 48px); padding: 12px 16px;
}
.report-header { border-color: var(--border-color); color: var(--text-secondary); }
.report-header > strong { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.report-task-name { font-size: 14px; line-height: 1.5; text-align: left; padding: 0; border: 0; background: none; font-family: inherit; }

.report-amount { display: flex; justify-content: space-between; gap: 16px; padding-block: 6px; }
.report-header i, .report-action-btn, .report-amount { color: var(--text-secondary); }
.report-task-name, .report-amount strong { color: var(--text-primary); }
.report-desc { color: var(--text-secondary); background: transparent; border-left: 2px solid var(--border-color); border-radius: 0; font-style: normal; padding: 4px 0 4px 10px; }
.report-action-btn { min-width: 36px; min-height: 36px; }
.report-action-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.evm-metric-grid { gap: 0 20px; }
.evm-metric { border: 0; border-bottom: 1px solid var(--border-color); border-radius: 0; padding: 14px 0; background: transparent; }
.evm-metric__val { font-weight: 600; font-size: 18px; overflow-wrap: anywhere; }
.evm-metric.is-good .evm-metric__val { color: var(--success-color); }
.evm-metric.is-warn .evm-metric__val { color: var(--warning-color); }
[data-theme="light"] { --warning-color: #b45309; }
.evm-metric.is-bad .evm-metric__val { color: var(--danger-color); }
.analytics-chart-card { border: 0; border-bottom: 1px solid var(--border-color); border-radius: 0; padding: 0 0 16px; background: transparent; }
.analytics-chart-host .scurve-full-svg { min-width: 760px; }
.analytics-detail-head h3 { white-space: normal; line-height: 1.4; }
#account-modal .placeholder { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0; text-align: center; }
/* Avatar + name stay a side-by-side pair, but the pair is centered as one unit
   (align-items:center on the column) so the whole modal reads centered. */
#account-modal .account-head { display: flex; align-items: center; gap: 16px; }
#account-modal .placeholder > p { grid-column: 1 / -1; margin: 0; font-size: 14px; }
#account-modal #account-avatar { margin: 0 !important; }
#account-modal #account-info { margin: 0 !important; text-align: left !important; }
#account-modal :is(.version-info, #theme-picker, #account-actions, .intuise-sessions-section) { grid-column: 1 / -1; margin: 8px 0 !important; max-width: none !important; width: 100%; }
#account-modal .version-info { font-size: 12px; }
#account-modal .intuise-session-item { border: 0; border-bottom: 1px solid var(--border-color); border-radius: 0; padding: 12px 0; margin: 0; }
#account-modal .intuise-session-label { flex-wrap: wrap; }
#account-modal .intuise-sessions-refresh { min-height: 40px; padding: 8px; }
#account-modal .intuise-session-revoke { min-height: 40px; }
.plan-duration { border-radius: var(--radius); min-height: 44px; }
.project-search-box { background: var(--surface-input); }
.project-item { border-radius: 0; margin: 0; padding: 14px 16px; background: transparent; border-bottom: 1px solid var(--border-color); }
.project-item.active { background: var(--surface-hover); box-shadow: none; }
.project-item .chat-name { font-size: 14px; font-weight: 600; }
.project-item .chat-preview, .project-item .project-subtitle { font-size: 12px; line-height: 1.5; }
.task-item { border-radius: 0; background: transparent; box-shadow: none; border: 0; border-bottom: 1px solid var(--border-color); padding: 16px; margin: 0; }
.task-name { font-size: 14px; line-height: 1.5; }
.task-price, .task-meta, .cost-amount { font-variant-numeric: tabular-nums; }
.project-header { padding: 12px 16px; }
.project-header-left { gap: 6px; flex-wrap: wrap; }
.project-header .chat-header-text { flex-basis: 160px; height: auto; min-height: 44px; }
.project-header .chat-header-text h3 { overflow: visible; scrollbar-gutter: auto; font-size: 15px; line-height: 1.35; }
.chat-header-text .chat-subtitle { font-size: 12px; }
.pane-side-header h3, .pane-left-mode-header h3 { font-size: 16px; font-weight: 600; }
.chat-input-area { padding: 12px 16px; gap: 8px; }
.chat-input-area input { min-height: 40px; border: 1px solid var(--border-color); background: var(--surface-input); }
.report-export-row { flex-wrap: wrap; gap: 12px; }
.report-export-meta { min-width: 0; overflow-wrap: anywhere; }
#account-modal .modal-container { max-width: 560px; }
#account-modal .theme-options { flex-wrap: wrap; }
.theme-swatch-name { color: var(--text-secondary); }
.project-tab-btn, .project-pill { min-height: 36px; }
@media (max-width: 1100px) {
    :root { --control-height: 44px; }
    .btn, .icon-btn, .btn-sm, .btn-small, .project-tab-btn, .project-pill,
    .report-action-btn, .modal-header .icon-btn { min-height: 44px; }
    .icon-btn, .report-action-btn { min-width: 44px; }
    .checkbox-row { min-height: 44px; }
}
@media (min-width: 768px) and (max-width: 1100px) {
    .pane-left { flex-basis: var(--pane-left-width, 280px); width: 280px; min-width: 240px; }
    .project-header .chat-header-text { flex-basis: calc(100% - 56px); }
    /* A third narrow column erases the conversation at tablet widths.
       Keep both primary panes mounted; the existing close/max controls return
       to that context after working in the support panel. */
    .pane-side.is-open { position: absolute; inset: 0 0 0 auto; width: min(560px, calc(100% - 56px)); z-index: 65; box-shadow: -8px 0 32px rgb(0 0 0 / .15); }
    #pane-side-resizer { display: none !important; }
    .company-form-body { padding: 20px; }
    .subscription-plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    :root { --control-height: 44px; }
    .input-field, .form-select, .chat-input-area input { font-size: 16px; }
    .btn, .icon-btn, .btn-sm, .btn-small, .project-tab-btn, .project-pill { min-height: 44px; }
    .icon-btn { min-width: 44px; }
    .modal-header, .modal-footer { padding: 16px; }
    .modal-body, .modal-section { padding: 16px; }
    dialog.app-modal .modal-container { max-width: 100%; }
    .modal-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .company-form-body { padding: 16px; }
    .subscription-plans { grid-template-columns: 1fr; }
    .project-item { padding: 14px 12px; }
    .chat-input-area { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
    .login-container { padding: 24px; }
    .login-container h1 { font-size: 22px; }
    #view-login { overflow-y: auto; }
    .project-search-clear { min-width: 32px; min-height: 32px; }
}
@media (max-width: 380px) { .form-row { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* QA corrections: native date/file controls need the same theme as the form. */
:root { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
.modal-container .field-error { color: var(--field-error-color); font-size: 13px; line-height: 1.5; margin: 6px 0 0; }
.input-field[aria-invalid="true"], .form-select[aria-invalid="true"] { border-color: var(--field-error-color); }
input[type="file"] { max-width: 100%; font-size: 13px; color: var(--text-secondary); }
input[type="file"]::file-selector-button { border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-secondary); color: var(--text-primary); min-height: 36px; padding: 6px 10px; margin-right: 10px; font: inherit; cursor: pointer; }
.cost-table { table-layout: fixed; min-width: 760px; font-variant-numeric: tabular-nums; }
.cost-table th:first-child { width: 200px; }
.cost-table th:nth-child(2) { width: 140px; }
.cost-table th:nth-child(3) { width: 120px; }
.cost-table th:nth-child(4) { width: 120px; }
.cost-table th:nth-child(5) { width: 80px; }
.cost-table th:nth-child(6) { width: 130px; }
.cost-table th, .cost-table td { white-space: normal; overflow-wrap: anywhere; }
.cost-table thead th { background: var(--bg-secondary); font-weight: 500; }
.cost-row-actions button { border: 0; background: transparent; color: var(--text-primary); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 8px; min-height: 36px; border-radius: var(--radius); }
.cost-row-actions button:hover { background: var(--surface-hover); }

/* Analytics project list: every row is the same navigational component. The
   active state changes emphasis only, so selecting a project never changes
   the list rhythm or makes neighbouring rows jump. */
.analytics-list {
    gap: 8px;
    padding: 12px 14px 16px;
}
.analytics-row {
    position: relative;
    min-height: 76px;
    padding: 12px 14px 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    box-shadow: none;
}
.analytics-row::before {
    content: "";
    position: absolute;
    inset: 10px auto 10px 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: transparent;
}
.analytics-row:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.analytics-row.is-active { border-color: color-mix(in srgb, var(--accent-color) 55%, var(--border-color)); background: var(--accent-soft); }
.analytics-row.is-active::before { background: var(--accent-color); }
.analytics-row__name { line-height: 1.3; }
.analytics-row__chips { gap: 5px; margin-top: 7px; }
.analytics-row__preview { width: 150px; height: 48px; opacity: .9; }
.analytics-empty { padding: 24px 8px; line-height: 1.5; }
@media (max-width: 600px) {
    .analytics-list { padding: 10px 12px 12px; }
    .analytics-row { min-height: 68px; padding: 10px 11px 10px 14px; }
    .analytics-row__preview { width: 112px; height: 40px; }
}
.cost-row-actions .cost-act-del { color: var(--field-error-color); }
.table-scroll-hint { margin: 0; padding: 6px 12px; font-size: 12px; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); }
.connection-banner { position: fixed; z-index: 80; left: 50%; top: max(8px, env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100% - 24px); background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 8px 14px; box-shadow: var(--shadow-md); font-size: 13px; }
.connection-banner[hidden] { display: none; }
@media (min-width:768px) and (max-width:1100px) {
    .btn, .btn-sm, .icon-btn, .plan-duration { min-height: 44px; }
    .icon-btn { min-width: 44px; }
    .input-field, .form-select { min-height: 44px; font-size: 16px; }
}
@media (max-width:767px) { .cost-row-actions button { min-height: 44px; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.report-export-notice { background: var(--surface-input); border-color: var(--border-color); }
.task-price { color: var(--text-secondary); }

.analytics-chart-host .scurve-full-svg text { font-size: 13px; }
.plan-card--custom { grid-column: 1 / -1; border: 0; border-top: 1px solid var(--border-color); background: transparent; border-radius: 0; padding: 16px 0; }
@media (min-width: 768px) {
 .plan-card--custom { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 24px; }
 .plan-card--custom h4, .plan-card--custom .plan-card__custom-blurb { grid-column: 1; margin: 0; }
 .plan-card--custom .btn { grid-column: 2; grid-row: 1 / 3; margin: 0; align-self: center; }
}
.ck-emoji-panel { border-radius: 10px; max-height: calc(100dvh - 140px); }
.ck-emoji-search { border-radius: 6px; padding: 4px 8px; background: var(--surface-input); }
.ck-emoji-search input { border: 0; background: transparent; border-radius: 4px; }
@media (max-width: 1100px) {
 .ck-emoji-tab { width: 44px; height: 44px; }
 .ck-emoji-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
 .ck-emoji { min-height: 44px; }
 .ck-emoji img { width: 28px; height: 28px; }
}
@media (max-width: 767px) {
 .chat-input-area .ck-emoji-panel { position: fixed; left: 16px; right: 16px; bottom: max(70px, calc(env(safe-area-inset-bottom) + 64px)); width: auto; }
}
@media (max-width: 767px) {
 .connection-banner { top: auto; bottom: max(78px, calc(env(safe-area-inset-bottom) + 70px)); width: calc(100% - 32px); max-width: 420px; }
}

/* Review refinements: project state and permissions should be legible without
   coloured strips or role pills. Keep person/entity avatar shapes distinct. */
/* Project avatars retain their deterministic initial palette. */
.role-badge, .role-badge.role-owner, .role-badge.role-admin,
#project-members-list .role-badge { background: transparent; color: var(--text-secondary); border-radius: 0; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; }
#project-members-modal .modal-container { max-width: 600px; }
.project-settings-heading { font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
#project-members-list .picker-contact-item { border-radius: 0; padding-block: 12px; }
#project-members-list .member-role-select { min-height: var(--control-height); border: 1px solid var(--border-color); border-radius: 5px; background-color: var(--surface-input); }
.member-kick-btn { color: var(--text-secondary); }
.member-kick-btn:hover { color: var(--danger-color); }
#user-profile-modal .modal-container { max-width: 440px; }
#user-profile-modal .placeholder { display: flex; flex-direction: row; align-items: center; gap: 20px; padding: 8px 0; text-align: left; }
#user-profile-modal .placeholder > div { margin: 0 !important; text-align: left !important; }
#user-profile-avatar { border-radius: 50%; flex-shrink: 0; }
.analytics-project-list { gap: 0; }
.analytics-row { border: 0; border-bottom: 1px solid var(--border-color); border-radius: 0; background: transparent; padding: 16px 8px; }
.analytics-row:hover, .analytics-row.is-active { border-color: var(--border-color); background: var(--surface-hover); }
.analytics-row__name { white-space: normal; }
.evm-chip { border-radius: 3px; background: transparent; padding-inline: 0; }
.evm-chip + .evm-chip { border-left: 1px solid var(--border-color); padding-left: 8px; }
.evm-chip.evm-bad, .evm-chip.evm-chip--bad { color: color-mix(in srgb, var(--text-primary) 55%, #c65d61); background: color-mix(in srgb, #c65d61 8%, transparent); }
.evm-chip.evm-warn, .evm-chip.evm-chip--warn { color: color-mix(in srgb, var(--text-primary) 55%, #aa792e); background: color-mix(in srgb, #aa792e 8%, transparent); }
.evm-chip.evm-ok, .evm-chip.evm-chip--good { color: color-mix(in srgb, var(--text-primary) 55%, #38846c); background: color-mix(in srgb, #38846c 8%, transparent); }
.contact-group__header { background: var(--bg-secondary); min-height: 44px; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.contact-group__count { background: transparent; border-radius: 0; }
.contacts-header .input-field, .contacts-header input { background: var(--surface-input); border-radius: 5px; }

.setting-editor > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; cursor: pointer; list-style: none; color: var(--text-primary); }
.setting-editor > summary::-webkit-details-marker { display: none; }
.setting-editor > summary:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.setting-change { color: var(--text-secondary); font-size: 13px; }
.setting-editor > summary:hover .setting-change { color: var(--text-primary); text-decoration: underline; }
.setting-editor[open] > summary { margin-bottom: 8px; }
.setting-editor .project-rename-row { flex-wrap: wrap; }
.setting-editor .project-rename-row .input-field { flex: 1 1 240px; }
.setting-editor .field-error { flex: 1 0 100%; order: 3; }
.member-role-editor { width: 124px; flex-shrink: 0; }
.member-role-editor > summary { justify-content: center; font-size: 12px; text-transform: capitalize; color: var(--text-secondary); }
.member-role-editor > summary i { font-size: 10px; }
.member-role-editor-actions { display: flex; margin-top: 8px; gap: 4px; }
.member-role-editor-actions .btn { padding-inline: 6px; flex: 1; }
@media (max-width: 1100px) { .setting-editor > summary { min-height: 44px; } }
/* Identity photos share their existing avatar's shape and fallback initials. */
[data-avatar-kind] { position: relative; overflow: hidden; isolation: isolate; }
[data-avatar-kind] > .avatar-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; pointer-events: none; }
.avatar-editor .modal-container { width: min(440px, 100%); }
.avatar-editor .modal-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.avatar-editor .avatar-subject { margin: 0; color: var(--text-secondary); }
.avatar-preview { width: 180px; height: 180px; flex: 0 0 180px; position: relative; overflow: hidden; border-radius: 8px; background: var(--bg-secondary); border: 1px solid var(--border-color); display: grid; place-items: center; }
.avatar-preview.is-person { border-radius: 50%; }
.avatar-preview canvas, .avatar-preview img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.avatar-preview [hidden] { display: none; }
.avatar-initials { color: var(--text-secondary); font-size: 42px; font-weight: 600; }
.avatar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.avatar-editor .form-hint, .avatar-editor .form-error { margin: 0; }
.avatar-crop { width: 100%; }
.avatar-crop summary { cursor: pointer; padding: 8px 0; color: var(--text-secondary); }
.avatar-crop label { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 12px; margin: 8px 0; font-size: 13px; }
.avatar-crop input { width: 100%; min-width: 0; min-height: 32px; accent-color: var(--primary-color); }
#btn-project-photo { margin: 4px 0 0; padding-inline: 0; width: fit-content; }
#btn-account-photo { margin-bottom: 12px; }
@media (max-width: 1024px) { .avatar-crop input { min-height: 44px; } }

/* Reports are task references. Their overflow menu owns mutation actions. */
.report-navigable { cursor: pointer; transition: border-color 140ms ease, background-color 140ms ease; }
.report-navigable:hover { border-color: var(--text-secondary); }
.report-navigable:focus-within { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.report-task-name { display: block; cursor: pointer; width: 100%; }
.report-task-name:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 4px; }
.report-navigable[aria-busy="true"] { cursor: progress; }
.progress-state { padding: 20px; color: var(--text-secondary); }
.progress-task-focus { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-color); }
.progress-task-focus[hidden] { display: none; }
.progress-task-focus > div { flex: 1; min-width: 0; }
.progress-task-focus strong { display: block; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.progress-task-focus span { display: block; margin-top: 4px; color: var(--text-secondary); font-size: 12px; }
.progress-task-focus button { flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) { .report-navigable { transition: none; } }

/* Notifications are a chronological inbox, with actions beside their context. */
.notifications-toolbar { display:flex; flex:0 0 auto; align-items:center; justify-content:space-between; gap:12px; padding:8px 16px; border-bottom:1px solid var(--border-color); }
.notifications-toolbar > span { font-size:12px; color:var(--text-secondary); }
.notifications-toolbar .icon-btn { width:36px; height:36px; font-size:14px; border-radius:6px; }
.notifications-list { padding:0; gap:0; }
.notif-item { border:0; border-bottom:1px solid var(--border-color); border-radius:0; background:transparent; padding:18px 16px; gap:12px; align-items:flex-start; }
.notif-item.notif-resolved { opacity:1; }
.notif-item.notif-resolved .notif-text { font-weight:500; }
.notif-avatar { background:var(--bg-tertiary); color:var(--text-secondary); font-size:14px; width:36px; height:36px; }
.notif-avatar-system { border-radius:6px; }
.notif-text { font-size:13px; line-height:1.5; font-weight:600; margin:0; overflow-wrap:anywhere; }
.notif-meta { font-size:13px; line-height:1.5; margin:4px 0 0; white-space:pre-wrap; overflow-wrap:anywhere; }
.notif-body time { display:block; color:var(--text-secondary); font-size:11px; margin-top:6px; }
.notif-actions { gap:8px; flex-wrap:wrap; margin-top:12px; }
.btn-notif-accept,.btn-notif-decline { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:36px; padding:7px 12px; font-family:inherit; font-size:12px; font-weight:500; line-height:1.4; text-decoration:none; border-radius:6px; }
.btn-notif-decline { border:1px solid var(--border-color); background:transparent; }
.btn-notif-decline:hover:not(:disabled) { background:var(--bg-tertiary); }
.notif-state { padding:36px 24px; max-width:380px; color:var(--text-secondary); }
.notif-state > i { font-size:22px; margin-bottom:16px; }
.notif-state h4 { margin:0 0 8px; color:var(--text-primary); font-size:14px; font-weight:600; }
.notif-state p { margin:0; font-size:13px; line-height:1.6; }
.notif-retry { margin-top:18px; }
.notif-feedback { margin:0; padding:12px 16px; font-size:12px; line-height:1.5; color:var(--text-secondary); border-bottom:1px solid var(--border-color); }
.notif-row-error { font-size:12px; line-height:1.5; color:var(--danger-color); margin:12px 0 0; }
.notif-actions button:focus-visible,.notif-actions a:focus-visible { outline:2px solid var(--accent-color); outline-offset:3px; }
@media (pointer:coarse), (max-width:1024px) { .notif-actions button,.notif-actions a,.notifications-toolbar .icon-btn { min-height:44px; min-width:44px; } }

/* Analytics sizing is based on the available pane, not the SVG aspect ratio. */
#analytics-detail-body { min-height:0; overflow:auto; scrollbar-gutter:auto; }
#analytics-detail-body .analytics-health { flex:none; display:grid; grid-template-columns:minmax(220px,2.6fr) repeat(3,minmax(110px,1fr)); gap:20px; padding:20px; }
.analytics-health-copy { display:flex; align-items:flex-start; gap:12px; }
.analytics-health-copy .analytics-health__dot { margin-top:5px; }
.analytics-health-copy p { margin:6px 0 0; color:var(--text-secondary); font-size:12px; }
.analytics-health-stat { border-left:1px solid var(--border-color); padding-left:20px; min-width:0; }
.analytics-health-stat > span,.analytics-health-stat small { display:block; color:var(--text-secondary); font-size:12px; }
.analytics-health-stat b { display:block; font-size:24px; line-height:1.4; }
.analytics-health-stat.is-bad b { color:var(--danger-color); }
.analytics-health-stat progress { display:block; width:100%; height:6px; margin-top:5px; accent-color:var(--accent-color); }
#analytics-detail-body .analytics-chart-card { flex:1 0 260px; min-height:260px; padding:16px; border:1px solid var(--border-color); border-radius:8px; box-shadow:none; }
#analytics-detail-body .analytics-chart-heading { flex:none; margin-bottom:12px; }
#analytics-detail-body .analytics-chart-host { position:relative; display:block; flex:1; min-height:180px; overflow:visible; }
#analytics-detail-body .scurve-full-svg { position:absolute; inset:0; min-width:0; width:100%!important; height:100%!important; }
#analytics-detail-body .evm-metric-groups { flex:none; grid-template-columns:1fr 1fr 1.4fr; }
#analytics-detail-body .evm-metric-group .evm-metric-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr)); }
#analytics-detail-body .evm-metric-group:last-child .evm-metric-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr)); }
#analytics-detail-body .evm-metric-group .evm-metric:last-child { grid-column:1/-1; }
#analytics-detail-body .evm-metric__val { overflow-wrap:normal; }
#analytics-detail-body .evm-metric-group h4 { display:flex; align-items:center; gap:10px; font-size:16px; font-weight:600; }
#analytics-detail-body .evm-metric-group h4 i { font-size:20px; color:var(--text-secondary); }
.analytics-completion { grid-column:1/-1; display:block; width:100%; height:6px; border:0; border-radius:3px; overflow:hidden; accent-color:var(--accent-color); margin:6px 0; }
.analytics-completion::-webkit-progress-bar { background:var(--bg-tertiary); }
.analytics-completion::-webkit-progress-value { background:var(--accent-color); border-radius:3px; }
.analytics-completion::-moz-progress-bar { background:var(--accent-color); }
#analytics-project-list .analytics-row { border:0; border-radius:6px; padding:14px; gap:12px; }
#analytics-project-list .analytics-row__preview { width:clamp(64px,30%,130px); }
#analytics-project-list .analytics-row__name { overflow-wrap:break-word; }
@media (max-width:1100px) {
    #analytics-detail-body .analytics-health { grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; padding:12px; }
    .analytics-health-copy { grid-column:1/-1; }
    .analytics-health-stat { padding-left:10px; }
    #analytics-detail-body .evm-metric-groups { grid-template-columns:1fr 1fr; gap:8px; }
    #analytics-detail-body .evm-metric-group:first-child { grid-column:1 / -1; }
}
@media (max-width:600px) {
    #analytics-detail-body { padding:8px; gap:8px; }
    #analytics-detail-body .analytics-health { gap:8px; padding:10px; }
    #analytics-detail-body .analytics-chart-card { flex-basis:270px; min-height:270px; padding:12px 10px 8px; }
    #analytics-detail-body .analytics-chart-host { min-height:170px; }
    #analytics-detail-body .evm-metric-groups { grid-template-columns:1fr 1fr; gap:8px; }
    #analytics-detail-body .evm-metric-group:first-child { grid-column:1/-1; }
    #analytics-detail-body .evm-metric-group { padding:8px; }
    #analytics-detail-body .evm-metric-group .evm-metric-grid { grid-template-columns:1fr; gap:0; }
    #analytics-detail-body .evm-metric-group:last-child .evm-metric-grid { grid-template-columns:1fr; gap:0; }
    #analytics-detail-body .evm-metric-group:last-child .evm-metric:last-child { grid-column:1 / -1; }
    #analytics-detail-body .evm-metric-group h4 { margin:0 0 10px; font-size:16px; font-weight:600; }
    #analytics-detail-body .evm-metric-group { padding:12px; border-radius:12px; }
    #analytics-detail-body .evm-metric { padding:6px 0; min-width:0; }
    #analytics-detail-body .evm-metric__label { font-size:12px; letter-spacing:0; text-transform:none; }
    #analytics-detail-body .evm-metric__val { font-size:13px; margin-top:4px; overflow-wrap:normal; word-break:normal; white-space:nowrap; }
    #analytics-detail-body .evm-metric__hint { font-size:11px; margin-top:3px; line-height:1.4; }
    #analytics-detail-body .evm-metric-group:first-child .evm-metric { display:grid; grid-template-columns:minmax(0,1fr) auto; column-gap:12px; align-items:baseline; }
    #analytics-detail-body .evm-metric-group:first-child .evm-metric__val { text-align:right; margin:0; font-size:17px; }
    #analytics-detail-body .evm-metric-group:first-child .evm-metric__hint { grid-column:1/-1; }
    #analytics-detail-body .analytics-health-stat { display:none; }
    #analytics-detail-body .analytics-health-copy p { margin-top:4px; }
    #analytics-detail-body .evm-metric-group .evm-metric:first-child { border-top:0; }
    #analytics-detail-body .evm-metric-group:not(:first-child) .evm-metric { padding:6px 0; }
    #analytics-detail-body .evm-metric-group h4 { margin-bottom:6px; }
    #analytics-detail-body .evm-metric__label,
    #analytics-detail-body .evm-metric__val { line-height:1.35; }
    .analytics-date-range { max-width:180px; font-size:10px; }
}

/* Product tokens cross the component API through its public CSS API. */
#project-tab-progress intuise-gantt {
    --intuise-gantt-bg: var(--bg-primary);
    --intuise-gantt-surface: var(--bg-secondary);
    --intuise-gantt-surface-raised: var(--bg-tertiary);
    --intuise-gantt-text: var(--text-primary);
    --intuise-gantt-text-muted: var(--text-secondary);
    --intuise-gantt-divider: var(--border-color);
    --intuise-gantt-grid-color: var(--border-color);
    --intuise-gantt-accent: var(--accent-color);
    --intuise-gantt-accent-text: var(--text-primary);
    --intuise-gantt-scrollbar-thumb: var(--bg-tertiary);
    --intuise-gantt-scrollbar-thumb-hover: var(--text-secondary);
    --intuise-gantt-radius-sm: var(--radius);
    --intuise-gantt-radius-md: var(--radius);
    --intuise-gantt-radius-lg: var(--radius);
}

/* Project profile stays in read mode until a specific value is edited. */
.project-info-modal .project-info-hero { padding-right: 72px; }
.project-members-section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }

/* Project actions row: Export report + Delete project as standalone buttons
   (replaced the old ⋯ overflow menu). Delete uses the danger token. */
.project-actions-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.project-actions-buttons .btn { flex: 0 0 auto; }
.project-actions-buttons .project-delete-action { color: var(--danger-color); border-color: var(--danger-color); }
.project-actions-buttons .project-delete-action:hover { background: var(--danger-color); border-color: var(--danger-color); color: #fff; }
.project-members-section-header .project-settings-heading { margin: 0; }
#project-rename-editor > summary { min-height: 40px; padding: 8px 0; cursor: text; }
#project-rename-editor[open] > summary { display: none; }
#project-rename-editor .project-rename-row { margin: 0; min-height: 40px; gap: 8px; }
#project-rename-input { min-width: 0; font: inherit; }
.profile-actions-menu { position: relative; flex: none; }
.profile-actions-menu > summary { display: grid; place-items: center; width: 36px; height: 40px; list-style: none; border-radius: var(--radius); cursor: pointer; color: var(--text-secondary); }
.profile-actions-menu > summary::-webkit-details-marker { display: none; }
.profile-actions-menu > summary:hover, .profile-actions-menu[open] > summary { background: var(--bg-tertiary); color: var(--text-primary); }
.profile-menu-items { position: absolute; right: 0; top: 100%; width: 210px; max-width: calc(100vw - 64px); padding: 6px; z-index: 10; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.profile-menu-items > button, .profile-menu-items > span, .profile-menu-items > details { display: block; width: 100%; height: auto; min-height: 36px; margin: 0; text-align: left; padding: 8px; background: none; border: 0; color: var(--text-primary); font: inherit; border-radius: var(--radius); }
.profile-menu-items > button:hover { background: var(--bg-tertiary); }
.profile-menu-items .profile-danger { color: var(--field-error-color, #e89b9b); }
.profile-menu-items .member-role-editor > summary { justify-content: space-between; }
.member-role-label { color: var(--text-secondary); font-size: 12px; }
#project-members-list .picker-contact-item { overflow: visible; }
#project-members-list .picker-contact-actions { gap: 8px; }

@media (max-width: 767px) {
 .profile-actions-menu > summary { width: 44px; height: 44px; }
 .profile-menu-items > button { min-height: 44px; }
 .project-info-modal .project-info-hero { padding-right: 64px; }
 #project-rename-editor .project-rename-row { flex-wrap: wrap; }
 #project-rename-input { flex: 1 1 100%; }
}

.project-members-section-header { border-top: 1px solid var(--border-color); padding-top: 16px; }
.project-members-section-header #project-members-heading { border: 0; padding: 0; margin: 0; }
.profile-actions-menu > summary { font-size: 22px; }
.project-info-modal .modal-floating-close { top: 14px; }

.project-info-modal .project-members-section-header { margin: 0 var(--pm-inset); padding: 12px 0 6px; }
#project-members-list .picker-contact-item { flex-wrap: nowrap; gap: 10px; }
#project-members-list .picker-contact-info { flex: 1; min-width: 0; }
#project-members-list .picker-contact-actions { flex: 0 0 auto; width: auto; margin: 0 0 0 auto; }
#project-members-list .member-role-label { white-space: nowrap; overflow-wrap: normal; }

.project-info-modal #project-members-list .picker-contact-item { display: flex; align-items: center; }
.project-info-modal #project-members-list .picker-contact-actions { display: flex; align-items: center; }

/* Inline value editing shares a baseline with read mode, not a second form. */
#project-rename-group { padding-block: 16px; }
#project-rename-group > .project-settings-heading { font-size: 13px; font-weight: 400; color: var(--text-secondary); margin-bottom: 6px; }
#project-rename-editor > summary, #project-rename-input { font-size: 16px; font-weight: 500; line-height: 24px; color: var(--text-primary); }
#project-rename-editor > summary { padding: 8px 0; }
#project-rename-editor .project-rename-row { align-items: flex-start; flex-wrap: wrap; }
#project-rename-input { padding: 8px 0; height: 40px; border: 0; border-radius: 0; background: transparent; box-shadow: inset 0 -1px var(--border-color); flex: 1 1 100%; }
#project-rename-input:focus { outline-offset: 3px; }
.profile-menu-items[popover] { position: fixed; margin: 0; inset: auto; box-sizing: border-box; width: 232px; max-width: calc(100vw - 16px); overflow-y: auto; color: var(--text-primary); }
.profile-menu-items[popover] {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity var(--motion-fast) var(--motion-ease), transform var(--motion-fast) var(--motion-ease), display var(--motion-fast) allow-discrete, overlay var(--motion-fast) allow-discrete;
}
.profile-menu-items[popover]:popover-open { opacity: 1; transform: translateY(0); }
@starting-style { .profile-menu-items[popover]:popover-open { opacity: 0; transform: translateY(4px); } }
.profile-actions-menu.menu-open-up .profile-menu-items[popover] { transform: translateY(4px); }
.profile-actions-menu.menu-open-up .profile-menu-items[popover]:popover-open { transform: translateY(0); }
@starting-style { .profile-actions-menu.menu-open-up .profile-menu-items[popover]:popover-open { transform: translateY(4px); } }
#project-members-modal .profile-menu-items .profile-menu-action { display: block; box-sizing: border-box; width: 100%; height: auto; min-height: 40px; padding: 10px 12px; border-radius: var(--radius); line-height: 20px; text-align: left; white-space: nowrap; }
#project-members-modal .profile-menu-items .member-role-editor { width: 100%; box-sizing: border-box; }
#project-members-modal .member-role-editor .member-role-select { width: 100%; min-height: 36px; }
#project-members-modal .member-role-editor-actions { margin-top: 6px; gap: 6px; }
#project-members-modal .member-role-editor-actions .btn { min-height: 36px; }
#project-members-modal .profile-menu-items .member-role-select { width: 100%; }
#project-members-modal .profile-menu-items .member-role-select {
  display: block;
  box-sizing: border-box;
  min-height: 40px;
  margin: 0;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  line-height: 20px;
  border-radius: var(--radius);
}
#project-members-modal .profile-menu-items > button { white-space: nowrap; min-height: 40px; }
@media (max-width: 520px) {
 .project-info-modal #project-members-list .picker-contact-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) 44px; grid-template-areas: 'avatar info menu' 'avatar role menu'; column-gap: 10px; row-gap: 2px; }
 .project-info-modal #project-members-list .picker-contact-actions { display: contents; }
 #project-members-list .member-role-label { grid-area: role; }
 #project-members-list .profile-actions-menu { grid-area: menu; }
 #project-members-modal .profile-menu-items .profile-menu-action, #project-members-modal .profile-menu-items > button { min-height: 44px; }
}

#project-members-modal .profile-menu-items .profile-danger { color: var(--field-error-color, #e89b9b); }
#project-rename-editor .field-error { flex-basis: 100%; margin: 0; }
#project-rename-editor > summary:hover { color: var(--accent-color); }

/* The last interactive row still needs a quiet edge inside the profile. */
#project-profile-page { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
#btn-modal-invite-member { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
#project-members-modal .modal-container { overflow: hidden; }
#project-invite-page { display: flex; flex-direction: column; min-height: 320px; min-width: 0; max-height: inherit; }
#project-invite-page .modal-header { padding-right: 64px; justify-content: flex-start; gap: 12px; }
#project-invite-page .modal-body { min-height: 0; overflow-y: auto; }

/* Keep the profile close control on the same surface as its modal. The
   inherited background avoids a darker, unrelated disc in either theme while
   hover and focus still provide a clear target. */
#project-members-modal .modal-floating-close {
    width: 36px;
    height: 36px;
    font-size: 26px !important;
    line-height: 1;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text-secondary);
    box-shadow: none;
}
#project-members-modal .modal-floating-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#project-members-modal .modal-floating-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
#project-members-modal .modal-floating-close:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}
/* Avatar edit affordance: reveal a quiet camera marker on hover/focus while
   keeping the existing Change photo action as the actual control. */
#account-avatar, #project-info-avatar, #sidebar-profile-avatar {
    position: relative;
    cursor: pointer;
}
#account-avatar::after, #project-info-avatar::after, #sidebar-profile-avatar::after {
    content: '\f030';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border-radius: inherit;
    background: rgb(15 23 42 / 0.62);
    color: var(--text-primary);
    font-size: 0.9em;
    opacity: 0;
    transition: opacity var(--motion-fast) var(--motion-ease);
}
#account-avatar:hover::after, #project-info-avatar:hover::after,
#sidebar-profile-avatar:hover::after,
#account-avatar:focus-visible::after, #project-info-avatar:focus-visible::after,
#sidebar-profile-avatar:focus-visible::after { opacity: 1; }
.project-info-hero #btn-project-photo { display: none !important; }
#account-info #btn-account-photo { display: none !important; }
#account-avatar { border-radius: 50%; }
@media (max-width: 767px) {
    #account-avatar::after, #project-info-avatar::after, #sidebar-profile-avatar::after {
        opacity: 1;
        inset: auto 2px 2px auto;
        width: 22px;
        height: 22px;
        border: 2px solid var(--bg-secondary);
        border-radius: 50%;
        font-size: 10px;
    }
}
/* Global modal close controls follow the design-system treatment: a quiet
   square hit area with a surface hover state, never a decorative dark disc. */
dialog.app-modal .modal-header > .icon-btn,
dialog.app-modal .modal-header > .close-modal {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text-secondary);
}
dialog.app-modal .modal-header > .icon-btn:hover,
dialog.app-modal .modal-header > .close-modal:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
/* Shared close affordance for dialogs, alerts, and modal headers. */
dialog.app-modal .modal-header > .icon-btn,
dialog.app-modal .modal-header > .close-modal,
.close-btn, .close-modal {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    font-size: 0;
    line-height: 1;
    border-radius: 6px;
}
dialog.app-modal .modal-header > .icon-btn:not(.modal-floating-close)::before,
dialog.app-modal .modal-header > .icon-btn:not(.modal-floating-close)::after,
dialog.app-modal .modal-header > .close-modal::before,
dialog.app-modal .modal-header > .close-modal::after,
.close-btn::before, .close-btn::after, .close-modal::before, .close-modal::after {
    content: '';
    grid-area: 1 / 1;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}
dialog.app-modal .modal-header > .icon-btn:not(.modal-floating-close)::before,
dialog.app-modal .modal-header > .close-modal::before,
.close-btn::before, .close-modal::before { transform: rotate(45deg); }
dialog.app-modal .modal-header > .icon-btn:not(.modal-floating-close)::after,
dialog.app-modal .modal-header > .close-modal::after,
.close-btn::after, .close-modal::after { transform: rotate(-45deg); }
#project-invite-back { font-size: 18px !important; }
#project-invite-back::before, #project-invite-back::after { display: none; }
#project-members-modal:has(#project-invite-page:not(.hidden)) > .modal-container > #close-project-members { display: none; }
#project-members-modal .modal-floating-close svg { display: block; }
dialog.app-modal.is-scrolled .modal-floating-close {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 20;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
#project-invite-page .picker-contact-list { max-height: none; }
#project-invite-page .picker-contact-list > .empty-state {
    padding: 28px 20px 0 !important;
    margin: 0;
    text-align: center;
}
#project-invite-page .modal-footer { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
@media (max-width: 520px) {
 #project-invite-page .picker-contact-item { flex-wrap: wrap; }
 #project-invite-page .picker-contact-actions { flex-basis: 100%; padding-left: 52px; }
}

#project-members-modal #project-profile-page {
    /* Keep the final row visually separated from the rounded modal edge. */
    padding-bottom: max(18px, env(safe-area-inset-bottom));
}
#project-members-modal .project-info-hero {
    padding-top: 18px;
    padding-bottom: 14px;
}
#project-members-modal #project-rename-group {
    padding-top: 14px;
    padding-bottom: 14px;
}
#project-members-modal .project-members-section-header {
    padding-top: 14px;
    padding-bottom: 8px;
}
#project-members-modal #project-rename-group { display: none !important; }
#project-members-modal #project-info-name[contenteditable="true"] {
    outline: none;
    border-radius: 0;
    box-shadow: inset 0 -2px var(--accent-color);
    cursor: text;
}
#project-members-modal #project-info-name {
    position: relative;
    display: inline-block;
}
#project-members-modal #project-info-name::after {
    content: '\f303';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0;
    transform: translateX(-3px);
    transition: opacity var(--motion-fast) var(--motion-ease), transform var(--motion-fast) var(--motion-ease);
}
#project-members-modal #project-info-name:hover::after,
#project-members-modal #project-info-name:focus-visible::after { opacity: 1; transform: translateX(0); }
#project-members-modal #project-info-name[contenteditable="true"]::after { display: none; }
#project-members-modal #project-invite-page { height: min(560px, calc(100dvh - 64px)); min-height: 0; max-height: calc(100dvh - 64px); }
#project-members-modal .modal-container { overflow: hidden; }
#project-invite-page > .modal-body { flex: 1; }
#project-invite-page > .modal-header, #project-invite-page > .modal-footer { flex: none; }
#project-invite-page > .modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
#project-invite-page > .modal-footer > .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    line-height: 1.2;
}

/* Import Excel -> AI task extraction modal */
.import-excel-sheet-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.import-excel-sheet-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius); cursor: pointer; }
.import-excel-sheet-row input { width: auto; margin: 0; }
.import-excel-progress { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.import-excel-status { font-size: 0.95em; color: var(--text-primary); }
.import-excel-bar { height: 8px; border-radius: 4px; background: var(--border-color); overflow: hidden; }
.import-excel-bar-fill { height: 100%; width: 0; border-radius: 4px; background: var(--accent-color); transition: width 0.2s; }
/* Each part is a single long, opaque AI call, so while work is in flight the
   bar runs as an indeterminate slider (a segment sweeping across) rather than
   sitting frozen; the status text carries the "part i of N" coarse progress. */
.import-excel-bar.indeterminate .import-excel-bar-fill {
    width: 35%;
    transition: none;
    animation: importBarSlide 1.2s ease-in-out infinite;
}
@keyframes importBarSlide {
    0% { margin-left: -35%; }
    100% { margin-left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .import-excel-bar.indeterminate .import-excel-bar-fill { animation: importBarPulse 1.4s ease-in-out infinite; margin-left: 0; width: 100%; }
    @keyframes importBarPulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
}

/* Device-limit logout picker */
.device-logout-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.device-logout-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: var(--radius); cursor: pointer; }
.device-logout-row input { width: auto; margin: 3px 0 0; }
.device-logout-name { display: flex; flex-direction: column; font-size: 0.95em; color: var(--text-primary); }
.device-logout-meta { font-size: 0.82em; color: var(--text-secondary); margin-top: 2px; }
