:root {
    --ink: #0b1420;
    --ink-soft: #1a2838;
    --paper: #eef2f6;
    --line: rgba(11, 20, 32, 0.12);
    --signal: #0f8f6e;
    --signal-deep: #0a6b53;
    --amber: #c9881a;
    --steel: #5a6d82;
    --danger: #b33a3a;
    --glass: rgba(255, 255, 255, 0.78);
    --font-brand: "Syne", sans-serif;
    --font-body: "Figtree", sans-serif;
    --radius: 14px;
    --msg-max: 820px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.atmosphere {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, #b8d4c8 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 0%, #c5d3e3 0%, transparent 50%),
        linear-gradient(165deg, #f5f7fa 0%, #e8eef4 45%, #dde7e2 100%);
}

.atmosphere::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.28;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem 2rem 1.1rem;
    border-bottom: 1px solid var(--line);
    animation: rise 0.55s ease both;
}

.brand {
    margin: 0;
    font-family: var(--font-brand);
    font-weight: 800;
    font-size: clamp(1.85rem, 3.5vw, 2.5rem);
    letter-spacing: -0.03em;
    line-height: 1;
}

.tagline {
    margin: 0.35rem 0 0;
    color: var(--steel);
    font-size: 0.92rem;
}

.top-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.88rem;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.55;
    cursor: wait;
    transform: none;
}

.btn-primary {
    background: var(--ink);
    color: #f4f7fa;
    border-radius: 12px;
    padding: 0.75rem 1.15rem;
}

.btn-primary:hover {
    background: var(--ink-soft);
}

.btn-signal {
    background: var(--signal);
    color: #f4fffb;
}

.btn-signal:hover {
    background: var(--signal-deep);
}

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--ink);
}

.btn-nav {
    background: rgba(255, 255, 255, 0.55);
    border-color: var(--line);
    color: var(--steel);
}

.btn-nav.active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    animation: rise 0.7s 0.05s ease both;
}

.view {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.view.is-active {
    display: flex;
}

.chat-view {
    width: min(880px, 100%);
    margin: 0 auto;
    padding: 0 1rem;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.msg {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    max-width: 100%;
    animation: fade-in 0.35s ease both;
}

.msg.user {
    grid-template-columns: minmax(0, 1fr) 40px;
}

.msg.user .msg-body {
    order: -1;
    justify-self: end;
}

.msg.system {
    grid-template-columns: 1fr;
    justify-items: center;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-family: var(--font-brand);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.avatar.agent {
    background: var(--signal);
    color: #f4fffb;
}

.avatar.you {
    background: var(--ink);
    color: #f2f6fa;
}

.msg-body {
    max-width: min(100%, var(--msg-max));
}

.msg-meta {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.msg.user .msg-meta {
    justify-content: flex-end;
}

.msg-name {
    font-weight: 700;
    font-size: 0.82rem;
}

.msg-time {
    color: var(--steel);
    font-size: 0.72rem;
}

.bubble {
    padding: 0.95rem 1.1rem;
    border-radius: var(--radius);
    word-break: break-word;
    line-height: 1.55;
    font-size: 0.98rem;
}

.msg.user .bubble {
    white-space: pre-wrap;
}

.bubble.md > *:first-child {
    margin-top: 0;
}

.bubble.md > *:last-child {
    margin-bottom: 0;
}

.bubble.md h1,
.bubble.md h2,
.bubble.md h3,
.bubble.md h4 {
    font-family: var(--font-brand);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin: 1rem 0 0.45rem;
}

.bubble.md h1 {
    font-size: 1.2rem;
}

.bubble.md h2,
.bubble.md h3 {
    font-size: 1.05rem;
}

.bubble.md p {
    margin: 0.45rem 0;
}

.bubble.md ul,
.bubble.md ol {
    margin: 0.4rem 0 0.55rem;
    padding-left: 1.25rem;
}

.bubble.md li {
    margin: 0.2rem 0;
}

.bubble.md strong {
    font-weight: 700;
}

.bubble.md table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.65rem 0;
    font-size: 0.86rem;
    display: block;
    overflow-x: auto;
}

.bubble.md th,
.bubble.md td {
    border: 1px solid var(--line);
    padding: 0.45rem 0.55rem;
    text-align: left;
    white-space: nowrap;
}

.bubble.md th {
    background: rgba(11, 20, 32, 0.05);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--steel);
}

.bubble.md hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 0.85rem 0;
}

.bubble.md code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.86em;
    background: rgba(11, 20, 32, 0.06);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

.msg.assistant .bubble {
    background: var(--glass);
    border: 1px solid var(--line);
    backdrop-filter: blur(8px);
    border-top-left-radius: 4px;
    box-shadow: 0 8px 24px rgba(11, 20, 32, 0.04);
}

.msg.user .bubble {
    background: var(--ink);
    color: #f2f6fa;
    border-top-right-radius: 4px;
}

.msg.system .bubble {
    background: transparent;
    border: none;
    color: var(--steel);
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    text-align: center;
}

.msg.typing .bubble {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    min-width: 3.5rem;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--steel);
    animation: bounce 1.1s infinite ease-in-out;
}

.dot:nth-child(2) {
    animation-delay: 0.15s;
}

.dot:nth-child(3) {
    animation-delay: 0.3s;
}

.composer-wrap {
    position: sticky;
    bottom: 0;
    padding: 0 0 1.25rem;
    background: linear-gradient(
        to top,
        rgba(238, 242, 246, 0.96) 55%,
        rgba(238, 242, 246, 0)
    );
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
}

.suggest {
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.suggest:hover {
    background: #fff;
    border-color: var(--signal);
    color: var(--signal-deep);
}

.composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 10px 30px rgba(11, 20, 32, 0.06);
    align-items: end;
}

.composer textarea {
    resize: none;
    font: inherit;
    padding: 0.65rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--ink);
    max-height: 140px;
    line-height: 1.4;
}

.composer textarea:focus {
    outline: none;
}

.quotes-view {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 1.25rem 1rem 1.5rem;
    background: var(--glass);
    backdrop-filter: blur(10px);
}

.quotes-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.toggle-row {
    display: flex;
    gap: 0.4rem;
}

.chip {
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--line);
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    color: var(--steel);
}

.chip.active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.rule-strip {
    margin: 0;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--signal-deep);
    background: rgba(15, 143, 110, 0.1);
    border-left: 3px solid var(--signal);
}

.table-wrap {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.65);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

th,
td {
    text-align: left;
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--steel);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.5);
    position: sticky;
    top: 0;
}

td.price {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.live {
    color: var(--signal-deep);
    background: rgba(15, 143, 110, 0.12);
}

.badge.collect {
    color: #5a4a12;
    background: rgba(201, 136, 26, 0.15);
}

.foot {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 2rem;
    border-top: 1px solid var(--line);
    color: var(--steel);
    font-size: 0.8rem;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@media (max-width: 720px) {
    .top {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.1rem 1rem;
    }

    .chat-view,
    .quotes-view {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .msg,
    .msg.user {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .msg.user .msg-body {
        order: 0;
        justify-self: stretch;
    }

    .msg.user .avatar {
        display: none;
    }

    .msg.user {
        grid-template-columns: 1fr;
    }

    .foot {
        padding: 0.7rem 1rem;
    }
}
