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

body {
  margin: 0;
  padding: clamp(0.85rem, 2vw, 1.4rem);
  font-family: system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: #e8e4dc;
  color: #2a2622;
}

.combo-lab {
  max-width: min(1760px, calc(100% - 2rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
  align-items: start;
}

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

  .token-row {
    grid-template-columns: 1fr;
  }

  .token-readout {
    text-align: left;
  }
}

.combo-pane {
  min-width: 0;
  display: grid;
}

.combo-controls {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto;
  gap: 0.65rem;
  margin: 0.85rem 0 0;
  padding: 0.85rem;
  border: 1px solid rgba(42, 38, 34, 0.18);
  background: rgba(255, 255, 255, 0.35);
  order: 2;
}

@media (max-width: 620px) {
  .combo-controls {
    grid-template-columns: 1fr;
  }
}

.combo-selector {
  display: grid;
  gap: 0.25rem;
}

.combo-selector[hidden] {
  display: none;
}

.combo-actions {
  align-self: end;
}

.pane-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.combo-selector label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5c574f;
}

.combo-selector select {
  width: 100%;
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  font: 500 0.82rem/1.2 system-ui, sans-serif;
  padding: 0.55rem 0.65rem;
}

/* ---------- Palette tokens (from explorations/palette.css; scoped per card) ---------- */
.combo-card {
  --paper: #eee7d3;
  --paper-deep: #e2d9c0;
  --ink: #1c2d2f;
  --ink-soft: #3a473f;
  --rule: #cfc4a8;
  --mark: #2d5240;
  --font-display: 'Zilla Slab', Georgia, serif;
  --font-body: 'Literata', Georgia, serif;
  --font-kicker: 'Literata', Georgia, serif;
  --font-marginalia: 'Red Hat Mono', ui-monospace, monospace;

  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
}

/* A · Theory pink */
.combo-card[data-palette="a"] {
  --paper: #f6f1e8;
  --paper-deep: #ede5d5;
  --ink: #1c1416;
  --ink-soft: #5b4d4f;
  --rule: #d9cdc0;
  --mark: #e60a6e;
}

/* C · Oxblood */
.combo-card[data-palette="c"] {
  --paper: #f4ece0;
  --paper-deep: #e9dfd0;
  --ink: #18100e;
  --ink-soft: #5a4840;
  --rule: #d4c6b5;
  --mark: #7a1524;
}

/* D · Library green */
.combo-card[data-palette="d"] {
  --paper: #eee7d3;
  --paper-deep: #e2d9c0;
  --ink: #1c2d2f;
  --ink-soft: #3a473f;
  --rule: #cfc4a8;
  --mark: #2d5240;
}

/* E1 · Notebook line */
.combo-card[data-palette="e1"] {
  --paper: #f8eeea;
  --paper-deep: #eee0d9;
  --ink: #1a1111;
  --ink-soft: #574949;
  --rule: #d7cbc5;
  --mark: #ef7d83;
}

/* E2 · Redline */
.combo-card[data-palette="e2"] {
  --paper: #f8eeea;
  --paper-deep: #eee0d9;
  --ink: #1a1111;
  --ink-soft: #574949;
  --rule: #d7cbc5;
  --mark: #e54b52;
}

/* E3 · Coral */
.combo-card[data-palette="e3"] {
  --paper: #f8eeea;
  --paper-deep: #eee0d9;
  --ink: #1a1111;
  --ink-soft: #574949;
  --rule: #d7cbc5;
  --mark: #e24942;
}

/* E4 · Carmine */
.combo-card[data-palette="e4"] {
  --paper: #f8eeea;
  --paper-deep: #eee0d9;
  --ink: #1a1111;
  --ink-soft: #574949;
  --rule: #d7cbc5;
  --mark: #d21d4e;
}

/* F1 · Ruled */
.combo-card[data-palette="f1"] {
  --paper: #f0f4f7;
  --paper-deep: #e2e9ee;
  --ink: #141619;
  --ink-soft: #4c5055;
  --rule: #aac8e7;
  --mark: #e54b52;
}

