/* ============================================================
   PWD Dashboard — app shell
   ============================================================
   Layout: fixed topbar + sidenav (desktop), bottom-tab nav (mobile).
   Content area scrolls.
   ============================================================ */

/* base.css is loaded as a separate <link> in includes/head.php so it
 * gets its own filemtime-based cache-bust query. Do not @import — that
 * defeats cache busting and the browser keeps stale base.css forever. */

/* ── Layout shell ──────────────────────────────────────────── */
.app-shell {
    min-height: 100vh;
    display: grid;
    /* minmax(0, 1fr) — see mobile breakpoint below for the why. Prevents the
       content column from expanding to its grid item's min-content size,
       which can make the whole page wider than the viewport. */
    grid-template-columns: var(--sidenav-width) minmax(0, 1fr);
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
        "sidenav topbar"
        "sidenav content";
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-search {
    flex: 1 1 0;
    min-width: 0;
    max-width: 480px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-sunken);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: text;
    transition: background 120ms, border-color 120ms;
}
.topbar-search:hover { background: var(--bg-hover); }
.topbar-search:focus-within { border-color: var(--brand); background: var(--bg-elevated); }
.topbar-search input {
    flex: 1;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--text);
}
.topbar-search-placeholder {
    flex: 1;
    min-width: 0;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
button.topbar-search {
    font: inherit;
    border: 1px solid transparent;
}

/* ── Search modal ─────────────────────────────────────────── */
/* ── AI chat panel + drawer ────────────────────────────────── */
.ai-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 0;          /* allow .ai-thread to shrink in flex parents */
    overflow: hidden;
}
.ai-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sunken);
}
.ai-panel-title {
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ai-panel-sub { margin: 0.15rem 0 0; }
.ai-head-btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
    line-height: 1;
}
.ai-head-btn[data-ai-action="close"] {
    font-size: 1.1rem;
    padding: 0.3rem 0.6rem;
}
.ai-panel-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    min-height: 0;
}
.ai-empty { color: var(--text-muted); text-align: center; padding: 2.5rem 1rem; }

.ai-thread { display: flex; flex-direction: column; gap: 0.75rem; }
.ai-msg { display: flex; flex-direction: column; max-width: 90%; }
.ai-msg-user { align-self: flex-end; align-items: flex-end; }
.ai-msg-assistant { align-self: flex-start; }
.ai-bubble {
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    line-height: 1.5;
    word-wrap: break-word;
}
.ai-msg-user .ai-bubble {
    background: var(--brand);
    color: white;
    border-color: transparent;
}
.ai-msg.is-pending .ai-bubble { color: var(--text-muted); }
.ai-msg.is-error   .ai-bubble {
    border-color: var(--danger);
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 8%, transparent);
}

/* ── AI tool-call cards (Phase 5 agent loop) ────────────────── */
.ai-tool-stack {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}
.ai-tool-stack:empty { display: none; }
.ai-tool-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--success) 6%, var(--bg-sunken));
    overflow: hidden;
}
.ai-tool-card.is-error {
    background: color-mix(in srgb, var(--danger) 8%, var(--bg-sunken));
    border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}
.ai-tool-card details > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
}
.ai-tool-card details > summary::-webkit-details-marker { display: none; }
.ai-tool-card details[open] > summary { border-bottom: 1px solid var(--border); }
.ai-tool-icon {
    width: 1rem;
    text-align: center;
    color: var(--success);
    font-weight: 700;
}
.ai-tool-card.is-error .ai-tool-icon { color: var(--danger); }
.ai-tool-label {
    flex: 1;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.3;
    word-break: break-word;
}
.ai-tool-detail {
    margin: 0;
    padding: 0.5rem 0.6rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.45;
    background: var(--bg-sunken);
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 280px;
    overflow-y: auto;
}
.ai-text { /* final text response from the model, sits below tool cards */ }
.ai-bubble p { margin: 0 0 0.5em; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 0.4em 0 0.5em; padding-left: 1.4em; }
.ai-bubble li { margin: 0.2em 0; }
.ai-bubble code.ai-inline-code {
    font-size: 0.88em;
    background: var(--bg-sunken);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}
