/* PaintMix — studio aesthetic */

* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; min-height: 100vh; }

body {
  font-family: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  background: var(--bg, #f6f2ea);
  color: var(--ink, #1e1b16);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02";
}

.mono {
  font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
}
.tiny { font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.dim { color: var(--ink-dim); }
.soft { color: var(--ink-soft); }

/* ── App shell ────────────────────────────────────────────────────────── */
.app {
  min-height: 100vh;
  padding: 28px 32px 80px;
  display: flex; flex-direction: column; gap: 24px;
  background: var(--bg);
  color: var(--ink);
}
.app[data-density="compact"] { padding: 18px 22px 64px; }
.app[data-density="comfy"]   { padding: 40px 48px 96px; }

/* ── Grid ─────────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1180px) {
  .grid { grid-template-columns: 1fr; }
}
.col {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius, 10px);
  padding: 22px;
  min-height: 100px;
}

/* ── Shared primitives ────────────────────────────────────────────────── */
.panel-title {
  font-family: var(--display-font);
  font-size: 22px; font-weight: 500; letter-spacing: -0.015em;
  margin: 0 0 18px;
  line-height: 1.1;
}

.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-size: 13px;
  padding: 8px 14px; border-radius: 8px;
  transition: background .1s, color .1s;
}
.btn-primary {
  background: var(--ink); color: var(--paper);
}
.btn-primary:hover { background: var(--accent); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--rule); color: var(--ink); }

.input {
  appearance: none; border: 1px solid var(--rule);
  background: var(--bg); color: var(--ink);
  padding: 8px 10px; border-radius: 7px;
  font: inherit; font-size: 13px; outline: none;
  transition: border-color .1s;
}
.input:focus { border-color: var(--ink-soft); }
.input.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 12px; }

/* ── Segmented ────────────────────────────────────────────────────────── */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 8px;
}
.seg-btn {
  appearance: none; border: 0; background: transparent;
  font: inherit; font-size: 12px; color: var(--ink-soft);
  padding: 5px 10px; border-radius: 6px;
  cursor: pointer;
}
.seg-btn.on {
  background: var(--paper); color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.seg-btn:hover:not(.on) { color: var(--ink); }

.stepper {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 8px; padding: 2px 10px;
}
.stepper button {
  appearance: none; border: 0; background: transparent;
  font: inherit; font-size: 16px; color: var(--ink-soft);
  width: 20px; height: 24px; cursor: pointer;
}
.stepper button:hover { color: var(--ink); }
.stepper span { font-size: 13px; min-width: 14px; text-align: center; }

/* ── Icon buttons ─────────────────────────────────────────────────────── */
.icon-btn {
  appearance: none; border: 0; background: transparent;
  width: 26px; height: 26px; border-radius: 6px;
  color: var(--ink-soft); cursor: pointer;
  font: inherit; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--rule); color: var(--ink); }
.icon-btn.armed { width: auto; padding: 0 8px; font-size: 11px; background: #b52a1f; color: #fff; }
.icon-btn.armed:hover { background: #c73a2e; }

/* ── Target panel ─────────────────────────────────────────────────────── */
.target-hero {
  display: flex; gap: 16px; align-items: stretch;
  margin-bottom: 16px;
}
.target-swatch {
  position: relative;
  width: 130px; height: 130px;
  border-radius: var(--radius, 10px);
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.15);
  overflow: hidden;
  flex-shrink: 0;
}
.target-color-input {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.pick-hint {
  position: absolute; bottom: 10px; left: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px; letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: .75;
}
.target-meta {
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  min-width: 0; flex: 1;
}
.target-big {
  font-size: 22px; letter-spacing: -0.02em;
  color: var(--ink);
}
.target-sub, .target-lab { font-size: 12px; }

.input-modes { margin-bottom: 12px; }

.field-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.field-row label {
  width: 40px; color: var(--ink-dim);
}
.field-row .input { flex: 1; }

.rgb-inputs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }


/* ── Mix panel ────────────────────────────────────────────────────────── */
.mix-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px;
}
.mix-head .panel-title { margin-bottom: 0; }

