/* ==========================================================================
   NeonForge · Base: design tokens, reset, typography, primitives
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #06070c;
  --bg-2: #0a0c15;
  --surface: rgba(16, 19, 31, 0.72);
  --surface-2: rgba(23, 27, 44, 0.86);
  --surface-solid: #10131f;
  --surface-raised: #151a2b;
  --surface-hover: rgba(40, 47, 74, 0.55);
  --border: rgba(132, 148, 205, 0.12);
  --border-strong: rgba(132, 148, 205, 0.24);

  /* Text */
  --text: #e8ebf7;
  --text-dim: #b6bcd4;
  --muted: #7f87a3;

  /* Neon palette */
  --cyan: #22d3ee;
  --cyan-rgb: 34, 211, 238;
  --magenta: #e040fb;
  --magenta-rgb: 224, 64, 251;
  --lime: #a3e635;
  --lime-rgb: 163, 230, 53;
  --amber: #fbbf24;
  --amber-rgb: 251, 191, 36;
  --violet: #a78bfa;
  --violet-rgb: 167, 139, 250;
  --red: #ff3d6e;
  --red-rgb: 255, 61, 110;

  --primary: var(--cyan);
  --primary-rgb: var(--cyan-rgb);
  --gradient: linear-gradient(135deg, var(--cyan) 0%, #818cf8 50%, var(--magenta) 100%);

  /* Shape & depth */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.85);
  --shadow-pop: 0 24px 60px -18px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--border-strong);
  --glow: 0 0 0 1px rgba(var(--primary-rgb), 0.45), 0 0 22px -4px rgba(var(--primary-rgb), 0.55);
  --blur: saturate(160%) blur(18px);

  /* Type */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Layout */
  --nav-h: 64px;
  --bottom-h: 64px;
  --gap: 20px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 160ms;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

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

body.modal-open {
  overflow: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

p {
  margin: 0;
}

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

:not(pre) > code {
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: rgba(var(--magenta-rgb), 0.1);
  border: 1px solid rgba(var(--magenta-rgb), 0.2);
  color: #f0abfc;
  font-size: 0.86em;
}

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

::selection {
  background: rgba(var(--magenta-rgb), 0.35);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(132, 148, 205, 0.18);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(132, 148, 205, 0.32);
}

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

.bg-grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(rgba(var(--cyan-rgb), 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--cyan-rgb), 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}

.bg-orb {
  position: absolute;
  width: 46vw;
  height: 46vw;
  max-width: 720px;
  max-height: 720px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.18;
  animation: orb-float 24s ease-in-out infinite alternate;
}

.orb-a {
  top: -18vw;
  left: -10vw;
  background: var(--cyan);
}

.orb-b {
  bottom: -22vw;
  right: -12vw;
  background: var(--magenta);
  animation-delay: -12s;
}

@keyframes orb-float {
  to {
    transform: translate3d(6vw, 4vw, 0) scale(1.1);
  }
}

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

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

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

.text-gradient {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.text-danger {
  color: var(--red);
}

.text-lime {
  color: var(--lime);
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--cyan);
  color: #001018;
  font-weight: 700;
  transform: translateY(-150%);
  transition: transform var(--fast) var(--ease);
}

.skip-link:focus {
  transform: none;
}

.noscript {
  padding: 40px;
  text-align: center;
  color: var(--amber);
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none !important;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast), border-color var(--fast), color var(--fast);
  user-select: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(var(--primary-rgb), 0.5);
}

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

.btn:disabled {
  opacity: 0.6;
}

.btn .icon {
  width: 17px;
  height: 17px;
}