.ai-bubble pre.ai-code {
    background: var(--bg-sunken);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.85em;
    margin: 0.5em 0;
}
.ai-meta { margin-top: 0.25rem; }

.ai-dots { display: inline-flex; gap: 4px; align-items: center; }
.ai-dots i {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-muted);
    animation: aiBlink 1.2s infinite ease-in-out;
}
.ai-dots i:nth-child(2) { animation-delay: 0.15s; }
.ai-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiBlink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
    40%           { opacity: 1;   transform: scale(1);    }
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-sunken);
}
.ai-suggestion {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    text-align: left;
}
.ai-suggestion:hover { border-color: var(--brand); color: var(--text); }

.ai-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    align-items: flex-end;
}
.ai-input {
    flex: 1 1 auto;
    min-height: 2.4rem;
    max-height: 11rem;
    resize: none;
}
.ai-send { white-space: nowrap; }
.ai-foot { margin: 0 1rem 0.6rem; }

.ai-template-row {
    padding: 0.5rem 1rem 0.4rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--brand) 4%, var(--bg-sunken));
}
.ai-template-picker {
    width: 100%;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}
.ai-form { flex-wrap: wrap; }

/* Right-side drawer (project page). Slides in over content. */
.ai-drawer {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(480px, 100vw);
    background: var(--bg);
    z-index: 95;
    box-shadow: -8px 0 24px rgba(15, 23, 42, 0.18);
    transform: translateX(100%);
    transition: transform 220ms ease;
    display: flex;
    flex-direction: column;
}
.ai-drawer.is-open { transform: translateX(0); }
.ai-drawer .ai-panel {
    border: 0;
    border-radius: 0;
    height: 100%;
    box-shadow: none;
}
.ai-drawer .ai-close-btn { display: inline-flex !important; }    /* show only in drawer */
@media (max-width: 700px) {
    /* On mobile the backdrop already closes the drawer on tap, so the X
       button is redundant clutter in the header. */
    .ai-drawer .ai-close-btn { display: none !important; }
}

.ai-drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 94;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}
.ai-drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Floating "Ask AI" button — bottom-right on project pages */
.ai-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 5.5rem;          /* above mobile bottom-nav */
    z-index: 90;
    border: 0;
    background: var(--brand);
    color: white;
    border-radius: 999px;
    padding: 0.7rem 1.1rem;
    box-shadow: var(--shadow-lg);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: transform 120ms ease, background 120ms ease;
}
.ai-fab:hover { transform: translateY(-2px); }
@media (min-width: 800px) {
    .ai-fab { bottom: 1.5rem; }
}

/* Task/Note toggle used in popover + /quick page (small variant here) */
.qc-kind-toggle-sm {
    display: inline-flex;
    background: var(--bg-sunken);
    border-radius: var(--radius);
    padding: 2px;
    gap: 2px;
}
.qc-kind-toggle-sm .qc-kind-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    padding: 0.18rem 0.55rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.qc-kind-toggle-sm .qc-kind-btn.is-active {
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Topbar action buttons (⚡ quick capture, 🌓 theme toggle, 🔔 bell) — base
   .btn-sm is too small for emoji glyphs to read at this size. */
.topbar #quick-popover-trigger,
.topbar #theme-toggle,
.topbar #notify-bell {
    font-size: 1.25rem;
    padding: 0.4rem 0.6rem;
    line-height: 1;
    min-width: 2.4rem;
    text-align: center;
}

