:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  color: #1b273a;
  background: #fff;
  --blue: #244da5;
  --border: #dce3ed;
  --muted: #56657a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.palette {
  display: grid;
  grid-template-rows: auto auto auto minmax(110px, 1fr) auto;
  gap: 12px;
  height: 100vh;
  padding: 14px 10px;
}

.palette-header, .tools, .selection, .dialog-top, .dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

h1, h2 { margin: 0; font-size: 1.25rem; line-height: 1.3; }
p { margin: 0; line-height: 1.45; }
.palette-header p, .note, .count, #detail-code, #copy-status {
  color: var(--muted);
  font-size: 0.875rem;
}
.palette-header p, #detail-code { margin-top: 4px; }

button, input, textarea, .button { font: inherit; }
button, .button {
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
button:disabled { opacity: 0.55; cursor: default; }
.secondary { background: #fff; color: var(--blue); border-color: var(--border); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, .results:focus-visible {
  outline: 3px solid #a46b08;
  outline-offset: 2px;
}

.tools { border-block: 1px solid var(--border); padding: 10px 0; }
.tools label { flex: 0 1 285px; }
#filters { display: flex; flex-wrap: wrap; gap: 6px; }
#filters button { font-size: 0.82rem; border-radius: 24px; padding: 6px 11px; }
#filters button[aria-pressed="true"] { color: #fff; background: var(--blue); border-color: var(--blue); }
input, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; }
.results { min-width: 0; overflow-y: auto; padding: 3px; overscroll-behavior: contain; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; }
.swatch {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 6px;
  color: #1b273a;
  text-align: left;
  background: #fff;
  border-color: var(--border);
}
.swatch:hover, .swatch[aria-pressed="true"] { border-color: var(--blue); }
.swatch img { width: 100%; aspect-ratio: 1.4; object-fit: cover; border-radius: 3px; }
.swatch small { color: var(--muted); font-size: 0.68rem; }
.swatch strong { font-size: 0.76rem; overflow-wrap: anywhere; line-height: 1.25; }
.note { border-top: 1px solid var(--border); padding-top: 8px; }
.selection { background: #edf2fc; border-radius: 6px; padding: 8px; margin-bottom: 8px; font-size: 0.84rem; }

dialog { width: min(500px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow: auto;
  border: 1px solid var(--border); border-radius: 10px; padding: 18px; color: inherit; }
dialog::backdrop { background: #132540a8; }
.dialog-top { align-items: flex-start; margin-bottom: 12px; }
.close { font-size: 1.4rem; line-height: 1; padding: 5px 10px; }
#detail-image { display: block; max-height: min(420px, 56vh); width: 100%; object-fit: contain; margin-bottom: 12px; }
#request-text { margin: 8px 0 12px; resize: vertical; }
#copy-status { margin-top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 480px) {
  .palette { padding-inline: 4px; gap: 9px; }
  .tools label { flex: 1 1 100%; }
  .swatches { grid-template-columns: repeat(auto-fill, minmax(81px, 1fr)); gap: 6px; }
  .swatch { padding: 4px; }
  .palette-header p, .note { font-size: 0.8rem; }
}
