:root {
    --bg-primary: #0d0b0f;
    --bg-secondary: #1a1520;
    --bg-tertiary: #201828;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --text-primary: #e2e8f0;
    --text-secondary: rgba(255, 255, 255, 0.54);
    --text-muted: rgba(255, 255, 255, 0.38);
    --accent: #c93545;
    --accent-light: #f07a86;
    --accent-dim: rgba(201, 53, 69, 0.15);
    --accent-glow: rgba(201, 53, 69, 0.08);
    /* Numbered fade tokens for the accent — used to retire 50+ hardcoded
       ``rgba(201, 53, 69, 0.XX)`` literals scattered across the file in
       v5.8.3-rc.5. Keep tokens as multiples of 0.02 so future tweaks stay
       expressible without re-introducing literals. The naming uses the
       integer percentage of the alpha channel for intuitive pairing
       (``--accent-04`` → ``rgba(..., 0.04)``). */
    --accent-04: rgba(201, 53, 69, 0.04);
    --accent-05: rgba(201, 53, 69, 0.05);
    --accent-08: rgba(201, 53, 69, 0.08);
    --accent-10: rgba(201, 53, 69, 0.10);
    --accent-12: rgba(201, 53, 69, 0.12);
    --accent-18: rgba(201, 53, 69, 0.18);
    --accent-22: rgba(201, 53, 69, 0.22);
    --accent-25: rgba(201, 53, 69, 0.25);
    --accent-55: rgba(201, 53, 69, 0.55);
    --blue: #3b82f6;
    --blue-dim: rgba(30, 64, 175, 0.3);
    --amber: #f59e0b;
    --amber-dim: rgba(245, 158, 11, 0.15);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.15);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.15);
    --divider: rgba(255, 255, 255, 0.06);
    --radius-xs: 3px;
    --radius-sm: 8px;
    /* ``--radius-md`` (10 px) is the in-between size used by chips, log
       repeat counters, and page-fade rules.  Pre-v5.8.3-rc.5 these were
       hardcoded ``border-radius: 10px`` literals. */
    --radius-md: 10px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --page-header-padding-y: 10px;
    --page-header-padding-x: 20px;
    --page-header-padding-bottom: 6px;
    --pill-padding-y: 7px;
    --pill-padding-x: 14px;
    --pill-font-size: 13px;
    --pill-radius: 999px;
    --pill-strip-padding: 6px 0 8px;
    --button-padding-y: 8px;
    --button-padding-x: 16px;
    --button-font-size: 13px;
    --button-min-height: 34px;
    --vvh: 100dvh;
}

/* oroboro-ui-render-fix */
:root {
    --vvh: 100vh;
    --vvh: 100dvh;
}
#app {
    min-height: 100vh;
    min-height: var(--vvh, 100vh);
}
#content {
    min-height: 0;
    flex: 1;
}
#reconnect-overlay:not(.visible) {
    display: none !important;
    pointer-events: none;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: var(--vvh);
    overflow: hidden;
}

#app {
    display: flex;
    height: var(--vvh);
    position: relative;
}

/* Matrix rain canvas */
#matrix-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

/* Navigation Rail — floating overlay.
   v5.7.0 spacing pass: top padding 12 -> 28 and inter-item gap 4 -> 10 so
   the rail is no longer "stuck" to the viewport top edge and tiles breathe.
   These values track the Material 3 / Apple HIG navigation rail norms and
   are documented in docs/DEVELOPMENT.md "Navigation rail spacing". */
#nav-rail {
    position: fixed;
    left: 0;
    top: 0;
    height: var(--vvh);
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 0 16px;
    gap: 10px;
    background: transparent;
    backdrop-filter: none;
    border-right: none;
    box-shadow: none;
    z-index: 10;
}

#nav-logo {
    display: none;
}

#nav-version {
    display: block;
    max-width: 64px;
    text-align: center;
    line-height: 1.15;
    white-space: normal;
    font-size: 8px;
    color: var(--text-muted);
    padding: 4px 0 8px;
    opacity: 0.6;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    width: 64px;
    border: 1px solid var(--accent-08);
    background: var(--accent-04);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
    font-size: 11px;
    font-family: inherit;
    position: relative;
}

.unread-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-sm);
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-btn:hover {
    background: var(--accent-10);
    border-color: var(--accent-18);
    color: var(--text-primary);
    transform: scale(1.04);
    box-shadow: 0 2px 12px var(--accent-08);
}
.nav-btn.active {
    background: var(--accent-12);
    border-color: var(--accent-25);
    color: var(--accent);
    box-shadow:
        0 0 16px var(--accent-10),
        inset 0 0 12px var(--accent-05);
}

#divider {
    display: none;
}

/* Main content — full width with left padding for floating nav */
#content {
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
    z-index: 1;
    padding-left: 84px;
}

.page {
    display: none;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
.page.active { display: flex; }

.app-page-glass {
    background:
        linear-gradient(180deg, rgba(13, 11, 15, 0.76) 0%, rgba(13, 11, 15, 0.34) 170px, rgba(13, 11, 15, 0.08) 100%),
        radial-gradient(circle at 18% 0%, rgba(232, 93, 111, 0.10), transparent 300px);
}

/* Shared containment for narrow screens and unbroken runtime text. */
#content,
#content .page,
#chat-messages,
#log-entries,
.log-entry,
.log-main,
.log-body,
.log-headline,
.log-task-summary,
.log-task-timeline,
.chat-bubble,
.chat-bubble .message,
.marketplace-shell,
.marketplace-card,
.skills-card,
.widgets-list,
.widgets-card {
    min-width: 0;
}

.log-body,
.log-headline,
.log-pill,
.log-raw,
.chat-bubble .message,
.marketplace-card-body,
.marketplace-card-meta,
.skills-card,
.widgets-card {
    overflow-wrap: anywhere;
}

.files-layout {
    position: relative;
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    grid-template-areas: "sidebar preview";
    flex: 1;
    height: auto;
    min-height: 0;
    overflow: hidden;
}

.files-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-right: 1px solid var(--divider);
    background: rgba(255, 255, 255, 0.02);
}

.files-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.files-toolbar input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--divider);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.files-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.files-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 280px;
    min-width: 0;
    overflow: hidden;
}

.files-browser-actions {
    display: inline-flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.files-crumb {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    max-width: min(360px, 70vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.files-crumb:hover {
    color: var(--text-primary);
}

.files-crumb-sep {
    color: var(--text-muted);
    font-size: 12px;
}

.files-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 8px;
}

.files-entry {
    width: 100%;
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
}

.files-entry:hover {
    background: rgba(255, 255, 255, 0.04);
}

.files-entry.parent-link {
    opacity: 0.88;
}

.files-entry.selected {
    background: var(--accent-10);
    box-shadow: inset 0 0 0 1px var(--accent-22);
}

.files-entry-icon {
    color: var(--accent);
    font-size: 12px;
}

.files-entry-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.files-entry-meta {
    color: var(--text-muted);
    font-size: 11px;
}

.files-empty {
    padding: 18px 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.files-preview {
    grid-area: preview;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background:
        linear-gradient(180deg, var(--accent-05), transparent 120px),
        rgba(255, 255, 255, 0.015);
}

.files-preview-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.files-preview-actions {
    display: inline-flex;
    gap: 8px;
    flex-shrink: 0;
}

.files-preview-path {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.files-preview-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.files-preview-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overflow-wrap: anywhere;
    overscroll-behavior: contain;
    margin: 0;
    padding: 20px;
    color: #d9dee8;
    font-size: 12px;
    line-height: 1.55;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.files-editor-shell {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    gap: 12px;
}

.files-editor-name {
    width: 100%;
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font: inherit;
}

.files-editor {
    width: 100%;
    flex: 1;
    min-height: 320px;
    border: 0;
    outline: none;
    resize: none;
    margin: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: inherit;
    white-space: pre;
    tab-size: 4;
}

.files-preview-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    border-radius: var(--radius);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.files-preview-frame {
    width: 100%;
    min-height: 70vh;
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    background: #111827;
}

.files-drop-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(12, 14, 18, 0.72);
    backdrop-filter: blur(3px);
    z-index: 5;
    pointer-events: none;
}

.files-layout.drag-active .files-drop-overlay {
    display: flex;
}

.files-drop-card {
    padding: 22px 28px;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--accent-55);
    background: var(--accent-10);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

.files-context-menu {
    position: fixed;
    min-width: 160px;
    padding: 6px;
    border-radius: var(--radius);
    border: 1px solid var(--divider);
    background: rgba(18, 20, 26, 0.96);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
    z-index: 20;
}

.files-context-item {
    width: 100%;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}

.files-context-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.files-context-item-danger {
    color: #fca5a5;
}

.files-context-item-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
}

.files-modal {
    position: absolute;
    inset: 0;
    z-index: 30;
}

.files-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 7, 10, 0.66);
    backdrop-filter: blur(4px);
}

.files-modal-card {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(420px, calc(100% - 32px));
    transform: translate(-50%, -50%);
    padding: 18px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background:
        linear-gradient(180deg, var(--accent-10), transparent 100px),
        rgba(18, 20, 26, 0.98);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
}

.files-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.files-modal-message {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.files-modal-input {
    width: 100%;
    margin-top: 14px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    padding: 11px 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font: inherit;
}

.files-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.page-header,
.app-page-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--page-header-padding-y) var(--page-header-padding-x) var(--page-header-padding-bottom);
    background: transparent;
    backdrop-filter: none;
    flex-shrink: 0;
    border-bottom: none;
}

.app-page-header {
    align-items: flex-start;
    gap: 10px 12px;
    flex-wrap: wrap;
}

.app-page-title-block {
    min-width: 0;
    flex: 1 1 auto;
}

