:root {
    --bg-1: #eaf3fa;
    --bg-2: #f7fafc;
    --ink-900: #132b3a;
    --ink-700: #334f61;
    --ink-500: #5a7484;
    --surface: #ffffff;
    --surface-soft: #f4f8fb;
    --edge: #d8e4ec;
    --edge-strong: #c7d7e2;
    --brand: #136f9c;
    --brand-strong: #0f587b;
    --brand-soft: #e4f3fb;
    --signal: #1fb774;
    --warn: #b98f26;
    --shadow-lg: 0 24px 48px rgba(20, 46, 64, 0.16);
    --shadow-md: 0 10px 28px rgba(20, 46, 64, 0.1);
    --focus: 0 0 0 4px rgba(19, 111, 156, 0.2);
}


* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Manrope", sans-serif;
    color: var(--ink-900);
    background:
        radial-gradient(circle at 86% 12%, rgba(19, 111, 156, 0.14), transparent 30%),
        radial-gradient(circle at 12% 88%, rgba(23, 167, 114, 0.12), transparent 32%),
        linear-gradient(160deg, var(--bg-1), var(--bg-2));
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(64, 108, 133, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(64, 108, 133, 0.08) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(circle at center, black 35%, transparent 100%);
}


.workspace {
    min-height: 100vh;
    padding: clamp(0.8rem, 1.6vw, 1.6rem);
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    gap: clamp(0.8rem, 1.2vw, 1.1rem);
    animation: panel-rise 0.45s ease;
}

.info-rail {
    background: linear-gradient(190deg, rgba(255, 255, 255, 0.96), rgba(244, 250, 255, 0.92));
    border: 1px solid var(--edge);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    backdrop-filter: blur(8px);
}

.rail-brand {
    border-radius: 16px;
    padding: 1rem;
    background: linear-gradient(145deg, #f7fcff, #edf5fb);
    border: 1px solid var(--edge);
}

.brand-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 6px rgba(19, 111, 156, 0.15);
}

.brand-kicker {
    margin: 0.8rem 0 0;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    color: var(--brand-strong);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rail-brand h2 {
    margin: 0.2rem 0 0;
    font-size: 1.35rem;
    line-height: 1.15;
}

.rail-brand p {
    margin: 0.5rem 0 0;
    color: var(--ink-500);
    font-size: 0.86rem;
    line-height: 1.45;
}

.rail-card {
    border: 1px solid var(--edge);
    background: var(--surface);
    border-radius: 14px;
    padding: 0.86rem 0.9rem;
}

.rail-card h3 {
    margin: 0;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
}

.rail-card ul {
    margin: 0.55rem 0 0;
    padding-left: 1rem;
    color: var(--ink-700);
    font-size: 0.82rem;
    display: grid;
    gap: 0.3rem;
}

.state {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 0.2rem;
    vertical-align: middle;
}

.state.online {
    background: var(--signal);
    box-shadow: 0 0 0 4px rgba(31, 183, 116, 0.12);
}

.rail-badge-row {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.rail-badge {
    border-radius: 999px;
    border: 1px solid var(--edge-strong);
    background: #f8fcff;
    padding: 0.3rem 0.56rem;
    font-size: 0.72rem;
    color: var(--ink-700);
}

.chat-panel {
    min-width: 0;
    height: min(94vh, 820px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(249, 253, 255, 0.94));
    border: 1px solid var(--edge);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.chat-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.9rem;
    padding: 1.1rem 1.2rem;
    border-bottom: 1px solid var(--edge);
    background:
        linear-gradient(180deg, rgba(19, 111, 156, 0.05), transparent 65%),
        linear-gradient(180deg, #fcfeff, #f7fbfe);
}

.assistant-avatar-wrap {
    position: relative;
}

.assistant-avatar {
    width: 62px;
    height: 62px;
    border-radius: 16px;
    border: 2px solid #fff;
    box-shadow: 0 10px 20px rgba(20, 74, 104, 0.2);
}

.assistant-status {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--signal);
    border: 2px solid #fff;
    animation: pulse 2s infinite;
}

.assistant-meta h1 {
    margin: 0;
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    line-height: 1.1;
}

.assistant-meta p {
    margin: 0.25rem 0 0;
    color: var(--ink-500);
    font-size: 0.9rem;
}

.header-chip {
    justify-self: end;
    border-radius: 999px;
    border: 1px solid var(--edge-strong);
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    padding: 0.45rem 0.6rem;
}


.chat-log {
    padding: 1.15rem 1.2rem;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

.chat-log::-webkit-scrollbar {
    width: 10px;
}

.chat-log::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(27, 99, 134, 0.22);
    border: 2px solid transparent;
    background-clip: content-box;
}

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 0.58rem;
    animation: message-rise 0.25s ease;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.user .message-avatar {
    order: 2;
}

.message-row.user .message-bubble {
    order: 1;
    background: linear-gradient(155deg, var(--brand), var(--brand-strong));
    color: #f5fcff;
    border-color: rgba(8, 76, 107, 0.22);
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid #fff;
    box-shadow: 0 4px 12px rgba(11, 45, 63, 0.15);
}


.message-bubble {
    width: fit-content;
    max-width: min(74ch, 84%);
    background: var(--surface-soft);
    border: 1px solid #dae7f0;
    border-radius: 14px 14px 14px 6px;
    padding: 0.72rem 0.9rem;
    line-height: 1.5;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}


.message-row.user .message-bubble {
    border-radius: 14px 14px 6px 14px;
}

.message-bubble p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.timestamp {
    display: block;
    margin-top: 0.4rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.7rem;
    opacity: 0.72;
}

.message-row.user .timestamp {
    color: rgba(239, 251, 255, 0.86);
}

.typing-bubble {
    min-width: 80px;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.34rem;
    height: 1.1rem;
}

.typing-dots span {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: rgba(18, 99, 138, 0.56);
    animation: dot-blink 1.15s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.chat-footer {
    border-top: 1px solid var(--edge);
    padding: 0.95rem 1.2rem 1.1rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 251, 254, 0.95));
}

.composer {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.composer input {
    flex: 1;
    border-radius: 12px;
    border: 1px solid var(--edge-strong);
    background: #fff;
    color: var(--ink-900);
    padding: 0.8rem 0.9rem;
    font-family: inherit;
    font-size: 0.95rem;
}


.composer input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus);
}

.composer input:disabled {
    opacity: 0.66;
}

.composer button {
    border: 0;
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: #f7fdff;
    background: linear-gradient(140deg, var(--brand), var(--brand-strong));
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.composer button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(16, 82, 114, 0.24);
}

.composer button:disabled {
    opacity: 0.62;
    cursor: wait;
}

.helper-text {
    margin: 0.72rem 0 0;
    font-size: 0.8rem;
    color: var(--ink-500);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .info-rail {
        display: none;
    }

    .chat-panel {
        height: min(96vh, 920px);
    }
}

@media (max-width: 640px) {
    .workspace {
        padding: 0.45rem;
    }

    .chat-panel {
        border-radius: 16px;
        height: 98vh;
    }

    .chat-header,
    .chat-log,
    .chat-footer {
        padding-left: 0.76rem;
        padding-right: 0.76rem;
    }

    .assistant-avatar {
        width: 52px;
        height: 52px;
    }

    .assistant-meta p {
        font-size: 0.82rem;
    }

    .header-chip {
        display: none;
    }

    .message-bubble {
        max-width: 90%;
    }
}

@keyframes panel-rise {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.995);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes message-rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dot-blink {
    0%,
    80%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(31, 183, 116, 0.35);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(31, 183, 116, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(31, 183, 116, 0);
    }
}
