/* ==========================================================================
   SysAdmin Wiki — base: tokens, reset, typography, primitives
   ========================================================================== */

:root {
  --bg: #08080f;
  --bg-soft: #0b0b14;
  --surface: rgba(17, 17, 29, 0.72);
  --surface-solid: #11111d;
  --surface-2: #161624;
  --surface-3: #1d1d2e;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0ff;
  --text-soft: #b8bad4;
  --muted: #8588a6;
  --violet: #a78bfa;
  --violet-bright: #c4b5fd;
  --blue: #60a5fa;
  --cyan: #22d3ee;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --accent: var(--violet);
  --accent-soft: rgba(167, 139, 250, 0.14);
  --accent-line: rgba(167, 139, 250, 0.34);
  --gradient: linear-gradient(135deg, #c4b5fd 0%, #818cf8 42%, #60a5fa 72%, #22d3ee 100%);
  --gradient-strong: linear-gradient(135deg, #7c3aed 0%, #4f46e5 52%, #2563eb 100%);
  --success-soft: rgba(52, 211, 153, 0.12);
  --danger-soft: rgba(251, 113, 133, 0.12);
  --warning-soft: rgba(251, 191, 36, 0.11);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 12px 36px rgba(0, 0, 0, 0.22);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --topbar-h: 68px;
  --sidebar-w: 288px;
  --container: 1440px;
  --font-sans: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg: #f4f5fb;
  --bg-soft: #ffffff;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-2: #f0f0f8;
  --surface-3: #e7e7f2;
  --border: rgba(24, 24, 60, 0.09);
  --border-strong: rgba(24, 24, 60, 0.16);
  --text: #15152b;
  --text-soft: #3e3e5e;
  --muted: #6c6c8c;
  --accent-soft: rgba(124, 58, 237, 0.09);
  --accent-line: rgba(124, 58, 237, 0.28);
  --shadow: 0 24px 70px rgba(35, 35, 90, 0.14);
  --shadow-soft: 0 12px 36px rgba(35, 35, 90, 0.09);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.search-open,
body.sidebar-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.6rem);
}

h2 {
  font-size: clamp(1.45rem, 2.6vw, 2rem);
}

h3 {
  font-size: 1.12rem;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

img,
svg {
  display: block;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

li {
  list-style: none;
}

::selection {
  background: rgba(167, 139, 250, 0.35);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 3px;
}

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

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

::-webkit-scrollbar-thumb {
  background: rgba(140, 140, 180, 0.25);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(167, 139, 250, 0.45);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---------- icons ---------- */

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.icon--logo {
  width: 24px;
  height: 24px;
  stroke-width: 1.6;
}

/* ---------- ambient background ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient__grid {
  position: absolute;
  inset: -20%;
  background-image:
    linear-gradient(rgba(140, 140, 210, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 140, 210, 0.055) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 75% 60% at 50% 0%, #000 10%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 75% 60% at 50% 0%, #000 10%, transparent 78%);
  opacity: 0.65;
}

.ambient__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.42;
  animation: drift 18s ease-in-out infinite alternate;
}

.ambient__glow--one {
  width: 620px;
  height: 620px;
  top: -240px;
  left: 8%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.55), transparent 68%);
}

.ambient__glow--two {
  width: 720px;
  height: 720px;
  top: -320px;
  right: -140px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.5), transparent 68%);
  animation-delay: -6s;
}

.ambient__glow--three {
  width: 540px;
  height: 540px;
  top: 42vh;
  left: -280px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.28), transparent 70%);
  animation-delay: -11s;
}

[data-theme="light"] .ambient__glow {
  opacity: 0.22;
}

[data-theme="light"] .ambient__grid {
  opacity: 0.4;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(30px, 40px, 0) scale(1.08); }
}

/* ---------- primitives ---------- */

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.15), 0 0 18px rgba(167, 139, 250, 0.8);
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.meta-item .icon {
  width: 16px;
  height: 16px;
}

.meta-item--muted {
  opacity: 0.85;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chip .icon {
  width: 14px;
  height: 14px;
}

.chip--link {
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.chip--link:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}

.chip--xs {
  padding: 3px 8px;
  font-size: 0.66rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge .icon {
  width: 14px;
  height: 14px;
}

.badge--success {
  border-color: rgba(52, 211, 153, 0.3);
  background: var(--success-soft);
  color: var(--emerald);
}

.level {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.level--base {
  background: rgba(52, 211, 153, 0.1);
  color: var(--emerald);
  border: 1px solid rgba(52, 211, 153, 0.22);
}

.level--mid {
  background: rgba(251, 191, 36, 0.09);
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.level--pro {
  background: rgba(251, 113, 133, 0.1);
  color: var(--rose);
  border: 1px solid rgba(251, 113, 133, 0.22);
}

.tag-link {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  transition: color 0.2s ease, background 0.2s ease;
}

.tag-link:hover {
  color: var(--violet-bright);
  background: var(--accent-soft);
}

.tag-link--sm {
  padding: 2px 4px;
  font-size: 0.74rem;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--violet-bright);
  font-size: 0.82rem;
  font-weight: 600;
  transition: color 0.2s ease, opacity 0.2s ease;
}

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

.text-btn .icon {
  width: 15px;
  height: 15px;
}

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

.text-btn--danger:hover {
  color: #ff9bab;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 700;
  transition: color 0.2s ease, gap 0.2s ease;
}

.link-arrow:hover {
  color: var(--text);
  gap: 11px;
}

.link-arrow .icon {
  width: 16px;
  height: 16px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  transition: transform 0.2s var(--ease), border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

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

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.btn--primary {
  border-color: transparent;
  background: var(--gradient-strong);
  color: #fff;
  box-shadow: 0 10px 28px rgba(76, 29, 149, 0.34);
}

.btn--primary:hover {
  background: var(--gradient-strong);
  box-shadow: 0 14px 34px rgba(76, 29, 149, 0.46);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.035);
}

.btn.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--violet-bright);
}

.btn.is-done {
  border-color: rgba(52, 211, 153, 0.32);
  background: var(--success-soft);
  color: var(--emerald);
  box-shadow: none;
}

.btn.is-done:hover {
  background: rgba(52, 211, 153, 0.18);
}

.btn--icon-label span {
  display: inline;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

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

.icon-btn--sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

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

.icon-btn--danger:hover {
  border-color: rgba(251, 113, 133, 0.35);
  background: var(--danger-soft);
  color: var(--rose);
}

.star-btn.is-active {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
  color: var(--amber);
}

.star-btn.is-active .icon {
  fill: currentColor;
  fill-opacity: 0.22;
}

/* ---------- progress ---------- */

.progress {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

[data-theme="light"] .progress {
  background: rgba(24, 24, 60, 0.08);
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-strong);
  transition: width 0.5s var(--ease);
}

.progress--sm {
  height: 4px;
}

/* ---------- fields ---------- */

.field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.field:focus-within {
  border-color: var(--accent-line);
  background: var(--surface-solid);
}

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

.field input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
}

.field input::placeholder {
  color: var(--muted);
}

/* ---------- utility ---------- */

.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;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--gradient-strong);
  color: #fff;
  font-weight: 700;
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.boot-error {
  max-width: 680px;
  margin: 80px auto;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.boot-error p {
  margin-top: 12px;
  color: var(--text-soft);
}

.noscript {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 500;
  max-width: 340px;
  padding: 14px 18px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 12px;
  background: #1b1608;
  color: #fde68a;
  font-size: 0.84rem;
}

/* ---------- accent scopes ---------- */

.accent-violet {
  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.13);
  --accent-line: rgba(167, 139, 250, 0.34);
}

.accent-blue {
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --accent-line: rgba(96, 165, 250, 0.32);
}

.accent-cyan {
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.11);
  --accent-line: rgba(34, 211, 238, 0.3);
}

.accent-emerald {
  --accent: #34d399;
  --accent-soft: rgba(52, 211, 153, 0.11);
  --accent-line: rgba(52, 211, 153, 0.3);
}

.accent-amber {
  --accent: #fbbf24;
  --accent-soft: rgba(251, 191, 36, 0.1);
  --accent-line: rgba(251, 191, 36, 0.3);
}

.accent-rose {
  --accent: #fb7185;
  --accent-soft: rgba(251, 113, 133, 0.11);
  --accent-line: rgba(251, 113, 133, 0.3);
}

[data-theme="light"] .accent-violet { --accent: #7c3aed; --accent-soft: rgba(124, 58, 237, 0.08); --accent-line: rgba(124, 58, 237, 0.26); }
[data-theme="light"] .accent-blue { --accent: #2563eb; --accent-soft: rgba(37, 99, 235, 0.08); --accent-line: rgba(37, 99, 235, 0.25); }
[data-theme="light"] .accent-cyan { --accent: #0891b2; --accent-soft: rgba(8, 145, 178, 0.08); --accent-line: rgba(8, 145, 178, 0.24); }
[data-theme="light"] .accent-emerald { --accent: #059669; --accent-soft: rgba(5, 150, 105, 0.08); --accent-line: rgba(5, 150, 105, 0.24); }
[data-theme="light"] .accent-amber { --accent: #b45309; --accent-soft: rgba(180, 83, 9, 0.08); --accent-line: rgba(180, 83, 9, 0.24); }
[data-theme="light"] .accent-rose { --accent: #be123c; --accent-soft: rgba(190, 18, 60, 0.08); --accent-line: rgba(190, 18, 60, 0.24); }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

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