:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1b1b1b;
  --muted: #6b6b6b;
  --line: #e2e0db;
  --accent: #1f5eff;
  --accent-text: #ffffff;
  --sale: #c2261b;
  --ok: #1d7a3e;
  --chip: #efede8;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1c1c1c;
    --text: #ececec;
    --muted: #9a9a9a;
    --line: #2e2e2e;
    --accent: #6f95ff;
    --accent-text: #0d0d0d;
    --sale: #ff6b5e;
    --ok: #5fcf86;
    --chip: #262626;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); font-size: 13px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 16px; align-items: center;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; min-width: 180px; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
#q {
  flex: 1; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg);
}

.layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; padding: 20px; max-width: 1500px; margin: 0 auto; }
.filters { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow: auto; padding-right: 4px; }
.filters section { margin: 18px 0; }
.filters h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.filters select, .filters input[type=number] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.row { display: flex; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 13px;
}
.chip[aria-pressed=true] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; margin: 2px 4px 2px 0; }

.btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none; display: inline-block;
}
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.toolbar-right { display: flex; gap: 8px; }
#sort { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.only-mobile { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer; position: relative;
}
.card:hover { border-color: var(--muted); }
.card .img { aspect-ratio: 4 / 5; background: var(--chip); }
.card .img img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card .store { font-size: 12px; color: var(--muted); }
.card .title { font-weight: 600; font-size: 14px; }
.card .sub { font-size: 12px; color: var(--muted); }
.price { font-weight: 700; }
.price s { color: var(--muted); font-weight: 400; margin-left: 6px; }
.price.sale { color: var(--sale); }
.card .cmp {
  position: absolute; top: 8px; right: 8px; padding: 4px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); font-size: 12px; display: flex; gap: 5px; align-items: center;
}
.badge { position: absolute; top: 8px; left: 8px; background: var(--sale); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 6px; }
.oos { opacity: .55; }
.more { text-align: center; margin: 24px 0 80px; }

.compare-bar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 14px; align-items: center;
  padding: 10px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 6px 24px rgb(0 0 0 / .15);
}

dialog {
  width: min(980px, 94vw); max-height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text);
}
dialog.wide { width: min(1300px, 96vw); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h2 { margin: 0; font-size: 17px; }
.close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }

.detail { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; padding: 18px; }
.gallery .main { aspect-ratio: 4 / 5; background: var(--chip); border-radius: 10px; overflow: hidden; }
.gallery .main img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.thumbs img { width: 60px; height: 75px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.thumbs img.on { border-color: var(--accent); }
.info h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
.info .price { font-size: 22px; }
.sizes { display: flex; flex-wrap: wrap; gap: 6px; }
.size { min-width: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 13px; }
.size[disabled] { text-decoration: line-through; opacity: .45; cursor: not-allowed; }
.size[aria-pressed=true] { border-color: var(--accent); outline: 2px solid var(--accent); }
.desc { white-space: pre-line; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.history { font-size: 13px; }
.history svg { width: 100%; height: 60px; }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }

.cmp-table { overflow-x: auto; padding: 0 18px 18px; }
.cmp-table table { border-collapse: collapse; width: 100%; }
.cmp-table th, .cmp-table td { text-align: left; vertical-align: top; padding: 10px; border-bottom: 1px solid var(--line); font-size: 13px; min-width: 200px; }
.cmp-table th { color: var(--muted); font-weight: 500; min-width: 110px; width: 110px; }
.cmp-table img { width: 160px; aspect-ratio: 4/5; object-fit: cover; border-radius: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .filters { display: none; position: static; max-height: none; }
  .filters.open { display: block; }
  .only-mobile { display: inline-block; }
  .top { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 16px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .detail { grid-template-columns: 1fr; }
}
.compare-bar[hidden] { display: none; }

.chip .n { color: var(--muted); font-size: 11px; margin-left: 2px; }
.chip[aria-pressed=true] .n { color: inherit; opacity: .7; }
.chip.pending { border-style: dashed; }
/* Store chips are checkboxes, all on by default: a tick when on, struck through when off. */
.chip.check[aria-pressed=true] { background: var(--surface); color: var(--text); border-color: var(--text); }
.chip.check[aria-pressed=true]::before { content: '✓'; margin-right: 5px; font-weight: 700; }
.chip.check[aria-pressed=true] .n { color: var(--muted); opacity: 1; }
.chip.check[aria-pressed=false] { color: var(--muted); text-decoration: line-through; }
.chip.add { font-weight: 700; min-width: 34px; color: var(--accent); border-color: var(--accent); }
dialog.narrow { width: min(520px, 94vw); }
.add-form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.add-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.add-form input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 15px; }
.add-form .actions { margin-top: 0; }
.add-result p { margin: 6px 0; font-size: 14px; }
.warn { color: var(--sale); }
.chip .x { margin-left: 6px; color: var(--muted); font-weight: 700; }
.chip .x:hover { color: var(--sale); }

/* ---------- Colour palettes ---------- */
.nav { display: flex; gap: 14px; align-items: center; white-space: nowrap; }
.nav a { color: var(--text); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--chip); }
.nav a[aria-current=page] { background: var(--text); color: var(--bg); }
.brand h1 a { color: inherit; text-decoration: none; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgb(0 0 0 / .18); flex: none; }
.dot.hit { outline: 2px solid var(--accent); outline-offset: 1px; }
.dots { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 3px 0 1px; }
.hit-label { font-size: 12px; color: var(--accent); margin-left: 2px; }

