:root {
  --ink: #17211d;
  --muted: #748078;
  --line: #dfe5df;
  --paper: #f7f8f5;
  --surface: #ffffff;
  --soft: #f1f5f0;
  --mint: #c8f2d5;
  --green: #4b9c64;
  --deep: #203b2c;
  --danger: #c95d54;
  --shadow: 0 14px 45px rgba(41, 69, 49, .08);
  --sans: "DM Sans", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Avenir Next", Inter, ui-sans-serif, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background-image: radial-gradient(#cad2cb .7px, transparent .7px);
  background-size: 14px 14px;
  content: "";
  opacity: .22;
  pointer-events: none;
}

button,
input,
select,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(77, 152, 98, .25);
  outline-offset: 2px;
}

/* Route headings receive focus for assistive technology, without a focus frame. */
[data-tool-page] h1[tabindex="-1"]:focus { outline: none; }

[hidden] { display: none !important; }

.shell {
  width: min(100%, 1128px);
  margin: auto;
  padding: 28px 34px 26px;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -1px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 10px;
  background: var(--deep);
  color: var(--mint);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -2px;
}

.dot { color: #64bd80; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar { gap: 20px; }
.tool-search { flex: 1; max-width: 380px; min-width: 0; }
.tool-search label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.tool-search input { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--control-line, var(--line)); border-radius: 10px; background: var(--soft); color: var(--ink); font-size: 13px; }
.tool-search input::placeholder { color: var(--muted); }
.tool-search-empty { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

@media (max-width: 650px) {
  .topbar:has(.tool-search:not([hidden])) { flex-wrap: wrap; }
  .tool-search { order: 3; flex-basis: 100%; max-width: none; }
}

.privacy {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.local-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: #5cca7c;
  box-shadow: 0 0 0 4px rgba(92, 202, 124, .11);
}

.tool-menu-item {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  color: var(--ink);
  gap: 11px;
  text-decoration: none;
  transition: background .15s ease;
}

.tool-menu-item:hover,
.tool-menu-item.active { background: #f1f7f1; }

.menu-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.code-icon { background: var(--deep); color: var(--mint); letter-spacing: -2px; }
.key-icon { background: #e7f7eb; color: #3b8d55; font-size: 17px; }
.color-icon { background: #f6e8ee; color: #a65f7b; font-size: 18px; }
.contrast-icon { background: #edf0fa; color: #586ba2; font-family: var(--display); font-size: 12px; }
.matrix-icon { background: #f6f0df; color: #92752e; font-size: 18px; }

.tool-menu-item strong,
.tool-menu-item small { display: block; }
.tool-menu-item strong { font-size: 12px; }
.tool-menu-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.menu-arrow { color: #a2ada5; font-size: 13px; }
.tool-menu-item.active .menu-arrow { color: var(--green); }

.tool-page:not([hidden]) { animation: page-in .24s ease-out; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero { padding: 85px 0 47px; }
.compact-hero { padding-bottom: 43px; }

.eyebrow,
.tool-overline {
  margin: 0 0 17px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font: 600 clamp(46px, 7vw, 76px)/.94 var(--display);
  letter-spacing: -4px;
}

.hero h1 em { color: var(--green); font-style: normal; }

.intro {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.tool {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar,
.generator-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
}

.tabs { display: flex; gap: 4px; }

.tab,
.button,
.clear,
.copy {
  border: 0;
  background: none;
  cursor: pointer;
  font: 600 12px var(--sans);
}

.tab {
  padding: 9px 13px;
  border-radius: 8px;
  color: var(--muted);
}

.tab:hover { color: var(--deep); }
.tab.active { background: var(--mint); color: var(--deep); }
.actions,
.inline-actions,
.form-actions { display: flex; gap: 9px; }

.button {
  padding: 10px 14px;
  border-radius: 8px;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .72; transform: none; }
.secondary { background: #f1f4f0; color: var(--muted); }
.secondary:hover { background: #e9eeea; color: var(--deep); }
.primary { background: var(--deep); color: #e0ffe8; }
.primary:hover { box-shadow: 0 7px 15px rgba(32, 59, 44, .18); }
.primary span { margin-right: 5px; color: var(--mint); }

.editor-wrap,
.result-wrap {
  overflow: hidden;
  margin: 18px 18px 0;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.result-wrap {
  margin-top: 12px;
  margin-bottom: 18px;
  background: #fafcf9;
}

.editor-head,
.editor-foot,
.result-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}

.editor-head { border-bottom: 1px solid var(--line); }

textarea,
.output {
  display: block;
  width: 100%;
  min-height: 265px;
  padding: 18px 16px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #385342;
  font: 13px/1.65 var(--mono);
  resize: vertical;
}

textarea::placeholder { color: #a8b3aa; }
.editor-foot { min-height: 38px; border-top: 1px solid var(--line); }
.clear { padding: 0; color: #9aa49d; }
.clear.accent { color: var(--green); }
.clear:hover,
.copy:hover { color: var(--deep); }
.copy:disabled { color: #b9c1bb; cursor: default; }
.status { font-weight: 500; }
.status.error { color: var(--danger); }
.status.ok { color: var(--green); }
.output { overflow: auto; margin: 0; white-space: pre-wrap; }
.placeholder { color: #a8b3aa; font-family: var(--sans); font-size: 13px; }

.tok-key { color: #9a5a24; }
.tok-string { color: #34805a; }
.tok-number { color: #9568ae; }
.tok-bool { color: #3979a6; }
.tok-tag { color: #a65050; }
.tok-brace { color: #257451; font-weight: 700; }
.tok-attr { color: #93612c; }
.tok-prop { color: #496da0; }
.tok-selector { color: #8a5797; }
.tok-comment { color: #99a39b; font-style: italic; }
.tok-sql { color: #a65050; font-weight: 700; }

.generator-toolbar { padding: 20px 24px; }
.generator-toolbar h2 { margin: 3px 0 0; font: 600 20px var(--display); letter-spacing: -.7px; }
.generator-toolbar .tool-overline { margin: 0; font-size: 9px; }

.local-badge {
  padding: 8px 10px;
  border: 1px solid #d8eadc;
  border-radius: 100px;
  background: #f3faf4;
  color: #4e785a;
  font-size: 10px;
  font-weight: 600;
}

.generator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 500px;
}

.generator-form { padding: 28px 30px 27px; }
.generator-result { padding: 28px 30px; border-left: 1px solid var(--line); background: #fafcf9; }
.field + .field { margin-top: 21px; }

.field label {
  display: block;
  margin-bottom: 8px;
  color: #314039;
  font-size: 12px;
  font-weight: 700;
}

.field > input,
.password-field,
.select-wrap {
  width: 100%;
  border: 1px solid #d8dfd9;
  border-radius: 9px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field > input,
.password-field input,
.select-wrap select {
  width: 100%;
  padding: 12px 13px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.field > input:focus,
.password-field:focus-within,
.select-wrap:focus-within {
  border-color: #75b889;
  box-shadow: 0 0 0 3px rgba(77, 152, 98, .12);
}

.field > input:focus-visible,
.password-field input:focus-visible,
.select-wrap select:focus-visible { outline: 0; }

.field input::placeholder { color: #a8b3aa; }
.field > small { display: block; margin-top: 7px; color: #98a29b; font-size: 10px; }
.password-field { display: flex; align-items: center; }
.password-field input { min-width: 0; }

.password-field button {
  margin-right: 7px;
  padding: 6px 7px;
  border: 0;
  border-radius: 6px;
  background: #f1f5f0;
  color: #738078;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.strength-row { display: flex; align-items: center; margin-top: 8px; gap: 9px; }
.strength-row small { color: #98a29b; font-size: 10px; }

.strength-track {
  width: 58px;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: #e4e9e5;
}

.strength-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: #c6cdc8; transition: width .2s ease, background .2s ease; }
.strength-track > span.weak { width: 28%; background: #d2756c; }
.strength-track > span.medium { width: 62%; background: #daa54a; }
.strength-track > span.strong { width: 100%; background: #57ad70; }

.select-wrap { position: relative; }
.select-wrap::after { position: absolute; top: 50%; right: 13px; color: #7f8b83; content: "⌄"; pointer-events: none; transform: translateY(-60%); }
.select-wrap select { padding-right: 34px; cursor: pointer; appearance: none; }

.algorithm-note {
  min-height: 31px;
  margin: 8px 1px 0;
  color: #87928a;
  font-size: 10px;
  line-height: 1.45;
}

.cost-setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding: 12px 13px;
  border: 1px solid #e0e6e1;
  border-radius: 9px;
  background: #f7faf7;
  gap: 14px;
}

.cost-setting label,
.cost-setting small { display: block; }
.cost-setting label { color: #405047; font-size: 11px; font-weight: 700; }
.cost-setting small { margin-top: 3px; color: #8b968e; font-size: 9px; line-height: 1.35; }
.compact-select { flex: 0 0 150px; background: #fff; }
.compact-select select { padding-top: 9px; padding-bottom: 9px; font-size: 11px; }

.form-actions { margin-top: 23px; }
.generate-button { min-width: 150px; }
.form-error { min-height: 17px; margin: 8px 0 0; color: var(--danger); font-size: 11px; }

.result-card { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.htpasswd-output {
  min-height: 210px;
  margin: 0;
  padding: 21px 17px;
  color: #315440;
  font: 12px/1.7 var(--mono);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.htpasswd-output .hash-user { color: #93612c; font-weight: 700; }
.htpasswd-output .hash-prefix { color: #8a5797; font-weight: 700; }
.htpasswd-output .hash-value { color: #34805a; }
.result-foot { min-height: 38px; border-top: 1px solid var(--line); font-size: 9px; }

.security-note {
  display: flex;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #dde7de;
  border-radius: 10px;
  background: #f1f7f1;
  color: #607066;
  gap: 11px;
}

.note-icon {
  display: grid;
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 50%;
  background: #d4ecd9;
  color: #3e8051;
  font-family: serif;
  font-size: 12px;
  font-weight: 700;
}

.security-note strong { color: #405047; font-size: 10px; }
.security-note p { margin: 3px 0 0; font-size: 10px; line-height: 1.5; }

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

.color-entry {
  padding: 23px 25px 20px;
  border-bottom: 1px solid var(--line);
  background: #fafcf9;
}

.color-main-field { margin: 0; }
.color-main-field > small { margin-left: 58px; }

.color-input-row {
  display: flex;
  align-items: stretch;
  gap: 9px;
}

.color-input-row input[type="color"] {
  flex: 0 0 49px;
  width: 49px;
  min-height: 43px;
  padding: 4px;
  border: 1px solid #d8dfd9;
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.color-input-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-input-row input[type="color"]::-moz-color-swatch { border: 0; border-radius: 5px; }

.color-input-row input[type="text"] {
  min-width: 0;
  flex: 1;
  padding: 11px 13px;
  border: 1px solid #d8dfd9;
  border-radius: 9px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font: 13px var(--mono);
}

.color-input-row input[type="text"]:focus {
  border-color: #75b889;
  box-shadow: 0 0 0 3px rgba(77, 152, 98, .12);
}

.color-entry .form-error { margin-left: 58px; }
.color-analysis-output { padding: 25px; }

.color-summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(190px, .75fr) minmax(280px, 1.25fr);
  overflow: hidden;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fafcf9;
}

.color-hero-swatch {
  display: flex;
  align-items: flex-end;
  min-height: 205px;
  padding: 15px;
  border: 0;
  background: var(--swatch);
  cursor: pointer;
}

.color-hero-swatch span {
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .83);
  color: #24342b;
  font-size: 9px;
  font-weight: 700;
}

.color-values { margin: 0; padding: 19px 22px; }
.color-values div { display: grid; grid-template-columns: 100px 1fr; padding: 8px 0; border-bottom: 1px solid #e6ebe7; gap: 15px; }
.color-values div:last-child { border-bottom: 0; }
.color-values dt { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.color-values dd { margin: 0; color: #36503f; font: 12px var(--mono); overflow-wrap: anywhere; }
.color-copy-status { position: absolute; right: 21px; bottom: 10px; font-size: 10px; }

.palette-section { margin-top: 25px; }
.palette-section > h3,
.palette-heading h3,
.result-section-head h3 { margin: 0 0 10px; font: 600 15px var(--display); letter-spacing: -.35px; }
.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.swatch-strip { display: flex; overflow: hidden; min-height: 70px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

.color-swatch-button {
  position: relative;
  flex: 1 1 48px;
  min-width: 38px;
  min-height: 68px;
  padding: 0;
  border: 0;
  background: var(--swatch);
  cursor: pointer;
  transition: flex-grow .18s ease, transform .18s ease;
}

.color-swatch-button:hover,
.color-swatch-button:focus-visible { z-index: 1; flex-grow: 1.5; transform: scaleY(1.04); }
.color-swatch-button span {
  position: absolute;
  right: 3px;
  bottom: 4px;
  left: 3px;
  overflow: hidden;
  padding: 3px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .82);
  color: #27352d;
  font: 8px var(--mono);
  opacity: 0;
  text-overflow: ellipsis;
  transition: opacity .15s ease;
  white-space: nowrap;
}
.color-swatch-button:hover span,
.color-swatch-button:focus-visible span { opacity: 1; }

.contrast-preview-grid { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.contrast-preview { display: flex; flex-direction: column; justify-content: center; min-height: 115px; padding: 14px; }
.contrast-preview strong { font: 700 28px var(--display); }
.contrast-preview span { margin-top: 5px; font-size: 10px; font-weight: 700; }
.contrast-preview small { margin-top: 4px; font-size: 9px; opacity: .72; }

.harmony-section { margin-top: 27px; }
.palette-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.palette-heading label { display: flex; align-items: center; color: var(--muted); font-size: 9px; font-weight: 700; gap: 5px; }
.palette-heading input[type="range"] { width: 125px; accent-color: var(--green); }

.contrast-optimizer-grid { display: grid; grid-template-columns: minmax(300px, .78fr) minmax(0, 1.22fr); }
.contrast-optimizer-grid .generator-form { border-right: 1px solid var(--line); }
.color-input-row.paired input[type="text"] { width: 100%; }
.optimizer-swap { margin-top: 12px; }

.contrast-current {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-top: 22px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7faf7;
}
.contrast-current > span:first-child { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.contrast-current strong { color: var(--deep); font: 700 19px var(--display); }
.contrast-current .contrast-rating { grid-column: 1 / -1; margin-top: 3px; font-size: 10px; }
.contrast-rating.pass { color: var(--green); }
.contrast-rating.fail { color: var(--danger); }

.contrast-target-field { margin-top: 21px; }
.contrast-target-field > input {
  display: block;
  min-height: 43px;
  padding: 11px 13px;
  border: 1px solid #d8dfd9;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}
.contrast-target-field > input:focus {
  border-color: #75b889;
  box-shadow: 0 0 0 3px rgba(77, 152, 98, .12);
}

.optimizer-results { min-height: 500px; padding: 27px 29px; background: #fafcf9; }
.result-section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.result-section-head .tool-overline { margin-bottom: 5px; font-size: 8px; }
.result-section-head h3 { margin: 0; font-size: 17px; }
.result-section-head > span { color: #98a29b; font-size: 9px; }
.optimizer-variant-list { display: grid; gap: 9px; }

.optimizer-variant {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  gap: 13px;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.optimizer-variant:hover { border-color: #bfcac1; box-shadow: 0 8px 20px rgba(41, 69, 49, .07); transform: translateY(-1px); }
.optimizer-preview { display: grid; align-self: stretch; min-height: 70px; place-items: center; border-right: 1px solid rgba(0, 0, 0, .06); }
.optimizer-preview b { font: 700 22px var(--display); }
.variant-copy { display: grid; grid-template-columns: 1fr auto; align-items: baseline; padding: 11px 0; gap: 3px 10px; }
.variant-copy strong { font-size: 11px; }
.variant-copy code { color: #3e7650; font: 11px var(--mono); }
.variant-copy small { grid-column: 1 / -1; color: #98a29b; font-size: 9px; }
.variant-ratio { padding-right: 14px; color: var(--deep); font: 700 17px var(--display); }
.variant-ratio small { margin-left: 1px; color: var(--muted); font-size: 9px; }
.empty-result { color: var(--muted); font-size: 12px; }

.matrix-controls {
  display: grid;
  grid-template-columns: minmax(280px, 1.45fr) minmax(220px, .75fr);
  padding: 23px 25px 18px;
  border-bottom: 1px solid var(--line);
  background: #fafcf9;
  gap: 0 22px;
}
.matrix-controls .field { margin: 0; }
.matrix-colors-field { grid-row: span 2; }
.matrix-colors-field textarea { min-height: 93px; padding: 12px 13px; border: 1px solid #d8dfd9; border-radius: 9px; background: #fff; font: 12px/1.5 var(--mono); resize: vertical; }
.matrix-options { display: flex; flex-direction: column; justify-content: end; padding-bottom: 2px; gap: 7px; }
.check-option { display: flex; align-items: center; color: #647269; cursor: pointer; font-size: 10px; gap: 7px; }
.check-option input { width: 14px; height: 14px; margin: 0; accent-color: var(--green); }
.matrix-actions { align-items: center; margin-top: 17px; }
.matrix-controls .form-error { align-self: center; margin: 17px 0 0; }
.matrix-controls > .status { align-self: center; margin: 8px 0 0; font-size: 10px; }

.matrix-result-wrap { padding: 20px 22px 24px; }
.matrix-legend { display: flex; margin-bottom: 12px; color: var(--muted); font-size: 9px; gap: 17px; }
.matrix-legend span { display: flex; align-items: center; gap: 5px; }
.matrix-legend span:last-child { margin-left: auto; }
.matrix-legend i { width: 9px; height: 9px; border-radius: 2px; }
.legend-pass { background: #70bd85; }
.legend-fail { border: 1px solid #cfd7d1; background: repeating-linear-gradient(45deg, #f0f3f0, #f0f3f0 2px, #fff 2px, #fff 4px); }
.matrix-container { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }

.contrast-matrix { width: 100%; min-width: 680px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.contrast-matrix th,
.contrast-matrix td { min-width: 80px; height: 62px; padding: 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.contrast-matrix tr > *:last-child { border-right: 0; }
.contrast-matrix tbody tr:last-child > * { border-bottom: 0; }
.contrast-matrix th { position: sticky; z-index: 2; background: #f7faf7; }
.contrast-matrix thead th { top: 0; }
.contrast-matrix tbody th { left: 0; }
.contrast-matrix thead th:first-child { left: 0; z-index: 3; }
.matrix-color-label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.matrix-color-label i { width: 22px; height: 22px; border: 1px solid rgba(23, 33, 29, .13); border-radius: 50%; background: var(--swatch); }
.matrix-color-label code { color: #627168; font: 8px var(--mono); }
.matrix-axis { color: #8b968e; font-size: 8px; line-height: 1.5; }
.contrast-matrix td { position: relative; font: 700 13px var(--mono); }
.contrast-matrix td small { position: absolute; top: 5px; right: 6px; font: 700 9px var(--sans); opacity: .65; }
.contrast-matrix td.matrix-fail:not([style]) { background: repeating-linear-gradient(45deg, #f1f3f1, #f1f3f1 6px, #fafbfa 6px, #fafbfa 12px); color: #929c95; }
.contrast-matrix td.matrix-value-hidden small { right: 50%; transform: translateX(50%); }
.matrix-optimize-link {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  border-radius: 6px;
  color: inherit;
  gap: 3px;
  text-decoration: none;
}
.matrix-optimize-link em {
  font: normal 700 8px var(--sans);
  opacity: .72;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.matrix-optimize-link:hover,
.matrix-optimize-link:focus-visible { background: rgba(255, 255, 255, .28); }
.matrix-optimize-link:hover em,
.matrix-optimize-link:focus-visible em { opacity: 1; }
.matrix-value-hidden .matrix-optimize-link { visibility: hidden; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 18px 2px 0;
  color: #99a39b;
  font-size: 11px;
  letter-spacing: .5px;
}

.text-stats-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 0; padding: 24px; border-bottom: 1px solid var(--line); }
.text-stats-summary > div { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.text-stats-summary dt { color: var(--muted); font-size: 12px; }
.text-stats-summary dd { margin: 10px 0 0; color: var(--deep); font: 600 32px/1.2 var(--display); overflow-wrap: anywhere; }
.text-stats-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.text-stats-editor { min-width: 0; }
#textStatsInput { min-height: 350px; font-family: var(--sans); }
.text-stats-editor .editor-foot { flex-wrap: wrap; gap: 10px; }
.text-stats-details { min-width: 0; padding: 20px; border-left: 1px solid var(--line); }
.text-stats-details .check-option { margin-bottom: 16px; font-size: 12px; }
.text-stats-table-wrap { max-height: 430px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.text-stats-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.text-stats-table th, .text-stats-table td { padding: 12px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.text-stats-table th { position: sticky; top: 0; background: var(--soft); }
.text-stats-table td { border-top: 1px solid var(--line); white-space: pre-wrap; }
.text-stats-table th:last-child, .text-stats-table td:last-child:not([colspan]) { width: 38%; text-align: right; }

@media (max-width: 820px) {
  .text-stats-grid { grid-template-columns: 1fr; }
  .text-stats-details { border-left: 0; border-top: 1px solid var(--line); }
  .privacy { display: none; }
  .hero { padding-top: 68px; }
  .generator-grid { grid-template-columns: 1fr; }
  .generator-result { border-top: 1px solid var(--line); border-left: 0; }
  .generator-grid { min-height: 0; }
  .contrast-preview-grid { grid-template-columns: 1fr 1fr; }
  .palette-grid { grid-template-columns: 1fr; }
  .contrast-optimizer-grid { grid-template-columns: 1fr; }
  .contrast-optimizer-grid .generator-form { border-right: 0; border-bottom: 1px solid var(--line); }
  .optimizer-results { min-height: 0; }
  .matrix-controls { grid-template-columns: 1fr; }
  .matrix-colors-field { grid-row: auto; }
  .matrix-controls .field + .field { margin-top: 18px; }
  .matrix-options { margin-top: 15px; }
}

@media (max-width: 650px) {
  .text-stats-summary { grid-template-columns: 1fr; padding: 18px; gap: 10px; }
  .text-stats-summary > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .text-stats-summary dd { margin: 0; font-size: 28px; }
  .shell { padding: 20px 16px; }
  .brand > span:last-child { display: none; }
  .hero { padding: 59px 0 35px; }
  .hero h1 { font-size: clamp(41px, 13vw, 58px); letter-spacing: -2.7px; }
  .intro { font-size: 14px; }
  .intro br { display: none; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 13px; }
  .tabs { overflow-x: auto; }
  .actions { justify-content: space-between; }
  .actions .button { flex: 1; }
  .editor-wrap,
  .result-wrap { margin-right: 10px; margin-left: 10px; }
  textarea,
  .output { min-height: 220px; }
  .generator-toolbar { align-items: flex-start; padding: 18px; gap: 15px; }
  .local-badge { white-space: nowrap; }
  .generator-form,
  .generator-result { padding: 22px 18px; }
  .color-entry,
  .color-analysis-output { padding-right: 18px; padding-left: 18px; }
  .color-input-row { flex-wrap: wrap; }
  .color-input-row input[type="text"] { flex-basis: calc(100% - 58px); }
  .color-input-row .button { flex: 1; }
  .color-main-field > small,
  .color-entry .form-error { margin-left: 0; }
  .color-summary { grid-template-columns: 1fr; }
  .color-hero-swatch { min-height: 150px; }
  .palette-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
  .palette-heading label { width: 100%; }
  .palette-heading input[type="range"] { flex: 1; width: auto; }
  .optimizer-results { padding: 22px 18px; }
  .matrix-controls { padding: 20px 18px; }
  .matrix-result-wrap { padding: 17px 10px 20px; }
  .matrix-legend { flex-wrap: wrap; }
  .matrix-legend span:last-child { width: 100%; margin-left: 0; }
}

@media (max-width: 430px) {
  .generator-toolbar { flex-direction: column; }
  .editor-foot { align-items: flex-start; flex-direction: column; gap: 9px; }
  .form-actions { flex-direction: column; }
  .form-actions .button { width: 100%; }
  .cost-setting { align-items: stretch; flex-direction: column; }
  .compact-select { flex-basis: auto; width: 100%; }
  .contrast-preview-grid { grid-template-columns: 1fr; }
  .color-values div { grid-template-columns: 82px 1fr; }
  .optimizer-variant { grid-template-columns: 60px 1fr auto; gap: 9px; }
  .variant-copy { grid-template-columns: 1fr; }
  .variant-copy small { grid-column: auto; }
  .variant-ratio { padding-right: 9px; font-size: 14px; }
  .result-section-head { align-items: flex-start; flex-direction: column; gap: 5px; }
  .matrix-actions { flex-direction: column; }
  .matrix-actions .button { width: 100%; }
}

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

/* Homepage tool discovery and shared menu cards. */
.tool-discovery { margin-top: 32px; padding: 26px; border: 1px solid #ceddce; border-radius: 24px; background: linear-gradient(120deg, #e7f2e6, #f3f7ee); }
.discovery-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.discovery-heading .eyebrow { margin-bottom: 7px; font-size: 10px; }
.discovery-heading h1 { margin: 0; font: 600 clamp(21px, 3vw, 28px)/1.2 var(--display); letter-spacing: -.8px; }
.tool-count { font-size: 12px; color: #52664f; }
.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tool-menu-item { position: relative; grid-template-columns: 1fr auto; gap: 12px; align-content: start; align-items: start; padding: 16px; min-width: 0; min-height: 150px; border: 1px solid #dce5d9; border-radius: 14px; background: #ffffffdb; transition: border-color .15s, background .15s; }
.tool-menu-item > .menu-icon { grid-column: 1; }
.tool-menu-item > span:nth-child(2) { grid-row: 2; grid-column: 1 / -1; }
.tool-menu-item .menu-arrow { grid-column: 2; grid-row: 1; font-size: 20px; }
.tool-menu-item strong { font-size: 14px; line-height: 1.4; }
.tool-menu-item small { font-size: 12px; line-height: 1.5; color: #647466; }
.tool-menu-item:hover { border-color: #7c9e7b; background: #fff; }
.tool-menu-item.active { background: var(--deep); border-color: var(--deep); color: #fff; box-shadow: 0 5px 15px #203b2c18; }
.tool-menu-item.active small, .tool-menu-item.active .menu-arrow { color: #c8f2d5; }
.menu-icon { background: #edf2e9; color: #365f42; }
.exif-feature { grid-column: span 2; background: #d7edcf; border-color: #b8d2af; }
.photo-icon { background: #294f3b; color: #e0f6d7; font-size: 24px; }
.new-badge { display: inline-block; padding: 2px 6px; margin-left: 5px; border-radius: 4px; background: #fff; color: #294f3b; vertical-align: middle; font-size: 9px; letter-spacing: .6px; }
.hero { padding-top: 48px; }
@media (max-width: 900px) { .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tool-menu-item { min-height: 130px; } }
@media (max-width: 650px) { .tool-discovery { margin-top: 24px; padding: 16px; border-radius: 18px; } .discovery-heading { display: block; } .tool-count { display: block; margin-top: 10px; } .tool-menu-item { padding: 12px; } .tool-menu-item strong { font-size: 13px; } .tool-menu-item small { font-size: 11px; } .hero { padding-top: 35px; } }