.app-page-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.app-page-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: var(--accent);
}

.app-page-icon svg {
    display: block;
}

.page-header h2,
.app-page-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.app-page-description {
    margin: 2px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.35;
    max-width: 760px;
}

.app-page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
    min-width: 0;
}

.app-page-tabs {
    flex: 1 0 100%;
    min-width: 0;
}

.app-tab-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    padding: var(--pill-strip-padding);
    scrollbar-width: none;
}

.app-tab-strip::-webkit-scrollbar {
    display: none;
}

.app-tab {
    flex: 0 0 auto;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border-radius: var(--pill-radius);
    padding: var(--pill-padding-y) var(--pill-padding-x);
    font: inherit;
    font-size: var(--pill-font-size);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.app-tab:hover,
.app-tab.active,
.app-tab.is-active {
    color: var(--text-primary);
    border-color: rgba(232, 93, 111, 0.4);
    background: rgba(232, 93, 111, 0.12);
}

.app-tab-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    padding: 0 6px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
}

.scroll-fade-y {
    --scroll-fade-edge: 32px;
    -webkit-mask-image: linear-gradient(
        180deg,
        transparent 0,
        black var(--scroll-fade-edge),
        black calc(100% - var(--scroll-fade-edge)),
        transparent 100%
    );
            mask-image: linear-gradient(
        180deg,
        transparent 0,
        black var(--scroll-fade-edge),
        black calc(100% - var(--scroll-fade-edge)),
        transparent 100%
    );
}

.page-header .spacer { flex: 1; }

.app-page-header-overlay {
    align-items: center;
}

.chat-page-header .app-page-title-block {
    flex: 0 0 auto;
}

.chat-page-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    flex-wrap: wrap;
    row-gap: 10px;
    pointer-events: none;
    /* Fade fully to transparent at the bottom edge so no hard border
       shows up between the scrim and the transcript. The previous stop
       at 0.32 alpha left a visible discontinuity; fading to 0 produces
       a clean scroll-under effect at every scroll position. */
    background: linear-gradient(
        180deg,
        rgba(13, 11, 15, 0.92) 0%,
        rgba(13, 11, 15, 0.78) 45%,
        rgba(13, 11, 15, 0.38) 80%,
        rgba(13, 11, 15, 0.00) 100%
    );
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Soft-mask the blur to fall off in lockstep with the gradient,
       otherwise the glass effect creates its own visible hard edge. */
    -webkit-mask-image: linear-gradient(180deg, black 0%, black 70%, transparent 100%);
            mask-image: linear-gradient(180deg, black 0%, black 70%, transparent 100%);
}

.chat-page-header > * {
    pointer-events: auto;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
    max-width: min(100%, 640px);
}

.chat-header-btn {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(13, 11, 15, 0.55);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.chat-header-btn:hover {
    border-color: rgba(255,255,255,0.16);
    color: var(--text-primary);
}

.chat-header-btn.on {
    border-color: rgba(201, 53, 69, 0.38);
    background: rgba(201, 53, 69, 0.14);
    color: var(--accent-light);
}

.chat-header-btn.danger {
    border-color: rgba(239, 68, 68, 0.22);
    color: rgba(248, 113, 113, 0.95);
}

.chat-header-btn.danger:hover {
    border-color: rgba(239, 68, 68, 0.40);
    background: rgba(239, 68, 68, 0.08);
}

/* Budget pill in chat header */
.chat-budget-pill {
    appearance: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.18);
    background: rgba(13, 11, 15, 0.55);
    backdrop-filter: blur(8px);
    cursor: pointer;
    min-width: 100px;
    font: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.chat-budget-pill:hover {
    border-color: rgba(245, 158, 11, 0.34);
    background: rgba(245, 158, 11, 0.08);
    transform: scale(1.02);
}

.chat-budget-pill:active {
    transform: scale(0.98);
}

.chat-budget-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--amber);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.chat-budget-bar {
    width: 100%;
    height: 2px;
    border-radius: 1px;
    background: rgba(245, 158, 11, 0.12);
    overflow: hidden;
}

.chat-budget-bar-fill {
    height: 100%;
    border-radius: 1px;
    background: var(--amber);
    transition: width 0.4s ease;
    width: 0;
}

/* Status badge */
.status-badge {
    padding: 4px 10px;
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 500;
    background: rgba(26, 21, 32, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.status-badge.online { color: var(--green); }
.status-badge.starting { color: var(--amber); }
.status-badge.error { color: var(--red); }
.status-badge.offline { color: var(--text-muted); }
.status-badge.thinking {
    color: var(--accent);
    animation: thinking-pulse 1.5s ease-in-out infinite;
}
@keyframes thinking-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Typing indicator */
.typing-bubble { opacity: 0.7; }
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 20px;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Web onboarding overlay */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.onboarding-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 7, 10, 0.78);
    backdrop-filter: blur(10px);
}

.onboarding-frame {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
}

@media (max-width: 980px) {
    .files-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(220px, 320px) minmax(0, 1fr);
        grid-template-areas:
            "sidebar"
            "preview";
    }

    .files-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--divider);
        max-height: none;
    }

    .chat-live-card {
        max-width: 100%;
        margin-right: 0;
    }
}

/* Chat page */
#chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-top: 56px;
    padding-bottom: var(--chat-input-reserve, 108px);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    max-width: 80%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

.chat-bubble.user {
    background: linear-gradient(135deg, rgba(80, 120, 190, 0.14), rgba(55, 85, 155, 0.12));
    border: 1px solid rgba(110, 150, 210, 0.18);
    box-shadow: inset 0 1px 0 rgba(160, 190, 245, 0.04);
    align-self: flex-end;
    margin-left: 20%;
}

.chat-bubble.assistant {
    background: linear-gradient(135deg, var(--accent-18), rgba(120, 24, 36, 0.18));
    border: 1px solid rgba(240, 122, 134, 0.24);
    box-shadow: inset 0 1px 0 rgba(255, 214, 220, 0.05);
    align-self: flex-start;
    margin-right: 20%;
}

.chat-bubble.system {
    background: rgba(245, 158, 11, 0.12);
    border-left: 2px solid rgba(245, 158, 11, 0.45);
    align-self: flex-start;
    margin-right: 20%;
}

.chat-bubble .sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
}
.chat-bubble.user .sender { color: rgba(155, 185, 240, 0.95); }
.chat-bubble.assistant .sender { color: rgba(250, 125, 125, 0.95); }
.chat-bubble.system .sender { color: rgba(245, 158, 11, 0.9); }

