/* Paint Finder — clean, swatch-led. Dark everywhere.
 *
 * Deliberately not following prefers-color-scheme: the same page looking
 * different on two machines is worse here than either palette is good, and
 * paint swatches need a consistent backdrop to be judged against at all.
 *
 * color-scheme: dark is load-bearing, not decoration — it tells the browser to
 * render native controls (checkboxes, selects, colour pickers, scrollbars) in
 * their dark form. Without it those stay light on a light-mode OS and look
 * pasted onto the page. */
:root {
  color-scheme: dark;

  --bg: #131315;
  --surface: #1c1c1f;
  --surface-2: #232327;
  --text: #f0efec;
  --text-dim: #a3a19c;
  --text-faint: #6f6d68;
  --line: #2e2e33;
  --accent: #e8724a;
  --focus: #7aa7d9;
  --danger: #ff6b6b; /* lifted for dark; a light-mode red reads muddy on #131315 */
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 5rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main, .masthead, footer { max-width: 780px; margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- account bar ---- */

.accountbar {
  max-width: 780px;
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem;
  padding-top: 1.25rem;
  min-height: 2.5rem;
  flex-wrap: wrap;
}

.navlinks { display: flex; gap: 1.1rem; }

.navlinks a {
  font-size: .9rem;
  color: var(--text-faint);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

.navlinks a:hover { color: var(--text-dim); }
.navlinks a.active { color: var(--text); border-bottom-color: var(--accent); }

#account { display: flex; align-items: center; gap: .6rem; }

.accountbar .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.accountbar .who { font-size: .9rem; color: var(--text-dim); }

.sync-warn {
  font-size: .78rem;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  padding: .25rem .6rem;
  cursor: help;
}

.accountbar button,
.accountbar .signin {
  font: inherit;
  font-size: .85rem;
  padding: .4rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s;
}

.accountbar button:hover,
.accountbar .signin:hover { border-color: var(--text-faint); }

/* ---- kit actions ---- */

.kit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
}

.kit-actions button {
  font: inherit;
  font-size: .85rem;
  padding: .4rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.kit-actions button:hover { border-color: var(--text-faint); }
.kit-actions button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.kit-actions button.danger:hover { border-color: var(--danger); color: var(--danger); }

.own-tag {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .6;
  margin-left: .4rem;
}

.dot.own { background: var(--focus); }

.swatch.unknown {
  background: repeating-linear-gradient(45deg, #888 0 4px, #bbb 4px 8px);
}

/* ---- custom scheme editor ---- */

.editor {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.editor h2 { margin: 0 0 .9rem; font-size: 1.05rem; }

.editor input,
.editor select {
  font: inherit;
  font-size: .9rem;
  padding: .4rem .6rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.editor input:focus, .editor select:focus {
  outline: none;
  border-color: var(--focus);
}

.ed-name { width: 100%; margin-bottom: 1rem; font-size: 1rem !important; }

.ed-part {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .8rem;
  margin-bottom: .7rem;
}

.ed-part-head { display: flex; gap: .5rem; margin-bottom: .6rem; }
.ed-part-name { flex: 1; }

.ed-step {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: .4rem;
  margin-bottom: .4rem;
}

.editor button {
  font: inherit;
  font-size: .85rem;
  padding: .35rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.editor button:hover { border-color: var(--text-faint); }
.editor button.danger:hover { border-color: var(--danger); color: var(--danger); }

.editor button.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.ed-add { margin-top: .3rem; }

.ed-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: 1rem;
}

.ed-error { font-size: .85rem; color: var(--danger); }

@media (max-width: 620px) {
  .ed-step { grid-template-columns: 1fr 1fr; }
  .ed-step .ed-note { grid-column: 1 / -1; }
}

/* ---- masthead ---- */

.masthead { padding: 3rem 0 2rem; text-align: center; }

.masthead h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -.03em;
}

.tagline { margin: .4rem 0 0; color: var(--text-dim); font-size: 1.05rem; }

/* ---- search ---- */

.search { position: relative; }

#q {
  width: 100%;
  padding: 1rem 1.15rem;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}

#q::placeholder { color: var(--text-faint); }

#q:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

#suggestions {
  position: absolute;
  z-index: 20;
  inset-inline: 0;
  top: calc(100% + .5rem);
  margin: 0;
  padding: .35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 22rem;
  overflow-y: auto;
}

#suggestions li {
  padding: .6rem .8rem;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

#suggestions li[aria-selected="true"] { background: var(--surface-2); }

#suggestions .faction {
  color: var(--text-faint);
  font-size: .82rem;
  white-space: nowrap;
}

#suggestions .none { color: var(--text-dim); cursor: default; }

/* ---- empty state ---- */

.empty { margin-top: 2.5rem; text-align: center; color: var(--text-dim); }

.shortcuts {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}

.shortcuts button {
  padding: .45rem .85rem;
  font: inherit;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}

.shortcuts button:hover { border-color: var(--text-faint); }
.shortcuts button:active { transform: translateY(1px); }

/* ---- result ---- */

#result { margin-top: 3rem; }

.kit-name {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.kit-meta { color: var(--text-dim); font-size: .92rem; margin-top: .15rem; }

.scheme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1.5rem 0 .75rem;
}

.scheme-picker button {
  padding: .45rem .9rem;
  font: inherit;
  font-size: .9rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}

.scheme-picker button:hover { color: var(--text); }

.scheme-picker button[aria-pressed="true"] {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.provenance {
  font-size: .82rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: 2rem;
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

/* ---- boxed set contents ---- */

.box-contents {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.box-contents h3 {
  margin: 0 0 .6rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.box-contents ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .5rem;
}

.box-contents li a {
  display: inline-block;
  font-size: .88rem;
  color: var(--text);
  text-decoration: none;
  padding: .3rem .7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.box-contents li a:hover { border-color: var(--text-faint); }

.box-contents .note {
  margin: .8rem 0 0;
  font-size: .82rem;
  color: var(--text-faint);
}

/* ---- parts ---- */

.part {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: .85rem;
  box-shadow: var(--shadow);
}

.part h3 {
  margin: 0 0 .85rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.step {
  display: grid;
  grid-template-columns: 5.5rem auto 1fr;
  align-items: center;
  gap: .75rem;
  padding: .42rem 0;
}

.step + .step { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }

.stage {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(128,128,128,.35);
  flex: none;
  position: relative;
}

/* A dashed ring marks a colour we haven't verified against a real source.
   Deliberately outside the fill — the swatch itself must stay true, since
   judging the colour is the whole point of showing it. */
.swatch.unverified {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--text-faint) 70%, transparent);
}

.paint-name { font-size: .97rem; }

.paint-type {
  color: var(--text-faint);
  font-size: .78rem;
  margin-left: .45rem;
}

.step-note {
  grid-column: 2 / -1;
  font-size: .85rem;
  color: var(--text-dim);
  margin-top: -.3rem;
}

/* ---- buy links ---- */

.buy { display: inline-flex; gap: .25rem; flex: none; }

.buy a {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1rem .3rem;
  line-height: 1.5;
  transition: color .15s, border-color .15s;
}

.buy a:hover { color: var(--accent); border-color: var(--accent); }

/* In the recipe the same paints repeat across parts, so three badges per row
   would be permanent noise. Reveal them on hover or keyboard focus instead —
   present everywhere, shouting nowhere. */
.buy.on-hover {
  margin-left: .5rem;
  opacity: 0;
  transition: opacity .12s;
}

.step:hover .buy.on-hover,
.buy.on-hover:focus-within { opacity: 1; }

@media (hover: none) {
  /* No hover on touch — always show, or they'd be unreachable. */
  .buy.on-hover { opacity: 1; }
}

.step-paint { display: flex; align-items: center; min-width: 0; }

/* ---- shopping list ---- */

.shopping {
  margin-top: 2.5rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
}

.shopping h2 {
  margin: 0 0 .25rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.shopping .hint { margin: 0 0 1rem; font-size: .86rem; color: var(--text-dim); }

.shopping ul { margin: 0; padding: 0; list-style: none; }

.shopping li { padding: .12rem 0; }

.shop-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.shop-row label { flex: 1; min-width: 0; }

/* Already owned — nothing to buy, so the links go away. Driven by the class
   refreshCollectionUI already toggles, so ticking a box updates this for free. */
.shop-row label.owned ~ .buy { display: none; }

.shopping label {
  display: flex;
  align-items: center;
  gap: .65rem;
  cursor: pointer;
  padding: .3rem .35rem;
  border-radius: 8px;
}

.shopping label:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }

.shopping input { width: 16px; height: 16px; accent-color: var(--focus); cursor: pointer; }

.shopping label.owned .paint-name { color: var(--text-faint); text-decoration: line-through; }
.shopping label.owned .swatch { opacity: .4; }

.tally { margin-top: 1rem; font-size: .86rem; color: var(--text-dim); }

/* ---- colour signature ---- */

/* A kit's identity, built from its own paints. Horizontal by default; .sig-v is
   the vertical spine used down the left edge of a collection card. */
.sig {
  display: flex;
  overflow: hidden;
  border-radius: 4px;
  flex: none;
}

.sig > span { display: block; }

.sig-sm { width: 28px; height: 10px; }
.sig-sm > span { flex: 1; }

.sig-lg {
  width: 100%;
  max-width: 240px;
  height: 8px;
  margin-top: .8rem;
  border-radius: 999px;
}
.sig-lg > span { flex: 1; }

/* Flush to the card's left edge rather than floating inside it — a spine, so
   the colours read as belonging to the whole row. */
.sig-v {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  flex-direction: column;
  width: 6px;
  border-radius: var(--radius) 0 0 var(--radius);
}
.sig-v > span { flex: 1; }

.sug-main { display: flex; align-items: center; gap: .6rem; min-width: 0; }

/* ---- my collection ---- */

#collection { max-width: 780px; margin-inline: auto; padding-top: 2.5rem; }

.c-title {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -.025em;
}

.c-sub { margin: .3rem 0 0; color: var(--text-dim); font-size: .95rem; }

.c-head {
  margin: 2.75rem 0 .9rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}

.c-lede { margin: 0 0 1rem; color: var(--text-dim); font-size: .92rem; }

.c-empty {
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: .92rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* saved kits */

.c-kits { display: flex; flex-direction: column; gap: .6rem; }

.c-kit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .9rem 1.15rem .9rem 1.6rem;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .1s;
}

.c-kit:hover { border-color: var(--text-faint); }
.c-kit:active { transform: translateY(1px); }
.c-kit.complete { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.c-kit-main { display: flex; flex-direction: column; min-width: 0; }
.c-kit-name { font-weight: 600; font-size: .98rem; }
.c-kit-meta { font-size: .82rem; color: var(--text-faint); margin-top: .1rem; }

.c-kit-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .35rem;
  flex: none;
  width: 8.5rem;
}

.c-kit-progress .bar {
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.c-kit-progress .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .25s;
}

.c-kit-count { font-size: .78rem; color: var(--text-faint); white-space: nowrap; }
.c-kit.complete .c-kit-count { color: var(--accent); }

/* paints owned */

.c-group { margin-bottom: 1.5rem; }

.c-group h3 {
  margin: 0 0 .6rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.c-count {
  color: var(--text-faint);
  font-weight: 400;
  margin-left: .35rem;
}

.c-paints {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .35rem;
}

.c-paint {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .4rem .6rem;
  font: inherit;
  font-size: .88rem;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color .15s;
}

.c-paint .paint-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.c-x { color: var(--text-faint); opacity: 0; transition: opacity .15s; }
.c-paint:hover { border-color: var(--danger); }
.c-paint:hover .c-x { opacity: 1; color: var(--danger); }

/* custom schemes */

.c-schemes { list-style: none; margin: 0; padding: 0; }

.c-schemes li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .5rem;
}

.c-open {
  font-size: .85rem;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .3rem .8rem;
  flex: none;
}

.c-open:hover { color: var(--text); border-color: var(--text-faint); }

.c-scheme-main { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }
.c-scheme-actions { display: flex; align-items: center; gap: .5rem; flex: none; }

.c-schemes button,
.c-share button {
  font: inherit;
  font-size: .85rem;
  padding: .35rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex: none;
}

.c-schemes button:hover,
.c-share button:hover { border-color: var(--text-faint); }
.c-schemes button:disabled,
.c-share button:disabled { opacity: .5; cursor: default; }

/* sharing */

.c-share {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.15rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.c-share strong { font-size: .95rem; font-weight: 600; }
.c-share p { margin: .25rem 0 0; font-size: .86rem; color: var(--text-dim); }

.c-link {
  margin-top: .6rem;
  width: 100%;
  max-width: 30rem;
  font: inherit;
  font-size: .82rem;
  font-family: ui-monospace, Menlo, monospace;
  padding: .4rem .6rem;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.c-link:focus { outline: none; border-color: var(--focus); color: var(--text); }

.c-paint.static { cursor: default; }
.c-paint.static:hover { border-color: var(--line); }

@media (max-width: 560px) {
  .c-share { flex-direction: column; align-items: stretch; }
  .c-schemes li { flex-direction: column; align-items: stretch; gap: .7rem; }
}

@media (max-width: 520px) {
  .c-kit { flex-direction: column; align-items: stretch; gap: .7rem; }
  .c-kit-progress { width: 100%; align-items: stretch; }
  .c-kit-count { text-align: right; }
}

/* ---- footer ---- */

footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: .82rem;
  text-align: center;
}

footer p { margin: .35rem 0; }

@media (max-width: 520px) {
  .step { grid-template-columns: 4.6rem auto 1fr; gap: .55rem; }
  .masthead { padding-top: 3rem; }
}
