/* Dashboard Shell — the Anna OS desktop (docs/design/apps/chat.md §8.3).
   Shared by /dashboard and the guest shell: status bar, Apps grid, Dock,
   in-place App update progress and the onboarding banner. One layout: the
   desktop fills the main area, the Dock is always visible. */

/* ===== Shell layout ===== */
:root {
    /* 外壳上下留白，与 .dashboard-container 的断点一致（≤1024 24px、≤768 0） */
    --shell-vpad: 32px;
}
@media (max-width: 1024px) { :root { --shell-vpad: 24px; } }
@media (max-width: 768px)  { :root { --shell-vpad: 0px; } }

/* 主区全宽：macOS 桌面不是 1200px 居中的卡片；桌面网格自身仍受 960px 居中约束。 */
.dashboard-container { max-width: none; }

.main-content {
    position: relative;             /* anchor for the status bar and the Dock */
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    height: calc(100vh - var(--shell-vpad));
}
.main-content > .apps-view { grid-column: 1; grid-row: 1; min-height: 0; }

@media (max-width: 768px) {
    .dashboard-container { padding: 0 !important; }
}

/* ===== Cloud Agent Upgrade Badge =====
   强 CTA：升级是强烈推荐动作 —— 实心主色 + 呼吸光晕 + 周期扫光诱导点击。 */
.agent-upgrade-badge {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 72%, #a855f7));
    border: 1px solid transparent;
    font-size: 12px;
    font-family: inherit;
    color: #fff;
    cursor: pointer;
    margin-left: 8px;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    animation: upgradeGlow 2.2s ease-in-out infinite;
}

.agent-upgrade-badge[hidden] {
    display: none;
}

.agent-upgrade-badge:hover {
    transform: translateY(-1px) scale(1.04);
    filter: brightness(1.08);
    box-shadow: 0 3px 12px color-mix(in srgb, var(--primary-color) 55%, transparent);
    animation-play-state: paused;
}

.agent-upgrade-badge:active {
    transform: scale(0.97);
}

.agent-upgrade-badge svg {
    flex-shrink: 0;
    animation: upgradeArrowBounce 2.2s ease-in-out infinite;
}

.agent-upgrade-label {
    font-weight: 600;
    white-space: nowrap;
}

/* 周期扫光（shine sweep）：高光带每 3.2s 掠过一次 */
.agent-upgrade-badge::after {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    animation: upgradeShine 3.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes upgradeGlow {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary-color) 45%, transparent); }
    50% { box-shadow: 0 0 10px 3px color-mix(in srgb, var(--primary-color) 35%, transparent); }
}

@keyframes upgradeShine {
    0% { left: -75%; }
    45%, 100% { left: 125%; }
}

@keyframes upgradeArrowBounce {
    0%, 55%, 100% { transform: translateY(0); }
    70% { transform: translateY(-1.5px); }
    85% { transform: translateY(0.5px); }
}

.agent-upgrade-badge.upgrading {
    opacity: 0.75;
    pointer-events: none;
    animation: none;
    box-shadow: none;
}

.agent-upgrade-badge.upgrading::after,
.agent-upgrade-badge.upgrading svg {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    .agent-upgrade-badge,
    .agent-upgrade-badge::after,
    .agent-upgrade-badge svg {
        animation: none;
    }
}

/* ===== Agent status indicator (desktop status bar) ===== */

.chat-status-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
    cursor: default;
    border: 1px solid transparent;
}

/* The hidden attribute must win over the display:flex above */
.chat-status-indicator[hidden] {
    display: none;
}

/* Agent status indicator */
.chat-agent-indicator {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    cursor: pointer;
}

.chat-agent-indicator:hover {
    filter: brightness(1.25);
}

/* 磁盘可用量（心跳携带，仅有数据时展示） */
.chat-agent-indicator .indicator-disk {
    font-size: 10px;
    opacity: 0.75;
    flex-shrink: 0;
    padding-left: 6px;
    border-left: 1px solid currentColor;
    white-space: nowrap;
}

.chat-agent-indicator .indicator-disk[hidden] {
    display: none;
}

/* 可用空间 < 20% → 磁盘告警（琥珀/红色，盖过类型色调） */
.chat-agent-indicator .indicator-disk.warn {
    color: #f59e0b;
    opacity: 1;
    font-weight: 600;
}

.chat-agent-indicator.disk-warn {
    border-color: rgba(245, 158, 11, 0.45);
}

[data-theme="light"] .chat-agent-indicator .indicator-disk.warn {
    color: #d97706;
}

.chat-agent-indicator .indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-secondary);
    opacity: 0.5;
}

.chat-agent-indicator.online .indicator-dot {
    background: #10b981;
    opacity: 1;
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}

.chat-agent-indicator.online {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.12);
    color: #10b981;
}

.chat-agent-indicator.offline .indicator-dot {
    background: var(--text-secondary);
    opacity: 0.4;
}

/* Sleeping (resolvable Cloud Agent, wakes on use) — amber breathing dot */
.chat-agent-indicator.sleeping .indicator-dot {
    background: #f59e0b;
    opacity: 1;
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.5);
    animation: agentDotBreath 2.4s ease-in-out infinite;
}