/* ── Notification bell + dropdown ──────────────────────────── */
.topbar-bell {
    position: relative;
}
.topbar-bell-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    padding: 0 5px;
    border: 2px solid var(--bg-elevated);
    box-sizing: content-box;
}
.bell-dropdown {
    position: absolute;
    top: calc(var(--topbar-height) - 6px);
    right: 1.25rem;
    width: min(380px, calc(100vw - 2rem));
    max-height: 70vh;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.bell-dropdown[hidden] { display: none; }
.bell-dropdown-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sunken);
    font-size: 0.92rem;
}
.bell-dropdown-head strong { flex: 1; }
.bell-dropdown-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.2rem 0;
}
.bell-dropdown-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}
.bell-item {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 80ms;
    text-decoration: none;
    color: inherit;
}
.bell-item:last-child { border-bottom: 0; }
.bell-item:hover { background: var(--bg-hover); text-decoration: none; }
.bell-item.is-unread {
    background: color-mix(in srgb, var(--brand) 6%, transparent);
}
.bell-item-icon {
    font-size: 1.1rem;
    line-height: 1.2;
    flex-shrink: 0;
}
.bell-item-body {
    flex: 1;
    min-width: 0;
}
.bell-item-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bell-item-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
    word-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.bell-item-time {
    font-size: 0.68rem;
    color: var(--text-subtle);
    margin-top: 0.15rem;
}
.bell-dropdown-foot {
    display: block;
    padding: 0.55rem 0.85rem;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-sunken);
    font-size: 0.82rem;
    color: var(--brand);
    text-decoration: none;
}
.bell-dropdown-foot:hover { background: var(--bg-hover); text-decoration: none; }
@media (max-width: 700px) {
    .bell-dropdown {
        right: 0.5rem;
        top: calc(var(--topbar-height) - 4px);
    }
}

/* ── Quick-capture popover (topbar ⚡) ──────────────────────── */
.qp-pop {
    position: fixed;
    inset: 0;
    z-index: 101;
    display: none;
    background: rgba(15, 23, 42, 0.25);
}
.qp-pop.is-open { display: block; }
.qp-card {
    position: absolute;
    /* default — desktop anchors to top-right under the topbar buttons */
    top: 3.6rem;
    right: 1rem;
    width: 360px;
    max-width: calc(100vw - 2rem);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: qpIn 120ms ease-out;
}
@keyframes qpIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0);    }
}
.qp-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.92rem;
}
.qp-icon { display: inline-flex; align-items: center; color: var(--brand); }
.qp-icon svg { display: block; }

/* Topbar search button — wrap SVG nicely beside the placeholder text */
.topbar-search-icon { display: inline-flex; align-items: center; color: var(--text-muted); }
.topbar-search-icon svg { display: block; }

/* Search modal magnifier glass */
.search-input-icon { display: inline-flex; align-items: center; color: var(--text-muted); }
.search-input-icon svg { display: block; }

/* Topbar/bell/theme buttons render Lucide SVGs — keep them centered */
.topbar-bell svg,
#theme-toggle svg,
#quick-popover-trigger svg,
.topbar-timer-stop svg,
.more-sheet-close svg { display: block; }
.qc-kind-btn svg { display: inline-block; vertical-align: -2px; margin-right: 0.25rem; }
.qp-text {
    width: 100%;
    min-height: 4.5rem;
    font-size: 0.95rem;
    resize: vertical;
}
.qp-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.qp-project { flex: 1 1 auto; min-width: 0; }
.qp-priority { flex: 0 0 92px; }
.qp-hint { margin: 0; }

/* On phones, take the full bottom of the screen so thumbs can hit it. */
@media (max-width: 600px) {
    .qp-card {
        top: auto;
        right: 0; left: 0;
        bottom: 5rem;     /* clear bottom-nav */
        width: auto;
        max-width: none;
        margin: 0 0.75rem;
        border-radius: var(--radius-lg);
    }
}