.chat-bubble .message {
    font-size: 15.5px;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.chat-photo {
    max-width: 100%;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.chat-bubble.user .message { color: rgba(215, 230, 255, 0.96); }
.chat-bubble.assistant .message { color: rgba(255, 235, 238, 0.96); }
.chat-bubble.system .message { color: rgba(255, 240, 210, 0.78); }

.chat-bubble.system[data-system-type="skill_review"] {
    padding: 0;
    overflow: hidden;
}

.chat-bubble.system[data-system-type="skill_review"] .sender,
.chat-bubble.system[data-system-type="skill_review"] .msg-time {
    margin-left: 14px;
    margin-right: 14px;
}

.chat-bubble.system[data-system-type="skill_review"] .sender {
    margin-top: 10px;
}

.chat-bubble.system[data-system-type="skill_review"] .message {
    white-space: normal;
}

.skill-review-disclosure {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.skill-review-summary-button {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 11px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    text-align: left;
}

.skill-review-summary-button:hover {
    background: rgba(245, 158, 11, 0.08);
}

.skill-review-summary-main {
    color: rgba(255, 244, 220, 0.96);
    font-weight: 650;
}

.skill-review-summary-side {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: rgba(255, 240, 210, 0.66);
    font-size: 12px;
}

.skill-review-meta {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.skill-review-toggle-label {
    flex-shrink: 0;
    color: rgba(245, 158, 11, 0.95);
    font-weight: 650;
}

.skill-review-full {
    padding: 0 14px 14px;
    color: rgba(255, 240, 210, 0.82);
    white-space: pre-wrap;
}

.chat-bubble.pending {
    opacity: 0.78;
    border-style: dashed;
}

.msg-pending {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.msg-time {
    font-size: 0.65rem;
    color: var(--text-secondary, #666);
    opacity: 0.4;
    margin-top: 6px;
    text-align: right;
    transition: opacity 0.3s ease;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    user-select: none;
}

.chat-bubble:hover .msg-time {
    opacity: 0.8;
}

.chat-bubble.user .msg-time {
    text-align: right;
}

.chat-bubble.assistant .msg-time {
    text-align: left;
}

.chat-bubble.system .msg-time {
    text-align: left;
}

/* Progress (thinking) messages — subdued and smaller than regular bubbles */
.chat-bubble.progress {
    border-left: 2px solid rgba(220, 38, 38, 0.2);
    padding-left: 14px;
    max-width: min(100%, 760px);
    margin-right: 0;
    opacity: 0.72;
}

.chat-bubble.progress .sender {
    font-size: 10px;
    color: rgba(248, 113, 113, 0.6);
}

.chat-bubble.progress .message {
    font-size: 13px;
    line-height: 1.45;
    color: rgba(255, 228, 232, 0.55);
}

.chat-live-card {
    align-self: flex-start;
    width: min(100%, 760px);
    max-width: calc(100% - 20%);
    margin-right: 20%;
    padding: 0;
    border-radius: var(--radius-lg);
    border: 1px solid var(--accent-dim);
    background: var(--accent-04);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 200, 210, 0.03);
    overflow: hidden;
}

.chat-live-card[data-finished="1"] {
    border-color: var(--accent-08);
    background: rgba(201, 53, 69, 0.02);
}

.chat-live-card[hidden] {
    display: none;
}

.chat-live-summary-button {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 11px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    user-select: none;
    text-align: left;
}

.chat-live-summary-button:hover {
    background: rgba(201, 53, 69, 0.06);
}

.chat-live-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chat-live-summary-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.chat-live-summary-side {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chat-live-phase,
.chat-live-line-phase {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: none;
}

.chat-live-phase.start,
.chat-live-phase.calling,
.chat-live-phase.context,
.chat-live-phase.progress,
.chat-live-phase.working,
.chat-live-phase.thought,
.chat-live-phase.thinking,
.chat-live-phase.boot,
.chat-live-line-phase.start,
.chat-live-line-phase.calling,
.chat-live-line-phase.context,
.chat-live-line-phase.progress,
.chat-live-line-phase.working,
.chat-live-line-phase.thought,
.chat-live-line-phase.thinking,
.chat-live-line-phase.boot {
    color: rgba(248, 130, 140, 0.95);
    border-color: rgba(201, 53, 69, 0.24);
    background: var(--accent-10);
}

/* Active (non-finished) live card: pulse the Working/Thinking phase badge */
.chat-live-card:not([data-finished="1"]) .chat-live-phase.working,
.chat-live-card:not([data-finished="1"]) .chat-live-phase.thinking,
.chat-live-card:not([data-finished="1"]) .chat-live-phase.progress,
.chat-live-card:not([data-finished="1"]) .chat-live-phase.calling,
.chat-live-card:not([data-finished="1"]) .chat-live-phase.context {
    animation: thinking-pulse 1.5s ease-in-out infinite;
}

.chat-live-phase.done,
.chat-live-phase.ready,
.chat-live-phase.ok,
.chat-live-phase.result,
.chat-live-phase.usage,
.chat-live-phase.metrics,
.chat-live-line-phase.done,
.chat-live-line-phase.ready,
.chat-live-line-phase.ok,
.chat-live-line-phase.result,
.chat-live-line-phase.usage,
.chat-live-line-phase.metrics {
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.22);
    background: rgba(34, 197, 94, 0.10);
}

.chat-live-phase.warn,
.chat-live-phase.alive,
.chat-live-phase.empty,
.chat-live-line-phase.warn,
.chat-live-line-phase.alive,
.chat-live-line-phase.empty {
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.10);
}

.chat-live-phase.error,
.chat-live-phase.timeout,
.chat-live-line-phase.error,
.chat-live-line-phase.timeout {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.10);
}

/* Inline typing dots inside the live card summary row */
.chat-live-typing {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
}

.chat-live-typing span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-55);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.chat-live-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-live-typing span:nth-child(3) { animation-delay: 0.4s; }

/* Hide typing dots when card is finished */
.chat-live-card[data-finished="1"] .chat-live-typing {
    display: none;
}

.chat-live-title {
    font-size: 13px;
    font-weight: 400;
    color: rgba(226, 232, 240, 0.68);
    flex: 1;
    min-width: 0;
    line-height: 1.45;
    white-space: pre-wrap;
}

.chat-live-count {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}

.chat-live-toggle {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.chat-live-chevron {
    color: var(--text-muted);
    transition: transform 0.18s ease;
}

.chat-live-card[data-expanded="1"] .chat-live-chevron {
    transform: rotate(180deg);
}

.chat-live-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-live-meta-text {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 12px;
}

.chat-live-timeline {
    padding: 0 14px 12px;
    display: none;
    flex-direction: column;
    gap: 8px;
}

.chat-live-card[data-expanded="1"] .chat-live-timeline {
    display: flex;
    border-top: 1px solid rgba(255,255,255,0.05);
    max-height: 420px;
    overflow-y: auto;
}

.chat-live-line {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-live-line:first-child {
    border-top: none;
    padding-top: 0;
}

.chat-live-line.expandable {
    border-radius: var(--radius);
    transition: background 0.18s ease;
}

.chat-live-line.expandable:hover {
    background: rgba(255,255,255,0.02);
}

.chat-live-line.expandable[data-expanded="1"] {
    background: rgba(59, 130, 246, 0.08);
}

.chat-live-line-toggle {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.chat-live-line-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.chat-live-line-title {
    color: rgba(226, 232, 240, 0.72);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
    white-space: pre-wrap;
}

.chat-live-line-repeat {
    color: var(--text-muted);
    font-size: 11px;
}

.chat-live-line-time {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 11px;
}

.chat-live-line-expand-label {
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 1px;
}

.chat-live-line-body {
    color: rgba(226, 232, 240, 0.64);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.5;
}

.chat-live-line[data-expanded="1"] .chat-live-line-title {
    color: rgba(239, 246, 255, 0.9);
}

.chat-live-line[data-expanded="1"] .chat-live-line-body {
    color: rgba(239, 246, 255, 0.82);
}

.chat-live-line.error .chat-live-line-title,
.chat-live-line.timeout .chat-live-line-title {
    color: #fda4af;
}

.chat-bubble .message pre {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 8px 10px;
    margin: 6px 0;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
}
.chat-bubble .message code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
}
.chat-bubble .message .inline-code {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 14px;
}
.chat-bubble .message del {
    opacity: 0.5;
    text-decoration: line-through;
}
.chat-bubble .message .md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 8px 0;
}
.chat-bubble .message .md-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}
.chat-bubble .message .md-table td {
    padding: 3px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Markdown rendering classes — global, used by renderMarkdown in all contexts */
.md-h1 {
    font-size: 16px;
    color: var(--text-primary);
    display: block;
    margin: 12px 0 6px;
}
.md-h2 {
    font-size: 14px;
    color: var(--text-primary);
    display: block;
    margin: 10px 0 4px;
}
.md-h3 {
    font-size: 13px;
    color: var(--text-primary);
    display: block;
    margin: 8px 0 4px;
}
.md-li {
    display: block;
    padding-left: 12px;
}
.md-link {
    color: var(--accent);
    text-decoration: underline;
}

/* Table overflow wrapper — prevents wide tables from breaking bubble layout */
.md-table-wrap {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Nav spacer (replaces inline style="flex:1") */
.nav-spacer {
    flex: 1;
}

/* Mobile responsive — narrow screens only; desktop layout unchanged.
   NOTE: Rules here apply only to selectors whose base definitions appear
   BEFORE this block. Overrides for selectors defined later live in the
   second @media (max-width: 640px) block at the END of this file so they
   reliably win without !important. */
@media (max-width: 640px) {
    /* Prevent iOS zoom on input focus */
    textarea, input[type="text"], input[type="password"], input[type="email"], select {
        font-size: 16px !important;
    }

    /* Compact chat bubbles on small screens */
    .chat-bubble {
        max-width: 92%;
    }
    .chat-bubble.user {
        margin-left: 8%;
    }
    .chat-bubble.assistant,
    .chat-bubble.system {
        margin-right: 8%;
    }
    .chat-bubble.progress {
        max-width: 100%;
        margin-right: 0;
    }

    /* Nav-rail — convert vertical sidebar to horizontal bottom bar.
       v5.7.0: ``justify-content: safe center`` centers the row when all
       buttons fit (~6 buttons × 60px ≈ 360-410px), and falls back to
       ``flex-start`` when content overflows so leftmost items remain
       reachable on narrow phones. ``min-width: 60px`` on .nav-btn keeps
       labels like "Dashboard" from truncating in space-evenly mode. */
    #nav-rail {
        flex-direction: row;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        padding: 6px 6px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
        gap: 2px;
        justify-content: safe center;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        background: rgba(13, 11, 15, 0.88);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    #nav-rail::-webkit-scrollbar {
        display: none;
    }

    .nav-btn {
        flex-direction: column;
        width: auto;
        min-width: 60px;
        flex: 0 0 auto;
        padding: 5px 8px;
        gap: 2px;
        font-size: 9px;
    }

    .nav-btn svg {
        width: 18px;
        height: 18px;
    }

    .unread-badge {
        top: 2px;
        right: 4px;
        min-width: 14px;
        height: 14px;
        font-size: 9px;
    }

    #nav-version,
    .nav-spacer {
        display: none;
    }

    #content {
        padding-left: 0;
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    }

    /* Chat header — keep the floating-overlay glass treatment on mobile too
       so the same soft-gradient + masked-blur scroll-under effect holds
       across viewports. v5.6.x had switched it to ``position: static`` to
       avoid hiding the first chat message under wrapped action rows, but
       that introduced a hard "black bar" edge above the transcript. We
       restore the overlay and instead reduce the row gap so the header
       stays compact on phones; #chat-messages already reserves
       ``padding-top: 12px`` and the absolute composer compensates for any
       wrapping via its own padding. */
    .chat-page-header {
        row-gap: 6px;
    }

    .chat-header-actions {
        gap: 4px;
    }

    .chat-header-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .chat-budget-pill {
        min-width: 0;
        padding: 3px 10px;
    }

    .chat-budget-text {
        font-size: 10px;
    }

    .page-header {
        padding: 10px 12px;
    }
}

#chat-input-area {
    /* Hybrid translucent overlay (v5.7.0). Mirrors the ``.chat-page-header``
       pattern at the bottom of the chat page: a compact absolute-positioned
       wrapper with a soft 4-stop gradient that only darkens transcript
       text as it approaches the composer. The actual frosted blur lives on
       the input field itself, not this wrapper, so the fade never becomes a
       tall smeared glass band. ``#chat-messages`` reserves enough bottom
       padding so the last bubble is reachable above the composer surface. */
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 32px 16px 16px;
    align-items: stretch;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 5;
    pointer-events: none;
    background: linear-gradient(
        0deg,
        rgba(13, 11, 15, 0.82) 0%,
        rgba(13, 11, 15, 0.58) 48%,
        rgba(13, 11, 15, 0.22) 78%,
        rgba(13, 11, 15, 0.00) 100%
    );
}

#chat-input-area > * {
    pointer-events: auto;
}

