/* ---------- Tokens ---------- */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --ink: #15161a;
  --muted: #666a73;
  --line: #e3e3dd;
  --chip: #ecece7;
  --accent: #15161a;
  --accent-ink: #ffffff;
  --focus: #3b6cf6;
  --radius: 12px;
  --ctl: 36px; /* height of buttons, inputs and selects */
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.05), 0 6px 20px rgba(20, 20, 30, 0.06);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --surface: #1a1c20; --ink: #f1f1ee; --muted: #9a9ea8; --line: #2b2e34; --chip: #25282e;
    --accent: #f1f1ee; --accent-ink: #15161a; --focus: #7da2ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --surface: #1a1c20; --ink: #f1f1ee; --muted: #9a9ea8; --line: #2b2e34; --chip: #25282e;
  --accent: #f1f1ee; --accent-ink: #15161a; --focus: #7da2ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
p { margin: 0 0 0.7em; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
kbd { font: 600 0.76em var(--mono); padding: 1px 5px; border-radius: 5px; border: 1px solid currentColor; opacity: 0.75; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.wrap { width: min(1200px, 100% - 28px); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.82rem; margin: 6px 0 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- Header / footer ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-in { display: flex; align-items: center; gap: 12px; height: 50px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; font-size: 1rem; }
.logo-text b { font-weight: 800; background: linear-gradient(90deg, #f0a92c, #2bb5a6 55%, #5c80f5); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-mark { display: flex; width: 24px; height: 19px; border-radius: 5px; overflow: hidden; }
.logo-mark i { flex: 1; }
.logo-mark i:nth-child(1) { background: #f26b4e; }
.logo-mark i:nth-child(2) { background: #f9c22e; }
.logo-mark i:nth-child(3) { background: #2ec4b6; }
.logo-mark i:nth-child(4) { background: #5c80f5; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; text-decoration: none; font-weight: 600; font-size: 0.88rem; color: var(--muted); }
.nav a:hover, .nav a[aria-current] { color: var(--ink); background: var(--chip); }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.site-footer { margin-top: 32px; border-top: 1px solid var(--line); padding: 18px 0 26px; color: var(--muted); font-size: 0.86rem; }
.footer-browse { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.footer-browse p { margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 2px 12px; }
.footer-browse strong { color: var(--ink); font-weight: 650; }
.footer-browse a { text-decoration: none; }
.footer-browse a:hover { text-decoration: underline; color: var(--ink); }
.footer-in { display: flex; flex-wrap: wrap; gap: 8px 28px; justify-content: space-between; }
.footer-in p { margin: 0; }
.footer-in nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* ---------- Buttons, chips, forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--ctl); padding: 0 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 650; font-size: 0.88rem; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { opacity: 0.88; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 0.84rem; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--chip); font-size: 0.82rem; font-weight: 600; text-decoration: none; color: var(--muted); border: 1px solid transparent; }
.chip i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, 0.4); }
.chip:hover { color: var(--ink); border-color: var(--line); }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.dot { width: 22px; height: 22px; border-radius: 50%; background: var(--c); border: 1px solid rgba(128, 128, 128, 0.45); box-shadow: inset 0 0 0 2px var(--surface); }
.dot:hover { transform: scale(1.12); }
.dot.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.select select, .search input, .form input, input[type="number"] { height: var(--ctl); border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 11px; }
.select select { padding-right: 6px; font-weight: 600; font-size: 0.88rem; cursor: pointer; }
.select-sm select { height: 32px; font-size: 0.84rem; }
input[type="range"] { accent-color: var(--ink); }

/* ---------- Ads ---------- */
.adslot { margin: 10px auto; text-align: center; min-height: 90px; overflow: hidden; }
.adslot-sidebar { min-height: 250px; margin-top: 0; }
.adslot-empty { display: grid; place-items: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.grid-ad { grid-column: 1 / -1; }
.grid-ad .adslot { margin: 0; }

/* ---------- Hero / page head ---------- */
.hero { padding: 14px 0 2px; text-align: center; }
.hero h1 { font-size: clamp(1.8rem, 4.2vw, 2.8rem); font-weight: 850; letter-spacing: -0.04em; }
.hero h1 span { background: linear-gradient(90deg, #f26b4e, #f0a92c 30%, #2bb5a6 62%, #5c80f5); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero > p { max-width: 58ch; margin: 8px auto 0; color: var(--muted); font-size: 1rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.hero .hero-stats { margin-top: 10px; font-size: 0.86rem; }
.hero-stats strong { color: var(--ink); }
.page-head { padding: 8px 0 2px; }
.page-head h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 800; }
.page-head p { color: var(--muted); max-width: 76ch; margin: 5px 0 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 7px; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }

/* ---------- Filters ---------- */
.library { margin-top: 14px; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px 24px; }
.filters-top { display: flex; gap: 8px; flex-basis: 100%; }
.search { flex: 1; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-left: 34px; }
.filter-row { display: flex; gap: 10px; align-items: center; }
.filter-row:last-child { flex-basis: 100%; align-items: flex-start; }
.filter-label { flex: none; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.filter-row:last-child .filter-label { padding-top: 5px; }
.result-count { margin: 10px 2px 8px; color: var(--muted); font-size: 0.86rem; }

/* ---------- Palette cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 14px; }
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-strip { display: block; }
.strip { display: flex; height: 100px; }
.strip i { flex: 1; position: relative; transition: flex 0.22s ease; }
.strip:not(.strip-2) i:hover { flex: 2.4; }
.strip i::after { content: attr(data-hex); position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%); font: 600 11px/1 var(--mono); padding: 4px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; opacity: 0; transition: opacity 0.15s; pointer-events: none; white-space: nowrap; }
.strip:not(.strip-2) i:hover::after { opacity: 1; }
.strip-2 { display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows, 2), 1fr); }
.card-meta { padding: 8px 11px 9px; }
.card-meta h3 { font-size: 0.93rem; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta h3 a { text-decoration: none; }
.card-meta h3 a:hover { text-decoration: underline; }
.card-meta p { display: flex; justify-content: space-between; margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }
.dl { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; font-weight: 600; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 18px; color: var(--muted); }
.pager > :last-child { justify-self: end; }
.pager > :first-child { justify-self: start; }
.empty { text-align: center; padding: 40px 16px; }
.empty h1, .empty h2 { margin-bottom: 8px; }
.empty p { color: var(--muted); }

/* ---------- Palette page ---------- */
.palette { padding-top: 8px; }
.palette-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 20px; margin-bottom: 10px; }
.palette-head h1 { font-size: clamp(1.5rem, 3.6vw, 2.2rem); font-weight: 850; letter-spacing: -0.03em; }
.h1-sub { color: var(--muted); font-weight: 600; }
.byline { color: var(--muted); margin: 4px 0 0; font-size: 0.9rem; }
.dl-big { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; }
.dl-big strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.swatches { display: flex; height: clamp(170px, 26vw, 270px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.swatches-many { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); height: auto; }
.sw { flex: 1; min-width: 0; border: 0; padding: 0 0 10px; display: flex; align-items: flex-end; justify-content: center; cursor: pointer; transition: flex 0.2s ease; }
.swatches:not(.swatches-many) .sw:hover { flex: 1.5; }
.swatches-many .sw { height: 88px; padding-bottom: 7px; }
.sw span { font: 700 0.78rem var(--mono); letter-spacing: 0.02em; }
.swatches-xl { grid-template-columns: repeat(auto-fit, minmax(66px, 1fr)); }
.swatches-xl .sw { height: 62px; padding-bottom: 5px; }
.swatches-xl .sw span { font-size: 0.64rem; }
.sw:focus-visible { outline-offset: -4px; }
.palette-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 14px; align-items: start; }
.palette-cols.no-side { grid-template-columns: minmax(0, 1fr); }
.palette-side { position: sticky; top: 62px; }
.pal-img { float: right; width: 190px; height: auto; margin: 2px 0 8px 14px; border-radius: 8px; border: 1px solid var(--line); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.panel h2 { font-size: 1.02rem; }
.panel h2 .muted { font-weight: 500; font-size: 0.86rem; letter-spacing: 0; }
.panel > p { margin: 6px 0 0; }
.formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 10px; }
.fmt { display: flex; flex-direction: column; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; background: var(--bg); line-height: 1.3; }
.fmt:hover { border-color: var(--ink); }
.fmt strong { font-size: 0.9rem; }
.fmt span { font-size: 0.7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.size-picker { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.size-picker > label { font-weight: 650; font-size: 0.86rem; }
.size-picker > label .muted { font-weight: 400; }
.size-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.size-custom { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; }
.size-custom input { width: 76px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
.table-scroll { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; }
.codes { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.codes th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 4px 8px; position: sticky; top: 0; background: var(--surface); }
.codes td { padding: 2px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
.chipcol { display: block; width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(128, 128, 128, 0.35); }
.code { font: 0.82rem var(--mono); background: none; border: 0; padding: 3px 6px; border-radius: 6px; cursor: copy; }
.code:hover { background: var(--chip); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0 0; }
.related { margin-top: 8px; }
.related h2 { font-size: 1.1rem; margin-bottom: 10px; }

/* ---------- Studio (palette maker + image extractor) ---------- */
.studio { margin-top: 10px; }
.drop { display: grid; justify-items: center; gap: 2px; padding: 30px 20px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); text-align: center; cursor: pointer; transition: border-color 0.15s; }
.drop svg { width: 30px; height: 30px; color: var(--muted); margin-bottom: 4px; }
.drop p { margin: 0; }
.drop:hover, .drop.over { border-color: var(--ink); }

/* Control row: generator buttons and the number-of-colors slider + box */
.st-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.st-n { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 10px; height: var(--ctl); padding: 0 4px 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.st-n label { font-weight: 650; font-size: 0.88rem; }
.st-n input[type="range"] { flex: 1; min-width: 0; }
.st-n input[type="number"] { width: 62px; height: 28px; padding: 0 4px 0 8px; border-radius: 7px; text-align: center; font-weight: 750; font-variant-numeric: tabular-nums; background: var(--bg); }

/* Up to 12 colors: tall columns */
.st-bar { display: flex; height: clamp(190px, 26vw, 260px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.st-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; padding: 8px 3px 10px; position: relative; }
.st-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; opacity: 0; transition: opacity 0.15s; margin-bottom: auto; position: relative; z-index: 1; }
.st-col:hover .st-tools, .st-col:focus-within .st-tools, .st-col.locked .st-tools { opacity: 1; }
.st-tools button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; border: 0; padding: 0; background: transparent; color: inherit; cursor: pointer; }
.st-tools button:hover { background: rgba(128, 128, 128, 0.3); }
.st-tools button[disabled] { opacity: 0.3; cursor: default; }
.st-col.locked [data-act="lock"] { background: rgba(128, 128, 128, 0.38); }
.st-pick { position: relative; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 9px; border-radius: 999px; border: 1px solid currentColor; cursor: pointer; opacity: 0.85; }
.st-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.st-hex { width: min(100%, 88px); text-align: center; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 3px 2px; font: 700 0.82rem var(--mono); text-transform: uppercase; position: relative; z-index: 1; }
.st-hex:hover, .st-hex:focus { border-color: currentColor; }

/* 13 or more colors: a grid of tiles. Click a tile to pick its color. */
.st-bar.dense { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); height: auto; }
.st-bar.dense .st-col { height: 68px; padding: 2px 2px 4px; gap: 0; }
.st-bar.dense .st-tools [data-act="left"], .st-bar.dense .st-tools [data-act="right"] { display: none; }
.st-bar.dense .st-tools button { width: 22px; height: 22px; }
.st-bar.dense .st-pick { position: absolute; inset: 0; border: 0; border-radius: 0; padding: 0; opacity: 1; }
.st-bar.dense .st-pick span { display: none; }
.st-bar.dense .st-hex { width: 100%; font-size: 0.66rem; padding: 2px 0; }

.st-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.st-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; align-items: start; }
.st-panels .panel { margin: 0; }
/* Publishing switched off: the form is greyed out behind a "coming soon" notice. */
.panel-soon { position: relative; overflow: hidden; }
.panel-soon > h2, .panel-soon > form { opacity: 0.32; filter: grayscale(1); pointer-events: none; user-select: none; }
.soon { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px; padding: 16px; text-align: center; background: color-mix(in srgb, var(--surface) 62%, transparent); backdrop-filter: blur(1.5px); }
.soon strong { font-size: 1.05rem; letter-spacing: -0.01em; }
.soon span { color: var(--muted); font-size: 0.88rem; max-width: 34ch; }
.soon svg { color: var(--muted); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 10px; }
.form label { display: grid; gap: 3px; font-weight: 650; font-size: 0.84rem; }
.form label .muted { font-weight: 400; }
.form input { width: 100%; font-size: 0.92rem; }
.f-wide { grid-column: 1 / -1; }
.form-foot { display: flex; align-items: center; gap: 12px; }
.form-foot .hint { margin: 0; }
.form .hp { position: absolute; left: -9999px; }
.form-msg { margin: 0; font-size: 0.86rem; }
.form-msg:empty { display: none; }
.form-msg.err { color: #d43d3d; }

/* Image extractor: small image on the left, controls + palette on the right */
.ex { display: grid; grid-template-columns: minmax(180px, 270px) minmax(0, 1fr); gap: 14px; align-items: start; }
.ex-side { display: grid; gap: 8px; justify-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.ex-side canvas { display: block; max-width: 100%; max-height: 200px; border-radius: 8px; cursor: crosshair; }
.ex-side .hint { margin: 0; text-align: center; }
.ex-side .btn { width: 100%; }
.ex .st-bar:not(.dense) { height: clamp(160px, 19vw, 214px); }

/* ---------- Prose ---------- */
.prose { max-width: 76ch; margin: 22px auto 0; font-size: 0.95rem; }
.prose.page { margin-top: 14px; }
.prose h1 { font-size: clamp(1.5rem, 3.4vw, 2rem); margin-bottom: 10px; }
.prose h2 { font-size: 1.08rem; margin: 18px 0 6px; }
.prose ol, .prose ul { margin: 0 0 0.7em; padding-left: 20px; }
.prose li { margin-bottom: 3px; }
.prose a { text-underline-offset: 2px; }
.faq details { border-top: 1px solid var(--line); padding: 8px 0; }
.faq summary { font-weight: 650; cursor: pointer; }
.faq details p { margin: 6px 0 0; color: var(--muted); }

/* ---------- Ad-blocker notice ---------- */
.adwall { width: min(500px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35); }
.adwall::backdrop { background: rgba(12, 13, 16, 0.72); backdrop-filter: blur(6px); }
.adwall-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--chip); margin-bottom: 12px; }
.adwall h2 { font-size: 1.3rem; margin-bottom: 8px; }
.adwall p, .adwall ol { color: var(--muted); }
.adwall ol { padding-left: 20px; margin: 0 0 14px; }
.adwall .btn { width: 100%; height: 40px; }
.adwall-msg { margin: 8px 0 0; font-size: 0.86rem; text-align: center; }
.adwall-msg:empty { display: none; }
html.walled { overflow: hidden; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-weight: 650; font-size: 0.86rem; opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 40; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .palette-cols, .st-panels { grid-template-columns: minmax(0, 1fr); }
  .palette-side { position: static; }
}
@media (max-width: 720px) {
  .ex { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .ex-side { grid-template-columns: auto 1fr; justify-items: stretch; align-items: center; padding: 8px; }
  .ex-side canvas { max-height: 96px; max-width: 130px; grid-row: span 2; }
  .ex-side .hint { text-align: left; }
  /* Keep the color-count control in reach while scrolling the palette on a phone. */
  .ex .st-controls { position: sticky; top: 56px; z-index: 5; }
  .ex .st-n { box-shadow: var(--shadow); }
}
@media (max-width: 640px) {
  .nav a span { display: none; }
  .nav a { padding: 7px 9px; }
  .filters-top { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .filter-row { flex-basis: 100%; align-items: flex-start; }
  .filter-label, .filter-row:last-child .filter-label { width: 50px; padding-top: 5px; }
  /* One swipeable line per filter instead of several wrapped rows. */
  .filter-row { min-width: 0; }
  .filter-row .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 2px 0; min-width: 0; }
  .filter-row .chips::-webkit-scrollbar { display: none; }
  .filter-row .chips > * { flex: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .strip { height: 84px; }
  .swatches:not(.swatches-many) { flex-direction: column; height: auto; }
  .swatches:not(.swatches-many) .sw { min-height: 46px; padding: 0 14px; align-items: center; justify-content: flex-start; }
  /* Editor: up to 12 colors stack as rows; more than that stay as tiles. */
  .st-bar:not(.dense), .ex .st-bar:not(.dense) { flex-direction: column; height: auto; }
  .st-bar:not(.dense) .st-col { flex-direction: row; justify-content: flex-start; padding: 5px 8px; min-height: 46px; gap: 8px; }
  .st-bar:not(.dense) .st-tools { opacity: 1; margin: 0 0 0 auto; order: 3; flex-wrap: nowrap; }
  .st-bar:not(.dense) .st-tools [data-act="left"] svg, .st-bar:not(.dense) .st-tools [data-act="right"] svg { transform: rotate(90deg); }
  .st-bar.dense { grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); }
  .st-bar.dense .st-tools { opacity: 1; }
  .st-n { flex-basis: 100%; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .pal-img { width: 120px; }
  .form-foot { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
