:root {
    --bg: #070b12;
    --panel: #0d131d;
    --panel-2: #101925;
    --border: rgba(96, 165, 250, 0.18);
    --text: #e7edf7;
    --muted: #8290a6;
    --accent: #42e8b4;
    --accent-2: #5aa7ff;
    --danger: #ff6b81;
    --shadow: 0 24px 80px rgba(0, 0, 0, .45);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 15% 15%, rgba(66, 232, 180, .08), transparent 28%),
        radial-gradient(circle at 85% 80%, rgba(90, 167, 255, .10), transparent 32%),
        var(--bg);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .22;
    background-image:
        linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
    background-size: 36px 36px;
}

.app-shell {
    width: min(100% - 32px, 980px);
    min-height: 100vh;
    margin: auto;
    display: grid;
    place-items: center;
    padding: 32px 0;
}

.chat-card {
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(16,25,37,.97), rgba(8,13,21,.97));
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.chat-header {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.015);
}

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

.brand-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(66,232,180,.35);
    border-radius: 12px;
    color: var(--accent);
    background: rgba(66,232,180,.06);
    box-shadow: inset 0 0 18px rgba(66,232,180,.05);
    font: 700 15px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

h1, h2, p {
    margin: 0;
}

.brand h1 {
    font-size: 19px;
    letter-spacing: .04em;
}

.brand h1 span {
    color: var(--accent);
}

.brand p {
    margin-top: 4px;
    color: var(--muted);
    font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.intro {
    padding: 30px 28px 20px;
}

.terminal-line {
    margin-bottom: 12px;
    color: var(--muted);
    font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.terminal-line span {
    color: var(--accent);
}

.intro h2 {
    font-size: clamp(23px, 4vw, 32px);
    letter-spacing: -.03em;
}

.intro p {
    max-width: 720px;
    margin-top: 9px;
    color: var(--muted);
    line-height: 1.65;
    font-size: 14px;
}

.chat-form {
    margin: 0 28px 20px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(0,0,0,.16);
}

.chat-form label {
    display: block;
    margin-bottom: 10px;
    color: #aebbd0;
    font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .08em;
    text-transform: uppercase;
}

textarea {
    width: 100%;
    min-height: 130px;
    resize: vertical;
    padding: 14px;
    border: 1px solid rgba(130,144,166,.2);
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: #080d15;
    font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
    transition: border-color .2s, box-shadow .2s;
}

textarea::placeholder {
    color: #526075;
}

textarea:focus {
    border-color: rgba(66,232,180,.5);
    box-shadow: 0 0 0 3px rgba(66,232,180,.07);
}

.form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-top: 12px;
}

#counter {
    color: #59677c;
    font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}

button {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    color: #04100c;
    background: var(--accent);
    cursor: pointer;
    font-weight: 800;
    transition: transform .2s, filter .2s, opacity .2s;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

button:disabled {
    cursor: wait;
    opacity: .65;
}

.button-arrow {
    font-size: 18px;
}

.result {
    display: none;
    max-height: 420px;
    overflow-y: auto;
    margin: 0 28px 22px;
    padding: 18px;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(4,8,14,.72);
}

.result.visible {
    display: flex;
}

.result.success {
    border-color: rgba(66,232,180,.20);
}

.result.error {
    border-color: rgba(255,107,129,.22);
}

.message-icon {
    flex: 0 0 auto;
    width: 35px;
    height: 35px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--accent);
    background: rgba(66,232,180,.08);
    font: 800 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.error .message-icon {
    color: var(--danger);
    background: rgba(255,107,129,.08);
}

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

.message-label {
    margin-bottom: 9px;
    color: #6f7e94;
    font: 800 10px ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .12em;
}

.message-content {
    color: #cbd5e3;
    font-size: 14px;
    line-height: 1.72;
    overflow-wrap: anywhere;
}

.message-content pre {
    overflow-x: auto;
    margin: 14px 0 4px;
    padding: 14px;
    border: 1px solid rgba(90,167,255,.15);
    border-radius: 10px;
    background: #050911;
}

.message-content pre code {
    color: #c5d5ea;
    font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.inline-code {
    padding: 2px 5px;
    border-radius: 4px;
    color: var(--accent);
    background: rgba(66,232,180,.08);
    font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.loader {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 5px 8px;
    border: 2px solid rgba(66,232,180,.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.chat-footer {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 15px 28px;
    border-top: 1px solid var(--border);
    color: #536177;
    font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.result::-webkit-scrollbar,
textarea::-webkit-scrollbar {
    width: 7px;
}

.result::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #263449;
}

@media (max-width: 640px) {
    .app-shell {
        width: min(100% - 16px, 980px);
        padding: 8px 0;
    }

    .chat-card {
        border-radius: 13px;
    }

    .chat-header,
    .intro,
    .chat-footer {
        padding-left: 17px;
        padding-right: 17px;
    }

    .chat-form,
    .result {
        margin-left: 17px;
        margin-right: 17px;
    }

    .status {
        display: none;
    }

    .intro {
        padding-top: 24px;
    }

    .form-footer {
        align-items: flex-end;
    }

    button {
        flex: 1;
        justify-content: center;
    }

    .chat-footer {
        flex-direction: column;
    }
}
