:root {
    --bg: #000000;
    --bg-elevated: #0a0a0a;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.07);
    --surface-3: rgba(255, 255, 255, 0.11);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-subtle: #6b7280;
    --accent: #ffffff;
    --danger: #f87171;
    --ok: #4ade80;
    --spicy: #fb923c;
    --glow: rgba(255, 255, 255, 0.06);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 26px;
    --radius-pill: 999px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --composer-max: 720px;
    --studio-max: 780px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    color-scheme: dark;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

[hidden] { display: none !important; }

/* Ambient background */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.ambient-bg::before {
    content: "";
    position: absolute;
    top: -25%;
    left: 50%;
    transform: translateX(-50%);
    width: 140%;
    height: 65%;
    background:
        radial-gradient(ellipse 55% 45% at 50% 35%, rgba(255, 255, 255, 0.055) 0%, transparent 68%),
        radial-gradient(ellipse 35% 28% at 20% 55%, rgba(147, 197, 253, 0.04) 0%, transparent 70%),
        radial-gradient(ellipse 30% 25% at 80% 50%, rgba(251, 146, 60, 0.035) 0%, transparent 72%);
    animation: ambient-drift 18s ease-in-out infinite alternate;
}

.ambient-bg::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, #000 0%, rgba(0, 0, 0, 0.85) 35%, transparent 100%);
}

@keyframes ambient-drift {
    0% { transform: translateX(-50%) translateY(0); opacity: 0.9; }
    100% { transform: translateX(-48%) translateY(2%); opacity: 1; }
}

/* Brand */
.brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    text-decoration: none;
    color: inherit;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--accent);
    color: #000;
    flex-shrink: 0;
}

.brand-mark svg {
    width: 18px;
    height: 18px;
}

.brand-mark--sm {
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.brand-mark--sm svg {
    width: 14px;
    height: 14px;
}

.brand__name {
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.03em;
}

.pill--subtle {
    border-color: transparent;
    background: transparent;
    color: var(--text-subtle);
    font-size: .68rem;
}

.btn--icon-text {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
}

.btn--icon-text svg {
    width: 17px;
    height: 17px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: .88rem;
    cursor: pointer;
    transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease);
}

.btn:active:not(:disabled) { transform: scale(0.98); }

.btn--white {
    background: var(--accent);
    color: #000;
    padding: .7rem 1.15rem;
}

.btn--white:hover:not(:disabled) {
    background: #e4e4e7;
}

.btn--full { width: 100%; }

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: .4rem .8rem;
}

.btn--ghost:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface);
}

.btn--sm {
    font-size: .8rem;
    padding: .35rem .7rem;
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* Pills & badges */
.pill {
    padding: .28rem .65rem;
    border-radius: var(--radius-pill);
    font-size: .72rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
}

.pill--ok {
    color: var(--ok);
    border-color: rgba(74, 222, 128, 0.25);
    background: rgba(74, 222, 128, 0.08);
}

.pill--error {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.25);
    background: rgba(248, 113, 113, 0.08);
}

.pill--user {
    background: var(--surface-2);
    color: var(--text);
}

/* Form fields */
.field {
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.field span {
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: .02em;
}

.field input,
.field select,
.field textarea {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: .75rem 1rem;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px var(--glow);
}

/* Icon buttons */
.icon-btn,
.send-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
}

.icon-btn svg,
.send-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text);
}

.icon-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.icon-btn--loading {
    animation: pulse-glow 1s ease-in-out infinite;
}

.send-btn {
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    width: 36px;
    height: 36px;
}

.send-btn:hover:not(:disabled) {
    background: #e4e4e7;
    transform: scale(1.04);
}

.send-btn svg {
    width: 15px;
    height: 15px;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

/* Spinner */
.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

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

/* Errors */
.error-banner {
    max-width: var(--composer-max);
    margin: 0 auto 1rem;
    padding: .75rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.22);
    color: #fca5a5;
    font-size: .88rem;
    text-align: center;
}

/* Gradient text utility */
.text-gradient {
    background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }