/* =====================================================================
   SpinDeck — design system
   Dark arcade palette: near-black base, violet -> cyan accent, neon edges.
   ===================================================================== */

:root {
    /* Surfaces */
    --bg: #06060d;
    --bg-deep: #04040a;
    --surface: #0e0e1a;
    --surface-2: #14142a;
    --surface-3: #1b1b34;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);

    /* Brand */
    --violet: #8b5cf6;
    --violet-deep: #6d28d9;
    --cyan: #22d3ee;
    --magenta: #e879f9;
    --lime: #a3e635;
    --brand: linear-gradient(120deg, #8b5cf6 0%, #6366f1 45%, #22d3ee 100%);
    --brand-soft: linear-gradient(120deg, rgba(139, 92, 246, .18), rgba(34, 211, 238, .18));
    --gold: linear-gradient(120deg, #fbbf24, #f59e0b 55%, #fb923c);

    /* Text */
    --text: #f2f2f8;
    --text-2: #a5a5c0;
    --text-3: #6c6c8a;

    /* Status */
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #f43f5e;
    --live: #ef4444;

    /* Shape */
    --r-sm: 10px;
    --r: 16px;
    --r-lg: 22px;
    --r-xl: 30px;

    --shadow: 0 20px 60px -20px rgba(0, 0, 0, .85);
    --glow-violet: 0 0 0 1px rgba(139, 92, 246, .35), 0 0 32px -6px rgba(139, 92, 246, .55);
    --glow-cyan: 0 0 0 1px rgba(34, 211, 238, .32), 0 0 30px -6px rgba(34, 211, 238, .5);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --header-h: 68px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Ambient arcade backdrop: two slow-drifting colour blooms over a faint grid.
   Fixed + pointer-events:none so it never interferes with layout or clicks. */
body::before,
body::after {
    content: '';
    position: fixed;
    inset: -30vmax;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(38vmax 38vmax at 18% 12%, rgba(139, 92, 246, .20), transparent 62%),
        radial-gradient(32vmax 32vmax at 82% 8%, rgba(34, 211, 238, .16), transparent 60%),
        radial-gradient(36vmax 36vmax at 62% 88%, rgba(232, 121, 249, .12), transparent 62%);
    animation: drift 34s ease-in-out infinite alternate;
}
body::after {
    z-index: -3;
    background-image:
        linear-gradient(rgba(255, 255, 255, .028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .028) 1px, transparent 1px);
    background-size: 64px 64px;
    animation: none;
    mask-image: radial-gradient(70vmax 60vmax at 50% 20%, #000 20%, transparent 78%);
    -webkit-mask-image: radial-gradient(70vmax 60vmax at 50% 20%, #000 20%, transparent 78%);
}

@keyframes drift {
    from { transform: translate3d(-2%, -1%, 0) scale(1); }
    to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

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

/* ------------------------------------------------------------- typography */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: 1.2rem; }
a { color: inherit; text-decoration: none; }

.grad-text {
    background: var(--brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ----------------------------------------------------------------- layout */
.wrap { width: min(1200px, 100% - 40px); margin-inline: auto; }
.wrap-narrow { width: min(760px, 100% - 40px); margin-inline: auto; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ cards */
.card {
    position: relative;
    background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015));
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.card-glow::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: var(--brand);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: .55;
    pointer-events: none;
}

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

/* ---------------------------------------------------------------- buttons */
.btn {
    --btn-bg: var(--surface-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 12px 20px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--btn-bg);
    color: var(--text);
    font: 600 .94rem/1 var(--font);
    cursor: pointer;
    transition: transform .16s cubic-bezier(.2, .9, .3, 1), box-shadow .2s, background .2s, border-color .2s, opacity .2s;
    white-space: nowrap;
    user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(255, 255, 255, .28); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn-primary {
    background: var(--brand);
    border-color: transparent;
    color: #0a0a14;
    font-weight: 800;
    box-shadow: 0 10px 30px -12px rgba(139, 92, 246, .9);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 16px 40px -12px rgba(139, 92, 246, 1); }

.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .05); }

.btn-danger { background: rgba(244, 63, 94, .12); border-color: rgba(244, 63, 94, .4); color: #fda4af; }
.btn-danger:hover:not(:disabled) { background: rgba(244, 63, 94, .2); }

.btn-sm { padding: 8px 14px; font-size: .84rem; border-radius: 10px; }
.btn-lg { padding: 15px 28px; font-size: 1.02rem; border-radius: 14px; }
.btn-block { width: 100%; }

/* ----------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.field .hint { font-size: .76rem; color: var(--text-3); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, .035);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    font: 500 .95rem var(--font);
    transition: border-color .18s, box-shadow .18s, background .18s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: rgba(139, 92, 246, .65);
    background: rgba(255, 255, 255, .055);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, .14);
}
select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236c6c8a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
select option { background: #14142a; color: var(--text); }
textarea { resize: vertical; min-height: 88px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
    width: 44px; height: 25px; border-radius: 999px;
    background: rgba(255, 255, 255, .1); border: 1px solid var(--line);
    position: relative; transition: background .2s, border-color .2s; flex: none;
}
.switch .track::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 19px; height: 19px; border-radius: 50%;
    background: var(--text-2); transition: transform .2s cubic-bezier(.3, .9, .3, 1), background .2s;
}
.switch input:checked + .track { background: rgba(139, 92, 246, .5); border-color: rgba(139, 92, 246, .8); }
.switch input:checked + .track::after { transform: translateX(19px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ----------------------------------------------------------------- chips */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 999px;
    background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
    font-size: .76rem; font-weight: 600; color: var(--text-2);
}
.chip-violet { background: rgba(139, 92, 246, .14); border-color: rgba(139, 92, 246, .38); color: #c4b5fd; }
.chip-cyan { background: rgba(34, 211, 238, .12); border-color: rgba(34, 211, 238, .34); color: #a5f3fc; }
.chip-ok { background: rgba(34, 197, 94, .13); border-color: rgba(34, 197, 94, .36); color: #86efac; }
.chip-warn { background: rgba(245, 158, 11, .13); border-color: rgba(245, 158, 11, .36); color: #fcd34d; }
.chip-danger { background: rgba(244, 63, 94, .13); border-color: rgba(244, 63, 94, .36); color: #fda4af; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot-live { background: var(--live); box-shadow: 0 0 0 0 rgba(239, 68, 68, .7); animation: pulse 1.8s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .65); }
    70% { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ---------------------------------------------------------------- header */
.site-header {
    position: sticky; top: 0; z-index: 60;
    height: var(--header-h);
    display: flex; align-items: center;
    background: rgba(6, 6, 13, .72);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 18px; }

.brand { display: flex; align-items: center; gap: 11px; font-family: var(--font-display); font-weight: 800; font-size: 1.16rem; letter-spacing: -.02em; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 11px; flex: none;
    background: var(--brand);
    display: grid; place-items: center;
    box-shadow: 0 6px 20px -6px rgba(139, 92, 246, .9);
}
.brand-mark svg { width: 20px; height: 20px; }

.nav { display: flex; align-items: center; gap: 8px; }
.nav a.navlink {
    padding: 8px 14px; border-radius: 10px; font-size: .9rem; font-weight: 600;
    color: var(--text-2); transition: color .18s, background .18s;
}
.nav a.navlink:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.nav a.navlink.active { color: var(--text); background: rgba(139, 92, 246, .16); }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none;
    background: var(--surface-2); border: 1px solid var(--line-strong);
}

/* ---------------------------------------------------------------- footer */
.site-footer {
    margin-top: 80px; padding: 34px 0;
    border-top: 1px solid var(--line);
    color: var(--text-3); font-size: .85rem;
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-footer a:hover { color: var(--text-2); }

/* --------------------------------------------------------------- toasts */
#toasts {
    position: fixed; right: 18px; bottom: 18px; z-index: 200;
    display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px));
}
.toast {
    padding: 13px 16px; border-radius: 13px;
    background: rgba(20, 20, 42, .96);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    font-size: .89rem; font-weight: 500;
    animation: toastIn .28s cubic-bezier(.2, .9, .3, 1);
}
.toast.ok { border-color: rgba(34, 197, 94, .5); }
.toast.err { border-color: rgba(244, 63, 94, .5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- misc */
.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, .05) 25%, rgba(255, 255, 255, .1) 37%, rgba(255, 255, 255, .05) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: 10px;
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

.empty {
    padding: 46px 24px; text-align: center; color: var(--text-3);
    border: 1px dashed var(--line-strong); border-radius: var(--r);
}
.empty .icon { font-size: 2.6rem; margin-bottom: 10px; opacity: .8; }

.copy-field {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255, 255, 255, .035); border: 1px solid var(--line);
    border-radius: 12px; padding: 4px 4px 4px 14px;
}
.copy-field input {
    border: none; background: none; padding: 8px 0; font-family: var(--font-mono);
    font-size: .84rem; color: var(--text-2);
}
.copy-field input:focus { box-shadow: none; background: none; }

@media (max-width: 720px) {
    .wrap, .wrap-narrow { width: calc(100% - 28px); }
    .nav a.navlink { padding: 8px 10px; font-size: .85rem; }
}
