/* Codex-inspired web shell. Keeps OmniSolver functionality, changes hierarchy. */
:root {
    --codex-chrome-h: 0px;
    --codex-sidebar-w: 318px;
    --sidebar-w: var(--codex-sidebar-w);
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.chat-screen {
    position: relative;
    box-sizing: border-box;
    padding-top: var(--codex-chrome-h);
    gap: 0;
    background-color: var(--bg);
}

.sidebar,
.chat-main {
    height: calc(100dvh - var(--codex-chrome-h));
}

:root[data-theme="cosmos"] body .chat-screen,
:root[data-theme="cosmos"] body .chat-main,
:root[data-theme="cosmos"] body .chat-messages {
    background: transparent !important;
}

.codex-webbar {
    display: none !important;
    position: absolute;
    inset: 0 0 auto;
    z-index: 130;
    height: var(--codex-chrome-h);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.codex-webbar-brand,
.codex-webbar-icon,
.codex-webbar-link {
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 0;
    border-radius: 7px;
    color: inherit;
    background: transparent;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: color .15s ease, background .15s ease;
}

.codex-webbar-brand {
    width: 30px;
    margin-right: 4px;
}

.codex-webbar-brand img {
    border-radius: 4px;
    filter: grayscale(.15);
}

.codex-webbar-icon {
    width: 30px;
}

.codex-webbar-link {
    padding: 0 10px;
    font-size: 13px;
}

.codex-webbar-brand:hover,
.codex-webbar-icon:hover,
.codex-webbar-link:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.codex-webbar-spacer {
    flex: 1;
}

.codex-webbar-status {
    padding-right: 6px;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: .02em;
}

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg-sidebar, var(--bg-card)) !important;
    border-right: 0 !important;
    box-shadow: none !important;
}

.sidebar-header {
    min-height: 48px;
    padding: 6px 12px 4px 14px;
    border-bottom: 0;
}

.sidebar-logo {
    gap: 9px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.sidebar-logo img {
    width: 20px;
    height: 20px;
    border-radius: 5px !important;
}

.sidebar-toggle {
    color: var(--text-muted);
    border-radius: 7px;
}

.sidebar-toggle:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.btn-new-chat {
    width: calc(100% - 20px);
    min-height: 38px;
    margin: 2px 10px;
    padding: 0 11px;
    justify-content: flex-start;
    gap: 11px;
    border: 0 !important;
    border-radius: 8px;
    color: var(--text-secondary);
    background: transparent !important;
    font-size: 14px;
    font-weight: 500;
    box-shadow: none !important;
}

.btn-new-chat:hover {
    color: var(--text);
    background: var(--bg-hover) !important;
    transform: none !important;
}

body.light-theme .btn-new-chat {
    color: var(--text-secondary, #3f4658) !important;
    background: transparent !important;
}

body.light-theme .btn-new-chat:hover {
    color: var(--text, #171827) !important;
    background: rgba(15, 23, 42, 0.06) !important;
}

.btn-new-chat > svg {
    width: 18px;
    height: 18px;
    padding: 1px;
    border: 1px solid currentColor;
    border-radius: 5px;
}

.btn-new-chat + div[data-style] {
    padding: 2px 10px 6px !important;
}

.btn-new-chat + div[data-style] .u-relative {
    min-height: 38px;
}

#chat-search {
    height: 38px;
    padding: 0 10px 0 38px !important;
    border: 0 !important;
    border-radius: 8px !important;
    color: var(--text-secondary) !important;
    background: transparent !important;
    font-size: 14px !important;
}

#chat-search::placeholder {
    color: var(--text-secondary);
    opacity: 1;
}

#chat-search:hover,
#chat-search:focus {
    color: var(--text) !important;
    background: var(--bg-hover) !important;
}

.btn-new-chat + div[data-style] svg {
    left: 11px !important;
    width: 18px;
    height: 18px;
    color: var(--text-secondary) !important;
}

