:root {
    --bg: #f4f7ff;
    --sidebar: #0f172a;
    --panel: rgba(255,255,255,0.94);
    --panel-soft: #e2e8f8;
    --text: #111827;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --line: rgba(148,163,184,0.15);
    --accent: #2563eb;
    --primary-blue: #2563eb;
    --accent-purple: #7c3aed;
    --success-color: #16a34a;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --slide-panel-width: min(320px, calc(100vw - 12px));
}

* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background: linear-gradient(180deg, #e2e8f0 0%, #f8fbff 100%);
    color: var(--text);
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    overflow: hidden;
}

button, textarea {
    font: inherit;
}

.app-shell {
    position: relative;
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.slide-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--slide-panel-width);
    max-width: 100vw;
    background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    transition: transform 280ms ease, box-shadow 280ms ease;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.14);
    z-index: 10;
}

.slide-panel.closed {
    transform: translateX(-100%);
}

.panel-toggle {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: #111827;
    color: #ffffff;
    display: grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.22);
    transition: left 280ms ease, transform 280ms ease, background 180ms ease, box-shadow 180ms ease;
    transform-origin: center;
    z-index: 20;
}

.panel-toggle::before {
    content: "";
    display: block;
    width: 7px;
    height: 7px;
    border-right: 2.5px solid #ffffff;
    border-bottom: 2.5px solid #ffffff;
    transform: rotate(-45deg);
    transition: transform 280ms ease;
}

.panel-toggle:hover,
.panel-toggle:focus {
    background: #1f2937;
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.28);
}

.slide-panel.closed + .panel-toggle {
    left: 0;
    transform: translateY(0) rotate(0deg);
}

.slide-panel:not(.closed) + .panel-toggle {
    left: calc(var(--slide-panel-width) - 22px);
    transform: translateY(0) rotate(180deg);
}

.panel-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 28px 20px 24px;
    height: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.panel-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo-image {
    width: 48px;
    height: 48px;
    min-width: 48px;
    object-fit: cover;
    border-radius: 14px;
    background: transparent;
    border: none;
    padding: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.brand {
    font-size: 24px;
    font-weight: 800;
}

.brand-tag {
    margin-top: 4px;
    font-size: 12px;
    color: #94a3b8;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-group-label {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 4px 2px;
    color: #005ac6;
}

.agent-group-label strong {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.agent-group-label span {
    font-size: 9px;
    color: #315d84;
    white-space: nowrap;
}

.panel-action.canonical-agent {
    border-color: rgba(56, 189, 248, 0.2);
    background: linear-gradient(115deg, rgba(14, 165, 233, 0.1), rgba(255, 255, 255, 0.035));
}

.panel-action.canonical-agent strong {
    color: #0057c7;
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: 0.015em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

:root[data-ui-surface="night"] .panel-action.canonical-agent strong,
:root[data-ui-surface="night"] .agent-group-label {
    color: #67d8ff;
    text-shadow: 0 0 16px rgba(0, 183, 255, 0.32);
}

:root[data-ui-surface="night"] .agent-group-label span {
    color: #8ccbec;
}

.panel-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #94a3b8;
}

.panel-action {
    width: 100%;
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: transform 150ms ease, background 150ms ease;
}

.panel-action strong,
.panel-action span {
    display: block;
}

.panel-action strong {
    font-size: 13px;
    line-height: 1.25;
}

.panel-action span {
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
}

.panel-action:hover {
    background: rgba(56,189,248,0.16);
    transform: translateX(4px);
}

.panel-action.active {
    background: rgba(255,255,255,0.04);
    transform: none;
}

.panel-note {
    font-size: 14px;
    line-height: 1.8;
    color: #cbd5e1;
}

.panel-input-section {
    margin-top: auto;
}

.chat-area {
    flex: 1;
    min-height: 90vh;
    display: flex;
    flex-direction: column;
    background: #eff6ff;
    padding: 16px 24px 12px;
    overflow: hidden;
}

.living-state {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    max-width: 100%;
    margin: 0 0 10px auto;
    padding: 9px 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(37, 99, 235, 0.14);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    color: #0f172a;
}

.living-state strong {
    display: block;
    white-space: nowrap;
}

.living-state strong {
    font-size: 12px;
    line-height: 1.2;
}

.living-pulse {
    position: relative;
    width: 10px;
    height: 10px;
    min-width: 10px;
    border-radius: 50%;
    background: #16a34a;
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.42);
    animation: livingPulse 1.8s ease-out infinite;
}

@keyframes livingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.42);
    }
    75% {
        box-shadow: 0 0 0 10px rgba(22, 163, 74, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
    }
}

