*{box-sizing:border-box;font-family:Segoe UI,Roboto,Arial,sans-serif}
body{margin:0;display:flex;flex-direction:column;min-height:100vh}
.app-header{padding:12px 20px;background:#111;color:#fff;display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.app-header h1{margin:0;font-size:18px;font-weight:600;flex:0 0 auto}
.app-header p{margin:0;color:#bbb;font-size:13px;flex:1;min-width:200px}
.app-header__back{color:#fff;text-decoration:none;font-size:18px;line-height:1;padding:4px 8px;border:1px solid #333;border-radius:4px}
.app-header__back:hover{background:#222;border-color:#555}
#app{display:flex;flex-direction:column;flex:1}
main{display:flex;flex:1;padding:20px;gap:20px}
.left{flex:0 0 660px}
.right{flex:1;overflow:auto}
canvas{display:block;border-radius:8px;background:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.15)}
.controls{margin-top:8px;display:flex;flex-wrap:wrap;gap:8px;align-items:center}
button{padding:6px 10px;border-radius:6px;border:1px solid #ccc;background:#fff;cursor:pointer}
#banners { position: fixed; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.banner { background: #fffbe6; border: 1px solid #f0c36d; padding: 8px 32px 8px 12px; border-radius: 6px; position: relative; box-shadow: 0 2px 8px rgba(0,0,0,0.1); max-width: 360px; }
.banner button { position: absolute; top: 4px; right: 4px; background: transparent; border: none; font-size: 18px; cursor: pointer; }
#wheel-tooltip { position: fixed; display: none; background: #111; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 12px; pointer-events: none; z-index: 1100; white-space: nowrap; }
.selected-list { list-style: decimal; padding-left: 24px; margin: 0; }
.selected-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.mini-swatch { display: inline-block; width: 18px; height: 18px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.15); flex: 0 0 18px; }
.paint-label { flex: 1; }
.remove { background: transparent; border: none; font-size: 16px; cursor: pointer; color: #888; padding: 0 6px; }
.remove:hover { color: #c33; }
.empty { color: #888; font-style: italic; margin: 4px 0; }
.hint { color: #888; font-size: 11px; margin: 4px 0 0; }

.inhull-list { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow-y: auto; }
.inhull-list li { display: flex; align-items: center; gap: 8px; padding: 3px 4px; }
.inhull-list li:hover { background: #f4f4f4; border-radius: 4px; }
.inhull-list .paint-label { flex: 1; font-size: 13px; }
.inhull-dim { opacity: 0.5; }
.add-btn { background: transparent; border: none; font-size: 16px; cursor: pointer; color: #888; padding: 0 6px; line-height: 1; }
.add-btn:hover { color: #2a8c3a; }
.rgb-bars { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.rgb-row { display: flex; align-items: center; gap: 8px; }
.rgb-label { width: 90px; font-variant-numeric: tabular-nums; font-size: 12px; }
.rgb-bar { position: relative; flex: 1; height: 14px; background: #eee; border-radius: 7px; overflow: hidden; }
.rgb-fill { position: absolute; top: 0; bottom: 0; border-radius: 7px; }
.sample-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 6px; }
.sample { aspect-ratio: 1 / 1; border-radius: 4px; border: 1px solid rgba(0,0,0,0.08); }

/* Mixing chart — rows = lightness (top is lightest), cols = hue.
   Cells are small fixed squares (not aspect-ratio-1/1 stretched to container),
   gap=0, no internal borders → reads as a gradient swatch grid. */
.mix-board {
  display: grid; gap: 0; margin-top: 6px;
  border: 1px solid rgba(0,0,0,0.15); border-radius: 6px; overflow: hidden;
  max-width: 320px; width: max-content;
}
.mix-cell { width: 22px; height: 22px; }
.btn { padding: 6px 12px; border-radius: 6px; border: 1px solid #bbb; background: #fff; cursor: pointer; font-size: 13px; }
.btn:hover { background: #f4f4f4; }
.btn:active { background: #eaeaea; }
.lightness { display: flex; flex-direction: column; gap: 4px; margin-left: 12px; }
.lightness label { font-size: 12px; color: #444; }
.dual-slider { position: relative; height: 28px; width: 220px; }
.dual-track { position: absolute; top: 13px; left: 0; right: 0; height: 4px; background: #ddd; border-radius: 2px; }
.dual-fill { position: absolute; top: 13px; height: 4px; background: linear-gradient(90deg, #888, #ccc); border-radius: 2px; }
.dual-slider input[type=range] {
  position: absolute; left: 0; right: 0; top: 0; height: 28px; width: 100%;
  -webkit-appearance: none; appearance: none; background: transparent; pointer-events: none;
}
.dual-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  border: 1px solid #555; pointer-events: auto; cursor: pointer; margin-top: -6px;
}
.dual-slider input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  border: 1px solid #555; pointer-events: auto; cursor: pointer;
}
.lightness-readout { font-size: 12px; color: #555; font-variant-numeric: tabular-nums; }
.brand-chips { display: flex; gap: 6px; margin-left: 12px; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid #bbb; background: #f4f4f4; color: #777; cursor: pointer; font-size: 12px; }
.chip-active { background: #222; color: #fff; border-color: #222; }

.hex-input { display: flex; gap: 6px; align-items: center; margin-left: 12px; }
.hex-swatch { display: inline-block; width: 22px; height: 22px; border-radius: 4px; border: 1px solid #ddd; flex: 0 0 22px; }
.hex-field { padding: 5px 8px; border-radius: 6px; border: 1px solid #bbb; background: #fff; font-family: ui-monospace, Consolas, monospace; font-size: 13px; width: 100px; text-transform: lowercase; }
.hex-field:focus { outline: none; border-color: #444; }

/* Color builder — sliders + hex input for new point creation */
.color-builder {
  display: flex; align-items: center; gap: 6px;
  margin-left: 12px;
  padding: 4px 10px;
  background: #f4f4f4; border: 1px solid #ddd; border-radius: 8px;
  background-image: linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}
.cb-swatch {
  position: relative; width: 24px; height: 24px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.25); overflow: hidden; flex: 0 0 24px;
  background: #fff;
  background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px; background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}
.cb-swatch-inner { position: absolute; inset: 0; }
.cb-hex {
  padding: 5px 8px; border-radius: 6px; border: 1px solid #bbb; background: #fff;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; width: 90px;
  text-transform: lowercase;
}
.cb-hex:focus { outline: none; border-color: #444; }
.cb-lbl { font-size: 11px; color: #555; font-weight: 600; margin-left: 2px; }
.cb-range { width: 80px; }
.cb-val { font-size: 11px; color: #555; font-variant-numeric: tabular-nums; min-width: 32px; }
.cb-add { font-size: 13px; padding: 5px 10px; }

/* Chooser landing — shown when no ?mode= is in the URL. */
.chooser { max-width: 880px; margin: 8vh auto 0; padding: 0 24px 48px; }
.chooser__header { text-align: center; margin-bottom: 32px; }
.chooser__header h1 { font-size: 32px; margin: 0 0 8px; letter-spacing: -0.01em; }
.chooser__header p { margin: 0; color: #555; font-size: 15px; }
.chooser__cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chooser__card {
  display: block; padding: 24px 24px 22px;
  border: 1px solid #ddd; border-radius: 10px;
  background: #fff; text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.chooser__card:hover { border-color: #222; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); }
.chooser__card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.chooser__lede { margin: 0 0 10px; color: #333; font-size: 14px; }
.chooser__detail { margin: 0 0 14px; color: #666; font-size: 13px; line-height: 1.55; }
.chooser__cta { font-size: 13px; color: #0067c0; font-weight: 500; }
.chooser__footer { text-align: center; color: #777; font-size: 12px; margin-top: 28px; }
.palettes { display: flex; gap: 6px; margin-left: 12px; align-items: center; }
.palette-select { padding: 5px 8px; border-radius: 6px; border: 1px solid #bbb; background: #fff; }
#print-host { display: none; }
.help-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 1200; }
.help-card { background: #fff; padding: 18px 24px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.3); min-width: 280px; }
.help-card h2 { margin: 0 0 8px 0; }
.help-list { list-style: none; padding: 0; margin: 0 0 12px 0; display: flex; flex-direction: column; gap: 4px; }
.help-list kbd { background: #f4f4f4; padding: 1px 6px; border-radius: 4px; border: 1px solid #ccc; font-family: monospace; font-size: 12px; }
/* Preset gamut shapes — strip of draggable thumbnails below the wheel */
.preset-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.preset-bar__label { font-size: 12px; color: #444; font-weight: 600; flex: 0 0 auto; }
.preset-bar__hint { font-size: 11px; color: #888; flex: 1 1 100%; margin-top: 2px; }
.preset-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 6px; border-radius: 6px; border: 1px solid #ccc; background: #fff;
  cursor: grab; font-size: 11px; color: #333;
  transition: border-color .12s, background .12s, transform .08s;
}
.preset-btn:hover { border-color: #444; background: #f8f8f8; }
.preset-btn:active { cursor: grabbing; transform: scale(0.97); background: #eee; }
.preset-btn--mask { border-style: dashed; }
.preset-thumb { display: block; }
.preset-btn__label { font-size: 10px; line-height: 1; white-space: nowrap; }

/* Shape controls — shown when a preset has been dropped (state.shape != null) */
.shape-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 6px; padding: 6px 10px;
  background: #f0f4ff; border: 1px solid #c7d3f0; border-radius: 6px;
}
.shape-controls__label { font-size: 12px; font-weight: 600; color: #1f3576; }
.shape-ctrl { display: flex; align-items: center; gap: 4px; }
.shape-ctrl__lbl { font-size: 11px; color: #555; font-weight: 600; }
.shape-ctrl__range { width: 110px; }
.shape-ctrl__val { font-size: 11px; color: #444; min-width: 38px; font-variant-numeric: tabular-nums; }
.shape-ctrl__btn { padding: 3px 8px; font-size: 12px; }
.shape-ctrl__btn--danger { color: #b03030; border-color: #d8a0a0; }
.shape-ctrl__btn--danger:hover { background: #ffeded; }

/* Locked shape vertices in selected list */
.selected-list li.shape-locked { background: rgba(31,53,118,0.06); border-radius: 4px; padding-left: 4px; }
.lock-hint { font-size: 10px; color: #1f3576; background: #e3eaff; padding: 2px 6px; border-radius: 3px; }

/* Manufacturer search link in inhull list */
.shop-link {
  text-decoration: none; font-size: 14px; color: #888; padding: 0 4px;
  cursor: pointer; line-height: 1;
}
.shop-link:hover { color: #1565c0; }

/* Mixing chart cells respond to hover for the closest-paint affordance */
/* The base size lives at the top of this file; just layer interaction state here. */
.mix-cell { cursor: crosshair; transition: outline .08s; }
.mix-cell:hover { outline: 2px solid #ffea00; outline-offset: -2px; z-index: 1; position: relative; }
.mix-mode { display: flex; gap: 4px; margin: 4px 0; flex-wrap: wrap; }
.mix-mode .chip { font-size: 11px; padding: 2px 8px; }

/* Diagonal cells in pairwise-mix matrix get a subtle inner border so the user
   can read "row paint A here, col paint B here, mix elsewhere" at a glance. */
.mix-cell--diag { box-shadow: inset 0 0 0 1.5px rgba(0,0,0,0.55); }

/* Wheel view toggle — pill-style chip group like brand chips */
.view-toggle { display: flex; gap: 6px; margin-left: 12px; align-items: center; }

/* Suggestion panel (generate-presets-from-selection) */
.suggestion-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.suggestion {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px;
  background: #fff; border: 1px solid #ccc; border-radius: 8px;
  cursor: pointer; text-align: left;
  transition: border-color .12s, background .12s, transform .08s;
}
.suggestion:hover { border-color: #1f3576; background: #f4f7ff; }
.suggestion:active { transform: scale(0.98); }
.suggestion__meta { display: flex; flex-direction: column; gap: 1px; }
.suggestion__label { font-size: 12px; font-weight: 600; color: #1f3576; }
.suggestion__score { font-size: 10px; color: #888; font-variant-numeric: tabular-nums; }

@media print {
  body > *:not(#print-host) { display: none !important; }
  #print-host { display: block; }
  .print-sheet { padding: 16mm; font-family: Segoe UI, Arial, sans-serif; color: #111; }
  .print-sheet h1 { margin: 0 0 12mm 0; font-size: 18pt; }
  .print-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm; }
  .print-chip { display: flex; flex-direction: column; gap: 3mm; }
  .print-color { height: 30mm; border-radius: 2mm; border: 0.4mm solid #999; }
  .print-label { font-size: 9pt; line-height: 1.3; word-wrap: break-word; }
}