/* ============================================
   OKLCH Color Space Explorer — Styles
   ============================================ */

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

:root {
  --primary: #7C3AED;
  --primary-light: #A78BFA;
  --accent: #06B6D4;
  --bg: #0B0E11;
  --bg-card: rgba(255,255,255,0.04);
  --bg-glass: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);
  --text: #E8E8E8;
  --text-dim: #9CA3AF;
  --text-muted: #6B7280;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 250ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(11,14,17,0.85); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header__inner {
  max-width: 1200px; margin: 0 auto; padding: 0.75rem 1.5rem;
  display: flex; align-items: center;
}
.header__brand { display: flex; align-items: center; gap: 0.6rem; }
.header__icon { font-size: 1.3rem; }
.header__title { font-size: 1.15rem; font-weight: 700; }
.header__badge {
  font-size: 0.62rem; font-weight: 600; text-transform: uppercase;
  background: var(--primary); color: #fff;
  padding: 0.15rem 0.5rem; border-radius: 999px; letter-spacing: 0.05em;
}

/* --- Layout --- */
.main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.layout { display: grid; grid-template-columns: 380px 1fr; gap: 1.5rem; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* --- Panel --- */
.panel { display: flex; flex-direction: column; gap: 1rem; }

/* --- Preview --- */
.preview {
  display: flex; align-items: center; gap: 1rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; cursor: pointer;
  transition: all var(--transition);
}
.preview:hover { border-color: var(--border-hover); }
.preview__swatch {
  width: 64px; height: 64px; border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.12);
  flex-shrink: 0; transition: background var(--transition);
}
.preview__info { display: flex; flex-direction: column; gap: 0.2rem; }
.preview__label { font-family: var(--mono); font-size: 0.85rem; font-weight: 500; }
.preview__sublabel { font-size: 0.78rem; color: var(--text-dim); font-family: var(--mono); }

/* --- Sliders --- */
.sliders { display: flex; flex-direction: column; gap: 0.85rem; }
.slider-group { display: flex; flex-direction: column; gap: 0.35rem; }
.slider-group__label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem; font-weight: 500; color: var(--text-dim);
}
.slider-group__val { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); }

.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; border-radius: 999px; outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; cursor: pointer; border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
}
.slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.slider--l { background: linear-gradient(to right, #000, #fff); }
.slider--c { background: linear-gradient(to right, #888, #f0f); }
.slider--h {
  background: linear-gradient(to right,
    oklch(0.7 0.15 0), oklch(0.7 0.15 60), oklch(0.7 0.15 120),
    oklch(0.7 0.15 180), oklch(0.7 0.15 240), oklch(0.7 0.15 300), oklch(0.7 0.15 360));
}
.slider--a {
  background: linear-gradient(to right, transparent, #fff);
  background-color: repeating-conic-gradient(#333 0% 25%, #555 0% 50%) 0 0 / 10px 10px;
}

/* --- Gamut Info --- */
.gamut-info { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.gamut-badge {
  font-size: 0.72rem; font-weight: 600; padding: 0.3rem 0.65rem;
  border-radius: 999px; border: 1px solid; opacity: 0.4;
  transition: all var(--transition);
}
.gamut-badge.in-gamut { opacity: 1; }
.gamut-badge--srgb { border-color: #10B981; color: #10B981; }
.gamut-badge--srgb.in-gamut { background: rgba(16,185,129,0.15); }
.gamut-badge--p3 { border-color: #F59E0B; color: #F59E0B; }
.gamut-badge--p3.in-gamut { background: rgba(245,158,11,0.15); }
.gamut-badge--rec2020 { border-color: #EF4444; color: #EF4444; }
.gamut-badge--rec2020.in-gamut { background: rgba(239,68,68,0.15); }

/* --- Code Output --- */
.code-outputs { display: flex; flex-direction: column; gap: 0.6rem; }
.code-block {
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.code-block__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.75rem; background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
}
.code-block__label {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  color: var(--primary-light); letter-spacing: 0.05em;
}
.code-block__code {
  padding: 0.5rem 0.75rem; font-family: var(--mono);
  font-size: 0.78rem; color: var(--accent); white-space: pre-wrap;
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: none; cursor: pointer; font-family: var(--font);
  font-size: 0.82rem; font-weight: 500; border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--ghost {
  background: var(--bg-glass); color: var(--text-dim);
  padding: 0.4rem 0.7rem; border: 1px solid var(--border);
}
.btn--ghost:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.btn--sm { font-size: 0.75rem; padding: 0.3rem 0.6rem; }

/* --- Viz Blocks --- */
.viz-block {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.viz-block__title {
  font-size: 0.88rem; font-weight: 600; margin-bottom: 0.75rem;
  display: flex; align-items: center; justify-content: space-between;
}
.viz-canvas {
  width: 100%; height: auto; border-radius: var(--radius-sm);
  cursor: crosshair; display: block;
}
.viz-strip {
  width: 100%; height: 32px; border-radius: var(--radius-sm);
  cursor: crosshair; display: block;
}

/* --- Harmony --- */
.harmony-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.htab {
  font-size: 0.72rem; font-weight: 500; font-family: var(--font);
  padding: 0.3rem 0.6rem; border-radius: 999px;
  background: var(--bg-glass); color: var(--text-dim);
  border: 1px solid var(--border); cursor: pointer;
  transition: all var(--transition);
}
.htab:hover { background: rgba(255,255,255,0.1); }
.htab--active { background: var(--primary); color: #fff; border-color: var(--primary); }

.harmony-swatches { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.harmony-swatch {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.1); cursor: pointer;
  transition: all var(--transition); position: relative;
}
.harmony-swatch:hover { transform: scale(1.1); border-color: rgba(255,255,255,0.3); }
.harmony-swatch__label {
  position: absolute; bottom: -1.2rem; left: 50%; transform: translateX(-50%);
  font-size: 0.6rem; color: var(--text-muted); white-space: nowrap;
  font-family: var(--mono);
}

/* --- Saved Colors --- */
.saved-colors { display: flex; gap: 0.5rem; flex-wrap: wrap; min-height: 40px; }
.saved-color {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.1); cursor: pointer;
  transition: all var(--transition);
}
.saved-color:hover { transform: scale(1.15); border-color: rgba(255,255,255,0.3); }
.saved-empty { font-size: 0.78rem; color: var(--text-muted); padding: 0.5rem 0; }

/* --- Toast --- */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff;
  padding: 0.6rem 1.25rem; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500; box-shadow: var(--shadow); z-index: 500;
  animation: toastIn 300ms ease;
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .main { padding: 1rem; }
  .header__inner { padding: 0.6rem 1rem; }
  .code-outputs { gap: 0.5rem; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
