:root {
    color-scheme: dark;
    --canvas: #07090a;
    --surface: #0d1110;
    --surface-raised: #131817;
    --surface-soft: #0a0d0c;
    --line: #252c28;
    --line-strong: #3a453f;
    --text: #edf2ee;
    --text-muted: #a7b1aa;
    --text-dim: #7f8a82;
    --green: #58e36d;
    --cyan: #59cbe8;
    --amber: #e6c766;
    --red: #ff7676;
    --focus: #8be9fd;
    --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: clamp(1.2rem, 2vw, 1.5rem);
    --text-xl: clamp(1.55rem, 4vw, 2.25rem);
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --control-compact: 36px;
    --control: 44px;
    --control-prominent: 52px;
    --header-height: 64px;
    --actions-height: 50px;
    --radius: 3px;
    --content: 78rem;
    --measure: 80ch;
    --motion-fast: 120ms;
    --motion-standard: 180ms;
    --motion-slow: 240ms;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--canvas);
    font-family: var(--font-mono);
}

body {
    min-width: 320px;
    min-height: 100dvh;
    margin: 0;
    background:
        radial-gradient(circle at 18% -12%, rgb(88 227 109 / 12%), transparent 34%),
        radial-gradient(circle at 88% 18%, rgb(89 203 232 / 7%), transparent 30%),
        linear-gradient(135deg, rgb(255 255 255 / 1.5%), transparent 42%),
        var(--canvas);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--text-md);
    font-synthesis: none;
    font-variant-ligatures: none;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body::before {
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 3px,
        rgb(255 255 255 / 1.25%) 4px
    );
    content: "";
    pointer-events: none;
}

[hidden] {
    display: none !important;
}

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

button,
.button-link {
    min-height: var(--control);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition:
        border-color var(--motion-fast) ease,
        background-color var(--motion-fast) ease,
        color var(--motion-fast) ease,
        opacity var(--motion-fast) ease,
        transform var(--motion-fast) var(--ease-out);
}

button:hover:not(:disabled),
.button-link:hover {
    border-color: var(--line-strong);
    color: var(--text);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

input,
textarea,
select {
    width: 100%;
    min-height: var(--control);
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    outline: 0;
    background: #090b0c;
    color: var(--text);
}

textarea {
    resize: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-dim);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 1px rgb(89 203 232 / 8%);
}

:where(button, input, textarea, select, summary, a, [tabindex]):focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

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

a {
    color: var(--cyan);
    text-underline-offset: 0.2em;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    color: var(--text);
    line-height: 1.2;
}

h1 {
    font-size: var(--text-xl);
}

h2 {
    font-size: var(--text-lg);
}

h3 {
    font-size: var(--text-md);
}

label,
.stack-form,
.auth-form {
    display: grid;
    gap: var(--space-2);
}

label {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.stack-form,
.auth-form {
    gap: var(--space-4);
}

.primary-button,
.send-button {
    border-color: color-mix(in srgb, var(--green) 66%, var(--line));
    background: color-mix(in srgb, var(--green) 9%, var(--surface));
    color: var(--green);
    font-weight: 700;
}

.primary-button:hover:not(:disabled),
.send-button:hover:not(:disabled) {
    border-color: var(--green);
    background: color-mix(in srgb, var(--green) 14%, var(--surface));
    color: var(--green);
}

.danger-button {
    border-color: color-mix(in srgb, var(--red) 60%, var(--line));
    color: var(--red);
}

.text-button {
    min-height: 36px;
    padding-inline: 0;
    border-color: transparent;
    text-align: left;
}

.field-hint,
.form-status,
.status,
.empty-state,
small {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.form-status,
.status {
    min-height: 1.5em;
    margin: var(--space-3) 0 0;
}

.form-status[data-state="error"],
.status[data-state="error"] {
    color: var(--red);
}

.form-status[data-state="success"],
.status[data-state="success"] {
    color: var(--green);
}

.section-label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--green);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.12em;
}

.section-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-block: var(--space-6) var(--space-4);
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
}

.section-divider::after {
    height: 1px;
    flex: 1;
    background: var(--line);
    content: "";
}

dialog {
    color: var(--text);
}

dialog::backdrop {
    background: rgb(0 0 0 / 74%);
    backdrop-filter: blur(3px);
}

dialog[open] {
    animation: dialog-enter var(--motion-standard) var(--ease-out);
}

@keyframes dialog-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.992);
    }
}

@starting-style {
    dialog[open] {
        opacity: 0;
        transform: translateY(8px) scale(0.992);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --line: #526059;
        --line-strong: #87928c;
        --text-muted: #c7cec9;
        --text-dim: #a7b0aa;
    }
}