.sidebar-section-title {
    padding: 8px 10px 6px !important;
    color: var(--text-muted) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

.sidebar-section {
    order: 2;
    flex: 1 1 auto;
    min-height: 160px;
    padding: 2px 10px 8px;
    overflow-y: auto;
}

.sidebar-chats-title {
    padding-left: 10px !important;
    padding-right: 4px !important;
}

.chat-archive-toggle {
    padding: 3px 7px;
    color: var(--text-muted);
    font-size: 10px;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-group-label {
    padding: 8px 10px 4px !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

.chat-list-item {
    position: relative;
    min-height: 38px;
    padding: 0 38px 0 9px;
    gap: 9px;
    border: 0 !important;
    border-radius: 9px;
    color: var(--text-secondary);
    background: transparent;
    box-shadow: none !important;
}

.chat-list-item:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.chat-list-item.active {
    color: var(--text);
    background: var(--bg-secondary) !important;
}

.chat-list-item .chat-item-icon {
    display: none;
}

.chat-list-item .chat-item-title {
    font-size: 13px;
}

.chat-list-item .chat-item-tokens {
    display: none;
}

.chat-list-item .chat-item-age {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.chat-list-item:hover .chat-item-age {
    opacity: 0;
}

.chat-list-item .chat-item-delete {
    position: absolute;
    right: 6px;
    width: 26px;
    height: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.chat-list-item.chat-item-archived {
    padding-right: 74px;
}

.chat-list-item.chat-item-archived .chat-item-age {
    display: none;
}

.chat-list-item .chat-item-restore {
    position: absolute;
    right: 40px;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    color: var(--text-secondary);
    background: transparent;
    z-index: 2;
}

.chat-list-item .chat-item-restore:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.sidebar-divider {
    order: 8;
    display: none;
}

.sidebar-bottom {
    order: 6;
    flex: 0 0 auto !important;
    position: relative;
    z-index: 1;
    width: auto;
    min-height: auto;
    max-height: none !important;
    box-sizing: border-box;
    display: block;
    overflow: visible !important;
    margin: 0 10px 8px;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg-card) 88%, transparent) !important;
    box-shadow: none;
}

.sidebar-bottom.codex-environment-open {
    display: block;
}

.sidebar-bottom.codex-env-pulse {
    animation: codex-env-pulse .55s ease-out;
}

@keyframes codex-env-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 28%, transparent); }
    100% { box-shadow: 0 0 0 8px transparent; }
}

.codex-environment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 2px 9px;
}

.codex-environment-head > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.codex-environment-kicker {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.codex-environment-head strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

#codex-environment-close {
    display: none;
}

.sidebar-bottom .model-selector {
    margin: 0 0 9px;
}

.sidebar-bottom .model-selector-label {
    color: var(--text-muted);
    font-size: 10px;
}

.sidebar-bottom .model-selector-btn {
    min-height: 40px;
    border-color: var(--border);
    border-radius: 10px;
    background: var(--bg-input);
}

.sidebar-bottom .sidebar-settings {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.sidebar-bottom .setting-toggle {
    min-height: 35px;
    padding: 0 4px;
    border-radius: 8px;
}

.sidebar-bottom .setting-toggle .tog-label {
    min-width: 0;
    gap: 8px;
}

.sidebar-bottom .setting-toggle .tog-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-bottom .setting-toggle:hover {
    background: var(--bg-hover);
}

.sidebar-footer {
    order: 9;
    margin-top: auto;
    padding: 8px 10px 12px;
    border-top: 0;
    background: var(--bg-sidebar, var(--bg-card)) !important;
}

.sidebar-footer .token-bar,
.sidebar-footer .proj-mem-bar,
.sidebar-footer .token-bar-bonus {
    display: none !important;
}

.sub-sidebar-btn,
.sidebar-user {
    min-height: 44px;
    margin: 0;
    padding: 0 10px;
    border: 0 !important;
    border-radius: 8px;
    color: var(--text-secondary);
    background: transparent !important;
}

.sub-sidebar-btn:hover,
.sidebar-user:hover {
    color: var(--text);
    background: var(--bg-hover) !important;
}

.sub-sidebar-btn {
    font-size: 13px;
}

.sub-sidebar-btn .sub-arrow {
    margin-left: auto;
}

.sidebar-user {
    margin-top: 2px;
}

.sidebar-user .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
    border-radius: 8px;
}

.sidebar-user .user-name {
    font-size: 13px;
}

.sidebar-user .user-sub {
    font-size: 11px;
}

.sidebar-profile-arrow {
    flex: 0 0 auto;
    margin-left: auto;
    color: var(--text-muted);
}

.sidebar-resize-grip {
    right: -3px;
    width: 6px;
}

.sidebar-resize-grip::after {
    background: transparent;
}

.chat-main {
    position: relative;
    min-width: 0;
    margin: 0 10px 10px 0;
    overflow: hidden;
    border: 1px solid var(--border-light);
    border-radius: 18px;
    background: var(--bg) !important;
    box-shadow: var(--shadow);
}

