:root {
    --bg: #f5f3f7;
    --bg-accent: radial-gradient(1200px 600px at 10% -10%, #e9defa 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 0%, #fde2f0 0%, transparent 55%);
    --surface: #ffffff;
    --surface-2: #f8f7fa;
    --border: #e6e2ec;
    --text: #1f1b24;
    --muted: #6b6475;
    --primary: #714b67;
    --primary-hover: #5e3d55;
    --primary-soft: #f1e9ef;
    --ok: #1f8a4c;
    --ok-soft: #e3f5ea;
    --warn: #a15c00;
    --warn-soft: #fff1d6;
    --err: #c62828;
    --err-soft: #fde7e7;
    --paper-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(31, 27, 36, 0.08);
    --radius: 14px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141217;
        --bg-accent: radial-gradient(1200px 600px at 10% -10%, #2a1f33 0%, transparent 60%),
            radial-gradient(900px 500px at 110% 0%, #2c1a26 0%, transparent 55%);
        --surface: #1d1a21;
        --surface-2: #24212a;
        --border: #34303b;
        --text: #eeeaf2;
        --muted: #a39cad;
        --primary: #c08bb3;
        --primary-hover: #d3a3c6;
        --primary-soft: #3a2a36;
        --ok: #5fd08f;
        --ok-soft: #173525;
        --warn: #f0b75a;
        --warn-soft: #3a2c12;
        --err: #ff7b7b;
        --err-soft: #3d1c1c;
        --paper-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.45);
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
}

body {
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-accent), var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
}

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

.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    border-bottom: 1px solid var(--border);
}

.topbar .container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.brand svg {
    width: 30px;
    height: 30px;
}

.topbar .spacer {
    flex: 1;
}

.crumb {
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crumb strong {
    color: var(--text);
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.card + .card {
    margin-top: 14px;
}

.card h2 {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 13px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--surface-2);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible,
.switch input:focus-visible + span,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

@media (prefers-color-scheme: dark) {
    .btn-primary {
        color: #1d1a21;
    }
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 8px;
}

.btn-danger:hover {
    color: var(--err);
    background: var(--err-soft);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* Inputs */
.input,
select.input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.field {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.field label {
    font-size: 13px;
    font-weight: 600;
}

/* Copy box */
.copy {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 12px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font-family: var(--mono);
    font-size: 13px;
}

.copy code {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.copy + .copy {
    margin-top: 8px;
}

.label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin: 12px 0 6px;
}

.label:first-of-type {
    margin-top: 0;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.badge.ok {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: transparent;
}

.badge.warn {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: transparent;
}

.badge.err {
    background: var(--err-soft);
    color: var(--err);
    border-color: transparent;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.dot.live {
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.35;
    }
}

/* Toast */
.toasts {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    gap: 8px;
    z-index: 50;
    width: min(420px, calc(100% - 32px));
}

.toast {
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: rise 0.2s ease-out;
}

.toast.err {
    background: var(--err);
    color: #fff;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