.chat-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

/* Attach button sits INSIDE the textarea on the left */
.chat-attach-btn {
    position: absolute;
    left: 10px;
    bottom: 9px;
    z-index: 2;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-xs);
    border: none;
    background: transparent;
    color: rgba(226, 232, 240, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s;
    padding: 0;
}

.chat-attach-btn:hover {
    color: rgba(226, 232, 240, 0.75);
}

.chat-file-input-hidden {
    display: none !important;
}

.chat-attach-btn.uploading {
    opacity: 0.5;
    pointer-events: none;
}

.chat-attachment-preview {
    display: none;
    padding: 4px 8px 2px;
}

.chat-attachment-preview.visible {
    display: flex;
    align-items: center;
}

.attach-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 6px;
    background: rgba(26, 21, 32, 0.78);
    border: 1px solid rgba(201, 53, 69, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: rgba(226, 232, 240, 0.85);
    max-width: 100%;
}

.attach-thumb {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: var(--radius-xs);
}

.attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.attach-remove {
    flex-shrink: 0;
    border: none;
    background: none;
    color: rgba(226, 232, 240, 0.5);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}

.attach-remove:hover {
    color: rgba(226, 232, 240, 0.9);
}

#chat-input {
    flex: 1;
    padding: 10px 76px 10px 42px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(26, 21, 32, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    /* The textarea is the focal "glass" element. Its own dense blur
       (20px) together with a moderately translucent fill (0.55) is what
       makes message bubbles read THROUGH the input field as a frosted
       surface. The wrapper's mask-faded blur handles the scroll-under
       gradient zone above the textarea, so the textarea itself does not
       need to carry the wrapper's gradient. */
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
#chat-input:focus {
    border-color: rgba(232, 93, 111, 0.4);
    background: rgba(26, 21, 32, 0.85);
    /* Focus ring only — no ambient halo. */
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 0 3px var(--accent-10);
}
#chat-input::placeholder { color: var(--text-muted); }

/* Send group: positions the Send button + chevron as an absolute unit */
.chat-send-group {
    position: absolute;
    right: 8px;
    bottom: 7px;
    display: flex;
    align-items: center;
    gap: 0;
    z-index: 1;
    height: 28px;
}

.chat-send-group[data-busy="1"] {
    opacity: 0.72;
}

/* --send-color: resolved per send-mode via dataset attribute below */
.chat-send-inline {
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 0 8px;
    height: 100%;
    border-radius: var(--radius) 0 0 var(--radius);
    transition: color 0.18s, background 0.18s, opacity 0.18s;
    opacity: 0.72;
    display: flex;
    align-items: center;
}
.chat-send-inline:hover {
    opacity: 1;
    background: var(--accent-10);
}
.chat-send-inline:active {
    background: var(--accent-18);
    opacity: 1;
}

/* Plan mode overrides — toggled via data-send-mode="plan" on the group */
.chat-send-group[data-send-mode="plan"] .chat-send-inline {
    color: var(--amber);
    opacity: 0.85;
}
.chat-send-group[data-send-mode="plan"] .chat-send-inline:hover {
    opacity: 1;
    background: var(--amber-dim);
}
.chat-send-group[data-send-mode="plan"] .chat-send-inline:active {
    background: rgba(245, 158, 11, 0.22);
    opacity: 1;
}

/* Chevron button — always visible for touch-screen accessibility */
.chat-send-chevron {
    border: none;
    border-left: 1px solid rgba(201, 53, 69, 0.20);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    padding: 0 5px;
    height: 100%;
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: background 0.15s, opacity 0.15s, color 0.18s, border-color 0.18s;
    opacity: 0.5;
    display: flex;
    align-items: center;
}
.chat-send-chevron:hover,
.chat-send-chevron.active {
    opacity: 1;
    background: var(--accent-10);
}
.chat-send-group[data-send-mode="plan"] .chat-send-chevron {
    color: var(--amber);
    border-left-color: rgba(245, 158, 11, 0.25);
}
.chat-send-group[data-send-mode="plan"] .chat-send-chevron:hover,
.chat-send-group[data-send-mode="plan"] .chat-send-chevron.active {
    background: var(--amber-dim);
    opacity: 1;
}

/* Dropdown panel */
.chat-send-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    min-width: 120px;
    background: rgba(26, 21, 32, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(201, 53, 69, 0.20);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    z-index: 10;
}
.chat-send-dropdown.open {
    display: block;
}
.chat-send-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    padding: 9px 14px;
    text-align: left;
    transition: background 0.13s, color 0.13s;
    opacity: 0.85;
}
.chat-send-dropdown-item:hover {
    background: var(--accent-12);
    color: var(--accent);
    opacity: 1;
}
/* Active-mode marker: the currently selected mode item gets a subtle tint */
.chat-send-dropdown-item[data-mode-active="true"] {
    opacity: 1;
    font-weight: 600;
}
/* Plan item tinted amber when it's the active mode */
#chat-dropdown-plan[data-mode-active="true"] {
    color: var(--amber);
}
/* Send item tinted accent when it's the active mode */
#chat-dropdown-send[data-mode-active="true"] {
    color: var(--accent);
}

/* Shared UI components (stat cards used by Costs, section titles by Evolution) */
.stat-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-radius: var(--radius);
    padding: 16px 20px;
    border: 1px solid var(--accent-08);
    backdrop-filter: blur(14px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    transition: border-color 0.3s;
}
.stat-card:hover {
    border-color: rgba(201, 53, 69, 0.2);
}

.stat-card .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-card .value {
    font-size: 20px;
    font-weight: 700;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 16px 0 12px;
}

/* Toggle switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle {
    width: 44px;
    height: 24px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.12);
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.toggle.on { background: var(--accent); }

.toggle::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(20px); }

.toggle-label { font-size: 13px; color: var(--text-secondary); }

/* Buttons */
.btn {
    padding: var(--button-padding-y) var(--button-padding-x);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: var(--button-font-size);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--button-min-height);
    text-align: center;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    transform: scale(1.02);
}

.btn:active {
    transform: scale(0.98);
    box-shadow: 0 0 0 3px var(--accent-08);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: var(--accent-dim);
    color: var(--accent-light);
    border-color: rgba(201, 53, 69, 0.20);
}
.btn-primary:hover {
    background: var(--accent-25);
    border-color: rgba(232, 93, 111, 0.35);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.10);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
    border-color: rgba(232, 93, 111, 0.28);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.08);
}
.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}
.btn-danger {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(220, 38, 38, 0.3);
    animation: panic-glow 2s ease-in-out infinite;
}
.btn-danger:hover { background: rgba(220, 38, 38, 0.35); }

@keyframes panic-glow {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 8px rgba(220, 38, 38, 0.3); }
}

.btn-save {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.22);
}
.btn-save:hover { background: rgba(34, 197, 94, 0.25); }
.btn-default {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.08);
}
.btn-default:hover {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.14);
}

.form-section { margin-bottom: 24px; }

.form-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field label {
    font-size: 12px;
    color: var(--text-secondary);
}

.form-field input, .form-field select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--divider);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    width: 320px;
    max-width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.local-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding-bottom: 8px;
    white-space: nowrap;
}
.local-toggle input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.local-toggle[title] {
    transition: color 0.2s;
}

.form-field input[type="range"] {
    -webkit-appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    border: none;
    padding: 0;
}

.divider {
    height: 1px;
    background: var(--divider);
    margin: 20px 0;
}

/* Logs */
.logs-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 20px;
    align-items: center;
}

/* v5.7.0: the embedded-Logs Clear button lives inside the filters row
   (right-aligned) instead of in a duplicate inner page header. */
.logs-inline-clear {
    margin-left: auto;
}

.filter-chip {
    padding: 4px 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--divider);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-chip.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

#log-entries {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.55;
    background: rgba(255, 255, 255, 0.02);
    margin: 0 12px 12px;
    border-radius: var(--radius-sm);
}

.log-entry {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid rgba(255,255,255,0.04);
    background: rgba(255,255,255,0.015);
    margin-bottom: 8px;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255,255,255,0.08);
}

.log-main {
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
}

.log-entry .log-ts {
    color: var(--text-muted);
    flex-shrink: 0;
}

.log-entry .log-type {
    font-weight: 700;
    flex-shrink: 0;
    min-width: 78px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 11px;
}

.log-entry .log-phase {
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-secondary);
    background: rgba(255,255,255,0.04);
}

.log-entry .log-phase.start,
.log-entry .log-phase.calling,
.log-entry .log-phase.context,
.log-entry .log-phase.progress,
.log-entry .log-phase.thought,
.log-entry .log-phase.boot,
.log-entry .log-phase.working,
.log-entry .log-phase.thinking {
    color: rgba(248, 130, 140, 0.95);
    border-color: var(--accent-25);
    background: var(--accent-10);
}

.log-entry .log-phase.done,
.log-entry .log-phase.ready,
.log-entry .log-phase.ok,
.log-entry .log-phase.result,
.log-entry .log-phase.usage,
.log-entry .log-phase.metrics {
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.22);
    background: rgba(34, 197, 94, 0.10);
}

.log-entry .log-phase.warn,
.log-entry .log-phase.alive,
.log-entry .log-phase.empty {
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.10);
}

.log-entry .log-phase.error,
.log-entry .log-phase.timeout {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.10);
}

.log-entry .log-headline {
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-word;
}

.log-entry .log-repeat {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 11px;
}

.log-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.log-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.05);
    font-size: 11px;
}

.log-body {
    color: var(--text-secondary);
    word-break: break-word;
    white-space: pre-wrap;
}