.chat-topbar {
    min-height: 54px;
    padding: 0 14px 0 22px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card) !important;
    backdrop-filter: none !important;
}

.chat-topbar-logo {
    display: none;
}

.chat-topbar-title {
    max-width: min(46vw, 620px);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.chat-topbar-model {
    min-height: 28px;
    margin-left: 7px;
    padding: 0 8px;
    border: 0;
    border-radius: 7px;
    color: var(--text-muted);
    background: transparent;
    font-size: 11px;
}

.chat-topbar-model:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.topbar-controls {
    gap: 3px;
}

.topbar-btn,
.codex-environment-btn {
    width: 34px;
    height: 34px;
    border: 0 !important;
    border-radius: 9px;
    color: var(--text-muted);
    background: transparent !important;
}

.topbar-btn:hover,
.codex-environment-btn:hover,
.codex-environment-btn.active {
    color: var(--text);
    background: var(--bg-hover) !important;
}

.resource-chips {
    margin-right: 3px !important;
}

.chat-messages {
    gap: 8px;
    padding: 22px clamp(16px, 2.5vw, 36px) 30px !important;
    background-color: var(--bg) !important;
}

.message {
    width: 100%;
    max-width: 1080px !important;
    margin-left: auto;
    margin-right: auto;
    padding-top: 2px;
    padding-bottom: 2px;
}

.message + .message {
    margin-top: 4px;
}

.message-user + .message-ai,
.message-ai + .message-user {
    margin-top: 7px;
}

.message-user .message-bubble {
    max-width: min(78%, 780px);
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    background: var(--msg-user);
    box-shadow: none;
}

.message-ai .message-bubble,
.message-ai .message-body {
    background: transparent;
    box-shadow: none;
}

.message-content {
    font-size: 15px;
    line-height: 1.68;
}

.chat-welcome {
    max-width: 820px;
    margin: auto;
}

.chat-welcome h2 {
    color: var(--text);
    font-family: Inter, sans-serif;
    font-size: 22px;
    font-weight: 600;
}

.welcome-accent {
    color: var(--text) !important;
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
}

.agent-switcher {
    border-color: var(--border);
    background: var(--bg-card);
    box-shadow: none;
}

.template-card {
    border-color: var(--border);
    border-radius: 12px;
    background: var(--bg-card);
}

.template-card:hover {
    border-color: var(--border-light);
    color: var(--text);
    background: var(--bg-hover);
    transform: none;
}

.chat-input-area {
    padding: 12px clamp(16px, 2.5vw, 36px) 18px !important;
    background: linear-gradient(180deg, transparent, var(--bg) 24%) !important;
}

.chat-input-wrapper {
    width: min(1080px, 100%);
    min-height: 66px;
    margin: 0 auto;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 17px;
    background: var(--bg-input) !important;
    box-shadow: var(--shadow);
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow), var(--shadow);
}

#chat-input {
    min-height: 42px !important;
    padding-top: 9px;
    padding-bottom: 9px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
}

.chat-input-wrapper button {
    color: var(--text-secondary);
}

.chat-input-wrapper button:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.chat-input-wrapper > .context-meter:not(.is-visible) {
    display: none;
}

.chat-input-wrapper > .context-meter.is-visible {
    width: auto;
    min-width: 74px;
    height: 30px;
    gap: 6px;
    padding: 0 9px 0 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-hover);
}

.context-meter-ring {
    width: 22px;
    height: 22px;
}

.context-meter-ring::before {
    inset: 3px;
    background: var(--bg-input);
}

.context-meter-ring > span {
    font-size: 7px;
}

.context-meter-label {
    color: currentColor;
    font-size: 11px;
    font-weight: 600;
}