.search-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
}
.search-modal.is-open { display: block; }
.search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.search-card {
    position: absolute;
    top: 12vh;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 640px;
    max-height: 70vh;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.search-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
}
.search-input-row input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
}
.search-results {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
}
.search-empty {
    padding: 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.search-section { margin-bottom: 0.5rem; }
.search-section h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    padding: 0.5rem 1rem 0.25rem;
    margin: 0;
}
.search-result {
    display: block;
    padding: 0.55rem 1rem;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.search-result:hover,
.search-result.is-active {
    background: var(--bg-hover);
    border-left-color: var(--brand);
    text-decoration: none;
}
.search-result-title {
    font-weight: 600;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.search-result-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.search-result-snip {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    line-height: 1.4;
}
.search-result mark {
    background: color-mix(in srgb, var(--warning) 30%, transparent);
    color: var(--text);
    padding: 0 2px;
    border-radius: var(--radius-sm);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
}
.topbar-user:hover { background: var(--bg-hover); text-decoration: none; }
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--text-inverse);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Topbar active-timer pill */
.topbar-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.55rem 0.3rem 0.6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--success) 14%, transparent);
    color: var(--success);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.topbar-timer-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: timer-pulse 1s infinite;
}
@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}
.topbar-timer-stop {
    border: 0; background: transparent; color: inherit;
    cursor: pointer; padding: 0 0.15rem; font-size: 1rem;
    line-height: 1;
}
.topbar-timer-stop:hover { color: var(--danger); }

/* Generic avatar — size + color come inline (from user_avatar()).
   This sets only the shape, text alignment, and a stable text color. */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    flex-shrink: 0;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    text-decoration: none;
    vertical-align: middle;
}
.avatar-stack {
    display: inline-flex;
    align-items: center;
}
.avatar-stack .avatar + .avatar { margin-left: -8px; border: 2px solid var(--bg-elevated); }

/* Photo avatar — no text shadow needed, cover the circle. */
.avatar-photo {
    object-fit: cover;
    text-shadow: none;
    background: var(--bg-sunken);
}

/* Avatar wrapped in <a> as a filter link — subtle hover ring. */
.avatar-link {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    border-radius: 50%;
    text-decoration: none;
    transition: box-shadow 120ms, transform 120ms;
}
.avatar-link:hover {
    box-shadow: 0 0 0 2px var(--brand);
    transform: translateY(-1px);
}
.avatar-link:hover { text-decoration: none; }

/* ── Side nav ──────────────────────────────────────────────── */
.sidenav {
    grid-area: sidenav;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 1rem 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sidenav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem 1rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
.sidenav-brand:hover { text-decoration: none; }
.sidenav-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    background: var(--brand);
    color: var(--text-inverse);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex: 0 0 28px;
}

/* ── Brand dropdown (org switcher) ───────────────────────────── */
.sidenav-brand-dropdown {
    position: relative;
}
.sidenav-brand-dropdown > summary {
    cursor: pointer;
    list-style: none;             /* remove default disclosure triangle */
    user-select: none;
}
.sidenav-brand-dropdown > summary::-webkit-details-marker { display: none; }
.sidenav-brand-dropdown[open] > summary { background: var(--bg-sunken); border-radius: var(--radius); }
.sidenav-brand-label { flex: 1; }
.sidenav-brand-caret {
    font-size: 1.1rem;
    line-height: 1;
    /* var(--text) — black-ish in light mode, light in dark mode. Avoids
       the invisible "white caret on white sidenav" in light. */
    color: var(--text);
    transition: transform 120ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sidenav-brand-dropdown[open] .sidenav-brand-caret { transform: rotate(180deg); }

.sidenav-brand-menu {
    list-style: none;
    margin: 0;
    padding: 0.25rem;
    position: absolute;
    top: 100%;
    left: 0.5rem;
    right: 0.5rem;
    z-index: 50;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.sidenav-brand-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
}
.sidenav-brand-menu-item:hover { background: var(--bg-sunken); text-decoration: none; color: var(--text); }
.sidenav-brand-menu-item.is-current { background: var(--bg-sunken); cursor: default; }
.sidenav-brand-mark--inline { width: 22px; height: 22px; font-size: 0.72rem; flex: 0 0 22px; }
.sidenav-section {
    padding: 0.75rem 0.75rem 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
}
.sidenav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}
.sidenav-link:hover {
    background: var(--bg-hover);
    color: var(--text);
    text-decoration: none;
}
.sidenav-link.is-active {
    background: var(--brand-light);
    color: var(--brand);
}
/* Lucide SVG icons in sidenav — sized, centered, inherit color from link */
.sidenav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.sidenav-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}
.sidenav-credit {
    margin-top: auto;
    padding: 0.85rem 0.6rem 0.4rem;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-subtle);
    letter-spacing: 0.01em;
}
.sidenav-credit a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
}
.sidenav-credit a:hover {
    color: var(--brand);
    text-decoration: none;
}