.delta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--rule);
  font-size: 12px;
}
.delta-label { font-weight: 500; }
.delta-ok    .delta-label { color: #2f7a3d; }
.delta-warn  .delta-label { color: #a06a10; }
.delta-bad   .delta-label { color: #b52a1f; }

/* compare */
.compare {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 12px; align-items: start;
  padding: 18px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius, 10px);
  margin-bottom: 20px;
}
.compare-col { text-align: center; }
.compare-label { margin-bottom: 8px; }
.compare-swatch {
  width: 100%; aspect-ratio: 4 / 3;
  border-radius: 8px;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18);
}
.compare-hex { margin-top: 8px; font-size: 12px; }
.compare-mid { align-self: stretch; display: flex; flex-direction: column; }
.compare-split {
  flex: 1; display: flex;
  border-radius: 8px; overflow: hidden;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18);
  min-height: 110px;
}

/* recipe controls */
.recipe-controls {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 14px 0; margin-bottom: 12px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.rc-group { display: flex; flex-direction: column; gap: 6px; }
.rc-group label { color: var(--ink-dim); font-size: 10.5px; letter-spacing: 0.06em; }

/* recipe rows */
.recipe { display: flex; flex-direction: column; gap: 10px; }
.recipe-row {
  display: grid;
  grid-template-columns: 44px minmax(160px, 1.4fr) minmax(120px, 2fr) 80px;
  gap: 12px; align-items: center;
}
.recipe-swatch {
  width: 44px; height: 44px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18);
}
.recipe-name {
  font-family: var(--display-font);
  font-size: 16px; letter-spacing: -0.01em;
}
.recipe-sub { font-size: 11px; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.recipe-bar-wrap {
  height: 8px; background: var(--rule); border-radius: 999px; overflow: hidden;
}
.recipe-bar {
  height: 100%; border-radius: 999px;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.15);
  transition: width .25s cubic-bezier(.3,.7,.4,1);
}
.recipe-qty {
  text-align: right; font-size: 13px;
}

.recipe-foot {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex; gap: 20px;
  align-items: center;
}
.recipe-foot .tone {
  font-style: italic; font-size: 13px; margin-left: auto;
  max-width: 380px; text-align: right;
  font-family: var(--display-font);
}
.tone-ok   { color: var(--ink-soft); }
.tone-warn { color: #a06a10; }
.tone-bad  { color: #b52a1f; }

/* ── Library ──────────────────────────────────────────────────────────── */
.lib-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.lib-head .panel-title { margin-bottom: 0; }
.lib-filters { margin-bottom: 14px; }
.lib-filters .seg { flex-wrap: wrap; max-width: 100%; }

.lib-list { display: flex; flex-direction: column; gap: 4px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.lib-list::-webkit-scrollbar { width: 6px; }
.lib-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.paint-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px; align-items: center;
  padding: 8px; border-radius: 8px;
  transition: background .1s;
}
.paint-row:hover { background: var(--bg); }
.paint-row.inactive { opacity: .5; }
.paint-row.selected { background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent); }

.paint-swatch {
  appearance: none; border: 0; cursor: pointer;
  width: 36px; height: 36px; border-radius: 7px;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18);
}
.paint-name-row { display: flex; align-items: center; gap: 8px; }
.paint-name {
  font-family: var(--display-font);
  font-size: 15px; letter-spacing: -0.005em;
}
.paint-meta {
  font-size: 11px; color: var(--ink-dim); margin-top: 2px;
}
.paint-notes { color: var(--ink-soft); font-style: italic; }
.paint-actions { display: flex; align-items: center; gap: 4px; }

.pill {
  appearance: none; border: 1px solid var(--rule);
  background: transparent; cursor: pointer;
  font: inherit; font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  color: var(--ink-soft);
}
.pill.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill.off { opacity: .6; }

