:root {
  --bg: #faf8f5;
  --bg-2: #f1ede7;
  --card: #ffffff;
  --text: #1d1b18;
  --muted: #6c675f;
  --line: #e6e1d9;
  --accent: #b3402f;
  --accent-2: #8f2f22;
  --accent-soft: #fbeae6;
  --accent-ink: #ffffff;
  --q0: #157a48; --q1: #3e8a2b; --q2: #8a6d00; --q3: #c25f1a; --q4: #a12b2b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 20, 10, 0.05), 0 6px 20px -8px rgba(30, 20, 10, 0.12);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17161a; --bg-2: #1e1d22; --card: #222126; --text: #ece8e2; --muted: #a39d94; --line: #35323a;
    --accent: #e3806f; --accent-2: #f0a091; --accent-soft: #3a2521; --accent-ink: #1a1a1a;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -10px rgba(0,0,0,0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #17161a; --bg-2: #1e1d22; --card: #222126; --text: #ece8e2; --muted: #a39d94; --line: #35323a;
  --accent: #e3806f; --accent-2: #f0a091; --accent-soft: #3a2521; --accent-ink: #1a1a1a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.55; font-size: 16px; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.85rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0.5em 0 0.4em; font-weight: 800; }
h1 small { display: block; font-size: 0.95rem; font-weight: 500; color: var(--muted); margin-top: 0.4em; letter-spacing: 0; }
h2 { font-size: 1.3rem; letter-spacing: -0.01em; margin: 1.6em 0 0.5em; font-weight: 700; }
h3 { font-size: 1.05rem; margin: 1.2em 0 0.4em; font-weight: 700; }
h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.6em; }
p { margin: 0.5em 0; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 72ch; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.78rem; }
.error { color: var(--q4); }
.hint { color: var(--muted); }
.more { font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.logo { font-weight: 800; letter-spacing: -0.01em; color: var(--text); display: inline-flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.logo:hover { text-decoration: none; }
.logo-dot { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(#e63946, #f4a261, #e9c46a, #2a9d8f, #457b9d, #8e44ad, #e63946); box-shadow: inset 0 0 0 3px var(--card); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: 0.92rem; font-weight: 500; }
.nav a:hover { background: var(--bg-2); text-decoration: none; }

/* page grid with right rail */
.page-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; padding-top: 4px; }
.page-main { min-width: 0; min-height: 60vh; }
.rail { display: none; }
@media (min-width: 1100px) {
  .page-grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .rail { display: block; position: sticky; top: 72px; }
  body.page-home .page-grid { grid-template-columns: minmax(0, 1fr); }
  body.page-home .rail { display: none; }
}
@media (min-width: 1300px) {
  body.page-home .page-grid { grid-template-columns: minmax(0, 1fr) 300px; }
  body.page-home .rail { display: block; }
}
.rail-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 16px; }
.rail-block h3 { margin: 0 0 8px; font-size: 0.95rem; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.link-list li:last-child { border-bottom: 0; }
.link-list a { color: var(--text); }
.link-list a:hover { color: var(--accent); }
.rail-block .more { display: inline-block; margin-top: 8px; }

/* ads */
.ad { margin: 14px 0; text-align: center; }
.ad-label { display: block; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 4px; }
.ad-placeholder .ad-box { border: 1px dashed var(--line); color: var(--muted); font-size: 0.78rem; padding: 22px 12px; border-radius: var(--radius); background: var(--bg-2); }
.ad-rail .ad-box { min-height: 250px; display: flex; align-items: center; justify-content: center; }
.ad-rail ins { margin: 0 auto; }
.ad-top { margin-top: 12px; }

/* cards & sections */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 12px 0; box-shadow: var(--shadow); }
.section { margin: 28px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-bottom: 0.4em; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.two-col h2 { margin-top: 0.6em; }

/* hero */
.hero { padding: 20px 0 8px; }
.hero h1 { font-size: 2.2rem; margin-top: 0.3em; }
.stats { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 0; margin: 10px 0 4px; color: var(--muted); font-size: 0.9rem; }
.stats strong { color: var(--text); font-weight: 700; }

/* converter */
.mode-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { background: var(--bg-2); border: 1px solid transparent; color: var(--text); padding: 8px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 0.9rem; font-weight: 500; }
.tab:hover { border-color: var(--line); }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mode { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.mode[hidden], .ac-list[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; color: var(--muted); min-width: 180px; font-weight: 500; }
.field em { font-style: normal; font-weight: 400; }
.field.grow { flex: 1 1 260px; }
input[type=text], input[type=search], select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type=color] { width: 56px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ac-wrap { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; z-index: 30; max-height: 320px; overflow: auto; box-shadow: 0 12px 32px rgba(0,0,0,0.16); }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; color: var(--text); }
.ac-item.active, .ac-item:hover { background: var(--bg-2); }
.ac-code { font-family: var(--mono); font-weight: 600; min-width: 60px; }
.ac-name { flex: 1; }
.targets { margin-top: 14px; font-size: 0.9rem; }
.targets summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.target-actions { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.target-actions button, .btn { font: inherit; font-size: 0.86rem; font-weight: 600; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; line-height: 1.3; }
.btn.ghost, .target-actions button { background: transparent; color: var(--accent); }
.btn.small { font-size: 0.78rem; padding: 4px 10px; }
.btn:hover, .target-actions button:hover { text-decoration: none; background: var(--accent-2); color: var(--accent-ink); border-color: var(--accent-2); }
.target-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; }
.target { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.target.popular { font-weight: 600; }

/* swatches */
.swatch { display: inline-block; width: 36px; height: 24px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.14); vertical-align: middle; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); }
.swatch-sm { width: 26px; height: 18px; }
.swatch-xs { width: 16px; height: 14px; border-radius: 3px; }
.big-swatch { width: 150px; height: 150px; border-radius: 18px; border: 1px solid rgba(0,0,0,0.14); flex: 0 0 auto; display: flex; align-items: flex-end; justify-content: flex-end; padding: 8px; font-family: var(--mono); font-size: 0.85rem; box-shadow: var(--shadow); }
.source, .color-hero { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.source-meta, .color-meta { flex: 1 1 300px; }
.source h2, .color-hero h1 { margin-top: 0; }
.code { font-family: var(--mono); background: var(--bg-2); padding: 0 8px; border-radius: 8px; font-weight: 700; }
.pantone-list { list-style: none; padding: 0; margin: 0.3em 0; }
.pantone-list li { padding: 4px 0; }
.pantone-inline .alt { margin-right: 6px; }

/* quality badges */
.q { display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; color: #fff; white-space: nowrap; letter-spacing: 0.01em; }
.q0 { background: var(--q0); } .q1 { background: var(--q1); } .q2 { background: var(--q2); } .q3 { background: var(--q3); } .q4 { background: var(--q4); }
.de { font-size: 0.8rem; }
.legend td { padding: 5px 8px; vertical-align: top; }
.tier-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 0; margin: 6px 0 12px; font-size: 0.9rem; }

/* stats row (pair pages) */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat strong { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.stat span { font-size: 0.82rem; color: var(--muted); }

/* tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table.chart { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.92rem; overflow: hidden; }
table.chart th, table.chart td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
table.chart th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; background: var(--bg-2); }
table.chart tr:last-child td { border-bottom: 0; }
table.chart th.sortable { cursor: pointer; user-select: none; }
table.chart th.sortable:hover { color: var(--accent); }
table.chart th.sortable::after { content: "↕"; opacity: 0.35; margin-left: 5px; font-size: 0.85em; }
table.chart th.sort-asc::after { content: "▲"; opacity: 1; color: var(--accent); }
table.chart th.sort-desc::after { content: "▼"; opacity: 1; color: var(--accent); }
table.chart th:empty.sortable::after { content: "↕"; }
table.chart tbody tr:hover td { background: var(--bg); }
table.pair td.arrow { color: var(--muted); text-align: center; }
.alts { white-space: normal !important; }
.alt { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.84rem; color: var(--text); margin: 2px 2px 2px 0; background: var(--card); }
.alt:hover { border-color: var(--accent); text-decoration: none; }
.tiny-link { font-size: 0.75rem; color: var(--muted); border-bottom: 1px dotted var(--muted); margin-left: 4px; }
.tiny-link:hover { color: var(--accent); text-decoration: none; }
.table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.table-tools input { flex: 1 1 200px; width: auto; }
.table-tools select { width: auto; }
.count { color: var(--muted); font-size: 0.85rem; }
.crumbs { font-size: 0.82rem; color: var(--muted); margin: 14px 0 0; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

/* pills, pair cards, brand grid */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: 0.86rem; font-weight: 500; }
.pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 10px; }
.link-grid a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: 0.9rem; font-weight: 500; }
.link-grid a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.link-grid a .arrow { color: var(--accent); font-weight: 800; flex: 0 0 auto; }
.link-grid a .from { color: var(--muted); font-weight: 400; flex: 0 0 auto; }
.pair-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.pair-card { display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "from arrow to" "n n n"; gap: 2px 8px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--text); font-size: 0.9rem; font-weight: 600; box-shadow: var(--shadow); }
.pair-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.pair-from { grid-area: from; } .pair-to { grid-area: to; text-align: right; }
.pair-arrow { grid-area: arrow; color: var(--accent); font-weight: 800; }
.pair-n { grid-area: n; font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 8px 0 24px; }
.brand-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; color: var(--text); box-shadow: var(--shadow); }
.brand-card:hover { border-color: var(--accent); text-decoration: none; }
.brand-card h3 { margin: 8px 0 2px; font-size: 1rem; }
.brand-card p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.strip { display: flex; gap: 2px; }
.strip .swatch { flex: 1; width: auto; height: 18px; border-radius: 3px; }
.badge { font-size: 0.68rem; background: var(--accent-soft); color: var(--accent-2); padding: 2px 7px; border-radius: 999px; vertical-align: middle; font-weight: 600; }
.cols { columns: 2; column-gap: 24px; padding-left: 1.2em; }