.log-actions {
    display: flex;
    justify-content: flex-end;
}

.log-raw-toggle {
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
}

.log-raw-toggle:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.14);
}

.log-raw {
    margin: 0;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-type.tools { color: var(--blue); }
.log-type.llm { color: var(--accent); }
.log-type.errors { color: var(--red); }
.log-type.tasks { color: var(--amber); }
.log-type.system { color: var(--text-muted); }
.log-type.consciousness { color: #d68cff; }

.log-task-card {
    border-color: var(--accent-12);
    background:
        linear-gradient(135deg, rgba(201, 53, 69, 0.07), rgba(255,255,255,0.01)),
        rgba(255,255,255,0.015);
}

.log-task-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.log-task-details {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 8px;
}

.log-task-details summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 11px;
    user-select: none;
}

.log-task-timeline {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-task-event {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201, 53, 69, 0.2); border-radius: var(--radius-xs); }
::-webkit-scrollbar-thumb:hover { background: rgba(201, 53, 69, 0.35); }

/* Reconnecting overlay */
#reconnect-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}
#reconnect-overlay.visible { display: flex; }
#reconnect-overlay .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--divider);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Cost tables */
.cost-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.cost-table th {
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--divider);
}
.cost-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-secondary);
}
.cost-table tbody tr:hover td {
    background: rgba(255,255,255,0.03);
}

/* ---------------------------------------------------------------------------
 * Settings — LAN reachability hint
 * Rendered by web/modules/settings.js::_renderNetworkHint into the
 * #settings-lan-hint container inside the Network Gate section.
 * --------------------------------------------------------------------------- */
.settings-lan-hint {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.84em;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-secondary, rgba(255,255,255,0.65));
}
.settings-lan-hint[data-tone="ok"] { border-color: rgba(100,200,100,0.25); }
.settings-lan-hint[data-tone="warn"] { border-color: rgba(220,180,50,0.35); }
.settings-lan-hint[data-tone="info"] { border-color: rgba(100,150,220,0.25); }
.settings-lan-hint a { color: inherit; text-decoration: underline; opacity: 0.9; }
.btn-sm {
    padding: calc(var(--button-padding-y) - 4px) calc(var(--button-padding-x) - 4px);
    font-size: calc(var(--button-font-size) - 1px);
    min-height: 28px;
}

.btn-md {
    padding: var(--button-padding-y) var(--button-padding-x);
    font-size: var(--button-font-size);
    min-height: var(--button-min-height);
}

.btn-lg {
    padding: calc(var(--button-padding-y) + 2px) calc(var(--button-padding-x) + 2px);
    font-size: calc(var(--button-font-size) + 1px);
    min-height: 42px;
}

/* Evolution Page */
.evo-refresh-btn {
    min-width: 92px;
}

.evolution-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 4px;
    height: calc(var(--vvh) - 120px);
    overflow-y: auto;
}

.evo-runtime-card,
.evo-chart-wrap {
    background:
        linear-gradient(180deg, var(--accent-05), rgba(255, 255, 255, 0.02)),
        rgba(255, 255, 255, 0.02);
    border: 1px solid var(--accent-12);
    border-radius: var(--radius-lg);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(14px);
}

.evo-runtime-card {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.evo-runtime-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}

.evo-runtime-detail {
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 880px;
}

.evo-runtime-pills,
.evo-runtime-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* v5.7.0: when Evolution is embedded in the Dashboard tab strip, the
   "Refresh" button + status badge that used to live in a duplicate
   inner ".page-header" relocate into the runtime card head, sitting
   alongside the existing pills cluster. */
.evo-runtime-controls {
    align-items: center;
}

.evo-runtime-pill,
.evo-runtime-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 12px;
}

.evo-runtime-pill.online {
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.22);
    background: rgba(34, 197, 94, 0.10);
}

.evo-runtime-pill.starting {
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.10);
}

.evo-runtime-pill.error {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.10);
}

.evo-runtime-chip strong {
    font-weight: 600;
    color: var(--text-primary);
}

.evo-chart-wrap {
    position: relative;
    width: 100%;
    min-height: 400px;
    max-height: 50vh;
    padding: 16px;
}

.evo-tags-list {
    overflow-x: auto;
}

.evo-tags-list table {
    width: 100%;
}

.evo-empty {
    padding: 18px;
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    line-height: 1.6;
}

@media (max-width: 900px) {
    .evo-runtime-head {
        flex-direction: column;
    }

    .evo-chart-wrap {
        min-height: 320px;
        max-height: none;
    }
}

/* About page */
.about-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 24px;
    padding: 40px 20px;
    text-align: center;
}
.about-logo {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-xl);
    object-fit: cover;
}
.about-title { font-size: 28px; font-weight: 700; margin: 0; }
.about-version { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }
.about-desc { max-width: 480px; color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.about-credits { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.about-links { display: flex; gap: 16px; justify-content: center; margin-top: 4px; }
.about-links a { color: var(--accent); text-decoration: none; }
.about-footer { margin-top: auto; padding-top: 32px; color: var(--text-muted); font-size: 12px; }

/* Costs page layout */
.costs-scroll { overflow-y: auto; flex: 1; padding: 16px 20px; }
.costs-budget-card {
    background: rgba(26, 21, 32, 0.72);
    backdrop-filter: blur(12px);
    border: 1px solid var(--accent-18);
    border-radius: 18px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.costs-budget-title { font-size: 15px; font-weight: 600; margin: 0; color: var(--text-primary); }
/* v5.7.0: budget card head row hosts the title plus (when costs is
   embedded in the Dashboard tab strip) the relocated Refresh button. */
.costs-budget-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.costs-budget-refresh { flex: 0 0 auto; }
.costs-budget-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 20px; margin-bottom: 16px; }
.costs-budget-fields .form-field { min-width: 0; }
.costs-budget-fields input { width: 100%; min-width: 0; }
.costs-budget-save { margin-top: 4px; }
.costs-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.costs-tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.costs-table-label { font-size: 14px; color: var(--text-secondary); margin: 0 0 8px; }
.cost-cell-name { font-size: 12px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-cell-right { text-align: right; }
.cost-top-model { font-size: 12px; }
.cost-bar-cell { width: 60px; }
.cost-bar { width: 60px; height: 6px; border: 0; border-radius: var(--radius-xs); overflow: hidden; opacity: 0.7; }
.cost-bar::-webkit-progress-bar { background: rgba(255, 255, 255, 0.08); }
.cost-bar::-webkit-progress-value { background: var(--accent); }
.cost-bar::-moz-progress-bar { background: var(--accent); }
.cost-empty-cell { color: var(--text-muted); text-align: center; }

/* Updates panel */
.updates-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.updates-card {
    background: rgba(26, 21, 32, 0.72);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(201, 53, 69, 0.14);
    border-radius: 18px;
    padding: 18px;
}

.updates-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.updates-card-head-main {
    min-width: 0;
    flex: 1 1 auto;
}

/* v5.7.0: actions cluster (status badge + relocated Check-for-updates
   button) sits to the right of the head row, replacing the duplicate
   inner page-header that used to host the button. */
.updates-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.updates-summary {
    color: var(--text-secondary);
    line-height: 1.55;
    overflow-wrap: break-word;
    word-break: normal;
}

.updates-meta,
.updates-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

/* Dashboard */
#page-dashboard {
    min-height: 0;
}

.dashboard-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 20px 18px;
    overflow: hidden;
}

/* ``.dashboard-tabs`` and ``.dashboard-tab`` previously redeclared the
   same flex/pill styling already covered by ``.app-tab-strip`` and
   ``.app-tab`` (lines 662-696). Both class names still ride along with
   the JS query selectors used by ``dashboard.js`` (so the layout
   selectors remain stable), but the styling now inherits from the
   shared ``.app-tab*`` rules — no duplicate CSS declaration. */

.dashboard-panels,
.dashboard-panel {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* v5.7.0 scroll-chain fix: ``.dashboard-panels`` is the parent of every
   embedded sub-panel. Without ``display: flex; flex-direction: column;``
   the active panel's ``flex: 1; min-height: 0`` collapses to content
   height, which kills overflow scrolling for Logs / Updates / Costs
   (and the 3-column Updates Tags view). Evolution previously bypassed
   the broken chain via an explicit ``height: calc(var(--vvh) - 120px)``
   on ``.evolution-container`` — that rule stays as a belt-and-braces.
   With this single rule the sub-panel's flex chain is intact end-to-end. */
.dashboard-panels {
    display: flex;
    flex-direction: column;
}

.dashboard-panel {
    display: none;
}

.dashboard-panel.active {
    display: flex;
    flex-direction: column;
}

.settings-embedded-content {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.evo-versions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.evo-versions-branch {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.evo-versions-cols {
    display: flex;
    gap: 24px;
    flex: 1;
    overflow: hidden;
}

.evo-versions-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.evo-versions-list {
    flex: 1;
    overflow-y: auto;
}

.evo-versions-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.evo-versions-row-label {
    min-width: 70px;
    text-align: center;
}

.evo-versions-row-msg {
    flex: 1;
}

/* Extra-small button variant */
.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    min-height: 22px;
}

.evo-empty-error {
    color: var(--red);
}

/* ------------------------------------------------------------------ */
/* Phase 5: Skills page                                               */
/* ------------------------------------------------------------------ */
#page-skills {
    flex-direction: column;
    min-height: 0;
    padding: 16px 24px;
    overflow: hidden;
}

.skills-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.skills-search-chrome {
    flex: 0 0 auto;
    margin: 2px 0 12px;
}

.skills-search-chrome[hidden] {
    display: none !important;
}

.skills-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* v5.2.3: redesigned skill card — calmer hierarchy, single status
 * chip, real toggle switch, technical detail collapsed under a
 * disclosure. The previous wall-of-badges design overwhelmed users
 * with developer metadata (NATIVE / PASS / LIVE / ENABLED / GRANT
 * MISSING) competing for attention; this rewrite shows one chip per
 * card and folds everything else into "Show details". */
.skills-card {
    border: 1px solid rgba(250, 250, 250, 0.08);
    border-radius: var(--radius);
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.025);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skills-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.skills-card-title {
    flex: 1 1 auto;
    min-width: 0;
}

.skills-card-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.skills-card-desc {
    margin: 4px 0 0;
    color: rgba(250, 250, 250, 0.65);
    font-size: 13px;
    line-height: 1.45;
}

.skills-card-installed {
    margin-top: 5px;
    font-size: 11.5px;
}

.skills-card-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

/* v5.2.3: single status chip — the "summary verdict" of the skill.
 * Replaces the old badge cluster (NATIVE / PASS / LIVE / ENABLED). */
.skills-status-chip {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.skills-status-chip.is-clickable,
.skills-lock-hint.is-clickable {
    cursor: pointer;
}

.skills-status-chip.is-clickable:hover,
.skills-lock-hint.is-clickable:hover {
    filter: brightness(1.12);
}

.skills-status-ok {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

.skills-status-warn {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

.skills-status-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.skills-status-muted {
    background: rgba(250, 250, 250, 0.06);
    color: rgba(250, 250, 250, 0.65);
    border-color: rgba(250, 250, 250, 0.12);
}

/* v5.2.3: iOS-style on/off toggle switch.
 * Replaces the previous Enable/Disable button so the on/off action
 * uses an affordance everyone recognizes. The native checkbox stays
 * keyboard-accessible; the visible track + thumb is purely
 * decorative (aria-hidden in the markup). The padding around the
 * track grows the click hit area to ~44x44 (WCAG 2.5.5) without
 * changing the visible track size. */
.skills-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 11px 4px;
    margin: -11px -4px;
}

.skills-switch input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
}

.skills-switch-track {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: rgba(250, 250, 250, 0.12);
    transition: background 120ms ease;
}

.skills-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #f8fafc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform 140ms ease, background 120ms ease;
}

.skills-switch input:checked + .skills-switch-track {
    background: #22c55e;
}

.skills-switch input:checked + .skills-switch-track .skills-switch-thumb {
    transform: translateX(18px);
}

.skills-switch input:focus-visible + .skills-switch-track {
    outline: 2px solid rgba(34, 197, 94, 0.6);
    outline-offset: 2px;
}

.skills-switch.is-locked,
.skills-switch input:disabled {
    cursor: not-allowed;
}

.skills-switch.is-locked .skills-switch-track,
.skills-switch input:disabled + .skills-switch-track {
    background: rgba(245, 158, 11, 0.18);
    opacity: 0.7;
}

.skills-switch.is-locked .skills-switch-thumb,
.skills-switch input:disabled + .skills-switch-track .skills-switch-thumb {
    background: rgba(245, 158, 11, 0.85);
}

/* v5.2.3: small inline hint shown right under the toggle when the
 * switch is locked by missing review or grants. Replaces the old
 * full-width "Locked: …" pill that competed with the status chip. */
.skills-lock-hint {
    font-size: 12px;
    color: #fbbf24;
    margin-left: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.skills-lock-hint[role="button"] {
    outline: none;
}

.skills-lock-hint[role="button"]:focus-visible,
.skills-status-chip[role="button"]:focus-visible {
    box-shadow: 0 0 0 2px var(--accent-55);
}

.skills-lock-hint::before {
    content: '\1F512';
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 11px;
}

.skills-review-progress {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(201, 53, 69, 0.24);
    background: var(--accent-08);
    color: rgba(255, 220, 226, 0.86);
    font-size: 12px;
}

.skills-review-spinner {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 220, 226, 0.24);
    border-top-color: rgba(255, 220, 226, 0.9);
    animation: skills-review-spin 900ms linear infinite;
}

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

#skills-refresh.is-loading::after,
#widgets-refresh.is-loading::after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 8px;
    border-radius: 50%;
    border: 2px solid rgba(250, 250, 250, 0.25);
    border-top-color: rgba(250, 250, 250, 0.9);
    animation: skills-review-spin 900ms linear infinite;
    vertical-align: -1px;
}

/* v5.2.3: friendly "Access" panel for skills that need API key grants.
 * Replaces the previous developer-style line "core key grants:
 * requested OPENROUTER_API_KEY; granted none; missing: ..." */
.skills-access {
    border: 1px solid rgba(250, 250, 250, 0.1);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.skills-access-warn {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.06);
}

.skills-access-ok {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.05);
}

