:root {
    color-scheme: dark;

    --bg: #10141A;
    --bg-elev: rgba(16, 20, 26, .86);
    --surface: #171C24;
    --surface-2: #1E242E;
    --well: #0B0E12;
    --line: #252C37;
    --line-strong: #343D4A;

    --ink: #E7EAEF;
    --ink-soft: #A4ADBA;
    --ink-faint: #7D8796;

    --brass: #D4B26A;
    --brass-hi: #E4C682;
    --brass-ink: #1A1407;
    --brass-soft: rgba(212, 178, 106, .12);
    --brass-line: rgba(212, 178, 106, .38);

    --ok: #3ECF8E;
    --ok-soft: rgba(62, 207, 142, .12);
    --ok-line: rgba(62, 207, 142, .32);
    --warn: #F0883E;
    --warn-soft: rgba(240, 136, 62, .12);
    --warn-line: rgba(240, 136, 62, .34);
    --bad: #F26D6D;
    --bad-soft: rgba(242, 109, 109, .12);
    --bad-line: rgba(242, 109, 109, .34);
    --info: #7FA8FF;
    --info-soft: rgba(127, 168, 255, .12);
    --info-line: rgba(127, 168, 255, .32);
    --violet: #B79CFF;
    --violet-soft: rgba(183, 156, 255, .12);
    --violet-line: rgba(183, 156, 255, .32);
    --cyan: #56D4E4;
    --cyan-soft: rgba(86, 212, 228, .12);
    --cyan-line: rgba(86, 212, 228, .32);
    --lime: #A6D65E;
    --lime-soft: rgba(166, 214, 94, .12);
    --lime-line: rgba(166, 214, 94, .34);
    --orchid: #D98BEF;
    --orchid-soft: rgba(217, 139, 239, .12);
    --orchid-line: rgba(217, 139, 239, .34);
    --silver: #C5CCD6;
    --silver-soft: rgba(197, 204, 214, .1);
    --silver-line: rgba(197, 204, 214, .28);

    --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --radius-lg: 14px;
    --radius: 10px;
    --radius-sm: 7px;

    --shadow-pop: 0 18px 48px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--brass);

    --ease: cubic-bezier(.2, .8, .3, 1);
    --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
    --dur-fast: 140ms;
    --dur: 240ms;
    --dur-slow: 520ms;

    --glow-brass: 0 0 0 1px rgba(212, 178, 106, .25), 0 8px 30px rgba(212, 178, 106, .12);
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3, h4 {
    margin: 0;
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.2;
}

p { margin: 0; }

a { color: var(--brass); text-decoration: none; }
a:hover { color: var(--brass-hi); }

::selection { background: var(--brass-soft); color: var(--ink); }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--radius-sm); }

code, kbd, pre, .mono { font-family: var(--font-mono); }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.brand:hover { color: var(--ink); }

