:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --line: #e4e0d8;
  --accent: #b4322a;
  --accent-ink: #ffffff;
  --pill: #f1eee8;
  --pill-on: #1f1d1a;
  --pill-on-ink: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513;
    --surface: #201e1b;
    --text: #ece8e1;
    --muted: #a39d93;
    --line: #36332e;
    --accent: #e0645a;
    --accent-ink: #161513;
    --pill: #2a2824;
    --pill-on: #ece8e1;
    --pill-on-ink: #161513;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --surface: #201e1b; --text: #ece8e1; --muted: #a39d93; --line: #36332e;
  --accent: #e0645a; --accent-ink: #161513; --pill: #2a2824; --pill-on: #ece8e1; --pill-on-ink: #161513;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); line-height: 1.2; margin: .2em 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 1.8em 0 .6em; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 46em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header / footer */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.logo-mark { width: 18px; height: 18px; border-radius: 4px; background: linear-gradient(135deg, #b4322a, #e8a33d 50%, #2f6db3); }
.nav { display: flex; gap: 4px 16px; flex-wrap: wrap; font-size: .95rem; }
.nav a { text-decoration: none; padding: 6px 0; }
.tray-count[hidden], .f-active[hidden] { display: none; }
.tray-count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; text-align: center; }
.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 24px 0 40px; font-size: .875rem; color: var(--muted); }

/* intro */
.intro { padding: 28px 0 8px; }

/* filters */
.db { margin-top: 8px; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.f-search input {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
.f-more { margin-top: 10px; }
.f-more summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.f-active { font-weight: 400; color: var(--accent); font-size: .875rem; }
fieldset { border: 0; margin: 10px 0 0; padding: 0; }
legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; padding: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px;
  background: var(--pill); font-size: .875rem; cursor: pointer; user-select: none; border: 1px solid transparent;
}
.pill input:checked + span { background: var(--pill-on); color: var(--pill-on-ink); }
.pill input:focus-visible + span { border-color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, .15); }
.fam-red { background: #c8303a; } .fam-yellow { background: #f2cf1d; } .fam-green { background: #2f8f5b; }
.fam-blue { background: #2f6db3; } .fam-violet { background: #6c3f9a; } .fam-brown { background: #8a4f2a; }
.fam-black { background: #1d1d1d; } .fam-grey { background: #8f8f8f; } .fam-white { background: #f7f7f5; }
.fam-metallic { background: linear-gradient(135deg, #d2a33b, #c0beb6); }
select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.f-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.count { font-weight: 600; margin-right: auto; }
.link-btn { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px; }

@media (min-width: 1000px) {
  .db { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; align-items: start; }
  .filters { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; }
  .db .grid { margin-top: 0; }
  .db .empty { grid-column: 2; }
}

/* grid */
.grid { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card[hidden] { display: none; }
.card-link { text-decoration: none; display: flex; flex-direction: column; flex: 1; }
.card-link:hover .card-name { color: var(--accent); }
.chip { display: block; height: 64px; background: linear-gradient(90deg, var(--mass) 0%, var(--mass) 35%, var(--tint) 100%); border-bottom: 1px solid var(--line); }
.chip-sm { display: inline-block; width: 36px; height: 24px; border-radius: 4px; flex: none; background: linear-gradient(90deg, var(--mass), var(--tint)); border: 1px solid var(--line); }
.chip-lg { display: block; width: 100%; max-width: 320px; aspect-ratio: 2 / 1; border-radius: var(--radius); background: linear-gradient(90deg, var(--mass) 0%, var(--mass) 30%, var(--tint) 100%); border: 1px solid var(--line); }
.card-body { padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.card-code { font-size: .8rem; font-weight: 600; }
.card-name { font-weight: 650; line-height: 1.25; }
.card-ja { font-size: .82rem; color: var(--muted); }
.card-pig { font: .82rem ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: .78rem; color: var(--muted); margin-top: 4px; }
.b-perm { color: #c28a00; letter-spacing: 1px; }
.b-gran { color: var(--text); }
.b-tox { color: var(--accent); font-weight: 600; }
.cmp-btn {
  font: inherit; font-size: .82rem; margin: 0 12px 12px; align-self: flex-start; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer;
}
.cmp-btn[aria-pressed="true"] { background: var(--pill-on); color: var(--pill-on-ink); border-color: var(--pill-on); }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.note { max-width: 46em; }

/* color page */
.crumbs { font-size: .875rem; color: var(--muted); margin: 18px 0 8px; }
.color-hero { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 24px; align-items: center; margin: 8px 0 8px; }
.color-hero .cmp-btn { margin: 8px 0 0; }
.eyebrow { margin: 0; font-size: .85rem; color: var(--muted); }
.ja { margin: 0; color: var(--muted); font-size: 1.05rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.spec { width: 100%; border-collapse: collapse; font-size: .95rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.spec th, .spec td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec tr:last-child th, .spec tr:last-child td { border-bottom: 0; }
.spec th { font-weight: 600; white-space: nowrap; width: 1%; }
.spec thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.sizes td:nth-child(3) { font-variant-numeric: tabular-nums; }
.tag { font-size: .75rem; padding: 1px 6px; border-radius: 99px; background: var(--pill); white-space: nowrap; }
.mini { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.mini a { display: flex; gap: 10px; align-items: center; text-decoration: none; padding: 4px 0; font-size: .92rem; }
.facts { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.facts li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; }
.fam-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* sets */
.set { border-top: 1px solid var(--line); padding-top: 4px; margin-top: 24px; }
.set-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.set-grid a { display: flex; gap: 8px; align-items: center; text-decoration: none; font-size: .88rem; padding: 2px 0; }

/* pigments */
.pig-table td:nth-child(4), .pig-table td:nth-child(5) { font-variant-numeric: tabular-nums; }

/* compare */
.cmp-pick { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.cmp-out { overflow-x: auto; }
.cmp-table { table-layout: fixed; border-collapse: collapse; min-width: 560px; width: 100%; background: var(--surface); border: 1px solid var(--line); }
.cmp-table th, .cmp-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .92rem; }
.cmp-table th[scope="row"] { color: var(--muted); font-weight: 600; width: 120px; }
.cmp-table .chip { height: 56px; border-radius: 6px; border: 1px solid var(--line); }
.cmp-table .rm { font-size: .8rem; }

@media (max-width: 760px) {
  .color-hero, .cols { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
  .chip { height: 48px; }
  .badges { font-size: .72rem; }
  .spec th { white-space: normal; }
}