.chat-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.chat-header h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.05;
}

.chat-header p {
    margin: 10px 0 0;
    max-width: 720px;
    color: #475569;
    font-size: 15px;
}

.chat-window {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    padding: 24px;
    border-radius: 32px;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(241,245,255,0.95));
    border: 1px solid rgba(148,163,184,0.18);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6), 0 22px 50px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    padding-right: 4px;
}

.chat-composer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    padding: 16px 18px;
    border-radius: 28px;
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(148,163,184,0.14);
}

.composer-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-input {
    display: none;
}

.upload-button {
    position: relative;
    flex: 0 0 48px;
    align-self: center;
    box-sizing: border-box;
    appearance: none;
    padding: 0;
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #0f172a;
    color: #ffffff;
    display: block;
    cursor: pointer;
    box-shadow: 0 14px 26px rgba(15, 23, 42, 0.18);
    transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.upload-button::before,
.upload-button::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #ffffff;
    transform: translate(-50%, -50%);
}

.upload-button::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.upload-button:hover,
.upload-button:focus {
    background: #1f2937;
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(15, 23, 42, 0.22);
}

.chat-composer .composer-input {
    flex: 1;
    min-height: 70px;
    max-height: 100px;
    resize: none;
    padding: 16px 18px;
    border-radius: 22px;
    border: 1px solid rgba(148,163,184,0.18);
    background: #f8fbff;
    color: #0f172a;
    font-size: 15px;
    line-height: 1.6;
}

.chat-composer .send-button {
    position: relative;
    flex: 0 0 48px;
    align-self: center;
    box-sizing: border-box;
    appearance: none;
    margin: 0;
    padding: 0;
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: transparent;
    cursor: pointer;
    display: block;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.25);
    transition: transform 180ms ease, background 180ms ease;
}

.chat-composer .send-button::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 17px;
    height: 18px;
    background: #ffffff;
    clip-path: polygon(10% 3%, 92% 50%, 10% 97%);
    transform: translate(-43%, -50%);
}

.chat-composer .send-button:hover,
.chat-composer .send-button:focus {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.panel-input-section {
    display: none;
}

.message {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    width: 100%;
}

.message-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e2e8f0;
    color: #111827;
    font-weight: 800;
    flex-shrink: 0;
}

.assistant-message .message-avatar {
    overflow: hidden;
    background: #020617;
    border: 1px solid rgba(245, 158, 11, 0.55);
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.26);
}

.message-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.message-content {
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #64748b;
    margin-bottom: 8px;
    font-size: 12px;
}

.message-header strong {
    color: #0f172a;
    font-size: 14px;
}

.message-text {
    font-size: 14px;
    line-height: 1.7;
    color: #1f2937;
    background: #f8fbff;
    border: 1px solid rgba(148,163,184,0.12);
    border-radius: 22px;
    padding: 16px;
    white-space: pre-wrap;
}

.user-message .message-text {
    background: #0f172a;
    color: #f8fafc;
}

.system-message .message-text {
    background: rgba(59,130,246,0.1);
}

