:root {
    color-scheme: light;
    --navy: #102742;
    --navy-2: #173b62;
    --blue: #1d69a7;
    --cyan: #2c9dd0;
    --gold: #f2b544;
    --ink: #172437;
    --muted: #66758a;
    --line: #d9e2ec;
    --surface: #ffffff;
    --soft: #f4f7fa;
    --success: #177245;
    --danger: #b42318;
    --shadow: 0 20px 60px rgba(16, 39, 66, .16);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 10%, rgba(44, 157, 208, .2), transparent 30rem),
        linear-gradient(145deg, #0d2139, #173b62 55%, #0d2139);
}

button, input, textarea, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

.chat-shell {
    width: min(1180px, 100%);
    height: 100dvh;
    margin: 0 auto;
    background: var(--surface);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat-header {
    min-height: 78px;
    padding: 14px clamp(16px, 3vw, 32px);
    color: white;
    background: linear-gradient(120deg, var(--navy), var(--navy-2));
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 3px solid var(--gold);
}

.brand-mark {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--navy);
    background: linear-gradient(145deg, #fff, #dbeefa);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .08em;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
}

.brand-copy { min-width: 0; }
.brand-title-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-copy h1, .chat-header h1 { margin: 0; font-size: clamp(18px, 2.4vw, 25px); line-height: 1.1; }
.brand-copy p, .chat-header p { margin: 4px 0 0; color: #bdd8eb; font-size: 13px; }
.header-version { color: #bdd8eb; font-size: 11px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-button {
    color: white;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 999px;
    padding: 8px 12px;
    text-decoration: none;
    cursor: pointer;
}

.text-button:hover, .text-button:focus-visible { background: rgba(255, 255, 255, .12); }

.icon-button {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    color: var(--navy);
    background: var(--gold);
    font-size: 23px;
    cursor: pointer;
}

.messages {
    overflow-y: auto;
    padding: clamp(20px, 4vw, 42px);
    background:
        linear-gradient(rgba(255,255,255,.88), rgba(255,255,255,.94)),
        radial-gradient(circle at 80% 25%, rgba(44, 157, 208, .14), transparent 25rem);
    scroll-behavior: smooth;
}

.message {
    width: min(820px, 88%);
    margin: 0 0 22px;
    animation: rise .22s ease-out;
}

.message.user { margin-left: auto; }

.message-label {
    margin: 0 10px 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message.user .message-label { text-align: right; }

.message-body {
    padding: 15px 18px;
    border: 1px solid var(--line);
    border-radius: 7px 20px 20px 20px;
    background: white;
    line-height: 1.55;
    box-shadow: 0 7px 22px rgba(25, 55, 87, .08);
    overflow-wrap: anywhere;
}

.message.user .message-body {
    color: white;
    border-color: var(--blue);
    border-radius: 20px 7px 20px 20px;
    background: linear-gradient(145deg, var(--blue), var(--navy-2));
}

.message-media {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.message-media img {
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    border-radius: 12px;
    background: var(--soft);
}

.bullet { color: var(--blue); font-weight: 900; }

.suggestions {
    padding: 8px clamp(12px, 3vw, 28px) 12px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background: white;
    scrollbar-width: thin;
}

.suggestions button {
    flex: 0 0 auto;
    color: var(--navy-2);
    background: var(--soft);
    border: 1px solid #bfd0df;
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
    transition: transform .15s, border-color .15s, background .15s;
}

.suggestions button:hover, .suggestions button:focus-visible {
    transform: translateY(-1px);
    border-color: var(--blue);
    background: #eaf5fb;
}

.composer {
    padding: 12px clamp(12px, 3vw, 28px) max(12px, env(safe-area-inset-bottom));
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-top: 1px solid var(--line);
    background: white;
}

.composer-center {
    flex: 1;
    min-width: 0;
    border: 1px solid #b7c8d8;
    border-radius: 18px;
    background: var(--soft);
    overflow: hidden;
}

.composer textarea {
    width: 100%;
    min-height: 48px;
    max-height: 160px;
    padding: 13px 15px;
    resize: none;
    color: var(--ink);
    background: transparent;
    border: 0;
    outline: 0;
    line-height: 1.4;
}

.composer-center:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 105, 167, .12); }

.attach-button, .send-button {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.attach-button { color: var(--navy); background: #e5edf4; font-size: 25px; }
.send-button { color: white; background: linear-gradient(145deg, var(--blue), var(--navy-2)); font-size: 20px; }
.attach-button:disabled, .send-button:disabled { opacity: .45; cursor: wait; }

.attachment-tray {
    display: flex;
    gap: 6px;
    padding: 7px 9px 0;
    overflow-x: auto;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    max-width: 260px;
    padding: 4px 8px;
    border-radius: 999px;
    color: var(--navy);
    background: #dcecf6;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-chip button { border: 0; background: transparent; cursor: pointer; font-size: 16px; }

.inline-form, .secure-card {
    margin-top: 14px;
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--soft);
}

.inline-form h3 { margin: 0; color: var(--navy); }
.inline-form p { margin: 0; color: var(--muted); }

label {
    display: grid;
    gap: 5px;
    color: var(--navy);
    font-size: 13px;
    font-weight: 700;
}

input, textarea, select {
    width: 100%;
    padding: 10px 11px;
    color: var(--ink);
    background: white;
    border: 1px solid #b9c8d5;
    border-radius: 9px;
    outline: none;
}

input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,105,167,.12); }

.primary-button, .secondary-button {
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 800;
    cursor: pointer;
}

.primary-button { color: white; background: var(--blue); border: 1px solid var(--blue); }
.secondary-button { color: var(--navy); background: white; border: 1px solid #afc1d1; }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.notice {
    margin: 0 auto 18px;
    width: min(820px, 95%);
    padding: 12px 14px;
    border-radius: 10px;
}

.notice.success { color: #0c5c36; background: #e4f6ec; border: 1px solid #9bd4b4; }
.notice.error, .form-error { color: var(--danger); background: #fff0ee; border: 1px solid #f3b5ad; padding: 9px 11px; border-radius: 9px; }

.typing { display: inline-flex; gap: 5px; align-items: center; min-height: 21px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .14s; }
.typing i:nth-child(3) { animation-delay: .28s; }

.seo-content {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.install-page { overflow: auto; }
.install-shell { min-height: 100dvh; height: auto; grid-template-rows: auto 1fr; }
.install-shell .messages { overflow: visible; }
.setup-step { display: none; }
.setup-step.active { display: block; }
.check-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.check-list li { display: flex; gap: 8px; align-items: center; }
.check-list .pass span { color: var(--success); }
.check-list .fail { color: var(--danger); }
.spinner { display: inline-block; width: 18px; height: 18px; margin-right: 8px; border: 3px solid #bdd2e2; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }

code { padding: 2px 5px; border-radius: 5px; background: #e8eef4; }

@keyframes rise { from { transform: translateY(6px); opacity: 0; } }
@keyframes pulse { 0%, 70%, 100% { transform: translateY(0); opacity: .35; } 35% { transform: translateY(-4px); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 680px) {
    .chat-header { min-height: 68px; padding: 10px 12px; }
    .brand-mark { width: 43px; height: 43px; border-radius: 13px; }
    .header-actions .text-button { padding: 7px 9px; font-size: 12px; }
    .header-actions a.text-button { display: none; }
    .messages { padding: 18px 12px; }
    .message { width: 94%; }
    .message-body { padding: 13px 14px; }
    .composer { padding-left: 8px; padding-right: 8px; gap: 7px; }
    .attach-button, .send-button { width: 44px; height: 44px; }
}