/* F2 · Ballpoint */
.combo-card[data-palette="f2"] {
  --paper: #f0f4f7;
  --paper-deep: #e2e9ee;
  --ink: #15233e;
  --ink-soft: #495972;
  --rule: #aac8e7;
  --mark: #e54b52;
}

/* ---------- Font pair presets ---------- */
/* Scratch FOSS (loads from Google Fonts above) */
.combo-card[data-font-pair="foss"] {
  --font-display: 'Zilla Slab', Georgia, serif;
  --font-body: 'Literata', Georgia, serif;
  --font-kicker: 'Literata', Georgia, serif;
  --font-marginalia: 'Red Hat Mono', ui-monospace, monospace;
}

/*
  Pangram names match fonts-face.css (internal TYPO family names).
  Valve cuts are per-weight families; Writer Text/Book/Thin are separate families.
*/
.combo-card[data-font-pair="pp-valve-writer"] {
  --font-display: 'PP Valve Stencil Extrabold', 'Zilla Slab', Impact, sans-serif;
  --font-body: 'PP Writer', 'Literata', Georgia, serif;
  --font-kicker: 'PP Writer Italic', 'Literata', Georgia, serif;
  --font-marginalia: 'PP Right Serif Mono', 'Red Hat Mono', ui-monospace, monospace;
}

.combo-card[data-font-pair="pp-serifmono-valve"] {
  --font-display: 'PP Right Serif Mono Dark', 'Red Hat Mono', ui-monospace, monospace;
  --font-body: 'PP Valve Plain Medium', system-ui, sans-serif;
  --font-kicker: 'PP Valve Medium', system-ui, sans-serif;
  --font-marginalia: 'PP Right Serif Mono Fine', 'Red Hat Mono', ui-monospace, monospace;
}

.combo-card[data-font-pair="pp-valve-writer"] .hero {
  font-weight: 800;
  font-style: normal;
}

.combo-card[data-font-pair="pp-valve-writer"] .kicker {
  font-weight: 400;
  font-style: normal;
}

.combo-card[data-font-pair="pp-serifmono-valve"] .hero {
  font-weight: 400;
  font-style: normal;
}

.combo-card[data-font-pair="pp-serifmono-valve"] .kicker {
  font-weight: 500;
  font-style: italic;
}

.combo-card__inner {
  padding: clamp(1.25rem, 3vw, 2rem);
  border-top: 3px solid var(--mark);
  --gradient-stop: 14%;
  --gradient-opacity: 1;
  background: linear-gradient(180deg,
    color-mix(in oklch, var(--paper-deep) calc(var(--gradient-opacity) * 100%), transparent) 0%,
    transparent var(--gradient-stop));
}

.combo-card[data-gradient="off"] .combo-card__inner {
  background: var(--paper);
}

.combo-card__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.combo-card__label::after {
  content: attr(data-mode-label);
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  padding: 0.14rem 0.45rem;
  border: 1px solid color-mix(in oklch, var(--mark) 42%, var(--rule));
  border-radius: 999px;
  background: color-mix(in oklch, var(--mark) 8%, var(--paper));
  color: var(--mark);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.hero {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 3.75rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  color: var(--ink);
}

.combo-card[data-font-pair="foss"] .hero {
  font-weight: 700;
}

.combo-card[data-font-pair="pp-serifmono-valve"] .hero {
  letter-spacing: -0.04em;
}

.hero-mark {
  color: var(--mark);
}

.kicker {
  font-family: var(--font-kicker);
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  font-weight: 600;
  font-style: italic;
  line-height: 1.35;
  margin: 0 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  text-wrap: pretty;
  color: var(--ink);
}

.specimen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(11rem, 26%);
  gap: clamp(1rem, 3vw, 1.75rem);
  align-items: start;
}

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

.body-col .body {
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 400;
  line-height: 1.58;
  margin: 0;
  color: var(--ink);
}