/* steps & faq */
.steps { padding-left: 1.3em; }
.steps li { margin: 6px 0; }
.faq { margin-top: 32px; }
.faq details { border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 10px 14px; margin: 8px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: 8px 0 2px; }

/* browse + results workspace */
.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 12px; }
.browse { position: sticky; top: 68px; max-height: calc(100vh - 84px); display: flex; flex-direction: column; padding: 12px; margin: 0; }
.browse-head { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.browse-head h2 { grid-column: 1 / -1; margin: 0 0 4px; font-size: 0.95rem; }
.browse-head select { width: auto; padding: 8px 30px 8px 10px; }
.browse-list { overflow-y: auto; min-height: 200px; display: flex; flex-direction: column; gap: 2px; }
.chip { display: grid; grid-template-columns: 34px 62px 1fr; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 8px; color: var(--text); font-size: 0.88rem; }
.chip:hover { background: var(--bg-2); text-decoration: none; }
.chip.active { background: var(--accent); color: var(--accent-ink); }
.chip-swatch { display: block; width: 34px; height: 22px; border-radius: 5px; border: 1px solid rgba(0,0,0,0.15); }
.chip-code { font-family: var(--mono); font-weight: 600; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results { min-width: 0; margin-top: 0; }
.results .empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px; }
.workspace .source { margin-top: 0; }
.workspace table.chart { font-size: 0.88rem; }
.workspace table.chart td:first-child { white-space: normal; min-width: 120px; }
table.matches td:first-child { white-space: normal; min-width: 130px; }
table.matches td:nth-child(4) { white-space: normal; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .browse { position: static; max-height: none; }
  .browse-list { max-height: 40vh; }
  .workspace.has-result .browse { order: 2; }
}

/* footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 32px 0 40px; color: var(--muted); font-size: 0.86rem; background: var(--bg-2); }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
.foot-grid ul { list-style: none; padding: 0; margin: 0; }
.foot-grid li { padding: 3px 0; }
.foot-grid a { color: var(--text); }
.foot-grid a:hover { color: var(--accent); }
.foot-grid .logo { margin-bottom: 6px; }

@media (max-width: 760px) {
  h1 { font-size: 1.45rem; }
  .hero h1 { font-size: 1.6rem; }
  .big-swatch { width: 100%; height: 96px; }
  .cols { columns: 1; }
  .nav a { padding: 6px 8px; font-size: 0.86rem; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-grid > div:first-child { grid-column: 1 / -1; }
  .stat strong { font-size: 1.25rem; }
}
