/* JM Pixel Art — jmforu dark editorial tool-desk (factory CSS, site-specific additions at the end).
   Tokens: #111914 / #1b2820 / #f2eee1 / #d4ff88; light paper #f3efe6.
   No purple gradients, no generic card shadows, no external fonts. */

:root,
html[data-theme="dark"] {
  --bg: #111914;
  --surface: #1b2820;
  --ink: #f2eee1;
  --accent: #d4ff88;
  --ink-soft: #c6c1b2;
  --rule: #2c3c33;
  --font-sans: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans", "Noto Sans JP", "Noto Sans KR", "Noto Sans SC", "Source Han Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --page: 1440px;
  --nav-h: 48px;
  --gutter: 2rem;
  color-scheme: dark;
}

html:has(.theme-checkbox:checked),
html[data-theme="light"]:has(.theme-checkbox:checked) {
  --bg: #f3efe6;
  --surface: #fffdf6;
  --ink: #171512;
  --accent: #21543c;
  --ink-soft: #4a453c;
  --rule: #d4cbb8;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
}

img, svg, video, canvas, iframe { max-width: 100%; height: auto; display: block; }
pre, code { max-width: 100%; overflow-x: auto; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { color: var(--ink); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3.5rem;
  z-index: 60;
  background: var(--ink);
  color: var(--bg);
  padding: 0.4rem 0.7rem;
}
.skip-link:focus { top: 0.4rem; }

.header-inner,
.page-desk,
.page-data,
.page-home,
.page-guide,
.page-palettes,
.page-legal,
.page-missing,
.site-footer {
  width: min(var(--page), calc(100% - var(--gutter)));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.brand:hover { color: var(--ink); }
.brand-mark { color: var(--accent); flex: 0 0 auto; }
.brand-full, .brand-short, .brand-demo {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-short { display: none; }
.brand-demo {
  font-weight: 600;
  font-size: 0.68rem;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  padding: 0.1rem 0.35rem;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 0.86rem;
}
.primary-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}
.primary-nav a:hover,
.primary-nav a[aria-current="page"] { color: var(--ink); }
.primary-nav a[aria-current="page"] { box-shadow: inset 0 -1px 0 var(--accent); }

.nav-compact { display: none; position: relative; }
.nav-compact > summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  height: 30px;
  padding: 0 0.55rem;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.nav-compact > summary::-webkit-details-marker { display: none; }
.nav-compact-list {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 10rem;
  max-width: calc(100vw - 2rem);
  background: var(--surface);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  padding: 0.28rem;
}
.nav-compact-list a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
}
.nav-compact-list a[aria-current="page"],
.nav-compact-list a:hover { background: var(--bg); color: var(--accent); }

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex: 0 0 auto;
}

.theme-checkbox {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.theme-switch label {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 0.55rem;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.theme-switch label:hover { color: var(--ink); }
.theme-short { display: none; }

.lang-nav { display: flex; align-items: center; }
.lang-menu { position: relative; display: inline-block; }
.lang-menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  height: 30px;
  padding: 0 0.55rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.lang-menu > summary::-webkit-details-marker { display: none; }
.lang-menu > summary:hover,
.lang-menu[open] > summary { border-color: var(--accent); color: var(--accent); }
.lang-menu[open] > summary::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 49;
  cursor: default;
}
.lang-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 10rem;
  max-width: calc(100vw - 2rem);
  padding: 0.28rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lang-dropdown a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.38rem 0.58rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.8rem;
  white-space: nowrap;
}
.lang-dropdown a:hover,
.lang-dropdown a[aria-current="page"] {
  background: var(--bg);
  color: var(--accent);
}
.lang-dropdown small { font-size: 0.7rem; color: var(--ink-soft); }

.demo-strip {
  margin: 0;
  padding: 0.45rem 0 0.35rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
}
.demo-badge {
  color: var(--ink);
  font-weight: 650;
}

.page-desk,
.page-data,
.page-home,
.page-guide,
.page-palettes,
.page-legal,
.page-missing { padding-bottom: 3rem; flex: 1 1 auto; }

.desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16rem;
  gap: 1.5rem 1.75rem;
  padding-top: 0.7rem;
  align-items: start;
}

.section-head,
.page-kicker {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.7rem 0 0.65rem;
}
.section-head h1,
.page-kicker h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0;
}

.lead {
  margin: 0 0 1rem;
  max-width: 62rem;
  color: var(--ink);
  font-size: 0.95rem;
}

.scroll-x {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}
.data-table caption {
  text-align: left;
  padding: 0.45rem 0.7rem;
  font-weight: 650;
  font-size: 0.8rem;
  color: var(--ink-soft);
  caption-side: top;
}
.data-table th,
.data-table td {
  padding: 0.38rem 0.7rem;
  border-top: 1px solid var(--rule);
  vertical-align: top;
  text-align: left;
}
.data-table thead th {
  font-weight: 650;
  font-size: 0.76rem;
  color: var(--ink-soft);
  background: var(--bg);
  white-space: nowrap;
}
.data-table .num,
.data-table th.num,
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover td,
.data-table tbody tr:hover th { background: var(--bg); }

.source-note {
  margin: 0.7rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  max-width: 62rem;
}

.desk-rail h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 650;
}
.rail-links {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  border: 1px solid var(--rule);
}
.rail-links li { border-top: 1px solid var(--rule); }
.rail-links li:first-child { border-top: 0; }
.rail-links a {
  display: block;
  padding: 0.45rem 0.65rem;
  color: var(--ink);
  text-decoration: none;
}
.rail-links a:hover { background: var(--surface); color: var(--accent); }