.brand-mark {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--brass-ink);
    background: linear-gradient(160deg, var(--brass-hi), var(--brass) 60%, #B8954F);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 0 0 1px rgba(0, 0, 0, .35);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--ink);
    font: 600 13.5px/1.2 var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.btn:hover { background: #252C38; border-color: #414B5A; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--focus); border-radius: var(--radius); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: default; transform: none; }

.btn-primary {
    background: var(--brass);
    border-color: var(--brass);
    color: var(--brass-ink);
}

.btn-primary:hover { background: var(--brass-hi); border-color: var(--brass-hi); color: var(--brass-ink); }

.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-quiet:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }

.btn-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.btn-warn:hover { background: rgba(240, 136, 62, .2); border-color: var(--warn); color: var(--warn); }

.btn-danger { background: transparent; border-color: var(--bad-line); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.btn-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.btn-ok:hover { background: rgba(62, 207, 142, .2); border-color: var(--ok); color: var(--ok); }

.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-lg { min-height: 46px; padding: 12px 22px; font-size: 15px; border-radius: 12px; }
.btn-block { display: flex; width: 100%; }

.field { display: grid; gap: 7px; margin-bottom: 16px; }

.field > label, .label {
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--well);
    color: var(--ink);
    font: 400 14px/1.4 var(--font-sans);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder, textarea::placeholder { color: #5D6674; }

input:hover, select:hover, textarea:hover { border-color: #414B5A; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px var(--brass-soft);
}

select {
    appearance: none;
    padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
    background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}

.input-mono, textarea.input-mono { font-family: var(--font-mono); font-size: 13px; }

textarea { min-height: 84px; resize: vertical; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

.badge-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.badge-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.badge-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.badge-info { background: var(--info-soft); border-color: var(--info-line); color: var(--info); }
.badge-brass { background: var(--brass-soft); border-color: var(--brass-line); color: var(--brass); }
.badge-violet { background: var(--violet-soft); border-color: var(--violet-line); color: var(--violet); }
.badge-cyan { background: var(--cyan-soft); border-color: var(--cyan-line); color: var(--cyan); }
.badge-lime { background: var(--lime-soft); border-color: var(--lime-line); color: var(--lime); }
.badge-mono { font-family: var(--font-mono); font-size: 11.5px; }

.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-live::before { animation: dot-pulse 1.6s ease-in-out infinite; }

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

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}

pre.code, .code-well {
    margin: 0;
    padding: 14px 16px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--well);
    color: #C9D1DC;
    font: 400 12.5px/1.6 var(--font-mono);
    tab-size: 2;
}

.alert {
    padding: 11px 14px;
    border: 1px solid var(--bad-line);
    border-radius: var(--radius);
    background: var(--bad-soft);
    color: #FFB4B4;
    font-size: 13.5px;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 200;
    max-width: min(420px, calc(100vw - 40px));
    padding: 12px 16px 12px 14px;
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--ok);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
    font-size: 13.5px;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms var(--ease);
}

.toast.show { opacity: 1; transform: none; }
.toast.is-error { border-left-color: var(--bad); }

.skeleton {
    position: relative;
    overflow: hidden;
    display: inline-block;
    min-width: 3ch;
    border-radius: 6px;
    background: var(--surface-2) !important;
    color: transparent !important;
    user-select: none;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent);
    transform: translateX(-100%);
    animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer { to { transform: translateX(100%); } }

kbd {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--ink-soft);
    font: 500 11px/1 var(--font-mono);
}

.reveal { animation: rise var(--dur-slow) var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }

@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

.scroll-reveal { opacity: 0; transform: translateY(22px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); transition-delay: calc(var(--i, 0) * 90ms); }
.scroll-reveal.in-view { opacity: 1; transform: none; }

.live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 11px 5px 9px;
    border: 1px solid var(--ok-line);
    border-radius: 999px;
    background: var(--ok-soft);
    color: var(--ok);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.live-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; animation: ping 1.8s var(--ease) infinite; }

@keyframes ping {
    0% { transform: scale(1); opacity: .7; }
    80%, 100% { transform: scale(2.6); opacity: 0; }
}

.live.is-paused { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink-faint); }
.live.is-paused .live-dot::after { animation: none; }
.live.is-error { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }

.json .j-key { color: #A9C3FF; }
.json .j-str { color: #9BE3B8; }
.json .j-num { color: #F3C98B; }
.json .j-bool { color: #D7A6FF; }
.json .j-null { color: var(--ink-faint); }

.icon { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.copied-flash { animation: copied 600ms var(--ease-spring); }

@keyframes copied {
    0% { transform: scale(1); }
    40% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.toast { transform: translateY(12px) scale(.98); }
.toast.show { transform: none; }

.toast::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    border-radius: 0 0 0 var(--radius);
    background: var(--ok);
    opacity: .55;
    transform-origin: left;
}

.toast.is-error::before { background: var(--bad); }

.toast.show::before { animation: toast-timer var(--toast-ms, 2600ms) linear forwards; }

@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }


@media (prefers-reduced-motion: reduce) {
    .scroll-reveal { opacity: 1; transform: none; }

    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }
}

.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; }
.lang-switch a { padding: 3px 8px; border-radius: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-decoration: none; }
.lang-switch a:hover { color: var(--ink); }
.lang-switch a[aria-current="true"] { background: var(--line); color: var(--ink); }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sidebar-foot .lang-switch { align-self: flex-start; margin-bottom: 10px; }
.head-actions { display: flex; align-items: center; gap: 12px; }
