:root {
  --panel-w: 360px;
  --panel-bg: var(--bg-dark);
  --panel-border: var(--border-default);
  --label: var(--neutral-300);
  --text: var(--neutral-100);
  --input-bg: var(--bg-extra-light);
  --accent: var(--accent-200);
  --active-bg: rgba(103, 144, 238, 0.15);
  --sep: var(--border-default);
}

html, body {
  height: 100%;
  background: var(--bg-dark);
  font-family: var(--sans);
  color: var(--text);
  overflow: hidden;
}

.layout {
  display: flex;
  height: 100vh;
}

/* ── Preview ── */
.preview {
  flex: 1;
  position: relative;
  transition: background-color 0.08s;
}

/* ── Panel ── */
.panel {
  width: var(--panel-w);
  flex-shrink: 0;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: var(--radius-s); }

.panel-header {
  height: 80px;
  padding: 0 24px 0 72px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.panel-title {
  font-size: var(--type-l-size);
  font-weight: var(--regular);
  color: var(--neutral-100);
  white-space: nowrap;
}

/* ── Mode toggle ── */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 24px 24px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.mode-btn {
  padding: 8px 0;
  font-size: var(--type-s-size);
  color: var(--label);
  background: transparent;
  border: 1px solid var(--neutral-500);
  border-radius: var(--radius-s);
  cursor: pointer;
  font-family: var(--sans);
  letter-spacing: 0.06em;
  text-align: center;
  transition: all 0.12s;
}
.mode-btn:hover { color: var(--text); background: var(--input-bg); }
.mode-btn.active {
  color: var(--text);
  background: var(--active-bg);
  border-color: rgba(255,255,255,0.26);
}

/* ── Controls ── */
.controls {
  padding: 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

.ctrl { display: flex; flex-direction: column; gap: 8px; }
.ctrl.disabled { opacity: 0.25; pointer-events: none; }

.ctrl-row { display: flex; align-items: baseline; justify-content: space-between; }
.ctrl-label {
  font-size: var(--type-xs-size);
  color: var(--label);
  font-family: var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ctrl-val {
  font-size: var(--type-s-size);
  color: var(--text);
  min-width: 42px;
  text-align: right;
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-s);
  outline: none;
  cursor: pointer;
}
input[type=range]::-moz-range-progress {
  background: var(--accent-400);
  height: 3px;
  border-radius: var(--radius-s);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.color-row { display: flex; align-items: stretch; gap: 8px; }
.color-pair { display: flex; gap: 24px; }
.color-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.color-swatch-wrap {
  aspect-ratio: 1;
  border-radius: var(--radius-m);
  border: 1px solid var(--neutral-500);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.color-swatch-wrap input[type=color] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
  padding: 0;
  border: none;
}
.color-swatch { width: 100%; height: 100%; pointer-events: none; }

.color-hex {
  flex: 1;
  min-width: 0;
  letter-spacing: 0.04em;
  font-size: var(--type-s-size);
}

.sep { height: 0.5px; background: var(--sep); margin: 8px 0; }

/* ── Code output ── */
.code-section {
  padding: 24px 24px 24px;
  flex-shrink: 0;
}
.code-label {
  font-size: var(--type-xs-size);
  color: var(--label);
  font-family: var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 9px;
}
.code-block {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--neutral-500);
  border-radius: var(--radius-m);
  padding: 12px 16px;
  font-size: var(--type-xs-size);
  line-height: 1.8;
  color: rgba(255,255,255,0.52);
  font-family: var(--mono);
  word-break: break-all;
  min-height: 72px;
  letter-spacing: 0.01em;
}
.code-block .k { color: #8cb4d8; }
.code-block .v { color: #c5a37e; }

.copy-btn {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: var(--type-s-size);
  font-weight: var(--medium);
  border-radius: var(--radius-m);
  cursor: pointer;
  font-family: var(--sans);
  letter-spacing: 0.06em;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.copy-btn:hover { background: rgba(255,255,255,0.09); }
.copy-btn.copied {
  color: var(--accent-100);
  border-color: rgba(103, 144, 238, 0.3);
}

/* ── Responsive: narrow screens ── */
@media (max-width: 600px) {
  :root { --panel-w: 100%; }
  .layout { flex-direction: column; overflow: auto; }
  .preview { height: 280px; flex: none; }
  html, body { overflow: auto; }
}