/* Compact Codex-style activity timeline over the existing persisted tool events. */
.message-events-stream.cli-agent-steps {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.message-events-stream .cli-step-card.osc-tool-stripe {
    border: 0;
    border-radius: 7px;
    background: transparent;
}

.message-events-stream .cli-step-card.osc-tool-stripe:hover {
    border-color: transparent;
    background: var(--bg-hover);
}

.message-events-stream .cli-step-card.osc-tool-stripe > .cli-step-header {
    min-height: 34px;
    padding: 5px 7px;
    gap: 8px;
}

.message-events-stream .cli-step-num,
.message-events-stream .cli-step-dot {
    display: none;
}

.message-events-stream .cli-step-badge {
    flex: 0 0 auto;
    min-width: 76px;
    padding: 0;
    border: 0;
    color: var(--text-muted) !important;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
}

.message-events-stream .cli-step-badge::before {
    content: '';
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 7px;
    vertical-align: -2px;
    border: 1px solid currentColor;
    border-radius: 4px;
    background: var(--bg-card);
}

.message-events-stream .cli-step-running .cli-step-badge::before {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 3px var(--bg-card), inset 0 0 0 7px var(--primary);
}

.message-events-stream .cli-step-done .cli-step-badge::before {
    content: '✓';
    color: var(--success);
    border-color: var(--success);
    background: transparent;
    font-size: 10px;
    line-height: 11px;
    text-align: center;
}

.message-events-stream .cli-step-error .cli-step-badge::before {
    content: '!';
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
    font-size: 10px;
    line-height: 11px;
    text-align: center;
}

.message-events-stream .cli-step-title {
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12.5px;
}

.message-events-stream .cli-step-elapsed {
    color: var(--text-muted);
    font-size: 10px;
}

.message-events-stream .cli-step-chevron {
    color: var(--text-muted);
}

.codex-activity-summary {
    width: fit-content;
    max-width: 100%;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border: 0;
    border-radius: 7px;
    color: var(--text-muted);
    background: transparent;
    font: inherit;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

.codex-activity-summary:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.codex-activity-summary-icon {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    box-sizing: border-box;
    border: 1px solid currentColor;
    border-radius: 4px;
}

.codex-activity-summary-icon::after {
    content: '✓';
    display: block;
    color: var(--success);
    font-size: 10px;
    line-height: 12px;
    text-align: center;
}

.codex-activity-summary.is-running .codex-activity-summary-icon::after {
    content: '';
    width: 5px;
    height: 5px;
    margin: 4px;
    border-radius: 50%;
    background: var(--primary);
}

.codex-activity-summary.has-error .codex-activity-summary-icon::after {
    content: '!';
    color: var(--danger);
}

.codex-activity-summary-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.codex-activity-summary-chevron {
    flex: 0 0 auto;
    font-size: 17px;
    transition: transform .16s ease;
}

.message-events-stream:not(.codex-activity-collapsed) .codex-activity-summary-chevron {
    transform: rotate(90deg);
}

.message-events-stream.codex-activity-collapsed > .cli-step-card,
.message-events-stream.codex-activity-collapsed > .osc-websearch,
.message-events-stream.codex-activity-collapsed > .think-block {
    display: none !important;
}

.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    border-right: 0 !important;
}

.sidebar.collapsed ~ .chat-main {
    margin-left: 10px;
}

@media (max-width: 980px) {
    :root {
        --codex-sidebar-w: 286px;
    }
    .codex-webbar-status {
        display: none;
    }
    .codex-webbar-link {
        padding: 0 7px;
    }
}

@media (max-width: 768px) {
    :root {
        --codex-chrome-h: 0px;
    }
    .chat-screen {
        padding-top: 0;
    }
    .codex-webbar {
        display: none;
    }
    .sidebar {
        width: min(88vw, 318px) !important;
        min-width: min(88vw, 318px) !important;
        border-right: 1px solid var(--border-light) !important;
    }
    .sidebar.collapsed {
        width: 0 !important;
        min-width: 0 !important;
    }
    .chat-main,
    .sidebar.collapsed ~ .chat-main {
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .chat-topbar {
        min-height: 50px;
        padding: 0 8px;
    }
    .chat-topbar-title {
        max-width: 38vw;
        font-size: 13px;
    }
    .chat-topbar-logo {
        display: none;
    }
    .sidebar-bottom {
        position: relative;
        inset: auto;
        width: auto;
        max-height: none;
        margin: 0 10px 8px;
        border-radius: 14px;
    }
    .chat-messages {
        padding: 12px 10px 82px !important;
    }
    .chat-list-item.chat-item-archived {
        padding-right: 74px !important;
    }
    .chat-input-area {
        padding: 8px 8px max(10px, env(safe-area-inset-bottom)) !important;
    }
    .chat-input-wrapper {
        min-height: 58px;
        padding: 8px 9px;
        border-radius: 15px;
    }

    .chat-input-wrapper > .context-meter.is-visible {
        width: 30px !important;
        min-width: 30px;
        padding: 0;
        border-radius: 999px;
    }

    .context-meter-label {
        display: none;
    }

    #chat-input {
        min-height: 38px !important;
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-bottom.codex-environment-open {
        animation: none;
    }
}