@keyframes agentDotBreath {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* Waking capsule (wake-latency-speedup P2): while a Cloud Agent wake is in
   flight the window manager sets body.cloud-agent-waking — the indicator dot
   pulses amber→sky regardless of the per-render state classes (which are
   wiped and re-added by updateAgentIndicator on every refresh). */
body.cloud-agent-waking .chat-agent-indicator .indicator-dot {
    background: linear-gradient(90deg, #f59e0b, #38bdf8);
    opacity: 1;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.55);
    animation: agentDotWaking 1.2s ease-in-out infinite;
}

@keyframes agentDotWaking {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(1.35); }
}

/* Agent type icon (cloud / monitor) — colored via container tint */
.chat-agent-indicator .indicator-type-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.chat-agent-indicator .indicator-type-icon[hidden] {
    display: none;
}

.chat-agent-indicator .indicator-type-icon svg {
    display: block;
}

/* Type tint — Cloud (sky blue) vs Local (violet); placed after .online so it
   wins the container colors, while the status dot keeps green/amber/gray. */
.chat-agent-indicator.cloud {
    background: rgba(14, 165, 233, 0.08);
    border-color: rgba(14, 165, 233, 0.18);
    color: #38bdf8;
}

.chat-agent-indicator.local {
    background: rgba(113, 113, 122, 0.08);
    border-color: rgba(113, 113, 122, 0.18);
    color: #a1a1aa;
}

/* Offline overrides the type tint back to neutral (icon still shows the type) */
.chat-agent-indicator.offline.cloud,
.chat-agent-indicator.offline.local {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

[data-theme="light"] .chat-agent-indicator {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .chat-agent-indicator.online {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.1);
    color: #059669;
}

[data-theme="light"] .chat-agent-indicator.cloud {
    background: rgba(14, 165, 233, 0.07);
    border-color: rgba(14, 165, 233, 0.16);
    color: #0284c7;
}

[data-theme="light"] .chat-agent-indicator.local {
    background: rgba(113, 113, 122, 0.07);
    border-color: rgba(113, 113, 122, 0.16);
    color: #52525b;
}

[data-theme="light"] .chat-agent-indicator.offline.cloud,
[data-theme="light"] .chat-agent-indicator.offline.local {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    /* Hide status indicator labels on mobile, keep dots */
    .chat-status-indicator .indicator-label {
        display: none;
    }
}

/* ================================================================== */
/* Apple-style App Deck (persistent dock)                              */
/* Anchored to the bottom of .main-content; always visible. The WM     */
/* shelves minimized windows in it.                                    */
/* ================================================================== */

.anna-app-deck {
    display: flex;
    justify-content: center;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 16px;
    padding: 80px 16px 0; /* top room for hover lift + tooltip — must NOT clip */
    pointer-events: none; /* container is transparent; only inner is interactive */
    z-index: 950; /* above the app window layer (900) — macOS dock semantics */
    overflow: visible;
    animation: annaDeckFadeUp 700ms cubic-bezier(0.22, 1, 0.36, 1) 250ms both;
}

@keyframes annaDeckFadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.anna-app-deck-inner {
    pointer-events: auto;
    display: flex;
    align-items: flex-end;
    padding: 10px 14px;
    max-width: min(820px, calc(100vw - 32px));
    /* MUST stay visible — any non-visible overflow on EITHER axis (incl. auto)
       silently clips the hover lift on the other axis (per CSS spec). The deck
       caps visible app count at the JS layer, so horizontal scroll isn't
       needed; surplus apps live behind the "Browse App Store" chip. */
    overflow: visible;

    background: rgba(28, 28, 30, 0.55);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.10),
        inset 0 -1px 0 rgba(0, 0, 0, 0.25),
        0 18px 50px rgba(0, 0, 0, 0.40),
        0 4px 12px rgba(0, 0, 0, 0.18);
}

/* Inner track — pure flex row, no overflow constraint, lets icons lift freely. */
.anna-app-deck-track {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    overflow: visible;
}

[data-theme="light"] .anna-app-deck-inner {
    background: rgba(255, 255, 255, 0.62);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        inset 0 -1px 0 rgba(0, 0, 0, 0.04),
        0 16px 40px rgba(0, 0, 0, 0.10),
        0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ----- Deck item (app icon button) ----- */
.anna-app-deck-item {
    position: relative;
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 14px;          /* squircle-like */
    background: rgba(255, 255, 255, 0.04);
    border: none;
    padding: 0;
    cursor: pointer;
    overflow: visible;            /* allow tooltip to escape */
    transition:
        transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 220ms ease,
        opacity    150ms ease,
        filter     200ms ease;
    transform-origin: bottom center;
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
}

.anna-app-deck-item .deck-icon-wrap {
    position: relative;
    /* span 是行内元素:width/height/overflow 不生效,且 ::after/::before 的
       inset:0 以行内片段为包含块(遮罩只盖半边)。必须显式转块级。 */
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.28),
        0 1px 2px rgba(0, 0, 0, 0.18);
}

.anna-app-deck-item img,
.anna-app-deck-item .deck-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}

.anna-app-deck-item .deck-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 22px;
    color: #fff;
    background: linear-gradient(135deg, #71717a, #71717a);
    letter-spacing: -0.5px;
    text-transform: uppercase;
}

/* Disabled (not enabled) — desaturate */
.anna-app-deck-item.is-disabled {
    filter: grayscale(0.6) opacity(0.55);
}
.anna-app-deck-item.is-disabled:hover {
    filter: grayscale(0.2) opacity(0.85);
}