.skills-access-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.skills-access-label {
    color: rgba(250, 250, 250, 0.5);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 4px;
}

.skills-access-status {
    color: rgba(250, 250, 250, 0.85);
}

.skills-access-actions {
    margin-top: 4px;
}

.skills-access code {
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 11.5px;
}

/* v5.2.3: collapsed details disclosure — keeps power-user metadata
 * (permissions, runtime info, version drift, provenance, review
 * findings list) one click away without crowding the card. */
.skills-details {
    margin-top: 4px;
    border-top: 1px solid rgba(250, 250, 250, 0.06);
    padding-top: 10px;
}

.skills-details > summary {
    cursor: pointer;
    user-select: none;
    color: rgba(250, 250, 250, 0.55);
    font-size: 12px;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.skills-details > summary::-webkit-details-marker {
    display: none;
}

.skills-details > summary::before {
    content: '\25B8';
    display: inline-block;
    transition: transform 120ms ease;
    font-size: 10px;
}

.skills-details[open] > summary::before {
    transform: rotate(90deg);
}

.skills-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
    font-size: 12.5px;
    color: rgba(250, 250, 250, 0.7);
    padding: 4px 0;
}

.skills-detail-label {
    color: rgba(250, 250, 250, 0.5);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 90px;
}

.skills-detail-row code {
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 11.5px;
}

.skills-card-actions {
    display: flex;
    gap: 8px;
    /* v5.2.3 review-cycle fix: align-items: flex-start so opening the
     * Show details disclosure does not vertically re-center the
     * Review/Update/Uninstall buttons mid-row. */
    align-items: flex-start;
    flex-wrap: wrap;
}

.skills-next-action {
    min-width: 130px;
}

.skills-primary-action {
    min-width: 130px;
}

.skills-card-actions .skills-details {
    margin-top: 0;
    border: none;
    padding: 0;
    margin-left: auto;
}

.skills-card-actions .skills-details > summary {
    /* Match the visual height of the action buttons so summary lines
     * up neatly with Review/Update/Uninstall on closed state. */
    padding: 6px 4px;
}

/* v5.7.0 kebab menu: anchored popover under the trigger (not a centered
   modal). The wrapper is position:relative so the dialog can position:
   absolute inside it under the button. The dialog opens via .show()
   (non-modal) so the rest of the page stays interactive and there is no
   ::backdrop dim. */
.skills-card-menu {
    position: relative;
    display: inline-flex;
}

.skills-card-menu-trigger {
    width: 32px;
    min-height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    font-size: 18px;
    line-height: 1;
    font-family: inherit;
    padding: 0;
}

.skills-card-menu-trigger:hover {
    border-color: rgba(232, 93, 111, 0.30);
    color: var(--text-primary);
}

.skills-card-menu-dialog {
    /* Anchored popover (non-modal). position: absolute relative to the
       wrapper so the menu sits right under the kebab; right: 0 keeps the
       menu's right edge aligned with the trigger's right edge so it
       never overflows the card on the right. */
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    margin: 0;
    min-width: 160px;
    padding: 6px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(18, 20, 26, 0.96);
    color: var(--text-primary);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
    z-index: 50;
}

.skills-menu-item {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    text-align: left;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
}

.skills-menu-item:hover {
    background: var(--accent-10);
    color: var(--text-primary);
}

/* v5.2.3 review-cycle fix: source chip on the card front face for
 * non-built-in skills. Surfaces P1 "Provenance matters" without
 * recreating the old 5-badge cluster: built-in skills carry no chip
 * (absence is the signal); ClawHub/External/User-repo skills get a
 * small inline pill next to the title. */
.skills-source-chip {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
    border: 1px solid transparent;
}

.skills-source-warn {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.25);
}

.skills-source-muted {
    background: rgba(250, 250, 250, 0.05);
    color: rgba(250, 250, 250, 0.55);
    border-color: rgba(250, 250, 250, 0.1);
}

.skills-load-error {
    color: var(--red);
    font-size: 12px;
    margin-bottom: 8px;
}