.composer-input {
    width: 100%;
    min-height: 140px;
    resize: none;
    border: 1px solid rgba(148,163,184,0.15);
    border-radius: 24px;
    background: #f8fbff;
    color: #0f172a;
    padding: 18px;
    outline: none;
    font-size: 15px;
    line-height: 1.7;
}

.composer-input::placeholder {
    color: #94a3b8;
}

.send-button {
    width: 100%;
    padding: 16px 18px;
    border-radius: 20px;
    border: none;
    background: #2563eb;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 12px;
}

.action-btn {
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 1160px) {
    .app-shell {
        flex-direction: row;
    }
    .slide-panel {
        width: var(--slide-panel-width);
        min-width: 0;
        transform: translateX(0);
        position: absolute;
        z-index: 10;
    }
    .slide-panel.closed {
        transform: translateX(-100%);
    }
    .panel-toggle {
        position: fixed;
        left: 4px;
        top: 4px;
        bottom: auto;
    }
    .slide-panel.closed + .panel-toggle,
    .slide-panel:not(.closed) + .panel-toggle {
        left: 4px;
        top: 4px;
    }
    .chat-area {
        width: 100%;
        min-height: 0;
        height: 100dvh;
        max-height: 100dvh;
        padding: 22px;
    }
}

@media (max-width: 760px) {
    .chat-header {
        flex-direction: column;
        gap: 14px;
    }
    .chat-window {
        min-height: 0;
        padding: 18px;
        border-radius: 24px;
    }
    .chat-area {
        height: 100dvh;
        max-height: 100dvh;
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    }
    .living-state {
        width: fit-content;
        margin: 0 0 8px auto;
        border-radius: 999px;
    }
    .chat-composer {
        flex: 0 0 auto;
        margin-top: 8px;
        padding: 8px;
        border-radius: 22px;
    }
    .composer-row {
        gap: 8px;
    }
    .upload-button,
    .chat-composer .send-button {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
    .chat-composer .composer-input {
        height: 48px;
        min-height: 48px;
        max-height: 96px;
        padding: 11px 14px;
        line-height: 1.35;
    }
}

@media (max-width: 340px) {
    .chat-area {
        padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    }
    .chat-window {
        padding: 12px;
        border-radius: 18px;
    }
    .chat-composer {
        margin-top: 6px;
        padding: 6px;
    }
    .composer-row {
        gap: 6px;
    }
    .upload-button,
    .chat-composer .send-button {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    .chat-composer .composer-input {
        min-width: 0;
        padding: 12px;
    }
}

.brand {
    font-size: 24px;
    font-weight: 800;
}

.brand-tag {
    margin-top: 4px;
    font-size: 12px;
    color: #94a3b8;
}

.nav-group {
    display: grid;
    gap: 10px;
}

.nav-item,
.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(148,163,184,0.12);
    color: inherit;
    cursor: pointer;
    transition: background 150ms ease, transform 150ms ease;
}

.nav-item:hover,
.chat-item:hover {
    background: rgba(148,163,184,0.12);
    transform: translateY(-1px);
}

.nav-item.active,
.chat-item.active {
    background: rgba(56,189,248,0.16);
    border-color: rgba(56,189,248,0.4);
}

.nav-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
}

.section-label {
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    margin-top: 14px;
}

.chat-list {
    display: grid;
    gap: 10px;
    overflow: auto;
}