/* Admin-pinned (locked) — no visual badge (macOS Dock convention): the item
   simply can't be dragged or removed, and the tooltip says "(pinned)".
   Cursor stays the default launcher cursor (no grab affordance). */
.anna-app-deck-item.is-locked .deck-icon-wrap {
    cursor: pointer;
}

/* Hover: gentle lift on the hovered icon ONLY.
   Note: macOS Dock magnifies neighbours too, but in a 56px row that
   feels jittery — neighbours visibly jump on micro mouse moves.
   Per user feedback, isolate the hover so only the targeted icon
   reacts. Keep the lift moderate so the dock baseline doesn't bounce. */
.anna-app-deck-item:hover {
    transform: translateY(-8px) scale(1.12);
    z-index: 3;
}
.anna-app-deck-item:hover .deck-icon-wrap {
    box-shadow:
        0 18px 28px rgba(0, 0, 0, 0.40),
        0 4px 10px rgba(0, 0, 0, 0.22);
}

.anna-app-deck-item:active {
    transform: translateY(-3px) scale(1.04);
    transition-duration: 120ms;
}

/* Running indicator — Apple-dock style dot under apps with an open window.
   The deck now doubles as the dock (the standalone bottom bar was removed),
   so a launched app shows a small glowing pip beneath its icon. */
.anna-app-deck-item.is-running::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.55);
    transition: opacity 200ms ease;
}
[data-theme="light"] .anna-app-deck-item.is-running::after {
    background: rgba(0, 0, 0, 0.5);
    box-shadow: none;
}

/* Drag-and-drop reorder (macOS-style) */
.anna-app-deck-item.is-dragging {
    opacity: 0.35;
    transform: scale(0.95);
    cursor: grabbing;
}
.anna-app-deck-item.drop-before {
    box-shadow: -3px 0 0 0 #71717a;
}
.anna-app-deck-item.drop-after {
    box-shadow: 3px 0 0 0 #71717a;
}
/* While a drag is in progress, suppress hover magnify so the row stays
   stable and the drop-indicator reads cleanly. */
.anna-app-deck.is-reordering .anna-app-deck-item:hover {
    transform: none;
}

.anna-app-deck-item:focus-visible {
    outline: none;
}
.anna-app-deck-item:focus-visible .deck-icon-wrap {
    box-shadow:
        0 0 0 2px var(--bg-color, #0c0c10),
        0 0 0 4px rgba(113, 113, 122, 0.7),
        0 6px 12px rgba(0, 0, 0, 0.25);
}

/* ----- Tooltip (app name) ----- */
.anna-app-deck-item .deck-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(6px) scale(0.92);
    background: rgba(28, 28, 30, 0.92);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    opacity: 0;
    transition: opacity 180ms ease, transform 220ms cubic-bezier(0.22, 1.4, 0.5, 1);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .anna-app-deck-item .deck-tooltip {
    background: rgba(255, 255, 255, 0.96);
    color: #1c1c1e;
    border-color: rgba(0, 0, 0, 0.06);
}
.anna-app-deck-item .deck-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(28, 28, 30, 0.92);
}
[data-theme="light"] .anna-app-deck-item .deck-tooltip::after {
    border-top-color: rgba(255, 255, 255, 0.96);
}
.anna-app-deck-item:hover .deck-tooltip,
.anna-app-deck-item:focus-visible .deck-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* ----- Divider before the "Browse" chip ----- */
.anna-app-deck-divider {
    flex: 0 0 auto;
    width: 1px;
    height: 36px;
    margin: 0 4px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.18), transparent);
    align-self: center;
}
[data-theme="light"] .anna-app-deck-divider {
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.12), transparent);
}

/* ----- Browse-more chip ----- */
.anna-app-deck-more {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 220ms cubic-bezier(0.22, 1, 0.36, 1);
    text-decoration: none;
    position: relative;
    transform-origin: bottom center;
}
.anna-app-deck-more svg {
    display: block;
    flex: 0 0 auto;
}
.anna-app-deck-more:hover {
    transform: translateY(-7px) scale(1.10);
    border-color: rgba(113, 113, 122, 0.55);
    border-style: solid;
    color: #a5b4fc;
    background: rgba(113, 113, 122, 0.10);
    box-shadow: 0 14px 26px rgba(113, 113, 122, 0.20);
}
[data-theme="light"] .anna-app-deck-more {
    border-color: rgba(0, 0, 0, 0.18);
    color: var(--text-secondary);
}
[data-theme="light"] .anna-app-deck-more:hover {
    color: #52525b;
    background: rgba(113, 113, 122, 0.08);
}

/* ----- Empty state ----- */
.anna-app-deck-empty {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 10px 6px 14px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}
.anna-app-deck-empty a {
    color: #a5b4fc;
    text-decoration: none;
    font-weight: 600;
}
.anna-app-deck-empty a:hover { text-decoration: underline; }