.pal-filter { padding: 14px; margin: 18px -4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pal-filter-head, .section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.pal-filter-head h3, .section-head h3 { margin: 0; }
.section-head .link { font-size: 13px; }
.pal-filter-head a { font-size: 13px; color: var(--accent); white-space: nowrap; }
.pal-fam { margin-bottom: 10px; }
.pal-fam-name { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.pal-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pal-tile {
  padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer;
  background: var(--bg); color: var(--text); display: flex; flex-direction: column; font: inherit;
}
.pal-tile:hover { border-color: var(--muted); }
.pal-tile[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pal-tile-strip { display: flex; height: 30px; }
.pal-tile-strip i { flex: 1; }
.pal-tile-name { font-size: 12px; padding: 4px 0; text-align: center; }
.pal-tile[aria-pressed=true] .pal-tile-name { font-weight: 700; }
.pal-filter .chips { margin-bottom: 8px; }
.pal-filter .chip.on { display: inline-flex; align-items: center; gap: 6px; background: var(--chip); }
.pal-filter .chip .dot { width: 11px; height: 11px; }
.pal-filter select.inline { width: auto; padding: 3px 6px; }
.pal-empty { margin: 0 0 8px; }
.pal-links { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; }
.pal-links a { color: var(--accent); }
.mini-strip { display: inline-flex; border-radius: 4px; overflow: hidden; }
.mini-strip i { width: 6px; height: 14px; }

.pal-main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 120px; }
.pal-intro h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.01em; }
.pal-intro p { margin: 0 0 14px; max-width: 640px; color: var(--muted); }
.pal-options { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; font-size: 14px; }
.pal-match { display: flex; gap: 8px; align-items: center; }
.pal-match select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.pal-family { margin-top: 32px; }
.pal-family > h2, .pal-basic h2 { font-size: 18px; margin: 0 0 12px; }
.pal-family > h2 .muted { font-weight: 400; margin-left: 6px; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch-row.small { gap: 6px; }
.swatch-row.small .muted { font-size: 12px; margin-right: 2px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--c); border: 1px solid rgb(0 0 0 / .15);
}
.swatch.small { width: 22px; height: 22px; }
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed=true] { outline: 3px solid var(--accent); outline-offset: 2px; }
.pal-basic { margin-top: 36px; }
.swatch-label { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; width: 64px; font-size: 12px; color: var(--muted); text-align: center; }
.pal-source { margin-top: 32px; }

.pal-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 14px; align-items: center; justify-content: flex-end;
  padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgb(0 0 0 / .08);
}
.pal-summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pal-bar .btn { white-space: nowrap; }

@media (max-width: 860px) {
  .nav { justify-content: flex-start; }
  .palette-page .top { flex-direction: row; align-items: center; justify-content: space-between; }
  .palette-page .nav #nav-shop { display: none; }
  .pal-main { padding: 16px 16px 120px; }
  .pal-bar { padding: 10px 16px; flex-wrap: wrap; }
  .pal-summary { flex-basis: 100%; }
  .pal-bar .btn { flex: 1; text-align: center; }
}