.chat-item span:last-child {
    color: #cbd5e1;
    font-size: 12px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(148,163,184,0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.footer-subtitle {
    color: #94a3b8;
    font-size: 12px;
}

.workspace {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    padding: 24px 24px 0;
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding-bottom: 24px;
}

.workspace-header h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.05;
}

.workspace-header p {
    margin: 10px 0 0;
    max-width: 620px;
    color: #475569;
    font-size: 15px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(56,189,248,0.18);
    background: rgba(56,189,248,0.12);
    color: #0ea5e9;
    font-weight: 700;
    font-size: 12px;
}

.status-pill.active {
    background: rgba(34,197,94,0.12);
    border-color: rgba(34,197,94,0.18);
    color: #16a34a;
}

.action-btn,
.panel-actions button {
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.action-btn:hover,
.panel-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 22px rgba(37,99,235,0.22);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.metric-card {
    padding: 28px;
    border-radius: 28px;
    background: var(--panel);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(148,163,184,0.12);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.metric-label {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
}

.metric-value {
    font-size: 44px;
    font-weight: 800;
    color: #0f172a;
}

.metric-note {
    color: #475569;
    font-size: 14px;
    line-height: 1.7;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    margin-bottom: 24px;
}

.main-panel {
    display: grid;
    gap: 22px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.panel-header h2 {
    margin: 0;
    font-size: 22px;
}

.panel-header p {
    margin: 8px 0 0;
    color: #475569;
    max-width: 620px;
    font-size: 14px;
    line-height: 1.7;
}

.chat-card,
.panel-card {
    background: var(--panel);
    border: 1px solid rgba(148,163,184,0.14);
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
}

.chat-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
}

.message {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e2e8f0;
    color: #111827;
    font-weight: 800;
    flex-shrink: 0;
}

.message-content {
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #64748b;
    margin-bottom: 8px;
    font-size: 13px;
}

.message-header strong {
    color: #0f172a;
    font-size: 14px;
}

.message-text {
    font-size: 14px;
    line-height: 1.7;
    color: #1f2937;
    background: #f8fbff;
    border: 1px solid rgba(148,163,184,0.12);
    border-radius: 22px;
    padding: 16px;
    white-space: pre-wrap;
}

.user-message .message-text {
    background: #0f172a;
    color: #f8fafc;
}

.message.system-message .message-text {
    background: rgba(59,130,246,0.08);
}

.composer-shell {
    padding-bottom: 16px;
}

.composer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px;
}

.composer-input {
    width: 100%;
    min-height: 100px;
    resize: none;
    border: 1px solid rgba(148,163,184,0.15);
    border-radius: 24px;
    background: #f8fbff;
    color: #0f172a;
    padding: 18px;
    outline: none;
    font-size: 15px;
    line-height: 1.7;
}

.composer-input::placeholder {
    color: #94a3b8;
}

.composer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.composer-left,
.composer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.composer-icon,
.composer-pill {
    border: none;
    border-radius: 16px;
    padding: 12px 14px;
    background: #eff6ff;
    color: #0f172a;
    cursor: pointer;
}

.composer-mode {
    color: #64748b;
    font-size: 13px;
}

/* H11I adaptive sky-glass interface */
:root {
    --ui-accent: #008cff;
    --ui-glow-rgb: 0, 174, 255;
    --ui-glass-opacity: 0.72;
    --ui-text-scale: 1;
    --ui-space: 1;
    --ui-ink: #073b78;
    --ui-ink-soft: #34668f;
    --ui-glass: rgba(244, 252, 255, var(--ui-glass-opacity));
    --ui-glass-soft: rgba(224, 246, 255, calc(var(--ui-glass-opacity) * 0.72));
    --ui-line: rgba(103, 200, 255, 0.42);
    --ui-shadow: 0 24px 70px rgba(14, 111, 185, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.88);
    --slide-panel-width: min(340px, calc(100vw - 16px));
}

:root[data-ui-density="compact"] { --ui-space: 0.78; }
:root[data-ui-density="spacious"] { --ui-space: 1.18; }

html,
body {
    min-height: 100%;
    background: #dff5ff;
    color: var(--ui-ink);
    font-family: "Manrope", sans-serif;
    font-size: calc(16px * var(--ui-text-scale));
}

body::before,
body::after {
    content: "";
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(10px);
    opacity: 0.9;
    z-index: 0;
}

body::before {
    width: 58vw;
    height: 58vw;
    left: -18vw;
    top: -28vw;
    background: radial-gradient(circle, rgba(29, 178, 255, 0.62), rgba(115, 218, 255, 0.12) 56%, transparent 72%);
    animation: skyDrift 16s ease-in-out infinite alternate;
}

body::after {
    width: 54vw;
    height: 54vw;
    right: -20vw;
    bottom: -30vw;
    background: radial-gradient(circle, rgba(0, 113, 255, 0.42), rgba(107, 223, 255, 0.12) 58%, transparent 72%);
    animation: skyDrift 19s ease-in-out infinite alternate-reverse;
}

@keyframes skyDrift {
    from { transform: translate3d(0, -1.5%, 0) scale(0.96); }
    to { transform: translate3d(4%, 3%, 0) scale(1.08); }
}

.app-shell {
    position: relative;
    z-index: 1;
    isolation: isolate;
    background:
        linear-gradient(rgba(255,255,255,0.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.12) 1px, transparent 1px),
        linear-gradient(145deg, rgba(217, 246, 255, 0.68), rgba(192, 232, 255, 0.46));
    background-size: 44px 44px, 44px 44px, auto;
}

.chat-area {
    min-height: 0;
    height: 100dvh;
    padding: 16px 20px 118px;
    background: transparent;
}

.interface-rail {
    position: relative;
    z-index: 4;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.living-state {
    min-height: 38px;
    margin: 0;
    padding: 9px 14px;
    border: 1px solid rgba(104, 203, 255, 0.48);
    border-radius: 999px;
    background: rgba(239, 251, 255, 0.62);
    color: #006dd6;
    box-shadow: 0 12px 32px rgba(0, 126, 209, 0.12), inset 0 1px 0 rgba(255,255,255,0.9);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.living-pulse {
    background: #00b8ff;
    box-shadow: 0 0 16px rgba(0, 184, 255, 0.82);
}

.chat-window {
    min-height: 0;
    padding: calc(24px * var(--ui-space));
    border: 1px solid var(--ui-line);
    border-radius: 34px;
    background: linear-gradient(145deg, var(--ui-glass), var(--ui-glass-soft));
    box-shadow: var(--ui-shadow);
    backdrop-filter: blur(30px) saturate(165%);
    -webkit-backdrop-filter: blur(30px) saturate(165%);
}

.messages-container {
    gap: calc(18px * var(--ui-space));
    padding: 4px 6px 28px;
    scrollbar-color: rgba(var(--ui-glow-rgb), 0.42) transparent;
}

.message {
    gap: 13px;
    animation: messageArrival 420ms cubic-bezier(.2,.8,.2,1) both;
}

@keyframes messageArrival {
    from { opacity: 0; transform: translateY(10px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message-header,
.message-header strong,
.response-main {
    color: var(--ui-ink);
}

.message-header strong,
.brand,
.panel-title {
    font-family: "Space Grotesk", sans-serif;
}

.message-header strong,
.brand {
    color: var(--ui-accent);
    text-shadow: 0 0 18px rgba(var(--ui-glow-rgb), 0.34);
}

.message-text {
    max-width: min(820px, 100%);
    padding: calc(16px * var(--ui-space));
    border: 1px solid rgba(107, 200, 255, 0.38);
    border-radius: 8px 24px 24px 24px;
    background: rgba(246, 253, 255, 0.58);
    color: var(--ui-ink);
    box-shadow: 0 12px 34px rgba(23, 119, 178, 0.09), inset 0 1px 0 rgba(255,255,255,0.9);
    backdrop-filter: blur(20px) saturate(145%);
    -webkit-backdrop-filter: blur(20px) saturate(145%);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-message .message-text {
    border-radius: 24px 8px 24px 24px;
    border-color: rgba(101, 213, 255, 0.52);
    background: linear-gradient(135deg, rgba(0, 119, 255, 0.88), rgba(0, 192, 255, 0.78));
    color: #ffffff;
    box-shadow: 0 16px 38px rgba(var(--ui-glow-rgb), 0.28);
}

.message-avatar {
    width: 40px;
    height: 40px;
    color: #0075e8;
    background: rgba(239, 251, 255, 0.76);
    border: 1px solid rgba(94, 198, 255, 0.48);
    box-shadow: 0 8px 22px rgba(0, 123, 205, 0.14);
}

.assistant-message .message-avatar {
    border-color: rgba(0, 174, 255, 0.68);
    box-shadow: 0 0 22px rgba(var(--ui-glow-rgb), 0.32);
}

.chat-composer {
    position: fixed;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 30;
    width: min(880px, calc(100vw - 28px));
    margin: 0;
    padding: 10px;
    border: 1px solid rgba(92, 201, 255, 0.58);
    border-radius: 30px;
    background: rgba(234, 249, 255, 0.68);
    box-shadow: 0 24px 70px rgba(0, 104, 196, 0.22), inset 0 1px 0 rgba(255,255,255,0.94);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    transform: translateX(-50%);
}

.composer-row { gap: 10px; }

.chat-composer .composer-input {
    min-height: 58px;
    height: 58px;
    max-height: 140px;
    padding: 17px 20px;
    border: 1px solid rgba(104, 198, 255, 0.42);
    border-radius: 22px;
    outline: none;
    background: rgba(250, 254, 255, 0.58);
    color: #005bb8;
    box-shadow: inset 0 1px 8px rgba(31, 137, 195, 0.06);
    overflow-y: auto;
    scrollbar-width: none;
}

.chat-composer .composer-input::-webkit-scrollbar { display: none; }

.chat-composer .composer-input:focus {
    border-color: var(--ui-accent);
    box-shadow: 0 0 0 4px rgba(var(--ui-glow-rgb), 0.11), inset 0 1px 8px rgba(31, 137, 195, 0.06);
}

.composer-input::placeholder { color: rgba(0, 91, 184, 0.48); }

.upload-button,
.chat-composer .send-button {
    flex-basis: 50px;
    width: 50px;
    height: 50px;
    min-width: 50px;
    border: 1px solid rgba(111, 218, 255, 0.64);
    background: linear-gradient(145deg, #0074ff, #00bfff);
    box-shadow: 0 12px 30px rgba(var(--ui-glow-rgb), 0.32), inset 0 1px 0 rgba(255,255,255,0.38);
}

.upload-button:hover,
.upload-button:focus,
.chat-composer .send-button:hover,
.chat-composer .send-button:focus {
    background: linear-gradient(145deg, #0066ee, #00aeea);
    box-shadow: 0 16px 36px rgba(var(--ui-glow-rgb), 0.42), 0 0 22px rgba(var(--ui-glow-rgb), 0.22);
}

.slide-panel {
    border-right: 1px solid rgba(99, 202, 255, 0.45);
    background: linear-gradient(160deg, rgba(229, 248, 255, 0.82), rgba(190, 231, 255, 0.7));
    color: var(--ui-ink);
    box-shadow: 28px 0 70px rgba(0, 105, 183, 0.18), inset -1px 0 0 rgba(255,255,255,0.7);
    backdrop-filter: blur(34px) saturate(170%);
    -webkit-backdrop-filter: blur(34px) saturate(170%);
}

.panel-brand {
    padding: 10px;
    border: 1px solid rgba(110, 205, 255, 0.35);
    border-radius: 22px;
    background: rgba(247, 253, 255, 0.4);
}

.brand-tag,
.panel-title,
.panel-action span,
.panel-note { color: var(--ui-ink-soft); }

.panel-action {
    border-color: rgba(102, 198, 255, 0.32);
    background: rgba(243, 252, 255, 0.42);
    color: var(--ui-ink);
}

.panel-action:hover,
.panel-action.active {
    border-color: rgba(var(--ui-glow-rgb), 0.58);
    background: rgba(219, 245, 255, 0.72);
    box-shadow: 0 10px 28px rgba(var(--ui-glow-rgb), 0.12);
}

.panel-toggle {
    top: 10px;
    left: 10px;
    border: 1px solid rgba(128, 219, 255, 0.72);
    background: linear-gradient(145deg, #006eff, #00b9f5);
    box-shadow: 0 10px 28px rgba(var(--ui-glow-rgb), 0.32);
}

:root[data-ui-surface="night"] {
    --ui-ink: #d9f6ff;
    --ui-ink-soft: #8ccbec;
    --ui-glass: rgba(5, 32, 60, var(--ui-glass-opacity));
    --ui-glass-soft: rgba(1, 54, 88, calc(var(--ui-glass-opacity) * 0.72));
    --ui-line: rgba(49, 186, 255, 0.38);
}

:root[data-ui-surface="night"] body { background: #031528; }
:root[data-ui-surface="night"] .app-shell { background-color: #031b30; background-blend-mode: soft-light; }
:root[data-ui-surface="night"] .slide-panel { background: rgba(3, 27, 49, 0.88); }
:root[data-ui-surface="night"] .message-text,
:root[data-ui-surface="night"] .chat-composer .composer-input,
:root[data-ui-surface="night"] .living-state { background: rgba(5, 42, 70, 0.68); color: #ccefff; }

:root[data-ui-motion="off"] *,
:root[data-ui-motion="off"] *::before,
:root[data-ui-motion="off"] *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
}

@media (max-width: 760px) {
    .chat-area { padding: 10px 10px 102px; }
    .interface-rail { margin: 0 4px 8px 34px; gap: 7px; }
    .living-state { min-height: 32px; padding: 7px 10px; font-size: 10px; }
    .chat-window { padding: calc(15px * var(--ui-space)); border-radius: 26px; }
    .chat-composer {
        bottom: max(8px, env(safe-area-inset-bottom));
        width: calc(100vw - 16px);
        padding: 7px;
        border-radius: 24px;
    }
    .chat-composer .composer-input { min-width: 0; height: 50px; min-height: 50px; padding: 13px 14px; }
    .upload-button,
    .chat-composer .send-button { flex-basis: 44px; width: 44px; height: 44px; min-width: 44px; }
    .message-text { max-width: 100%; }
}

@media (max-width: 390px) {
    .chat-area { padding: 8px 8px 94px; }
    .composer-row { gap: 6px; }
    .chat-composer .composer-input { padding-inline: 12px; }
}

.send-button {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.power-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.power-value {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border-radius: 20px;
    background: rgba(59,130,246,0.08);
    border: 1px solid rgba(59,130,246,0.16);
}

.power-value span {
    font-size: 32px;
    font-weight: 800;
}

.power-value small {
    color: #475569;
    font-size: 13px;
}

.panel-badge {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(34,197,94,0.12);
    color: #166534;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 18px;
}

.panel-section {
    display: grid;
    gap: 12px;
}

.panel-empty {
    color: #64748b;
    font-size: 14px;
    line-height: 1.7;
}

.panel-note {
    color: #475569;
}

.right-sidebar {
    display: grid;
    gap: 18px;
    padding: 0;
}

@media (max-width: 1160px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar,
    .right-sidebar {
        display: none;
    }
    .workspace {
        padding: 24px;
    }
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .workspace {
        padding: 18px;
    }
    .metrics-grid,
    .content-grid {
        gap: 16px;
    }
    .composer {
        padding: 18px;
    }
    .chat-card,
    .metric-card,
    .panel-card {
        border-radius: 24px;
    }
}

/* H11-BIVERSE preview and download controls */
.response-media-preview {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(95, 203, 255, 0.5);
    border-radius: 22px;
    background: rgba(3, 34, 62, 0.82);
    cursor: zoom-in;
    box-shadow: 0 18px 42px rgba(var(--ui-glow-rgb), 0.2);
}

.response-media-preview img {
    transition: transform 300ms ease, filter 300ms ease;
}

.response-media-preview:hover img {
    transform: scale(1.015);
    filter: saturate(1.06);
}

.response-media figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.response-media-actions {
    display: flex;
    gap: 8px;
}

.media-action {
    min-height: 34px;
    padding: 7px 13px;
    border: 1px solid rgba(80, 194, 255, 0.5);
    border-radius: 999px;
    background: rgba(234, 249, 255, 0.72);
    color: #006bd6;
    font-family: "Space Grotesk", sans-serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(var(--ui-glow-rgb), 0.12);
}

.media-action:hover,
.media-action:focus-visible {
    border-color: var(--ui-accent);
    background: #ffffff;
    box-shadow: 0 0 22px rgba(var(--ui-glow-rgb), 0.22);
}

.media-download {
    border-color: transparent;
    background: linear-gradient(135deg, #006eff, #00b8f5);
    color: #ffffff;
}

.image-preview-dialog {
    width: min(1120px, calc(100vw - 28px));
    max-width: none;
    height: min(88dvh, 900px);
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(90, 202, 255, 0.58);
    border-radius: 30px;
    background: rgba(222, 246, 255, 0.78);
    color: var(--ui-ink);
    box-shadow: 0 34px 100px rgba(0, 73, 145, 0.38), inset 0 1px 0 rgba(255,255,255,0.9);
    backdrop-filter: blur(36px) saturate(175%);
    -webkit-backdrop-filter: blur(36px) saturate(175%);
}

.image-preview-dialog::backdrop {
    background: rgba(0, 31, 61, 0.64);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.image-preview-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
}

.image-preview-header,
.image-preview-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-color: rgba(93, 199, 255, 0.34);
    background: rgba(244, 252, 255, 0.62);
}

.image-preview-header { border-bottom: 1px solid rgba(93, 199, 255, 0.34); }
.image-preview-footer { border-top: 1px solid rgba(93, 199, 255, 0.34); }

.image-preview-header > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.image-preview-header strong {
    color: var(--ui-accent);
    font-family: "Space Grotesk", sans-serif;
    text-shadow: 0 0 18px rgba(var(--ui-glow-rgb), 0.3);
}

.image-preview-header span,
.image-preview-footer span {
    color: var(--ui-ink-soft);
    font-size: 12px;
}

.image-preview-close {
    position: relative;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid rgba(83, 192, 255, 0.52);
    border-radius: 50%;
    background: rgba(241, 251, 255, 0.72);
    cursor: pointer;
}

.image-preview-close::before,
.image-preview-close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: var(--ui-accent);
    transform: translate(-50%, -50%) rotate(45deg);
}

.image-preview-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.image-preview-stage {
    display: grid;
    place-items: center;
    min-height: 0;
    padding: 18px;
    overflow: auto;
    background: radial-gradient(circle at 50% 40%, rgba(0, 162, 255, 0.14), rgba(0, 28, 54, 0.88));
}

.image-preview-stage img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border-radius: 18px;
    box-shadow: 0 22px 64px rgba(0, 12, 29, 0.38);
}

:root[data-ui-surface="night"] .image-preview-dialog,
:root[data-ui-surface="night"] .image-preview-header,
:root[data-ui-surface="night"] .image-preview-footer {
    background: rgba(3, 32, 56, 0.88);
}

@media (max-width: 760px) {
    .response-media figcaption {
        align-items: flex-start;
        flex-direction: column;
    }
    .image-preview-dialog {
        width: calc(100vw - 16px);
        height: calc(100dvh - 24px);
        border-radius: 24px;
    }
    .image-preview-header,
    .image-preview-footer { padding: 11px 13px; }
    .image-preview-footer span { max-width: 54%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