.marginalia-col {
  padding: 0.85rem 0.95rem;
  background: var(--paper-deep);
  border-left: 2px solid var(--mark);
}

.marginalia-col .marginalia {
  font-family: var(--font-marginalia);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.55;
  margin: 0;
  color: var(--ink-soft);
}

.marginalia-ref {
  display: inline-block;
  font-weight: 700;
  color: var(--mark);
  margin-right: 0.35em;
}

/* ================================================================
   Phase 1-6 additions: controls panel, palette editor, OT chips,
   surface controls, share controls, editable affordance
   ================================================================ */

/* ---------- Controls panel ---------- */
.controls-panel {
  margin: 0;
  border: 1px solid rgba(42, 38, 34, 0.18);
  background: rgba(255, 255, 255, 0.35);
  order: 3;
}

.combo-card {
  order: 1;
}

.controls-section {
  border-bottom: 1px solid rgba(42, 38, 34, 0.12);
}

.controls-section:last-child {
  border-bottom: none;
}

.controls-section summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5c574f;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.controls-section summary::-webkit-details-marker {
  display: none;
}

.controls-section summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 0.28rem solid transparent;
  border-bottom: 0.28rem solid transparent;
  border-left: 0.36rem solid currentColor;
  transform-origin: 45% 50%;
  transition: transform 120ms ease;
}

.controls-section[open] summary::before {
  transform: rotate(90deg);
}

.controls-section > div {
  padding: 0 0.85rem 0.65rem;
}

.display-text-control {
  display: grid;
  gap: 0.25rem;
}

.display-text-control label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5c574f;
}

.display-text-control input[type="text"] {
  width: 100%;
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  font: 500 0.88rem/1.2 system-ui, sans-serif;
  padding: 0.55rem 0.65rem;
}

/* ---------- Slot pickers ---------- */
.display-text-control .hero-mark-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: normal;
  text-transform: none;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 1.25rem 0.85rem;
}

.slot-picker {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.slot-picker legend {
  margin-bottom: 0.5rem;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.slot-control {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  color: #5c574f;
  font-size: 0.75rem;
}

.slot-axes {
  display: grid;
  gap: 0.5rem;
}

.slot-hint {
  margin-top: -0.3rem;
  color: #5c574f;
  font-size: 0.72rem;
  line-height: 1.4;
}

.slot-axes:empty {
  display: none;
}

.slot-picker select,
.slot-picker input {
  width: 100%;
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  font: 500 0.82rem/1.2 system-ui, sans-serif;
  padding: 0.55rem 0.65rem;
}

/* ---------- Palette editor ---------- */
.palette-editor {
  container-type: inline-size;
  display: grid;
  gap: 0.35rem;
}

.palette-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
}

.palette-editor-header h3 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5c574f;
  margin: 0;
}

.palette-reset-btn,
.palette-copy-btn,
.pane-action-btn {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  cursor: pointer;
  font-family: system-ui, sans-serif;
}

.palette-mode-control {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5c574f;
}

.palette-mode-control select {
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  font: 600 0.68rem/1.2 system-ui, sans-serif;
  padding: 0.25rem 0.4rem;
}

.control-instructions {
  max-width: 76ch;
  margin: -0.1rem 0 0.2rem;
  color: #4a4540;
  font-size: 0.72rem;
  line-height: 1.35;
}

.palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.2rem;
}

.palette-swatch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.45rem 0.18rem 0.22rem;
  border: 1px solid rgba(42, 38, 34, 0.16);
  border-radius: 999px;
  background: rgba(247, 244, 238, 0.7);
  color: #4a4540;
  font-size: 0.6rem;
  font-weight: 650;
}

.palette-swatch-chip {
  width: 0.9rem;
  height: 0.9rem;
  border: 1px solid rgba(42, 38, 34, 0.24);
  border-radius: 999px;
}

.palette-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.token-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 7.25rem 4.8rem;
  gap: 0.4rem;
  align-items: center;
  padding: 0.25rem 0;
}

.token-row label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #4a4540;
}