.skills-badge {
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.skills-badge-ok { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.skills-badge-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.skills-badge-warn { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.skills-badge-muted { background: rgba(250, 250, 250, 0.06); color: rgba(250, 250, 250, 0.55); }

.toast-stack {
    position: fixed;
    right: 18px;
    top: calc(76px + env(safe-area-inset-top));
    z-index: 120;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.toast {
    max-width: min(420px, calc(100vw - 112px));
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(18, 20, 26, 0.94);
    color: var(--text-primary);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    font-size: 13px;
    line-height: 1.45;
    pointer-events: auto;
    cursor: pointer;
    animation: toast-in 160ms ease-out;
}

.toast.is-hiding {
    animation: toast-out 160ms ease-in forwards;
}

.toast-ok { border-color: rgba(34, 197, 94, 0.28); color: #bbf7d0; }
.toast-danger { border-color: rgba(239, 68, 68, 0.35); color: #fecaca; }
.toast-warn { border-color: rgba(245, 158, 11, 0.35); color: #fde68a; }
.toast-muted,
.toast-info { color: rgba(250, 250, 250, 0.78); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(8px); }
}

/* ----- Skills tab navigation (Installed / Marketplace) -----
   Layout/look is inherited from the shared ``.app-tab-strip`` and
   ``.app-tab`` rules above (lines 662-696); ``.skills-tabs`` /
   ``.skills-tab`` previously redeclared the same flex/pill styling
   verbatim. Only the Skills-page-specific spacing override survives. */

.skills-tabs {
    margin-bottom: 14px;
}

.skills-tab-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    padding: 0 6px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
}

.skills-tab-panel {
    margin-top: 4px;
}

/* ----- ClawHub Marketplace shell ----- */

.marketplace-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.marketplace-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.marketplace-search {
    flex: 1 1 240px;
    min-width: 200px;
    height: 36px;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid rgba(250, 250, 250, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: inherit;
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
}

.marketplace-search:focus {
    outline: none;
    border-color: rgba(250, 250, 250, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.marketplace-select,
.marketplace-input {
    padding: 6px 10px;
    border: 1px solid rgba(250, 250, 250, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: inherit;
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
}

.marketplace-input {
    flex: 0 1 220px;
}

.marketplace-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(250, 250, 250, 0.7);
    font-size: 13px;
}

.marketplace-status {
    min-height: 18px;
    font-size: 12px;
}

.marketplace-status[data-tone="ok"] { color: #22c55e; }
.marketplace-status[data-tone="warn"] { color: #f59e0b; }
.marketplace-status[data-tone="danger"] { color: #ef4444; }

.marketplace-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.marketplace-card {
    border: 1px solid rgba(250, 250, 250, 0.08);
    border-radius: var(--radius-lg);
    padding: 14px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.marketplace-card.is-working {
    border-color: rgba(245, 158, 11, 0.35);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(255, 255, 255, 0.02));
    /* v5.7.0: gentle pulsing background so a long install (download +
       adapt + review + deps) reads as actively in progress rather than
       a frozen card. Animation runs only while the card carries the
       is-working class. */
    animation: marketplace-card-pulse 2.4s ease-in-out infinite;
}

@keyframes marketplace-card-pulse {
    0%   { background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(255, 255, 255, 0.02)); }
    50%  { background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(255, 255, 255, 0.04)); }
    100% { background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(255, 255, 255, 0.02)); }
}

/* v5.7.0: marketplace filter row + Official-only toggle (replaces the
   awkward inline native <input type="checkbox"> wedged between the search
   field and the Search button). The toggle visually mirrors the design
   system's switch surface (track + thumb) but uses a real <input> for
   keyboard / a11y. */
.marketplace-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 6px 0 8px;
}

.marketplace-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    user-select: none;
}

.marketplace-filter-toggle input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.marketplace-filter-track {
    width: 36px;
    height: 20px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    flex-shrink: 0;
    transition: background 0.18s ease;
}

.marketplace-filter-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    transition: transform 0.18s ease;
}

.marketplace-filter-toggle input[type="checkbox"]:checked + .marketplace-filter-track {
    background: rgba(232, 93, 111, 0.55);
    border-color: rgba(232, 93, 111, 0.65);
}

.marketplace-filter-toggle input[type="checkbox"]:checked + .marketplace-filter-track::after {
    transform: translateX(16px);
    background: #fff;
}

.marketplace-filter-toggle input[type="checkbox"]:focus-visible + .marketplace-filter-track {
    outline: 2px solid rgba(232, 93, 111, 0.45);
    outline-offset: 2px;
}

.marketplace-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.marketplace-card-title strong {
    font-size: 14px;
    margin-right: 8px;
    display: block;
}

.marketplace-card-title .muted {
    font-size: 12px;
    color: rgba(250, 250, 250, 0.55);
    word-break: break-all;
}

.marketplace-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    align-items: flex-start;
    min-width: 0;
    max-width: 100%;
}

.marketplace-card-body {
    color: rgba(250, 250, 250, 0.8);
    font-size: 13px;
    line-height: 1.45;
    min-height: 38px;
}

.marketplace-card-state {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.marketplace-card-state strong {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.marketplace-working-spinner {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(245, 158, 11, 0.22);
    border-top-color: rgba(245, 158, 11, 0.95);
    animation: skills-review-spin 900ms linear infinite;
}

.marketplace-card-state-hint {
    color: rgba(250, 250, 250, 0.68);
    line-height: 1.45;
}

.marketplace-state-ok {
    border-color: rgba(34, 197, 94, 0.25);
}

.marketplace-state-warn {
    border-color: rgba(245, 158, 11, 0.30);
}

.marketplace-state-danger {
    border-color: rgba(239, 68, 68, 0.30);
}

.marketplace-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: rgba(250, 250, 250, 0.55);
}

.marketplace-card-meta a {
    color: rgba(250, 250, 250, 0.75);
}

.marketplace-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

.marketplace-primary-action .btn {
    width: 100%;
}

.marketplace-secondary-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.marketplace-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 12px;
}

/* ----- Detail modal ----- */

.marketplace-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 90;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4vh 16px;
    overflow-y: auto;
}

.marketplace-modal {
    background: var(--bg, #0e0e10);
    border: 1px solid rgba(250, 250, 250, 0.08);
    border-radius: var(--radius-md);
    padding: 16px;
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.confirm-dialog {
    max-width: 520px;
}

.confirm-dialog .marketplace-modal-body p {
    margin: 0;
    white-space: pre-line;
}

.marketplace-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.marketplace-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 70vh;
    overflow-y: auto;
}

.marketplace-modal-body section h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
}

.marketplace-modal-body section h4 {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: rgba(250, 250, 250, 0.75);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.marketplace-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.marketplace-manifest-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.marketplace-manifest-table th {
    text-align: left;
    width: 30%;
    padding: 4px 8px;
    color: rgba(250, 250, 250, 0.55);
    font-weight: 500;
    vertical-align: top;
}

.marketplace-manifest-table td {
    padding: 4px 8px;
    border-top: 1px solid rgba(250, 250, 250, 0.05);
    word-break: break-word;
}

.marketplace-manifest-table ul {
    margin: 0;
    padding-left: 16px;
}

.marketplace-block-list h4 { color: #ef4444; }
.marketplace-block-list ul { margin: 4px 0 0 0; padding-left: 18px; color: #ef4444; font-size: 12px; }
.marketplace-warn-list h4 { color: #f59e0b; }
.marketplace-warn-list ul { margin: 4px 0 0 0; padding-left: 18px; color: #f59e0b; font-size: 12px; }

.marketplace-file-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: rgba(250, 250, 250, 0.7);
    columns: 2;
}

.marketplace-skillmd {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(250, 250, 250, 0.05);
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    max-height: 280px;
    overflow: auto;
}

/* v5: rendered Markdown body inside the marketplace detail modal.
   Uses the same surface as the plain ``<pre>`` fallback but applies
   typography to make the rendered headings/lists/links readable. */
.marketplace-skillmd-rendered {
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(250, 250, 250, 0.05);
    border-radius: 6px;
    padding: 14px 18px;
    font-size: 13px;
    line-height: 1.55;
    max-height: 360px;
    overflow: auto;
}
.marketplace-skillmd-rendered h1,
.marketplace-skillmd-rendered h2,
.marketplace-skillmd-rendered h3,
.marketplace-skillmd-rendered h4 {
    margin: 14px 0 6px;
    line-height: 1.25;
}
.marketplace-skillmd-rendered h1 { font-size: 18px; }
.marketplace-skillmd-rendered h2 { font-size: 16px; }
.marketplace-skillmd-rendered h3 { font-size: 14px; }
.marketplace-skillmd-rendered h4 { font-size: 13px; color: var(--text-secondary); }
.marketplace-skillmd-rendered p { margin: 6px 0; }
.marketplace-skillmd-rendered ul,
.marketplace-skillmd-rendered ol { padding-left: 22px; margin: 6px 0; }
.marketplace-skillmd-rendered code {
    background: rgba(255, 255, 255, 0.07);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    font-size: 12px;
}
.marketplace-skillmd-rendered pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
}
.marketplace-skillmd-rendered pre code {
    background: transparent;
    padding: 0;
}
.marketplace-skillmd-rendered a {
    color: rgba(232, 93, 111, 0.9);
    text-decoration: underline;
}
.marketplace-skillmd-rendered blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.16);
    margin: 6px 0;
    padding-left: 12px;
    color: var(--text-secondary);
}

/* v5: meta strip inside the marketplace detail modal (version pin
   select + sha snippet + license + homepage link). Items wrap cleanly
   on narrow viewports. */
.marketplace-modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-top: 6px;
}
.marketplace-version-pin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.marketplace-version-pin select {
    background: rgba(26, 21, 32, 0.7);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 12px;
}

/* v5: provenance + adapter-warning rows inside Installed-tab cards. */
.skills-card-provenance {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
}
.skills-card-warnings {
    margin-top: 4px;
    font-size: 12px;
}
.skills-card-warnings summary {
    cursor: pointer;
    user-select: none;
}
.skills-card-warnings ul {
    margin: 6px 0 4px 16px;
    padding: 0;
}

/* v5: native-skill upgrade migration banner — surfaced on the Skills
   tab when the launcher's per-skill version-aware resync replaces an
   installed seeded skill. Operators see the change, can dismiss the
   banner, and can act on stale skill_exec / extension call shapes. */
.skills-migration-banner {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0;
}
.skills-migration-banner-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(232, 165, 53, 0.35);
    background: linear-gradient(135deg, rgba(232, 165, 53, 0.10), rgba(180, 110, 30, 0.06));
}
.skills-migration-banner-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.45;
}
.skills-migration-banner-text strong {
    color: var(--text-primary);
}

/* ------------------------------------------------------------------ */
/* Widgets page                                                       */
/* ------------------------------------------------------------------ */

.skill-widget-weather-form {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.skill-widget-weather-city {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 9px;
    background: rgba(13, 11, 15, 0.74);
    color: var(--text-primary);
    padding: 8px 10px;
    font: inherit;
}

.skill-widget-weather-city:focus {
    outline: 2px solid var(--accent-25);
}

.skill-widget-weather-body[data-state="loading"] {
    opacity: 0.72;
}

.skill-widget-weather-card {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.skill-widget-weather-head {
    font-size: 15px;
}

.skill-widget-weather-temp {
    font-size: 24px;
    font-weight: 700;
    color: rgba(250, 250, 250, 0.95);
}

.skill-widget-weather-cond {
    color: rgba(250, 250, 250, 0.8);
}

.skill-widget-weather-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#page-widgets {
    flex-direction: column;
    min-height: 0;
    padding: 16px 24px;
    overflow: hidden;
}

.widgets-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.widgets-list {
    position: relative;
    margin-top: 16px;
}

.widgets-card {
    position: absolute;
    left: 0;
    top: 0;
    transition: transform 0.18s ease;
    background: rgba(26, 21, 32, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 14px;
    backdrop-filter: blur(12px);
}

.widgets-card-span-2 {
    grid-column: span 2;
}

@media (max-width: 760px) {
    .widgets-card-span-2 {
        grid-column: span 1;
    }
}

.widgets-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
}

.widgets-card-source {
    color: rgba(250, 250, 250, 0.5);
    font-size: 12px;
}

.widgets-frame {
    width: 100%;
    min-height: 320px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    background: rgba(13, 11, 15, 0.88);
}

.widget-form,
.widget-kv,
.widget-markdown,
.widget-json,
.widget-code,
.widget-chart,
.widget-tabs,
.widget-stream,
.widget-media,
.widget-gallery,
.widget-progress {
    margin-top: 10px;
}

.widget-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.widget-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: rgba(250, 250, 250, 0.72);
    font-size: 13px;
}

.widget-field-inline {
    flex-direction: row;
    align-items: center;
}

.widget-field input,
.widget-field textarea,
.widget-field select {
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--radius-sm);
    background: rgba(13, 11, 15, 0.74);
    color: var(--text-primary);
    padding: 8px 10px;
    font: inherit;
}