.btn-primary {
  --btn-bg: linear-gradient(135deg, #22d3ee, #6366f1 130%);
  --btn-fg: #020617;
  --btn-border: transparent;
  box-shadow: 0 6px 24px -8px rgba(var(--cyan-rgb), 0.7);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 32px -8px rgba(var(--cyan-rgb), 0.85), 0 0 0 1px rgba(var(--cyan-rgb), 0.5);
}

.btn-outline {
  --btn-bg: transparent;
  --btn-border: rgba(var(--primary-rgb), 0.45);
  --btn-fg: var(--cyan);
}

.btn-outline:hover:not(:disabled) {
  --btn-bg: rgba(var(--primary-rgb), 0.08);
  box-shadow: var(--glow);
}

.btn-outline.danger {
  --btn-border: rgba(var(--red-rgb), 0.45);
  --btn-fg: var(--red);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-fg: var(--text-dim);
}

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

.btn-danger {
  --btn-bg: linear-gradient(135deg, #ff3d6e, #e040fb 140%);
  --btn-fg: #fff;
  --btn-border: transparent;
  box-shadow: 0 6px 24px -8px rgba(var(--red-rgb), 0.7);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-xs {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-lg {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn-block {
  width: 100%;
}

.btn.is-busy {
  cursor: progress;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-dim);
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
  position: relative;
}

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

.icon-btn.danger:hover {
  color: var(--red);
  background: rgba(var(--red-rgb), 0.1);
}

.link-btn {
  color: var(--cyan);
  font-weight: 500;
  font-size: inherit;
}

.link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.field-label .icon {
  width: 15px;
  height: 15px;
  color: var(--cyan);
}

.field-label-note {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

.req {
  color: var(--magenta);
  margin-left: 2px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(var(--ink-rgb), 0.65);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
  appearance: none;
}

textarea.input {
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
}

select.input {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237f87a3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  cursor: pointer;
}

select.input option {
  background: var(--surface-solid);
}

.input::placeholder {
  color: #5c6380;
}

.input:hover {
  border-color: rgba(132, 148, 205, 0.36);
}

.input:focus {
  outline: none;
  border-color: rgba(var(--cyan-rgb), 0.7);
  box-shadow: 0 0 0 3px rgba(var(--cyan-rgb), 0.16);
  background: rgba(var(--ink-rgb), 0.85);
}

.input[readonly] {
  color: var(--text-dim);
}

.input-sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

select.input-sm {
  padding-right: 30px;
  background-position: right 6px center;
}

.input.has-icon {
  padding-left: 42px;
}

.input.has-toggle {
  padding-right: 44px;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
  width: 17px;
  height: 17px;
}

.input-wrap:focus-within .input-icon {
  color: var(--cyan);
}

.input-toggle {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
}

.input-toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.field-error {
  min-height: 0;
  font-size: 12.5px;
  color: var(--red);
}

.field-error:empty {
  display: none;
}

.field.has-error .input {
  border-color: rgba(var(--red-rgb), 0.7);
  box-shadow: 0 0 0 3px rgba(var(--red-rgb), 0.12);
}

.field.has-error .input-icon {
  color: var(--red);
}

.field.is-valid .input {
  border-color: rgba(var(--lime-rgb), 0.45);
}

.form-error,
.form-success {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.form-error {
  background: rgba(var(--red-rgb), 0.1);
  border: 1px solid rgba(var(--red-rgb), 0.35);
  color: var(--danger-text-soft);
}

.form-success {
  background: rgba(var(--lime-rgb), 0.08);
  border: 1px solid rgba(var(--lime-rgb), 0.3);
  color: #d9f99d;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.form-row.between {
  justify-content: space-between;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkbox-box {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: rgba(var(--ink-rgb), 0.6);
  flex-shrink: 0;
  transition: all var(--fast);
}

.checkbox-box .icon {
  width: 13px;
  height: 13px;
  color: #020617;
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--fast) var(--ease);
  stroke-width: 3.2;
}

.checkbox input:checked + .checkbox-box {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 14px -2px rgba(var(--cyan-rgb), 0.7);
}

.checkbox input:checked + .checkbox-box .icon {
  opacity: 1;
  transform: none;
}

.checkbox input:focus-visible + .checkbox-box {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.switch-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(132, 148, 205, 0.2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  padding: 2px;
  transition: background var(--fast);
}

.switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #cbd2ea;
  transition: transform var(--fast) var(--ease), background var(--fast);
}

.switch input:checked + .switch-track {
  background: rgba(var(--cyan-rgb), 0.35);
  border-color: rgba(var(--cyan-rgb), 0.6);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(var(--cyan-rgb), 0.8);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.hue-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(0 85% 60%), hsl(60 85% 60%), hsl(120 85% 55%), hsl(180 85% 55%), hsl(240 85% 65%), hsl(300 85% 60%), hsl(359 85% 60%));
  cursor: pointer;
  margin: 12px 0;
}

.hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px #fff, 0 4px 12px rgba(0, 0, 0, 0.6);
}

.hue-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bg);
}

.radio-list {
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(var(--ink-rgb), 0.45);
  cursor: pointer;
  font-size: 14px;
  transition: border-color var(--fast), background var(--fast);
}

.radio-option:hover {
  border-color: var(--border-strong);
}

.radio-option input {
  accent-color: var(--red);
  width: 16px;
  height: 16px;
}

.radio-option:has(input:checked) {
  border-color: rgba(var(--red-rgb), 0.55);
  background: rgba(var(--red-rgb), 0.08);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: var(--radius);
  background: rgba(var(--ink-rgb), 0.6);
  border: 1px solid var(--border);
}

.segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--fast);
  text-align: center;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.segment.is-active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(var(--cyan-rgb), 0.2), rgba(var(--magenta-rgb), 0.16));
  box-shadow: inset 0 0 0 1px rgba(var(--cyan-rgb), 0.45);
}

.segment.is-active .icon {
  color: var(--cyan);
}

.segment:has(input:focus-visible) {
  outline: 2px solid var(--cyan);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 18px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

/* ---------- Preferences ---------- */
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

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