.token-sliders {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  align-items: center;
}

.token-channel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.25rem;
  gap: 0.25rem;
  align-items: center;
}

.token-sliders input[type="range"] {
  width: 100%;
  margin: 0;
}

.token-channel input[type="number"] {
  width: 100%;
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  font: 600 0.65rem/1 ui-monospace, monospace;
  padding: 0.25rem 0.3rem;
}

.token-slider-label {
  font-size: 0.55rem;
  color: #6a6560;
  text-align: center;
  grid-column: 1 / -1;
}

.token-readout {
  min-width: 0;
  color: #4a4540;
  text-align: left;
}

.token-readout label {
  display: grid;
  gap: 0.2rem;
}

.token-hex {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  font: 500 0.8rem/1.3 ui-monospace, monospace;
  padding: 0.4rem;
}

.token-hex:focus-visible {
  outline: 2px solid #2a2622;
  outline-offset: 2px;
}

.token-hex:disabled {
  background: #eeeae3;
  color: #6a6560;
  cursor: not-allowed;
}

.token-hex[aria-invalid="true"] {
  border-color: #a11919;
}

.token-hex-error {
  color: #a11919;
  font-size: 0.75rem;
}

.token-readout.oog label::before {
  content: 'sRGB preview';
  font-size: 0.7rem;
  font-weight: 400;
}

@container (max-width: 40rem) {
  .token-row {
    grid-template-columns: minmax(0, 1fr) 7.25rem 4.8rem;
    row-gap: 0.6rem;
    padding: 0.5rem 0;
  }

  .token-sliders {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@container (max-width: 24rem) {
  .palette-editor-header {
    flex-wrap: wrap;
  }

  .token-row {
    grid-template-columns: minmax(0, 1fr) 7.25rem auto;
  }

  .token-channel {
    grid-template-columns: minmax(0, 1fr);
  }
}

.token-lock {
  font-size: 0.7rem;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(42, 38, 34, 0.22);
  border-radius: 2px;
  background: #f7f4ee;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.token-lock[data-locked="true"] {
  background: var(--mark);
  color: var(--paper);
  border-color: var(--mark);
}

.token-lock[data-locked="false"] {
  opacity: 0.45;
}

.token-affordance {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
}

.token-source {
  color: #6a6560;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.token-anchor {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6a6560;
  text-align: center;
}

.token-row[data-locked="true"] .token-sliders input {
  opacity: 0.4;
  pointer-events: none;
}

.palette-copy-btn[data-copied="true"],
.pane-action-btn[data-copied="true"] {
  background: var(--mark);
  color: var(--paper);
  border-color: var(--mark);
}

/* ---------- OT feature chips ---------- */
.ot-features {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ot-row {
  display: grid;
  gap: 0.3rem;
}

.ot-row-header {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5c574f;
}

.ot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.ot-chip {
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid rgba(42, 38, 34, 0.18);
  border-radius: 2px;
  background: #f7f4ee;
  color: #2a2622;
  cursor: pointer;
  user-select: none;
  font-family: system-ui, sans-serif;
}

.ot-chip[data-active="true"] {
  background: var(--mark);
  color: var(--paper);
  border-color: var(--mark);
}

.ot-chip[data-active="false"] {
  opacity: 0.55;
}

/* ---------- Surface controls ---------- */
.surface-controls {
  display: grid;
  gap: 0.5rem;
}

.surface-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.surface-row label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #4a4540;
  min-width: 5.5rem;
}

.surface-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

.surface-value {
  font-size: 0.6rem;
  font-family: ui-monospace, monospace;
  color: #4a4540;
  min-width: 2.5rem;
  text-align: right;
}

/* ---------- Editable specimen affordance ---------- */
.hero:hover {
  outline: 1px dashed var(--rule);
  outline-offset: 2px;
}

/* ---------- Out-of-gamut warning ---------- */
.oog-warning {
  font-size: 0.6rem;
  color: var(--mark);
  font-weight: 600;
  margin-left: 0.3rem;
}