.widget-kv-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.widget-table-wrap {
    overflow-x: auto;
}

.widget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.widget-table th,
.widget-table td {
    padding: 7px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.widget-media img,
.widget-media video {
    max-width: 100%;
    border-radius: var(--radius);
}

.widget-media audio {
    width: 100%;
}

.widget-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

/* v5.7.0: host-owned map / calendar / kanban renderers. Lightweight
   declarative layouts; Leaflet upgrade for ``.widget-map`` is kept as
   a follow-up integration so the widget surface ships without a new
   third-party dependency in this update. */
.widget-map {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
}
.widget-map-list { margin: 0; padding-left: 18px; font-size: 13px; }
.widget-map-list li { padding: 2px 0; }

.widget-calendar { font-size: 13px; }
.widget-calendar-list { list-style: none; margin: 0; padding: 0; }
.widget-calendar-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.widget-kanban {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 8px;
}
.widget-kanban-col {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 10px;
    min-height: 120px;
}
.widget-kanban-col-head { margin-bottom: 8px; font-size: 12px; color: var(--text-secondary); }
.widget-kanban-card {
    background: rgba(232, 93, 111, 0.12);
    border: 1px solid rgba(232, 93, 111, 0.25);
    border-radius: 6px;
    padding: 6px 8px;
    margin: 4px 0;
    cursor: grab;
    font-size: 12px;
}
.widget-kanban-card:active { cursor: grabbing; }

.widget-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.widget-code pre {
    margin: 0;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.24);
    overflow-x: auto;
}

.widget-code-label {
    color: rgba(250, 250, 250, 0.65);
    font-size: 12px;
    margin-bottom: 6px;
}

.widget-chart {
    min-height: 240px;
}

.widget-tab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.widget-tab-btn {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px 10px;
}

.widget-tab-btn.active {
    border-color: rgba(232, 93, 111, 0.4);
    background: rgba(232, 93, 111, 0.12);
    color: var(--text-primary);
}

/* Mobile overrides — second block, placed AFTER all base rules so media-query
   rules reliably win without !important. Kept scoped to <= 640px so desktop
   is never affected. */
@media (max-width: 640px) {
    /* Input area safe-area inset for iOS notch */
    #chat-input-area {
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    }

    .chat-input-wrap,
    #chat-input {
        min-width: 0;
    }

    /* Header is back to being a floating overlay on mobile (v5.7.0). The
       transcript needs to clear the absolute header (taller on phones
       because action buttons wrap to ~2 rows). Bottom padding clears
       the absolute composer + safe-area. */
    #chat-messages {
        padding-top: 80px;
        padding-bottom: calc(var(--chat-input-reserve, 108px) + env(safe-area-inset-bottom, 0px));
        overflow-x: hidden;
    }

    /* Keyboard-open chat layout: make the document itself no taller than the
       visual viewport, then keep only #chat-messages scrollable. Boundary-aware
       touch handling in web/app.js prevents message overscroll from chaining
       back into page / visualViewport movement on iOS and Android browsers. */
    html.keyboard-open,
    body.keyboard-open {
        position: fixed;
        inset: 0;
        width: 100%;
        height: var(--vvh);
        max-height: var(--vvh);
        overflow: hidden;
        overscroll-behavior: none;
    }

    body.keyboard-open #nav-rail {
        display: none;
    }

    body.keyboard-open #content {
        position: fixed;
        inset: 0;
        height: var(--vvh);
        max-height: var(--vvh);
        padding-left: 0;
        padding-bottom: 0;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body.keyboard-open #page-chat.active {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--vvh);
        max-height: var(--vvh);
        display: flex;
        flex-direction: column;
        z-index: 20;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body.keyboard-open #page-chat.active .chat-page-header {
        flex-shrink: 0;
        position: relative;
    }

    body.keyboard-open #page-chat.active #chat-messages {
        flex: 1;
        min-height: 0;
        position: relative;
        height: auto;
        max-height: none;
        padding-top: 0;
        padding-bottom: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    body.keyboard-open #page-chat.active #chat-input-area {
        flex-shrink: 0;
        position: relative;
        bottom: auto;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    /* Logs page — reduce horizontal padding on filters and entries margin. */
    .logs-filters {
        padding: 8px 12px;
    }

    #log-entries {
        margin: 0 8px 8px;
        min-width: 0;
        overflow-x: hidden;
    }

    /* Updates page — stack version columns and use taller chart area. */
    .evo-versions-cols {
        flex-direction: column;
        gap: 16px;
        overflow: visible;
    }

    .evo-chart-wrap {
        min-height: 260px;
        max-height: none;
        padding: 10px;
    }

    /* Costs page — collapse multi-column grids to single column. */
    .costs-budget-fields {
        grid-template-columns: 1fr;
    }

    .costs-stats-grid {
        grid-template-columns: 1fr;
    }

    .costs-tables-grid {
        grid-template-columns: 1fr;
    }

    .costs-scroll {
        padding: 12px 12px;
    }

    .updates-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .updates-head-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    /* Skills page — reduce padding so cards don't get squeezed. */
    #page-skills {
        padding: 12px 12px;
    }

    .skills-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .skills-card-title {
        width: 100%;
    }

    .skills-card-title h3,
    .skills-card-desc {
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .skills-card-toggle {
        justify-content: flex-start;
        width: 100%;
    }

    .skills-next-action {
        min-width: 0;
        flex: 1 1 150px;
    }

    /* Marketplace controls collapse to single column on phone screens. */
    .marketplace-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .marketplace-search {
        flex: 0 0 auto;
        width: 100%;
    }

    .marketplace-results {
        grid-template-columns: 1fr;
    }

    .marketplace-file-list {
        columns: 1;
    }
}

/* KPA / long markdown in chat — tables and section breaks (oroboro.platikso.ru) */

.chat-bubble.assistant {
    max-width: min(96%, 920px);
    margin-right: 2%;
}

.chat-bubble .message {
    white-space: normal;
}

.chat-bubble .message pre,
.chat-bubble .message code {
    white-space: pre-wrap;
}

.chat-bubble .message .md-hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin: 14px 0;
}

.chat-bubble .message .md-table-wrap {
    margin: 10px 0 14px;
    max-width: 100%;
}

.chat-bubble .message .md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
    line-height: 1.45;
}

.chat-bubble .message .md-table th,
.chat-bubble .message .md-table td {
    vertical-align: top;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.chat-bubble .message .md-table th {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}

.chat-bubble .message .md-table td:first-child,
.chat-bubble .message .md-table th:first-child {
    width: 2.5em;
    text-align: center;
    white-space: nowrap;
}

.chat-bubble .message .md-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Таблица сверки (раздел 6): последняя колонка «Замечание» */
.chat-bubble .message .md-table-sverka th:nth-child(5),
.chat-bubble .message .md-table-sverka td:nth-child(5) {
    min-width: 11rem;
    max-width: 22rem;
}

.chat-bubble .message .md-table-sverka th:nth-child(4),
.chat-bubble .message .md-table-sverka td:nth-child(4) {
    min-width: 10rem;
    max-width: 20rem;
}

.chat-bubble .message .md-table-sverka th:nth-child(1),
.chat-bubble .message .md-table-sverka td:nth-child(1) {
    min-width: 9rem;
    max-width: 14rem;
    text-align: left;
    white-space: normal;
}

.chat-bubble .message .md-h1,
.chat-bubble .message .md-h2,
.chat-bubble .message .md-h3 {
    display: block;
    margin-top: 16px;
    margin-bottom: 8px;
}

/* end KPA tables */

