/* crtcolor.com shared styles — phosphor CRT aesthetic */
@import url('https://fonts.googleapis.com/css2?family=VT323&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #0a0e0a;
  --bg-panel: #11160f;
  --phosphor: #33ff66;
  --phosphor-dim: #1f9c3f;
  --amber: #ffb000;
  --text: #c8e6c8;
  --text-dim: #6f8a6f;
  --border: #1e2a1e;
  --border-bright: #2f4a2f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  line-height: 1.6;
  padding: 0;
  position: relative;
}

/* scanline overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.18) 0px, rgba(0,0,0,0.18) 1px, transparent 1px, transparent 3px);
  z-index: 9999;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 2rem 1.25rem 5rem; }

header.site {
  border-bottom: 1px solid var(--border-bright);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}
.logo {
  font-family: 'VT323', monospace;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--phosphor);
  text-shadow: 0 0 8px rgba(51,255,102,0.45);
  letter-spacing: 1px;
}
.logo a { color: inherit; text-decoration: none; }
.tagline { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; }

nav.site { margin-top: 1rem; display: flex; gap: 1.25rem; flex-wrap: wrap; }
nav.site a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
nav.site a:hover, nav.site a[aria-current="page"] {
  color: var(--phosphor);
  border-bottom-color: var(--phosphor-dim);
}

h1 {
  font-family: 'VT323', monospace;
  font-size: 2.8rem;
  line-height: 1.05;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(51,255,102,0.35);
  margin-bottom: 0.5rem;
}
h2 {
  font-family: 'VT323', monospace;
  font-size: 1.9rem;
  color: var(--amber);
  margin: 2.5rem 0 1rem;
}
h3 { font-size: 1rem; font-weight: 500; color: var(--text); margin: 1.5rem 0 0.5rem; }
p { margin-bottom: 1rem; max-width: 68ch; }
a { color: var(--phosphor); }
.lead { font-size: 1.05rem; color: var(--text); margin-bottom: 2rem; max-width: 70ch; }
code {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
  color: var(--amber);
}

/* palette swatch grid */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 1.5rem 0;
}
.swatch {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.swatch:hover { border-color: var(--border-bright); transform: translateY(-2px); }
.swatch:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; }
.swatch.sel { outline: 2px solid var(--phosphor); outline-offset: 2px; }
.swatch .idx2 { font-size: 0.7rem; color: var(--phosphor-dim); font-family: 'VT323', monospace; }
.swatch .chip { height: 70px; width: 100%; }
.swatch .meta { padding: 8px 10px; }
.swatch .nm { font-size: 0.82rem; color: var(--text); text-transform: lowercase; }
.swatch .hx { font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.5px; }
.swatch .idx {
  font-size: 0.7rem; color: var(--phosphor-dim);
  float: right; font-family: 'VT323', monospace;
}

/* dense 64-grid */
.grid64 { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: 1.5rem 0; max-width: 520px; }
.cell64 { aspect-ratio: 1; border-radius: 3px; cursor: pointer; border: 1px solid rgba(0,0,0,0.4); position: relative; }
.cell64:hover { outline: 2px solid var(--phosphor); outline-offset: 1px; z-index: 2; }
.cell64.dflt::after {
  content: ""; position: absolute; inset: 0; border: 2px solid var(--amber); border-radius: 2px;
}
.cell64.cur { outline: 3px solid var(--phosphor); outline-offset: 1px; z-index: 3; }

.controls { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin: 1.5rem 0; }
.btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  color: var(--phosphor);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
}
.btn:hover { background: #16201450; border-color: var(--phosphor-dim); }
.btn:active { transform: scale(0.98); }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--phosphor); color: #03150a; font-weight: 500;
  padding: 0.6rem 1.2rem; border-radius: 4px; font-size: 0.85rem;
  opacity: 0; transition: opacity 0.18s, transform 0.18s; pointer-events: none; z-index: 10000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.note {
  border-left: 3px solid var(--amber);
  background: #1a140030;
  padding: 0.9rem 1.1rem;
  margin: 1.5rem 0;
  font-size: 0.92rem;
  border-radius: 0 4px 4px 0;
}
.note strong { color: var(--amber); }

