/* Palette generator — tool styles on top of the diffui kit. Kit tokens only; no external url(). */

.palettePage { gap: 18px; }

/* ------------------------------------------------------------------ small shared bits */
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px;
  border: 1px solid var(--share-border); border-radius: 999px;
  font: 10px var(--font-mono); letter-spacing: .3px; color: var(--muted); text-transform: lowercase;
  white-space: nowrap;
}
.tag--gold { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.counter { margin-left: auto; font: 11px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--danger); }
.smallBtn { --height: 28px; --font-size: 11px; --padding-x: 9px; }
.iconBtn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto;
  border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted);
  font: 12px var(--font-mono); cursor: pointer;
}
.iconBtn:hover { color: var(--text); border-color: var(--border2); }
.linkLike, .linkBtn {
  color: var(--gold); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
  background: none; border: 0; padding: 0; font: inherit;
}
.linkLike:hover, .linkBtn:hover { color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 6px; font: 12px var(--font-mono); color: var(--muted); cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--gold); width: 14px; height: 14px; margin: 0; }
.check:has(input:disabled) { opacity: .55; cursor: default; }

/* ------------------------------------------------------------------ banner */
.banner { animation: pal-fade-in 200ms ease; }
.bannerText { min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ controls (promptBox) */
.controls { gap: 12px; padding: 14px; }
.drop {
  position: relative; min-height: 64px; justify-content: center;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.drop:hover { border-color: color-mix(in srgb, var(--gold) 55%, var(--border2)); }
.drop:focus-within { border-color: var(--gold); }
.drop.is-dragover { border-color: var(--gold); border-style: solid; background: var(--share-input-focus); }
.dropEmpty { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dropIcon { width: 20px; height: 20px; flex: 0 0 auto; opacity: .9; }
html[data-theme="dark"] .dropIcon { filter: brightness(1.55) saturate(.9); }
.dropText { margin: 0; font: 12px/1.5 var(--font-mono); color: var(--muted); min-width: 0; }
.dropText strong { color: var(--text); font-weight: 500; }
.dropFilled { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thumb {
  width: 56px; height: 56px; border-radius: 4px; object-fit: cover; flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px var(--border); background: var(--share-frame-bg);
}
.dropMeta { display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; }
.dropName { font: 12px var(--font-mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropOverlay {
  position: absolute; inset: 0; display: none; place-items: center; border-radius: 4px;
  font: 12px var(--font-mono); color: var(--gold); background: var(--share-input-focus); pointer-events: none;
}
.drop.is-dragover .dropOverlay { display: grid; }
.drop.is-dragover .dropEmpty, .drop.is-dragover .dropFilled { visibility: hidden; }

.vibeField > label { align-items: center; }
.promptInput.vibeInput { min-height: 0; height: 38px; resize: none; padding: 0 10px; }
.promptInput[aria-invalid=true] { outline-color: var(--danger); }

.controlsRow { display: flex; align-items: flex-end; gap: 14px 20px; flex-wrap: wrap; }
.controlsRow .field { align-content: start; }
.fieldLabel .tag, .field > label .tag { margin-left: 2px; }
.lookField .toggle { background: var(--share-input-bg); }
.lookField .toggle button { font: 12px var(--font-mono); min-width: 84px; }
.brandRow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brandRow .brandHex { width: 96px; }
.controlsRow .promptActions { margin-left: auto; align-self: flex-end; }
.generateBtn { min-width: 168px; }
.privacyNote { padding-top: 2px; }

/* ------------------------------------------------------------------ status */
.statusRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; margin: -4px 0; }
/* an empty status row (live region stays in the DOM) takes no visual space */
.statusRow.is-empty { min-height: 0; margin: -9px 0; }
.status { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status.is-error { color: var(--danger); }
.status.is-done { color: var(--success); }
#statusText { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ frame */
.sheetFrame {
  position: relative; aspect-ratio: 3 / 2;
  background:
    radial-gradient(color-mix(in srgb, var(--share-dot) 140%, transparent) 1px, transparent 1px) 0 0 / 12px 12px,
    var(--share-frame-bg);
}
.sheetFrame > * { grid-area: 1 / 1; }
.sheet { width: 100%; height: 100%; object-fit: contain; background: #f7f7f5; transition: filter 260ms ease, opacity 260ms ease; }
.sheet.isPartial { filter: blur(6px) saturate(1.05); transform: scale(1.02); }
.previewChip {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  padding: 3px 8px; border-radius: 999px; font: 10px var(--font-mono); letter-spacing: .4px; text-transform: uppercase;
  background: var(--menu-bg); color: var(--muted); box-shadow: var(--menu-shadow);
}
.frameEmpty {
  position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center;
  font: 12px var(--font-mono); color: var(--muted); pointer-events: none; z-index: 1;
}

/* the ghost sheet: a quiet 8 × 10 grid that breathes while a palette renders */
.ghost {
  position: absolute; inset: 8% 6% 10%;
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3% 2.2%;
  grid-auto-flow: column; grid-template-rows: repeat(10, minmax(0, 1fr));
  pointer-events: none;
}
.ghostCell { border-radius: 3px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.sheetFrame.is-busy .ghostCell { animation: pal-breathe 2.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes pal-breathe {
  0%, 100% { background: color-mix(in srgb, var(--text) 5%, transparent); }
  50% { background: color-mix(in srgb, var(--gold) 22%, transparent); }
}
.sheetFrame.has-sheet .ghost, .sheetFrame.has-sheet .frameEmpty { display: none; }
.sheetFrame.is-busy .frameEmpty { display: none; }

.overlay { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.handles { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.handle {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; padding: 0;
  border-radius: 999px; border: 2px solid #fff; background: var(--gold);
  box-shadow: 0 0 0 1px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.35);
  cursor: grab; pointer-events: auto; touch-action: none;
}
.handle::after { content: ""; position: absolute; inset: 7px; border-radius: 999px; background: #fff; }
.handle:active, .handle.is-dragging { cursor: grabbing; transform: scale(1.12); }
.handle:focus-visible { box-shadow: 0 0 0 3px var(--gold), 0 0 0 5px #fff; }

.frameTools {
  position: absolute; right: 10px; bottom: 10px; z-index: 4;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
}
.frameTools .dui-btn.subtle { background: var(--menu-bg); box-shadow: var(--menu-shadow); border-color: transparent; }
.frameTools .dui-btn.subtle[aria-pressed=true] { background: var(--active-wash), var(--menu-bg); color: var(--text); }

/* ------------------------------------------------------------------ grid editor */
.gridEditor { gap: 12px; animation: pal-fade-in 180ms ease; }
.gridEditorFields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; align-items: end; }
.gridEditorFields input[type=number] { width: 100%; }
.padField input[type=range] { width: 100%; accent-color: var(--gold); height: 32px; margin: 0; }
.gridEditorFoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gridEditorFoot .note { flex: 1 1 260px; }
.gridEditorActions { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ result */
.result { display: grid; gap: 14px; animation: pal-fade-in 240ms ease; }
.result h2:focus { outline: none; }
.result h2:focus-visible { box-shadow: var(--focus-ring); border-radius: 2px; }
.resultMeta { display: flex; align-items: center; gap: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: 999px; border: 1px solid var(--share-border); background: var(--share-surface);
  font: 11px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--success); }
.badge.is-ok::before { background: var(--gold); }
.badge.is-low::before { background: var(--danger); }

.ramps {
  --cols: 10;
  display: grid; gap: 10px;
  padding: 14px; border: 1px solid var(--share-border); border-radius: 8px; background: var(--share-surface);
  overflow-x: auto; overscroll-behavior-x: contain;
}
.rampRow, .rampHead {
  display: grid; grid-template-columns: 116px repeat(var(--cols), minmax(56px, 1fr));
  gap: 8px; align-items: start; min-width: calc(116px + var(--cols) * 64px);
}
.rampHead span { font: 10px var(--font-mono); color: var(--muted); letter-spacing: .3px; }
.rampHead span:first-child { visibility: hidden; }
.rampName {
  height: 44px; width: 100%; border: 0; border-radius: 4px; padding: 0 8px;
  background: transparent; color: var(--text); font: 12px var(--font-mono);
  outline: 1px solid transparent; text-overflow: ellipsis;
}
.rampName:hover { outline-color: var(--share-input-outline); background: var(--share-input-bg); }
.rampName:focus { outline-color: var(--share-gold); background: var(--share-input-focus); box-shadow: none; }
.chip { position: relative; }
.chip .chipSwatch { position: relative; }
.chip.is-anchored .chipSwatch::after {
  content: "brand"; position: absolute; left: 4px; bottom: 4px;
  padding: 1px 4px; border-radius: 3px; font: 9px var(--font-mono); letter-spacing: .3px;
  background: rgba(0,0,0,.42); color: #fff;
}
.chip.is-inferred .chipHex::after { content: " ·"; color: var(--gold); }
.chip.is-copied .chipHex { color: var(--success); }

.resultActions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.handoffBtn { --padding-x: 14px; }
.exportRow { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ recent */
.recent { display: grid; gap: 12px; }
.recentCard { position: relative; transition: border-color 120ms ease, transform 120ms ease; }
.recentCard:hover, .recentCard:focus-within { border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.recentCard:hover { transform: translateY(-1px); }
.recentLink { display: grid; color: inherit; text-decoration: none; border-radius: 7px; }
.recentLink:focus-visible { box-shadow: inset var(--focus-ring); }
.recentCard img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; object-position: center; background: var(--share-frame-bg); }
.recentCard .thumbMissing { aspect-ratio: 3 / 2; display: grid; place-items: center; background: var(--share-frame-bg); font: 11px var(--font-mono); color: var(--share-empty); }
.recentStrip { display: flex; height: 8px; }
.recentStrip span { flex: 1 1 0; }
.recentMeta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; font: 11px var(--font-mono); color: var(--muted); }
.recentForget {
  position: absolute; top: 6px; right: 6px; z-index: 1;
  width: 24px; height: 24px; border-radius: 4px; border: 0; cursor: pointer;
  background: var(--menu-bg); color: var(--muted); box-shadow: var(--menu-shadow); font: 11px var(--font-mono);
  opacity: 0; transition: opacity 120ms ease;
}
.recentCard:hover .recentForget, .recentCard:focus-within .recentForget { opacity: 1; }
@media (hover: none) { .recentForget { opacity: 1; } }

@keyframes pal-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 700px) {
  .controlsRow { flex-direction: column; align-items: stretch; }
  .controlsRow .promptActions { margin-left: 0; align-self: stretch; }
  .generateBtn, .handoffBtn { width: 100%; }
  .lookField .toggle button { flex: 1 1 0; }
  .resultActions { flex-direction: column; align-items: stretch; }
  .rampRow, .rampHead { grid-template-columns: 84px repeat(var(--cols), minmax(52px, 1fr)); min-width: calc(84px + var(--cols) * 60px); gap: 6px; }
  .exportRow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exportRow .dui-btn { width: 100%; }
  .exportRow .dui-btn:last-child { grid-column: 1 / -1; }
  .ramps { padding: 12px; margin: 0; }
  .frameTools { right: 8px; bottom: 8px; }
  .handoffBtn { white-space: normal; height: auto; min-height: 33px; padding-top: 6px; padding-bottom: 6px; text-align: center; }
}
@media (max-width: 420px) {
  .dropFilled { flex-wrap: wrap; }
  .examples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet { transition: none; }
  .sheet.isPartial { transform: none; }
  .sheetFrame.is-busy .ghostCell { animation: none; background: color-mix(in srgb, var(--gold) 12%, transparent); }
  .banner, .gridEditor, .result { animation: none; }
  .recentCard, .recentCard:hover { transition: none; transform: none; }
}