.convert-card {
  border: 1px solid var(--rule);
  padding: 0.75rem 0.8rem;
  background: var(--surface);
}
.convert-card h2 {
  margin: 0 0 0.4rem;
  font-size: 0.92rem;
}
.convert-card p { margin: 0 0 0.55rem; font-size: 0.82rem; color: var(--ink-soft); }
.convert-btn {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  background: var(--accent);
  color: #111914;
  text-decoration: none;
  font-weight: 650;
  font-size: 0.84rem;
}
html:has(.theme-checkbox:checked) .convert-btn { color: #f3efe6; background: #21543c; }
.convert-btn:hover { color: #111914; opacity: 0.92; }

.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(14rem, 0.7fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  align-items: start;
}
.calc-form {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.85rem 1rem 1rem;
}
.js-note { margin: 0 0 0.8rem; font-size: 0.82rem; color: var(--ink-soft); }
.field { margin: 0 0 0.7rem; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 0.85rem;
}

.field-grid > label,
.field-grid > .field {
  margin: 0;
  min-width: 0;
}

@media (max-width: 640px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

.field label, .unit-field legend {
  display: block;
  font-size: 0.78rem;
  font-weight: 650;
  margin-bottom: 0.25rem;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}
.field-grid > label > span,
.calc-form > label > span {
  display: block;
  font-size: 0.78rem;
  font-weight: 650;
  margin-bottom: 0.25rem;
}
.field input,
.field select,
.field-grid input,
.field-grid select,
.calc-form input[type="text"],
.calc-form button {
  font: inherit;
  font-size: 0.92rem;
  width: 100%;
  max-width: 100%;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.35rem 0.45rem;
}
.unit-field {
  border: 0;
  margin: 0 0 0.7rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  justify-content: flex-end;
}
.unit-field label { font-weight: 500; display: flex; gap: 0.35rem; align-items: center; }
.unit-field input { width: auto; }

.mode-set {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0.7rem 0.85rem;
  margin: 0 0 0.85rem;
}
.mode-set legend {
  font-weight: 650;
  padding: 0 0.25rem;
}
.mode-option {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  margin: 0.35rem 0 0;
  font-weight: 500;
}
.mode-option input { width: auto; margin-top: 0.2rem; flex: 0 0 auto; }

.form-actions { margin: 0.4rem 0 0.8rem; }
.calc-form button {
  width: auto;
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: #111914;
  font-weight: 650;
  cursor: pointer;
  border-color: var(--accent);
}
html:has(.theme-checkbox:checked) .calc-form button { color: #f3efe6; background: #21543c; border-color: #21543c; }
.formula-line { font-size: 0.8rem; color: var(--ink-soft); }
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0.5rem 0 0;
}
.result-grid dt { font-size: 0.74rem; color: var(--ink-soft); }
.result-grid dd {
  margin: 0.15rem 0 0;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 650;
}

.faq-block { margin-top: 1.75rem; max-width: 52rem; }
.faq-block h2, .page-data > h2 {
  margin: 1.25rem 0 0.6rem;
  font-size: 1rem;
}
.faq-item {
  border-top: 1px solid var(--rule);
  padding: 0.45rem 0;
}
.faq-item summary { cursor: pointer; font-weight: 650; }
.faq-item p { margin: 0.4rem 0 0; color: var(--ink); }

.letter-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  margin: 0 0 1rem;
  font-size: 0.88rem;
}
.letter-group h2 {
  margin: 1.1rem 0 0.4rem;
  font-size: 1rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.6rem;
}
.term { margin: 0 0 0.85rem; max-width: 46rem; }
.term h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.term p { margin: 0; }

.tool-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}
.tool-item {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.8rem 0.85rem;
}
.tool-cat {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.tool-item h2 { margin: 0 0 0.2rem; font-size: 1rem; }
.tool-pub { margin: 0 0 0.45rem; font-size: 0.8rem; color: var(--ink-soft); }
.tool-item p { margin: 0 0 0.5rem; font-size: 0.9rem; }
.tool-link { margin: 0; }

.page-legal p, .page-missing p { max-width: 42rem; }

.site-footer {
  padding: 0.7rem 0 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.footer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem 1rem;
}
.footer-copy { margin: 0; }
.footer-copy a, .footer-nav a { color: var(--ink-soft); text-decoration: none; }
.footer-copy a:hover, .footer-nav a:hover { color: var(--ink); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.disclosure-zone {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--rule);
  max-width: 62rem;
}
.disclosure-zone p { margin: 0 0 0.35rem; }
.cj-slot { color: var(--ink-soft); }
.cj-slot code {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}


.calc-aside {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.partner-offers {
  margin-top: 1rem;
}
.calc-aside .partner-offers,
.desk-rail .partner-offers {
  margin-top: 0;
}
.partner-offers > h2 {
  margin: 0 0 0.4rem;
  font-size: 0.92rem;
}
.partner-offers > p {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.partner-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.desk-rail .partner-grid,
.calc-aside .partner-grid {
  grid-template-columns: minmax(0, 1fr);
}
.partner-card {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.75rem 0.8rem;
}
.partner-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}
.partner-card p { margin: 0 0 0.45rem; font-size: 0.82rem; color: var(--ink-soft); }
.partner-card a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}
.partner-card a:hover { text-decoration: underline; }
.partner-disclosure {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.disclosure-zone .cj-slot {
  margin: 0.55rem 0 0;
}
.disclosure-zone .cj-slot a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}
.disclosure-zone .cj-slot a:hover { text-decoration: underline; }

@media (min-width: 90rem) {
  /* 1440px desk: keep the first grid tight so the table is in the opening screen. */
  .desk-grid { padding-top: 0.55rem; }
}

@media (max-width: 64rem) {
  :root { --gutter: 1.25rem; }
  .desk-grid,
  .calc-layout { grid-template-columns: minmax(0, 1fr); }
  .tool-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-full { display: none; }
  .brand-short { display: inline; }
}

@media (max-width: 44rem) {
  .primary-nav { display: none; }
  .nav-compact { display: inline-block; }
  .theme-long { display: none; }
  .theme-short { display: inline; }
  .brand-demo { display: none; }
  .field-row,
  .result-grid { grid-template-columns: minmax(0, 1fr); }
  .tool-list,
  .partner-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .lang-nav, .theme-switch, .skip-link, .convert-card, .partner-offers { display: none !important; }
  body { background: white; color: black; }
  .scroll-x, .tool-item, .calc-form { border-color: #ccc; }
}

/* Rates extras: unverified marks, calculator notes, affiliate tool slots, tighter first-screen table. */
.rail-lead {
  margin: 0 0 0.7rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.mark-unverified {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  padding: 0 0.3rem;
  vertical-align: middle;
  white-space: nowrap;
}
.data-table td.figure,
.data-table th code,
.data-table td code {
  font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.78rem;
  font-weight: 500;
}
.calc-note {
  margin: 0.7rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.flag-field label { font-weight: 500; }
.data-table tbody th code { font-weight: 650; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.calc-form button[type="button"] {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}
html:has(.theme-checkbox:checked) .calc-form button[type="button"] {
  color: var(--ink);
  background: transparent;
  border-color: var(--rule);
}
.result-grid.rate-results {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cj-tools {
  border: 1px solid var(--rule);
  padding: 0.75rem 0.8rem;
  background: var(--surface);
  margin: 0 0 1rem;
}
.cj-tools h2 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 650;
}
.cj-tools .cj-lead,
.disclosure-zone .cj-lead {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.cj-link-block { margin: 0 0 0.7rem; }
.cj-link-block:last-child { margin-bottom: 0; }
.cj-link-block p {
  margin: 0.28rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.irs-banner {
  margin: 0.7rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  max-width: 62rem;
}
.note-cell { font-size: 0.78rem; color: var(--ink-soft); max-width: 22rem; }

/* Ad Waste extras: first-screen calculator + benchmark table, cache-bust-safe layout. */
.desk-grid.is-tool {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}
.article-head h1 {
  max-width: none;
}

/* Pixel art editor */
.crumbs {
  margin: 0.7rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.page-home .page-kicker { margin-top: 0.45rem; margin-bottom: 0.35rem; }
.page-home .lead { margin-bottom: 0.7rem; }

.pixel-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 18rem);
  gap: 1rem 1.15rem;
  align-items: start;
  margin: 0 0 1.5rem;
}

.editor-stage {
  min-width: 0;
}

.canvas-frame {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.65rem;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  aspect-ratio: 1;
  background-color: #0a0c10;
  background-image:
    linear-gradient(45deg, #1b2820 25%, transparent 25%),
    linear-gradient(-45deg, #1b2820 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1b2820 75%),
    linear-gradient(-45deg, transparent 75%, #1b2820 75%);
  background-size: 1.25rem 1.25rem;
  background-position: 0 0, 0 0.625rem, 0.625rem -0.625rem, -0.625rem 0;
  touch-action: none;
}
html:has(.theme-checkbox:checked) .canvas-wrap {
  background-color: #e7e1d2;
  background-image:
    linear-gradient(45deg, #d4cbb8 25%, transparent 25%),
    linear-gradient(-45deg, #d4cbb8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d4cbb8 75%),
    linear-gradient(-45deg, transparent 75%, #d4cbb8 75%);
}

.pixel-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
  display: block;
  position: relative;
  z-index: 1;
}

.canvas-grid {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  background-image:
    linear-gradient(to right, rgba(242, 238, 225, 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(242, 238, 225, 0.16) 1px, transparent 1px);
  background-size: calc(100% / var(--cells, 16)) calc(100% / var(--cells, 16));
}
html:has(.theme-checkbox:checked) .canvas-grid {
  background-image:
    linear-gradient(to right, rgba(23, 21, 18, 0.14) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(23, 21, 18, 0.14) 1px, transparent 1px);
}
.canvas-wrap[data-grid="off"] .canvas-grid { display: none; }

.tool-row,
.size-row,
.export-row,
.preview-row,
.mirror-row,
.frame-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.55rem 0 0;
}

.pixel-editor button,
.export-row button,
.preview-row button,
.frame-actions button,
.tool-row button,
.size-row button {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.32rem 0.55rem;
  cursor: pointer;
}

.pixel-editor button[aria-pressed="true"],
.pixel-editor button.is-on {
  background: var(--accent);
  color: #111914;
  border-color: var(--accent);
}
html:has(.theme-checkbox:checked) .pixel-editor button[aria-pressed="true"],
html:has(.theme-checkbox:checked) .pixel-editor button.is-on {
  color: #f3efe6;
  background: #21543c;
  border-color: #21543c;
}

.editor-rail {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.rail-block {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.7rem 0.75rem;
}
.rail-block h2 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 650;
}

.palette-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.5rem;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.28rem;
}
.swatch-grid[data-palette="gameboy"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--rule);
  padding: 0;
  cursor: pointer;
  background: var(--swatch, var(--surface));
}
.color-swatch[aria-pressed="true"],
.color-swatch.is-on {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.color-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.55rem;
}
.active-swatch {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--rule);
  background: var(--swatch, transparent);
}
.color-row input[type="color"] {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--bg);
  cursor: pointer;
}
.color-row input[type="text"] {
  font: inherit;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  width: 100%;
  max-width: 100%;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.28rem 0.4rem;
}

.frame-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}
.frame-thumb {
  border: 1px solid var(--rule);
  background: var(--bg);
  padding: 0.2rem;
  cursor: pointer;
  min-width: 0;
}
.frame-thumb[aria-current="true"],
.frame-thumb.is-on {
  border-color: var(--accent);
}
.frame-thumb canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background:
    linear-gradient(45deg, #1b2820 25%, transparent 25%) 0 0 / 0.6rem 0.6rem,
    linear-gradient(-45deg, #1b2820 25%, transparent 25%) 0 0.3rem / 0.6rem 0.6rem,
    #0a0c10;
}
.frame-thumb span {
  display: block;
  font-size: 0.68rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.15rem;
}

.preview-canvas {
  width: 6rem;
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid var(--rule);
  background: #0a0c10;
}

.mix-label,
.fps-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 650;
}
.mix-label input[type="range"],
.fps-label input[type="range"] {
  width: 7rem;
  max-width: 100%;
  accent-color: var(--accent);
}

.css-panel textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 7rem;
  box-sizing: border-box;
  font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.75rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.5rem 0.55rem;
  margin: 0.4rem 0;
}
.css-preview-stage {
  position: relative;
  width: 8rem;
  height: 8rem;
  margin: 0.5rem 0 0;
  border: 1px solid var(--rule);
  background: var(--bg);
  overflow: hidden;
}
.css-preview-pixel {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  width: 1px;
  height: 1px;
  transform: scale(4);
  transform-origin: top left;
}

.palette-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 0.8rem 0 1.2rem;
}
.palette-card {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.8rem 0.85rem;
}
.palette-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}
.palette-card p { margin: 0 0 0.6rem; font-size: 0.88rem; }
.static-swatches {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.3rem;
}
.static-swatches[data-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.static-swatch {
  min-width: 0;
}
.static-swatch i {
  display: block;
  aspect-ratio: 1;
  border: 1px solid var(--rule);
  background: var(--swatch);
}
.static-swatch code {
  display: block;
  font-size: 0.65rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
  word-break: break-all;
}

.guide-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0.6rem 0 1rem;
}
.guide-tool {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.7rem 0.8rem;
}
.guide-tool h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.guide-tool p { margin: 0; font-size: 0.88rem; }

.sibling-tool {
  margin: 1.2rem 0 0;
  max-width: 52rem;
}
.sibling-tool h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.sibling-tool p { margin: 0 0 0.45rem; }
.sibling-list { margin: 0; padding-left: 1.1rem; }

@media (max-width: 64rem) {
  .pixel-editor { grid-template-columns: minmax(0, 1fr); }
  .palette-cards,
  .guide-tools { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 44rem) {
  .swatch-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .frame-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .css-preview-pixel { transform: none; }
}

/* Visual QA grid-span fix: keep banners full-width so canvas stays in primary 1fr stage */
.pixel-editor > .privacy-banner,
.pixel-editor > .js-note {
  grid-column: 1 / -1;
  margin: 0;
}
.pixel-editor {
  grid-template-columns: minmax(0, 1fr) minmax(0, 22rem);
}
.canvas-wrap {
  max-width: 34rem;
}
.swatch-grid[data-palette="gameboy"] {
  grid-template-columns: repeat(4, minmax(0, 2.5rem));
}
.color-swatch {
  max-height: 2.5rem;
}