table.ref { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.85rem; }
table.ref th, table.ref td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); }
table.ref th { color: var(--amber); font-weight: 500; }
table.ref td.swcell { width: 40px; }
table.ref .mini { width: 26px; height: 26px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.4); }

footer.site {
  border-top: 1px solid var(--border);
  margin-top: 4rem; padding-top: 1.5rem;
  color: var(--text-dim); font-size: 0.8rem;
}
footer.site a { color: var(--phosphor-dim); }
footer.site .foot-links { margin-top: 0.6rem; }
footer.site .foot-links a { color: var(--phosphor); }

.faq dt { color: var(--amber); font-weight: 500; margin-top: 1.25rem; }
.faq dd { margin-left: 0; color: var(--text); }

/* CGA mode simulator */
.ctl-label { color: var(--text-dim); font-size: 0.8rem; margin-right: 0.25rem; }
.btn.active { background: var(--phosphor); color: #03150a; border-color: var(--phosphor); }
.btn.active:hover { background: var(--phosphor); }
.bgpick { display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; max-width: 520px; margin: 0.5rem 0 1.5rem; }
.bgpick .sw { aspect-ratio: 1; border-radius: 3px; cursor: pointer; border: 1px solid rgba(0,0,0,0.4); position: relative; }
.bgpick .sw:hover { outline: 2px solid var(--phosphor); outline-offset: 1px; z-index: 2; }
.bgpick .sw[aria-pressed="true"]::after {
  content: ""; position: absolute; inset: 0; border: 2px solid var(--phosphor); border-radius: 2px;
}
.sim-stage { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; margin: 1.5rem 0; }
.sim-screen { background: #000; border: 1px solid var(--border-bright); border-radius: 4px; padding: 8px; }
.sim-screen canvas { display: block; width: 320px; height: 200px; image-rendering: pixelated; }
.sim-side { flex: 1; min-width: 280px; }
.sim-side .palname { color: var(--amber); font-family: 'VT323', monospace; font-size: 1.3rem; margin-bottom: 0.5rem; }
.sim-swatches { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 10px; }

/* image converter */
.drop {
  border: 1px dashed var(--border-bright); border-radius: 6px;
  padding: 1.4rem; text-align: center; color: var(--text-dim);
  cursor: pointer; margin: 1rem 0; transition: border-color 0.12s, color 0.12s;
}
.drop:hover, .drop.drag { border-color: var(--phosphor); color: var(--phosphor); }
.drop strong { color: var(--phosphor); }
.conv-fields { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-end; margin: 1.25rem 0 0.5rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field > span { color: var(--text-dim); font-size: 0.8rem; }
.field select {
  background: var(--bg-panel); color: var(--phosphor);
  border: 1px solid var(--border-bright); border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem; padding: 0.5rem 0.6rem;
}
.subctl { margin: 0.25rem 0 0.75rem; }
.subctl .ctl-label { display: block; margin-bottom: 0.3rem; }
.conv-grid { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 1.5rem 0; }
.conv-grid figure { margin: 0; }
.conv-grid figcaption { color: var(--text-dim); font-size: 0.78rem; margin-bottom: 0.4rem; }
.conv-canvas {
  width: 380px; max-width: 100%; border: 1px solid var(--border-bright);
  border-radius: 4px; background: #000; display: block; height: auto;
}
.conv-canvas.pixel { image-rendering: pixelated; }
.ntsc-knobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem 1.25rem; margin: 0.5rem 0; max-width: 720px; }
.ntsc-knobs label { display: grid; grid-template-columns: 5.5rem 1fr 2.5rem; align-items: center; gap: 0.5rem; color: var(--text-dim); font-size: 0.8rem; }
.ntsc-knobs input[type="range"] { width: 100%; accent-color: var(--phosphor); }
.ntsc-knobs output { color: var(--phosphor); font-size: 0.8rem; text-align: right; }

@media (prefers-reduced-motion: reduce) {
  .swatch { transition: none; }
}