/* ----- Skeleton placeholders while loading ----- */
.anna-app-deck-skeleton {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.anna-app-deck-skeleton span {
    display: block;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.10) 50%,
        rgba(255, 255, 255, 0.04) 100%
    );
    background-size: 200% 100%;
    animation: annaDeckShimmer 1.4s ease-in-out infinite;
}
[data-theme="light"] .anna-app-deck-skeleton span {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.04) 0%,
        rgba(0, 0, 0, 0.08) 50%,
        rgba(0, 0, 0, 0.04) 100%
    );
    background-size: 200% 100%;
}
@keyframes annaDeckShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----- Responsive: shrink + reposition on small screens ----- */
@media (max-width: 640px) {
    .anna-app-deck {
        bottom: 14px;
        padding: 0 12px;
    }
    .anna-app-deck-inner {
        gap: 6px;
        padding: 8px 10px;
        border-radius: 20px;
    }
    .anna-app-deck-item,
    .anna-app-deck-more,
    .anna-app-deck-skeleton span {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }
    .anna-app-deck-item:hover {
        transform: translateY(-6px) scale(1.10);
    }
}

/* Reduced motion: keep static, no lift / shimmer */
@media (prefers-reduced-motion: reduce) {
    .anna-app-deck { animation: none; }
    .anna-app-deck-item,
    .anna-app-deck-more { transition: none; }
    .anna-app-deck-item:hover,
    .anna-app-deck-item:hover + .anna-app-deck-item,
    .anna-app-deck-item:has(+ .anna-app-deck-item:hover),
    .anna-app-deck-more:hover {
        transform: none;
    }
    .anna-app-deck-skeleton span { animation: none; }
}

/* ----- Minimized-window shelf (macOS Dock 右侧最小化区) ----- */
/* Populated by AnnaAppWM._syncMinimizedShelf(); one item per minimized
   window. Click restores; the window genie-scales to/from this slot. */
.anna-app-deck-minimized {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.14);
    overflow: visible;
}
.anna-app-deck-minimized[hidden] { display: none; }
[data-theme="light"] .anna-app-deck-minimized {
    border-left-color: rgba(0, 0, 0, 0.10);
}
/* Slightly muted icon so "minimized window" reads apart from launchers */
.anna-app-deck-min-item .deck-icon-wrap {
    filter: saturate(0.8) brightness(0.92);
}
.anna-app-deck-min-item:hover .deck-icon-wrap {
    filter: none;
}
.anna-app-deck-min-item .deck-min-badge {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(20, 20, 24, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 4;
}
[data-theme="light"] .anna-app-deck-min-item .deck-min-badge {
    background: rgba(60, 60, 67, 0.92);
    border-color: rgba(255, 255, 255, 0.95);
}

/* ----- Right-click context menu (macOS-style) ----- */
.anna-deck-context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 180px;
    padding: 6px;
    background: rgba(28, 28, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    color: #fff;
    font-size: 13px;
    user-select: none;
    animation: annaDeckCtxIn 120ms ease-out;
}
[data-theme="light"] .anna-deck-context-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.08);
    color: #1c1c1e;
}
@keyframes annaDeckCtxIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.anna-deck-context-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: inherit;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.2;
}
.anna-deck-context-menu button:hover,
.anna-deck-context-menu button:focus-visible {
    background: rgba(113, 113, 122, 0.85);
    color: #fff;
    outline: none;
}
.anna-deck-context-menu button.is-danger:hover {
    background: #d73a49;
}
.anna-deck-context-menu .anna-deck-ctx-divider {
    height: 1px;
    margin: 4px 2px;
    background: rgba(255, 255, 255, 0.10);
}
[data-theme="light"] .anna-deck-context-menu .anna-deck-ctx-divider {
    background: rgba(0, 0, 0, 0.08);
}
.anna-deck-context-menu .anna-deck-ctx-locked {
    padding: 7px 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    cursor: default;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
[data-theme="light"] .anna-deck-context-menu .anna-deck-ctx-locked {
    color: rgba(0, 0, 0, 0.40);
}

/* ══════════════════════════════════════════════════════════════════════
 * App dialog — shared OAuth-consent-styled panel used by the in-place
 * update prompt, the "close windows to update" prompt and the uninstall
 * confirmation.
 * ══════════════════════════════════════════════════════════════════════ */
.app-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.24s ease;
}
.app-dialog-overlay.is-open { opacity: 1; }
.app-dialog-overlay.is-closing { opacity: 0; }

.app-dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 11, 22, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.app-dialog-panel {
    position: relative;
    width: min(440px, calc(100vw - 40px));
    padding: 26px 26px 20px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--surface-color, #fff);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 80px -24px rgba(8, 11, 22, 0.7);
    transform: translateY(14px) scale(0.96);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
.app-dialog-overlay.is-open .app-dialog-panel { transform: translateY(0) scale(1); opacity: 1; }
.app-dialog-overlay.is-closing .app-dialog-panel { transform: translateY(10px) scale(0.97); opacity: 0; }

[data-theme="dark"] .app-dialog-panel {
    background: #12151f;
    border-color: rgba(255, 255, 255, 0.08);
}

.app-dialog-glow {
    position: absolute;
    inset: -50% -20% auto -20%;
    height: 160px;
    background: radial-gradient(60% 100% at 30% 0%, rgba(113, 113, 122, 0.35), transparent 70%),
                radial-gradient(50% 100% at 80% 0%, rgba(56, 189, 248, 0.28), transparent 72%);
    filter: blur(24px);
    pointer-events: none;
}

.app-dialog-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}
.app-dialog-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(113, 113, 122, 0.12);
    border: 1px solid rgba(113, 113, 122, 0.22);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.24);
}
.app-dialog-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.app-dialog-headtext h3 {
    margin: 0 0 3px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    letter-spacing: -0.01em;
}
.app-dialog-headtext p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-secondary, #6b7280);
}


