:root {
  /* Surface */
  --base: #000000;
  --sidebar: #141414;
  --selection: #2d2d2d;
  --border: #636363;
  /* Phosphor */
  --text: #ffffff;
  --variable: #e8e8e8;
  --comment: #b3b3b3;
  --ignored: #757575;
  /* Glow */
  --wheat: #fae2c8;
  --tan: #d9b98c;
  --gold: #ffb86c;
  --amber: #ff9e3b;
  --clay: #f08d49;
  /* Accents */
  --red: #ff6b6b;
  --green: #b9d665;
  --cyan: #aee6d6;
  --blue: #9cd9e6;
  --purple: #eba4be;

  color-scheme: dark;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 12px;
  --focus: var(--gold);
}

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

* { margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--base);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* Accessibility */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: var(--amber);
  color: #000;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

h1, h2, h3 { font-weight: 700; line-height: 1.2; }

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

/* Canvas + scanlines */
#crt-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: overlay;
}

/* Hero */
.hero {
  text-align: center;
  padding: 100px 0 60px;
}

.logo {
  width: 120px;
  height: 120px;
  border-radius: 20px;
  filter: drop-shadow(0 0 15px rgba(255, 158, 59, 0.3));
  margin-bottom: 20px;
}

.title {
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  margin-bottom: 10px;
  background: linear-gradient(to right, var(--wheat), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.subtitle {
  font-size: 1.2rem;
  color: var(--comment);
  margin-bottom: 40px;
}
.subtitle .accent { color: var(--gold); }

.actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 30px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-block;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.btn.primary {
  background-color: var(--amber);
  color: #000;
  box-shadow: 0 0 15px rgba(255, 158, 59, 0.4);
}
.btn.primary:hover { background-color: var(--gold); box-shadow: 0 0 25px rgba(255, 158, 59, 0.6); }
.btn.secondary {
  background-color: var(--selection);
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { background-color: var(--border); }

/* Code preview */
.preview { margin: 60px 0; }

.code-window {
  background-color: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 99, 99, 0.1);
}

.window-header {
  background-color: #0a0a0a;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--selection);
}
.dot { width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; }
.dot.red { background-color: var(--red); }
.dot.yellow { background-color: var(--gold); }
.dot.green { background-color: var(--green); }
.file-name { margin-left: 10px; font-size: 0.9rem; color: var(--comment); }

pre {
  padding: 20px;
  overflow-x: auto;
  background-color: var(--base);
  color: var(--text);
}
code { font-family: var(--font-mono); font-size: 0.95rem; }

.k { color: var(--gold); }
.f { color: var(--amber); }
.a { color: var(--variable); }
.v { color: var(--wheat); }
.s { color: var(--green); }
.c { color: var(--comment); }
.n { color: var(--purple); }
.t { color: var(--wheat); }

/* Palette */
.palette { padding: 40px 0; }
.section-title { text-align: center; margin-bottom: 8px; color: var(--wheat); font-size: 1.8rem; }
.section-hint { text-align: center; color: var(--ignored); font-size: 0.9rem; margin-bottom: 32px; }
.palette-group { margin-bottom: 30px; }
.palette-group h3 {
  margin-bottom: 15px;
  color: var(--wheat);
  font-size: 1.1rem;
  border-bottom: 1px solid var(--selection);
  display: inline-block;
  padding-bottom: 5px;
}
.strip {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--selection);
}
.strip-swatch {
  flex: 1 1 0;
  min-width: 0;
  min-height: 168px;
  border: 0;
  border-radius: 0;
  background-color: var(--swatch, var(--sidebar));
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: flex-grow 0.25s ease, filter 0.15s ease;
  position: relative;
}
.strip-swatch:hover, .strip-swatch:focus-visible { flex-grow: 1.7; filter: brightness(1.05); z-index: 1; }
.strip-swatch .name { order: -1; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.strip-swatch .code { font-family: var(--font-mono); font-size: 0.8rem; opacity: 0.85; }
.strip-swatch::after {
  content: 'Copied';
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.strip-swatch.copied::after { opacity: 0.9; }
.copy-status { min-height: 1.5em; text-align: center; color: var(--green); font-size: 0.9rem; }

/* Ports */
.ecosystem { padding: 60px 0 100px; }
.search-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.search-row label { color: var(--comment); font-size: 0.95rem; }
#port-search {
  background: var(--sidebar);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  min-width: min(320px, 80vw);
  font-family: inherit;
}
#port-search::placeholder { color: var(--ignored); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.card {
  background-color: var(--sidebar);
  border: 1px solid var(--border);
  padding: 25px;
  border-radius: var(--radius);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card:hover {
  transform: translateY(-5px);
  border-color: var(--amber);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}
.card[hidden] { display: none; }
.card-icon { color: var(--amber); line-height: 1; }
.card-icon svg { width: 32px; height: 32px; fill: currentColor; display: block; filter: drop-shadow(0 0 8px rgba(255, 158, 59, 0.35)); }
.card-glyph {
  min-height: 32px;
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 800;
  filter: drop-shadow(0 0 8px rgba(255, 158, 59, 0.35));
}
.card h3 { color: var(--wheat); }
.card p { color: var(--comment); font-size: 0.95rem; }
.install {
  padding: 10px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--selection);
}
.install code { font-size: 0.8rem; word-break: break-all; white-space: pre-wrap; }
.card-row { display: flex; align-items: center; gap: 12px; margin-top: auto; }
.copy-btn {
  background: var(--selection);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease;
}
.copy-btn:hover { background: var(--border); }
.card-link { color: var(--gold); font-size: 0.9rem; }
.card-link:hover { color: var(--amber); }
.no-results { text-align: center; color: var(--comment); margin-top: 24px; }

/* Footer */
footer {
  text-align: center;
  padding: 40px;
  border-top: 1px solid var(--selection);
  color: var(--comment);
  font-size: 0.9rem;
  position: relative;
  z-index: 1;
}

@media (max-width: 600px) {
  .hero { padding: 72px 0 44px; }
  .grid { grid-template-columns: 1fr; }
  .strip { flex-wrap: wrap; }
  .strip-swatch { flex: 1 1 45%; min-height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none; animation: none; }
  #crt-canvas, .scanlines { display: none; }
}