/* On active links the icon stroke gets a tiny bit thicker for emphasis. */
.sidenav-link.is-active .sidenav-icon svg {
    stroke-width: 2.25;
}

/* ── Content area ──────────────────────────────────────────── */
.content {
    grid-area: content;
    padding: 1.5rem;
    max-width: 100%;
    overflow-x: hidden;
}
.content-inner {
    max-width: var(--content-max);
    margin: 0 auto;
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.page-subtitle {
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-size: 0.95rem;
}

/* ── Bottom nav (mobile only) ──────────────────────────────── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
    z-index: 30;
}
.bottom-nav-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.25rem;
    list-style: none;
}
.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.4rem 0.25rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
}
.bottom-nav-link:hover { text-decoration: none; color: var(--text); background: var(--bg-hover); }
.bottom-nav-link.is-active { color: var(--brand); }
.bottom-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    line-height: 1;
}
.bottom-nav-icon svg { display: block; }
/* "More" trigger is a <button>, normalize it against the <a> siblings */
button.bottom-nav-link {
    background: transparent;
    border: 0;
    font: inherit;
    cursor: pointer;
    width: 100%;
}

/* ── "More" bottom sheet (mobile only) ─────────────────────── */
.more-sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
}
.more-sheet.is-open { display: block; }
.more-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    animation: more-fade-in 160ms ease-out;
}
@keyframes more-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes more-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.more-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85vh;
    background: var(--bg-elevated);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    animation: more-slide-up 200ms cubic-bezier(0.22, 0.61, 0.36, 1);
    padding-bottom: env(safe-area-inset-bottom);
}
.more-sheet-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem 0.5rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.more-sheet-grabber {
    position: absolute;
    top: 0.4rem;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong, var(--border));
}
.more-sheet-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
}
.more-sheet-close {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    cursor: pointer;
}
.more-sheet-close:hover { background: var(--bg-hover); color: var(--text); }
.more-sheet-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}
.more-sheet-section {
    margin: 1.25rem 0 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
}
.more-sheet-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.more-sheet-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.9rem 0.5rem;
    background: var(--bg-sunken);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 100ms, border-color 100ms;
}
.more-sheet-tile:hover { background: var(--bg-hover); text-decoration: none; }
.more-sheet-tile.is-active {
    border-color: var(--brand);
    color: var(--brand);
}
.more-sheet-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    line-height: 1;
    color: var(--text-muted);
}
.more-sheet-tile.is-active .more-sheet-icon,
.more-sheet-tile:hover .more-sheet-icon { color: inherit; }
.more-sheet-icon svg { display: block; }
.more-sheet-signout {
    display: block;
    margin: 1.25rem 0 0.5rem;
    padding: 0.75rem;
    text-align: center;
    color: var(--danger);
    font-weight: 600;
    background: color-mix(in srgb, var(--danger) 8%, transparent);
    border-radius: var(--radius);
    text-decoration: none;
}
.more-sheet-signout:hover { text-decoration: none; background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* ── Login screen ──────────────────────────────────────────── */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 2rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.auth-brand-mark {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--brand);
    color: var(--text-inverse);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}
.auth-title { font-size: 1.2rem; font-weight: 600; }

/* ── Mobile breakpoint ─────────────────────────────────────── */
@media (max-width: 800px) {
    .app-shell {
        /* minmax(0, 1fr) instead of plain 1fr: a 1fr grid track is actually
           minmax(auto, 1fr), and 'auto' min equals the largest grid item's
           min-content. The topbar's min-content (search bar + 3 buttons +
           avatar + padding + gaps) was ~398px, so the track was expanding
           to 398px on a 352px viewport and pushing the page wider.
           minmax(0, 1fr) tells the track to never exceed 1fr's share. */
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: var(--topbar-height) 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }
    .sidenav { display: none; }
    .bottom-nav { display: block; }
    .content { padding: 1rem 1rem calc(80px + env(safe-area-inset-bottom)); }
    .page-title { font-size: 1.25rem; }
    .topbar {
        padding: 0 0.75rem;
        gap: 0.4rem;
    }
    .topbar > .spacer { display: none; }   /* spacer steals layout room on mobile */
    .topbar-search {
        max-width: none;
        padding: 0.4rem 0.6rem;     /* slightly tighter inner padding */
    }
    .topbar-search-placeholder { font-size: 0.85rem; }
}

