:root {
  --cell-min: 64px;
  --gap: 12px;
}

/* Base */
body {
  margin: 0;
  padding: 20px;
  background: #0f0f12;
  color: #eef1f4;
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
h1 {
  font-size: 22px;
  margin: 0 0 10px;
}
.app {
  width: min(100%, 1200px);
  margin: 48px auto;
}
.app h1 {
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Cards & controls */
.card {
  background: #16171c;
  border: 1px solid #262a32;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}
.controls label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
input,
button,
select {
  border-radius: 8px;
  border: 1px solid #2a3039;
  background: #0e1014;
  color: #e8ecf1;
  padding: 8px 10px;
}
button {
  cursor: pointer;
  font-weight: 700;
  background: #e28f5b;
  color: #0b0b0b;
  border: none;
}
.mini {
  font-size: 14px;
  opacity: 0.95;
  line-height: 1.35;
  padding-left: 15px;
}

.controls {
  display: grid;
  gap: 10px;
  align-items: end;
  grid-template-columns: repeat(12, 1fr);
}
.col {
  grid-column: span 3;
  padding: 8px;
  border-radius: 10px;
}

/* Hide the native color chips; we open pickers from the parent boxes */
#boxA input[type="color"],
#boxB input[type="color"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  clip: rect(0 0 0 0);
}

/* Selected panel (in header) */
.sel-wrap {
  grid-column: span 6;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
}
.swatch {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid #333;
}
.meta {
  font-size: 13px;
  line-height: 1.35;
}
.kv {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 4px 10px;
}
.kv b {
  font-weight: 700;
  opacity: 0.9;
}

/* Shades area: two columns */
.shades-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr 1fr; /* A | B */
  align-items: start;
}
.stack {
  display: grid;
  gap: var(--gap);
}
.stack h3 {
  margin: 0 0 6px;
  font-size: 14px;
  opacity: 0.9;
}
.swatch-sm {
  min-height: var(--cell-min);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  padding: 6px;
}
.val {
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  border: 1px solid #333;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show {
  opacity: 1;
}

/* Make cells feel copyable */
.swatch-sm::after {
  content: attr(data-tip);
}

.swatch-sm {
  position: relative;
  cursor: copy;
}

/* Show a tiny copy icon in the corner on hover/focus (desktop only) */
@media (hover: hover) and (pointer: fine) {
  .swatch-sm::before {
    content: "⧉";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 12px;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
  }
  .swatch-sm:hover::before,
  .swatch-sm:focus-visible::before {
    opacity: 1;
    transform: translateY(0);
  }

  /* Tooltip that reads from data-tip (set by JS) */
  .swatch-sm::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%) translateY(4px);
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
  }
  .swatch-sm:hover::after,
  .swatch-sm:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Keyboard focus ring for accessibility */
.swatch-sm:focus-visible {
  outline: 2px solid #fff8;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Responsive */
@media (max-width: 1100px) {
  .sel-wrap {
    grid-column: span 12;
  }
}
@media (max-width: 900px) {
  .col {
    grid-column: span 6;
  }
  .shades-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  .col {
    grid-column: span 12;
  }
}
/* --- Highlight the bottom toolbar row inside the controls grid --- */
/* Targets the row that contains Shades, Render, and Color format */
.controls > .col:last-child {
  position: relative;
  grid-column: span 12 !important;
  background: linear-gradient(180deg, #151820, #12141a);
  border: 1px solid #2a3039;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Soft accent bar along the top edge */
.controls > .col:last-child::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  height: 3px;
  width: 100%;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, #e28f5b, #6aa6ff);
  opacity: 0.55;
  pointer-events: none;
}

/* Subtle lift on focus/hover so it feels interactive */
@media (hover: hover) and (pointer: fine) {
  .controls > .col:last-child:hover {
    border-color: #344052;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset,
      0 12px 36px rgba(0, 0, 0, 0.45);
  }
}
.controls > .col:last-child:focus-within {
  border-color: #4b89ff;
  box-shadow: 0 0 0 1px rgba(75, 137, 255, 0.25),
    0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Tighten and brighten the controls inside the toolbar */
.controls > .col:last-child input,
.controls > .col:last-child select {
  background: #0e1117;
  border-color: #354052;
}
.controls > .col:last-child input:focus,
.controls > .col:last-child select:focus {
  outline: none;
  border-color: #4b89ff;
  box-shadow: 0 0 0 2px rgba(75, 137, 255, 0.25);
}

/* Make the helper text and labels a touch brighter inside the toolbar */
.controls > .col:last-child .mini,
.controls > .col:last-child label {
  color: #d9dde3;
  opacity: 0.9;
}

/* Keep things readable on small screens */
@media (max-width: 600px) {
  .controls > .col:last-child {
    padding: 12px;
    border-radius: 10px;
  }
}