/* Palette ranking + feedback */
.grid-section { grid-column: 1 / -1; margin: 10px 0 -4px; font-size: 16px; }
.grid-section:first-child { margin-top: 0; }
.grid-section .muted { font-weight: 400; margin-left: 4px; }
.vote { display: flex; align-items: center; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.vote span { margin-right: auto; }
.vote button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 2px 8px; cursor: pointer; font-size: 14px; filter: grayscale(1); opacity: .7; }
.vote button:hover { opacity: 1; filter: none; }
.vote button[aria-pressed=true] { filter: none; opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.card.rated-down .img { opacity: .4; }
.pal-feedback { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--chip); font-size: 13px; }
.pal-feedback .link { text-align: left; }

/* Palette page: one expandable row per season */
.season-nav { position: sticky; top: 64px; z-index: 4; display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; margin-top: 18px; background: var(--bg); scrollbar-width: thin; }
.season-nav a { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 13px; }
.season-nav a.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pal-tools { display: flex; justify-content: flex-end; margin: 4px 0 -8px; font-size: 14px; }
.season { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; scroll-margin-top: 120px; }
.season.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.season > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.season > summary::-webkit-details-marker { display: none; }
.season-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.season-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.season-title h3 { margin: 0; font-size: 17px; }
.season-title .tags { display: flex; flex-wrap: wrap; gap: 4px; flex-basis: 100%; }
.season-title .tag { margin: 0; font-size: 11px; }
.season-title .tag.n { background: none; border: 1px solid var(--line); }
.season-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.pal-count { font-size: 12px; text-align: right; }
.pal-toggle { padding: 6px 12px; font-size: 13px; }
.pal-toggle[aria-pressed=true] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.season-more { font-size: 12px; }
.season-more::after { content: ' ▾'; }
.season[open] .season-more::after { content: ' ▴'; }
.season[open] .season-more { font-size: 0; }
.season[open] .season-more::after { font-size: 12px; content: 'Hide colours ▴'; }

.spectrum { display: flex; height: 46px; border-radius: 10px; overflow: hidden; border: 1px solid rgb(0 0 0 / .08); }
.sp-tile { flex: 1 1 0; min-width: 0; border: 0; padding: 0; cursor: pointer; }
.sp-tile.sig { flex-grow: 4; }
.sp-tile.neu { flex-grow: .8; }
.sp-tile[aria-pressed=true] { box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 5px var(--surface); }
.sp-gap { width: 3px; background: var(--surface); flex: none; }

.season-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.cgroup h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cgroup h4 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 4px; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px 6px; }
.cgrid.big { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.cgrid.big .tile { height: 64px; }
.swatch-chip { display: flex; flex-direction: column; gap: 2px; padding: 0 0 2px; cursor: pointer; min-width: 0; background: none; border: 0; text-align: left; color: inherit; font: inherit; }
.swatch-chip .tile { display: block; height: 44px; border-radius: 8px; border: 1px solid rgb(0 0 0 / .12); }
.swatch-chip .name { font-size: 11px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch-chip .hex { font-size: 10px; color: var(--muted); font-family: ui-monospace, monospace; }
.swatch-chip[aria-pressed=true] .tile { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch-chip.avoid { cursor: default; }
.swatch-chip.avoid .tile { position: relative; opacity: .85; background-clip: padding-box; }
.swatch-chip.avoid .tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 1.5px), var(--sale) calc(50% - 1.5px), var(--sale) calc(50% + 1.5px), transparent calc(50% + 1.5px)); border-radius: 8px; }
.swatch-chip.avoid .name { text-decoration: line-through; color: var(--muted); }

@media (max-width: 860px) {
  .season-nav { top: 56px; }
  .season-head { flex-direction: column; }
  .season-actions { width: 100%; justify-content: space-between; }
  .spectrum { height: 38px; }
  .cgrid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .cgrid.big { grid-template-columns: repeat(3, 1fr); }
}

/* Exclude colours + advanced options */
.ex-chip { display: inline-flex; align-items: center; gap: 6px; }
.ex-chip .dot { width: 11px; height: 11px; }
.ex-chip[aria-pressed=true] { background: var(--chip); color: var(--text); border-color: var(--sale); text-decoration: line-through; text-decoration-color: var(--sale); }
.ex-chip[aria-pressed=true] .dot { opacity: .5; }
.pal-advanced { margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px 14px; max-width: 760px; }
.pal-advanced > summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.pal-advanced > summary .muted { font-weight: 400; }
.pal-advanced[open] > summary { margin-bottom: 10px; }
.pal-exclude { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; font-size: 14px; }
.pal-exclude-label .muted { margin-left: 4px; }
.brand-search { width: 100%; padding: 7px 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
#f-brands-more { margin-top: 8px; font-size: 13px; }
