:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5a626d;
  --border: #e1e4e8;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0fe;
  --radius: 10px;
  --max: 1040px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --text: #e8eaed;
    --muted: #a0a8b2;
    --border: #2f343a;
    --accent: #a5b4fc;
    --accent-ink: #12133a;
    --accent-soft: #1e2040;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a { color: var(--accent); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 14px; font-size: 0.95rem; overflow-x: auto; white-space: nowrap; max-width: 100%; padding-bottom: 2px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); }

main { padding: 24px 0 48px; }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 8px 0 8px; }
h2 { font-size: 1.3rem; margin: 32px 0 12px; }
h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.breadcrumbs { font-size: 0.85rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }

/* The big answer at the top of generated pages and under each tool */
.answer {
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 18px 20px; margin: 16px 0;
}
.answer .label { font-size: 0.9rem; color: var(--muted); margin: 0; }
.answer .value { font-size: 1.7rem; font-weight: 700; line-height: 1.25; margin: 4px 0; }
.answer .sub { margin: 0; color: var(--muted); }

/* Tool forms */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.tool input, .tool select {
  font: inherit; font-size: 1.05rem; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%;
}
.tool input:focus, .tool select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.tool .check { flex-direction: row; align-items: center; gap: 8px; font-size: 0.95rem; color: var(--text); }
.tool .check input { width: auto; }
.tool .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.tool button {
  font: inherit; font-weight: 600; padding: 9px 16px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.tool button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.tabs button[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.error { color: #c0392b; margin: 8px 0 0; }

/* Fact tables */
table.facts { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.facts th, table.facts td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.facts tr:last-child th, table.facts tr:last-child td { border-bottom: 0; }
table.facts th { font-weight: 500; color: var(--muted); width: 42%; }
table.facts td { font-weight: 600; }

/* Ads: reserve space so the page doesn't jump when an ad loads */
.ad-slot { margin: 24px 0; min-height: 100px; display: flex; justify-content: center; }

.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; padding: 0; list-style: none; }
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; padding: 0; list-style: none; }
.num-grid a {
  display: block; text-align: center; padding: 6px 0; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); text-decoration: none; font-weight: 600; font-variant-numeric: tabular-nums;
}
.num-grid a:hover { border-color: var(--accent); }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.pill-list a { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; background: var(--surface); }

.faq dt { font-weight: 600; margin-top: 12px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }

.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 0.9rem; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.site-footer a { color: var(--muted); }

.prose p, .prose li { max-width: 70ch; }
.muted { color: var(--muted); }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num { font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 32px 0 0; flex-wrap: wrap; }
.result:empty { display: none; }
.result { margin-top: 16px; }

/* Color Code Box */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(#ef4444, #f59e0b, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #ef4444); }
.search { display: flex; gap: 6px; flex: 1 1 220px; max-width: 320px; }
.search input { flex: 1; min-width: 0; font: inherit; font-size: 0.95rem; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.search button, .quick button, button.copy, .btn {
  font: inherit; font-size: 0.9rem; font-weight: 600; padding: 6px 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; display: inline-block;
}
button.copy { background: transparent; color: var(--accent); border: 1px solid var(--border); padding: 3px 10px; font-size: 0.82rem; }
button.copy.done { border-color: var(--accent); }
.hero { border-radius: var(--radius); min-height: 180px; display: flex; flex-direction: column; justify-content: flex-end; padding: 18px 20px; border: 1px solid var(--border); margin: 12px 0; }
.hero-hex { font-size: 2.2rem; font-weight: 700; letter-spacing: 0.02em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hero-rgb { opacity: 0.85; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.chip-link { margin-left: auto; font-size: 0.92rem; }
.small { font-size: 0.88rem; }
table.codes { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.codes th, table.codes td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); }
table.codes tr:last-child th, table.codes tr:last-child td { border-bottom: 0; }
table.codes th { font-weight: 500; color: var(--muted); width: 30%; white-space: nowrap; }
table.codes td code { font-size: 0.95rem; }
.copy-cell { width: 1%; text-align: right; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; padding: 0; list-style: none; margin: 8px 0 16px; }
.swatches.big { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sw { display: block; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); text-decoration: none; color: var(--text); font-size: 0.82rem; }
.sw:hover { border-color: var(--accent); }
.sw .chip { display: block; height: 52px; border-bottom: 1px solid var(--border); }
.swatches.big .sw .chip { height: 72px; }
.sw code { display: block; padding: 4px 8px 0; font-size: 0.8rem; }
.sw-label { display: block; padding: 0 8px 6px; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
.sw code:last-child { padding-bottom: 6px; }
.harmonies { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 20px; }
.harmonies h3 { margin-bottom: 2px; }
.harmonies p { margin: 0; }
.sample { display: inline-block; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); font-weight: 600; }
.pass { color: #15803d; font-weight: 600; }
.fail { color: #b91c1c; font-weight: 600; }
@media (prefers-color-scheme: dark) { .pass { color: #4ade80; } .fail { color: #f87171; } }
pre.code { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-size: 0.88rem; }
.demo { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.demo > div { border-radius: 8px; padding: 18px; text-align: center; font-weight: 600; border: 1px solid var(--border); background: var(--surface); }
.demo-border { border-width: 3px !important; border-style: solid !important; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; padding: 0; list-style: none; }
.tool-grid a { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--text); font-weight: 600; }
.tool-grid a:hover { border-color: var(--accent); }
.tool-grid span { display: block; font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 0; list-style: none; }
.family-grid a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--text); font-weight: 600; }
.family-grid .dot { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); flex: none; }
.letters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.letters a, .letters span { display: inline-block; min-width: 34px; text-align: center; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); text-decoration: none; font-weight: 600; }
.letters span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.picker { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
@media (max-width: 680px) { .picker { grid-template-columns: 1fr; } }
.tool.picker input[type=color] { width: 100%; height: 220px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: none; cursor: pointer; }
.preview { height: 90px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 10px; }
.swatch-inline { display: inline-block; width: 1em; height: 1em; border-radius: 3px; vertical-align: -0.15em; border: 1px solid var(--border); }
canvas.pick { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); cursor: crosshair; display: block; }
.gradient-preview { height: 160px; border-radius: var(--radius); border: 1px solid var(--border); }
.tool input[type=color] { height: 42px; padding: 2px; cursor: pointer; }
.tool input[type=range] { padding: 0; }
.picker .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