/* "sensitive" badge on higher-impact scopes (Agent / Credentials / Storage) */


.app-dialog-actions {
    position: relative;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
/* Granular-review escape hatch — de-emphasized, pushed to the left */
.app-dialog-btn {
    padding: 9px 18px;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary, #0f172a);
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    transition: background 0.15s, transform 0.1s, filter 0.15s;
}
.app-dialog-btn:hover { background: var(--hover-bg, rgba(0, 0, 0, 0.05)); }
.app-dialog-btn:active { transform: translateY(1px); }
[data-theme="dark"] .app-dialog-btn { border-color: rgba(255, 255, 255, 0.14); }
[data-theme="dark"] .app-dialog-btn:hover { background: rgba(255, 255, 255, 0.06); }

.app-dialog-btn-primary {
    color: #fff;
    border: none;
    background: linear-gradient(120deg, #52525b, #a1a1aa);
    box-shadow: 0 8px 20px -8px rgba(113, 113, 122, 0.8);
}
.app-dialog-btn-primary:hover { filter: brightness(1.06); background: linear-gradient(120deg, #52525b, #a1a1aa); }

/* ============================================================
   Apps 桌面 SpringBoard grid — docs/design/dashboard-apps-view.md §7
   ============================================================ */

/* The overflow chip is a <button> when it focuses the desktop search (G7). */
button.anna-app-deck-more { padding: 0; font: inherit; }

/* Danger primary for the uninstall confirm (reuses app-dialog visuals, §7.8) */
.app-dialog-btn-danger {
    color: #fff;
    border: none;
    background: linear-gradient(120deg, #dc2626, #ef4444);
    box-shadow: 0 8px 20px -8px rgba(239, 68, 68, 0.8);
}
.app-dialog-btn-danger:hover { filter: brightness(1.06); }

/* ----- Apps view container（桌面常驻，无进入动画） ----- */
.apps-view {
    height: calc(100vh - var(--shell-vpad));
    max-height: calc(100vh - var(--shell-vpad));
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 12px;
}

/* 搜索框与右上角桌面状态栏同一行：行盒与网格同宽（960px 居中），
   左放搜索、右侧为状态栏留出 --statusbar-w（JS ResizeObserver 写入）。 */
.apps-view-search {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    box-sizing: border-box;
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 32px 4px;
    padding-right: calc(32px + var(--statusbar-w, 0px) + 12px);
}
.apps-view-search input {
    flex: 0 1 420px;
    min-width: 140px;
    width: auto;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, var(--surface-color, #f4f4f5));
    color: var(--text-color, var(--text-primary, #0f172a));
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.apps-view-search input:focus {
    border-color: var(--primary-color, #C96442);
    box-shadow: 0 0 0 3px var(--primary-rgba-010, rgba(201, 100, 66, 0.1));
}
.apps-view-search input:disabled { opacity: 0.45; }

/* ----- Grid ----- */
.apps-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 28px 12px;
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 32px 132px;       /* 最后一行要能滚到 Dock 之上 */
}

.apps-view-skeleton {
    display: contents;
}
.apps-view-skeleton span {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto;
    border-radius: 16px;
    background: var(--hover-bg, rgba(0, 0, 0, 0.06));
    animation: apps-skeleton-pulse 1.2s ease-in-out infinite;
}
@keyframes apps-skeleton-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.apps-view-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border: none;
    background: transparent;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}
.apps-view-item:focus-visible {
    outline: 2px solid var(--primary-color, #C96442);
    outline-offset: 2px;
}

.apps-icon-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    overflow: visible;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.apps-view-item:hover .apps-icon-wrap { transform: scale(1.08); }
.apps-icon-wrap img,
.apps-icon-wrap .apps-icon-fallback {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.apps-icon-wrap img { display: block; }
/* Same specificity as the sizing rule above so flex centering wins. */
.apps-icon-wrap .apps-icon-fallback,
.apps-icon-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-dark, #a1533a), var(--primary-color, #C96442));
}

.apps-view-item-name {
    max-width: 96px;
    font-size: 12px;
    line-height: 1.25;
    color: var(--text-color, var(--text-primary, #0f172a));
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.apps-view-item.is-disabled { opacity: 0.45; }

/* Running indicator dot (synced by AnnaAppWM.syncDeckIndicators) */
.apps-view-item .apps-running-dot {
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-secondary, #6b7280);
    opacity: 0;
    transition: opacity 0.15s;
}
.apps-view-item.is-running .apps-running-dot { opacity: 1; }

/* deck_pinned pin badge */
.apps-view-item .apps-pin-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-secondary, var(--surface-color, #f4f4f5));
    border: 1px solid var(--border-color, #e5e7eb);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.apps-view-item.is-pinned .apps-pin-badge { display: flex; }

/* update_available blue dot */
.apps-view-item .apps-update-dot {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #3b82f6;
    border: 1.5px solid var(--bg-primary, #fff);
    display: none;
}
.apps-view-item.has-update .apps-update-dot { display: block; cursor: pointer; }
.apps-view-item.has-update .apps-update-dot:hover { transform: scale(1.35); }

/* ----- In-place update / deploy progress -----
   app-update-in-place-phase1 §3.3 + dashboard-app-icon-deploy-progress-grey-mask.md
   P1 改动 3(类统一)/ P3(iOS 视觉)。
   `.is-deploying` 基类:图标压暗 + 轻 scrim + 中央白环小饼图(--update-progress 驱动);
   `.is-deploying.is-indeterminate` 修饰类:饼图退为旋转弧 —— 无百分比可画
   (deploying 无 job,或有 job 但 SSE 尚无首个有效 progress)。 */
/* Registered property → the pie fill animates smoothly between ticks.
   inherits: true 是必须的:变量由 JS 设在 wrap 上,而消费方是 ::before 伪元素
   ——registered property 若不继承,伪元素只能拿到 initial-value 0,饼图永远空
   (这也是旧实现 conic 遮罩恒为「整块全灰」的隐藏根因之一)。 */
@property --update-progress {
    syntax: '<number>';
    inherits: true;
    initial-value: 0;
}

.apps-icon-wrap.is-deploying,
.anna-app-deck-item .deck-icon-wrap.is-deploying {
    transition: --update-progress 0.3s ease;
}
.apps-icon-wrap.is-deploying img,
.apps-icon-wrap.is-deploying .apps-icon-fallback,
.deck-icon-wrap.is-deploying img,
.deck-icon-wrap.is-deploying .deck-fallback {
    filter: grayscale(0.4) brightness(0.6);
}
/* ::after = 半透明 scrim,不承载进度 */
.apps-icon-wrap.is-deploying::after,
.deck-icon-wrap.is-deploying::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 2;
}
.apps-icon-wrap.is-deploying::after { border-radius: 16px; }
/* ::before = 中央饼图:白色细环 + 内部 conic 填充(iOS App Store 下载语义) */
.apps-icon-wrap.is-deploying::before,
.deck-icon-wrap.is-deploying::before {
    content: '';
    position: absolute;
    z-index: 3;
    pointer-events: none;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: conic-gradient(
        rgba(255, 255, 255, 0.9) calc(var(--update-progress, 0) * 1%),
        transparent 0
    );
    background-clip: padding-box; /* 环与饼之间留出环宽的透明间隙 */
    box-shadow: inset 0 0 0 2px transparent;
}
.deck-icon-wrap.is-deploying::before {
    width: 22px;
    height: 22px;
}
/* 不确定态:同样的环,去掉饼,改为旋转弧 */
@keyframes apps-installing-spin {
    to { transform: rotate(360deg); }
}
.apps-icon-wrap.is-deploying.is-indeterminate::before,
.deck-icon-wrap.is-deploying.is-indeterminate::before {
    border-color: rgba(255, 255, 255, 0.25);
    border-top-color: rgba(255, 255, 255, 0.9);
    background: none;
    animation: apps-installing-spin 1s linear infinite;
}
/* 部署中禁用悬停放大,视觉聚焦在进度上 */
.apps-view-item:hover .apps-icon-wrap.is-deploying { transform: none; }
@media (prefers-reduced-motion: reduce) {
    .apps-icon-wrap.is-deploying.is-indeterminate::before,
    .deck-icon-wrap.is-deploying.is-indeterminate::before {
        /* 静态 3/4 弧 */
        animation: none;
        border-color: rgba(255, 255, 255, 0.9);
        border-bottom-color: rgba(255, 255, 255, 0.25);
    }
}

/* Dock update dot(网格 .apps-update-dot 的 Dock 版) */
.anna-app-deck-item .deck-update-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #3b82f6;
    border: 1.5px solid var(--bg-primary, #fff);
    display: none;
    z-index: 3;
    cursor: pointer;
}
.anna-app-deck-item.has-update .deck-update-dot { display: block; }
.anna-app-deck-item.has-update .deck-update-dot:hover { transform: scale(1.35); }

/* 「已更新」绿色对勾角标(§3.3.1,首次打开新版本时清除) */
@keyframes apps-updated-pop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}
.apps-view-item .apps-updated-badge,
.anna-app-deck-item .deck-updated-badge {
    position: absolute;
    display: none;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    font-size: 9px;
    line-height: 1;
    font-weight: 700;
    border: 1.5px solid var(--bg-primary, #fff);
    z-index: 3;
    pointer-events: none;
}
.apps-view-item .apps-updated-badge { top: -4px; left: -4px; }
.anna-app-deck-item .deck-updated-badge { top: -3px; right: -3px; }
.apps-view-item.is-recently-updated:not(.has-update) .apps-updated-badge,
.anna-app-deck-item.is-recently-updated:not(.has-update) .deck-updated-badge {
    display: flex;
    animation: apps-updated-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 打开时更新提示的「此版本不再提醒」行(复用 app-dialog 面板) */
.app-dialog-panel .app-update-snooze {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 2px 12px;
    font-size: 12.5px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    user-select: none;
}
.app-dialog-panel .app-update-snooze input { accent-color: #3b82f6; }

/* App Store trailing tile */
.apps-view-store-tile .apps-icon-fallback {
    background: transparent;
    border: 1.5px dashed var(--border-color, #cbd5e1);
    color: var(--text-secondary, #6b7280);
    box-shadow: none;
}
.apps-view--editing .apps-view-store-tile { display: none; }

/* ----- Edit mode (iOS wiggle) ----- */
@keyframes apps-wiggle {
    0%   { transform: rotate(-1.6deg); }
    100% { transform: rotate(1.6deg); }
}
.apps-view--editing .apps-view-item:not(.apps-view-store-tile) {
    animation: apps-wiggle 0.28s ease-in-out infinite alternate;
    cursor: grab;
}
.apps-view--editing .apps-view-item:nth-child(2n) { animation-delay: 0.14s; }
.apps-view--editing .apps-view-item.is-dragging {
    opacity: 0.4;
    cursor: grabbing;
}
.apps-view--editing .apps-view-item.drop-before::before,
.apps-view--editing .apps-view-item.drop-after::after {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
    background: var(--primary-color, #C96442);
}
.apps-view--editing .apps-view-item.drop-before::before { left: -7px; }
.apps-view--editing .apps-view-item.drop-after::after { right: -7px; }

@media (prefers-reduced-motion: reduce) {
    .apps-view--editing .apps-view-item:not(.apps-view-store-tile) {
        animation: none;
        outline: 1.5px dashed var(--primary-color, #C96442);
        outline-offset: 3px;
        border-radius: 14px;
    }
    .apps-view { animation: none; }
}

/* Remove (uninstall) corner badge — visible only while editing */
.apps-view-remove {
    position: absolute;
    top: -6px;
    left: -6px;
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    border: none;
    font-size: 13px;
    line-height: 1;
    color: var(--text-color, #0f172a);
    background: var(--bg-secondary, var(--surface-color, #e5e7eb));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}
.apps-view--editing .apps-view-item:not(.apps-view-store-tile) .apps-view-remove { display: flex; }
.apps-view-remove:hover { background: #ef4444; color: #fff; }

/* Done button (edit mode) */
.apps-view-done {
    position: fixed;
    top: 14px;
    right: 24px;
    z-index: 61;
    padding: 6px 18px;
    border-radius: 999px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--primary-color, #C96442);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ----- Empty / error states ----- */
.apps-view-empty,
.apps-view-error {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 64px 16px;
    color: var(--text-secondary, #6b7280);
    font-size: 14px;
    text-align: center;
}
.apps-view-empty a { color: var(--primary-color, #C96442); text-decoration: none; }
.apps-view-error button {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: transparent;
    color: var(--text-color, var(--text-primary, #0f172a));
    cursor: pointer;
}
.apps-view-error button:hover { background: var(--hover-bg, rgba(0, 0, 0, 0.05)); }

/* ===== Apps view folders (dashboard-apps-view-folders.md §8.7) ===== */

/* Folder tile: 2×2 member-logo collage on a rounded plate */
.apps-folder-tile .apps-folder-collage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
    width: 64px;
    height: 64px;
    padding: 7px;
    box-sizing: border-box;
    border-radius: 16px;
    background: var(--bg-secondary, rgba(0, 0, 0, 0.06));
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
}
.apps-folder-tile .apps-folder-collage img,
.apps-folder-tile .apps-folder-mini-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}
.apps-folder-tile .apps-folder-mini-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-primary, #fff);
}

/* Combine ring: drop target's center band while dragging over (§8.3) */
.apps-combine-target .apps-icon-wrap {
    outline: 2px solid var(--primary-color, #C96442);
    outline-offset: 3px;
    border-radius: 18px;
    transform: scale(1.08);
    transition: transform 0.12s ease;
}

/* Folder expand overlay (§8.4) — reuses app-dialog backdrop system */
.apps-folder-overlay .apps-folder-panel {
    position: relative;
    z-index: 1;
    width: min(560px, 92vw);
    max-height: min(70vh, 640px);
    overflow-y: auto;
    margin: auto;
    padding: 22px 26px 30px;
    border-radius: 20px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}
.apps-folder-overlay { display: flex; align-items: center; justify-content: center; }
.apps-folder-head { text-align: center; margin-bottom: 14px; }
.apps-folder-name {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-color, var(--text-primary, #0f172a));
}
.apps-folder-name-input {
    max-width: 260px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-color, var(--text-primary, #0f172a));
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    outline: none;
}
.apps-folder-name-input:focus { border-color: var(--primary-color, #C96442); }
.apps-folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 20px 10px;
    padding: 4px 0 0;
    max-width: none;
    margin: 0;
}

/* Context-menu flyout submenu (Move to Folder ▸, §8.5) */
.anna-deck-ctx-subwrap { position: relative; }
.anna-deck-ctx-subwrap > .has-submenu::after {
    content: '▸';
    float: right;
    margin-left: 12px;
    opacity: 0.55;
}
.anna-deck-ctx-submenu {
    display: none;
    position: absolute;
    left: calc(100% - 4px);
    top: -4px;
    min-width: 140px;
}
.anna-deck-ctx-subwrap:hover .anna-deck-ctx-submenu,
.anna-deck-ctx-subwrap.is-open .anna-deck-ctx-submenu { display: block; }

/* Folder tiles wiggle with everything else; no uninstall ×; reduced motion
   falls back with the existing .apps-view--editing rule. */
[data-theme="dark"] .apps-folder-tile .apps-folder-collage {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .apps-folder-tile .apps-folder-mini-fallback { background: rgba(255, 255, 255, 0.12); }
[data-theme="dark"] .apps-folder-overlay .apps-folder-panel { box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6); }


/* ----- Dark theme tweaks ----- */
[data-theme="dark"] .apps-view-remove { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
[data-theme="dark"] .apps-icon-wrap img,
[data-theme="dark"] .apps-icon-wrap .apps-icon-fallback { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }

/* ----- Mobile ----- */
@media (max-width: 768px) {
    .apps-view-grid {
        grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
        gap: 22px 8px;
        padding: 16px 16px 120px;
    }
    .apps-icon-wrap,
    .apps-icon-wrap img,
    .apps-icon-wrap .apps-icon-fallback,
    .apps-view-skeleton span { width: 56px; height: 56px; border-radius: 14px; }
    .apps-view-done { top: 10px; right: 12px; }
}

/* ===== 登录初始化后台横幅（degate §5.2） ===== */
/* 默认 fixed 右上；dashboard 上 JS 会把它挂进 #desktopStatusbar 成为一个
   菜单栏状态项（见下方 .desktop-statusbar .ob-banner 覆盖），其他页面保持 fixed。 */
.ob-banner {
    position: fixed;
    top: 14px;
    right: 24px;
    z-index: 59;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-color);
    background: var(--card-bg, var(--bg-secondary));
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
    max-width: min(46vw, 420px);
    overflow: hidden;
    text-overflow: ellipsis;
}

.ob-banner::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
    animation: ob-banner-breathe 1.8s ease-in-out infinite;
}

.ob-banner:hover { transform: translateY(-1px); }

/* Apps 编辑模式：让位给同角落的 Done 按钮（编辑是短暂操作态） */
body.dashboard--apps-editing .ob-banner { display: none; }

.ob-banner.is-warn {
    color: var(--warning-color, #d97706);
    border-color: rgba(217, 119, 6, 0.4);
}

.ob-banner.is-warn::before {
    background: var(--warning-color, #d97706);
    animation: none;
}

@keyframes ob-banner-breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

[data-theme="dark"] .ob-banner { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45); }

/* 窄屏：切换条与右上角空间不足，退到底部居中（deck 上方），避免与顶部元素挤压 */
@media (max-width: 640px) {
    .ob-banner {
        top: auto;
        bottom: 96px;
        right: 50%;
        transform: translateX(50%);
        max-width: calc(100vw - 32px);
    }
    .ob-banner:hover { transform: translateX(50%) translateY(-1px); }
}


/* ===== 桌面状态栏（dashboard-desktop-first.md §7.9，macOS 菜单栏状态项） ===== */
.desktop-statusbar {
    position: absolute;
    top: 12px;
    /* 与桌面网格（960px 居中盒）右缘对齐，和搜索框同一行 */
    right: max(16px, calc((100% - 960px) / 2 + 32px));
    z-index: 60;                    /* 低于 WM 窗口，高于桌面 */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border-radius: 999px;
    background: var(--bg-secondary, var(--surface-color, #f4f4f5));
    border: 1px solid var(--border-color, #e5e7eb);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}
.desktop-statusbar .agent-upgrade-badge { margin-left: 0; }
.desktop-statusbar .chat-agent-indicator { cursor: pointer; min-width: 0; }
/* 窄桌面列：Agent 名称省略号而不是把整条状态栏挤出可视区 */
.desktop-statusbar .chat-agent-indicator .indicator-label {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
.desktop-statusbar { max-width: calc(100% - 32px); }
/* onboarding 横幅挂进状态栏后变成普通状态项 */
.desktop-statusbar .ob-banner {
    position: static;
    transform: none;
    padding: 2px 8px;
    border: none;
    background: transparent;
    box-shadow: none;
    max-width: 40vw;
}
.desktop-statusbar .ob-banner:hover { transform: none; }
body.dashboard--apps-editing .desktop-statusbar { display: none; }   /* 让位给同角落的 Done */
[data-theme="dark"] .desktop-statusbar { box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }

@media (max-width: 768px) {
    .desktop-statusbar { top: 8px; right: 8px; padding: 2px 4px; gap: 4px; }
    /* ☰（侧栏开关）钉在左上，搜索框让出它的位置 */
    .main-content > .mobile-sidebar-toggle {
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 61;
    }
    .apps-view-search { padding: 8px 16px 4px 56px; padding-right: calc(16px + var(--statusbar-w, 0px) + 8px); }
    .desktop-statusbar .indicator-disk,
    .desktop-statusbar .chat-agent-indicator .indicator-label { display: none; }
    .desktop-statusbar .ob-banner { max-width: 44vw; font-size: 11px; }
}

/* ===== Toast（桌面通知：无界面 App 提示、更新结果、后台任务完成） ===== */
.shell-toast {
    position: fixed;
    left: 50%;
    bottom: 120px;                  /* Dock 之上 */
    z-index: 3000;
    max-width: min(520px, calc(100vw - 32px));
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-color);
    background: var(--surface-color, var(--bg-secondary));
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translate(-50%, 8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.shell-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.shell-toast.is-success { border-color: rgba(5, 150, 105, 0.5); }
.shell-toast.is-warning { border-color: rgba(217, 119, 6, 0.5); }
.shell-toast.is-error { border-color: rgba(220, 38, 38, 0.55); }
[data-theme="dark"] .shell-toast { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
@media (prefers-reduced-motion: reduce) {
    .shell-toast { transition: none; }
}