/* ── Type chips ───────────────────────────────────────────────────────── */
.chip, .chip-inline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  background: var(--rule); color: var(--ink-soft);
}
.chip-primary     { background: #E9E3F4; color: #5A3B8C; }
.chip-earth       { background: #EDE2D1; color: #6E4A20; }
.chip-white       { background: #F2EEE5; color: #6B6255; }
.chip-black       { background: #2a2720; color: #e4decf; }
.chip-metallic    { background: #E3E6EA; color: #4B5560; }
.chip-transparent { background: #E4EEEB; color: #3A6B5C; }

[data-theme="dark"] .chip-primary     { background: #3a2d55; color: #c9b8f0; }
[data-theme="dark"] .chip-earth       { background: #3f2f1c; color: #e4c98f; }
[data-theme="dark"] .chip-white       { background: #2a2722; color: #d4cdbd; }
[data-theme="dark"] .chip-black       { background: #1a1815; color: #a8a295; }
[data-theme="dark"] .chip-metallic    { background: #2a3038; color: #b4c0cf; }
[data-theme="dark"] .chip-transparent { background: #1e332d; color: #9fd4c2; }

/* ── Paint editor ─────────────────────────────────────────────────────── */
.paint-editor {
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 10px; padding: 14px;
  margin: 6px 0 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.editor-top { display: flex; gap: 12px; align-items: stretch; }
.editor-color {
  appearance: none; -webkit-appearance: none;
  width: 52px; height: 52px; flex-shrink: 0;
  border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; padding: 0;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18);
}
.editor-color::-webkit-color-swatch-wrapper { padding: 0; }
.editor-color::-webkit-color-swatch { border: 0; border-radius: 7px; }
.editor-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.editor-row { display: flex; gap: 6px; }
.editor-row .input:last-child { flex: 1; }
.editor-actions { display: flex; align-items: center; gap: 8px; }
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }

.empty {
  padding: 24px 12px; text-align: center;
  color: var(--ink-dim); font-style: italic;
  font-family: var(--display-font);
}
.empty.big { padding: 48px 20px; font-size: 16px; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.bottombar {
  display: flex; align-items: center; gap: 8px;
  padding-top: 18px; border-top: 1px solid var(--rule);
  font-size: 11px; letter-spacing: 0;
  text-transform: none;
}
.link-btn {
  appearance: none; border: 0; background: transparent;
  font: inherit; color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer; padding: 0;
}
.link-btn:hover { color: var(--ink); }

/* ── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Shell */
  .app                         { padding: 14px 14px 64px; gap: 16px; }
  .app[data-density="compact"] { padding: 10px 10px 52px; }
  .app[data-density="comfy"]   { padding: 20px 20px 72px; }

  /* Grid & panels */
  .grid { gap: 10px; }
  .col  { padding: 16px; }

  /* Target panel */
  .target-swatch { width: 88px; height: 88px; }
  .target-big    { font-size: 18px; }

  /* Compare: drop the side-by-side split, show target + predicted only */
  .compare     { grid-template-columns: 1fr 1fr; padding: 12px; gap: 8px; }
  .compare-mid { display: none; }

  /* Recipe controls row */
  .recipe-controls { gap: 12px; }

  /* Recipe row: 3 columns, push the bar onto its own second line */
  .recipe-row {
    grid-template-columns: 40px 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
  }
  .recipe-swatch   { grid-column: 1; grid-row: 1 / 3; width: 40px; height: 40px; }
  .recipe-main     { grid-column: 2; grid-row: 1; }
  .recipe-qty      { grid-column: 3; grid-row: 1; font-size: 12px; }
  .recipe-bar-wrap { grid-column: 2 / 4; grid-row: 2; }

  /* Recipe footer: stack instead of side-by-side */
  .recipe-foot       { flex-direction: column; align-items: flex-start; gap: 8px; }
  .recipe-foot .tone { margin-left: 0; text-align: left; }

  /* Bigger tap targets on segmented controls */
  .seg-btn { padding: 8px 10px; }

  /* Library list: let the page scroll rather than inner scroll */
  .lib-list { max-height: none; }

  /* Paint editor actions: allow wrapping on small screens */
  .editor-actions { flex-wrap: wrap; }

  /* Footer: wrap the links rather than overflow */
  .bottombar { flex-wrap: wrap; row-gap: 4px; }
}