/* ─────────────────────────────────────────────────────────────
   Edit-website form (inside .collapse-card on the project page)
   Was a jumbled flexbox grid — now broken into sections + grids
   so URL, billing, flags, etc. group logically and align cleanly.
   ───────────────────────────────────────────────────────────── */
.edit-website-form .edit-section {
    padding: 1rem 0 1.25rem;
    border-top: 1px solid var(--border);
}
.edit-website-form .edit-section:first-of-type {
    border-top: 0;
    padding-top: 0.25rem;
}
.edit-website-form .edit-section-title {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.edit-website-form .edit-section-title svg { display: block; opacity: 0.8; }

/* Field grids — three layouts to cover everything cleanly. */
.edit-website-form .edit-grid {
    display: grid;
    gap: 0.85rem 1rem;
    margin-bottom: 0.5rem;
}
.edit-website-form .edit-grid:last-child  { margin-bottom: 0; }
/* Basics: Name takes 2 columns, Slug + Status one each, description full. */
.edit-website-form .edit-grid-basics {
    grid-template-columns: 2fr 1fr 1fr;
}
.edit-website-form .edit-grid-thirds {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.edit-website-form .edit-grid-halves {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.edit-website-form .edit-field-full {
    grid-column: 1 / -1;
}
@media (max-width: 720px) {
    .edit-website-form .edit-grid-basics,
    .edit-website-form .edit-grid-thirds,
    .edit-website-form .edit-grid-halves {
        grid-template-columns: 1fr;
    }
}

/* Toggle rows — replace the old hacky `margin-top:1.6rem` checkbox column
   with a proper aligned row that puts the help text under the label. */
.edit-website-form .edit-toggle-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.5rem 1rem;
}
.edit-website-form .edit-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-sunken);
    cursor: pointer;
    transition: background 100ms, border-color 100ms;
}
.edit-website-form .edit-toggle:hover {
    background: var(--bg-hover);
    border-color: color-mix(in srgb, var(--brand) 30%, var(--border));
}
.edit-website-form .edit-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex: 0 0 auto;
    cursor: pointer;
}
.edit-website-form .edit-toggle-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.edit-website-form .edit-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    color: var(--text);
}
.edit-website-form .edit-toggle-label svg { display: block; color: var(--text-muted); }
.edit-website-form .edit-toggle-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* Inline-style toggle for the GSC checkbox inside the integrations grid */
.edit-website-form .edit-toggle-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-sunken);
    cursor: pointer;
}
.edit-website-form .edit-toggle-inline input[type="checkbox"] {
    width: 16px; height: 16px; cursor: pointer;
}
.edit-website-form .edit-field-checkbox .field-help { margin-top: 0.4rem; }

/* Action bar at the bottom */
.edit-website-form .edit-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 1rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────────────
   Inline Lucide SVGs inside ghost / small action buttons.
   Centers the glyph vertically and prevents stray inline-block
   spacing from offsetting things by a pixel or two.
   ───────────────────────────────────────────────────────────── */
.btn-ghost svg,
.btn-sm svg {
    display: inline-block;
    vertical-align: -0.15em;
}
.btn-ghost > svg:only-child,
.btn-sm   > svg:only-child {
    vertical-align: middle;
}
.task-actions .btn svg,
.cred-card-actions .btn svg,
.recurring-actions .btn svg { vertical-align: middle; }

/* Task meta pills — image / comment counts now render an SVG + number
   instead of an emoji. Keep them inline and vertically aligned. */
.task-meta-pill,
.task-comment-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.task-meta-pill svg,
.task-comment-count svg {
    display: block;
    opacity: 0.85;
}
