:root {
  --ui-ink: #202827;
  --ui-muted: #59645f;
  --ui-line: #c9d0ca;
  --ui-line-strong: #8e9992;
  --ui-paper: #f5f6f2;
  --ui-sheet: #fcfdf9;
  --ui-blue: #165dff;
  --ui-lime: #d7f33a;
}

html { overflow-x: clip; }
body { background-color: var(--ui-paper); background-image: linear-gradient(90deg, #25342c0a 1px, transparent 1px); background-size: 48px 48px; }
main { width: 100%; max-width: 1200px; padding: 38px 28px 72px; }
main > .eyebrow:first-child,
main > .crumb + .eyebrow { display: inline-block; }
main > h1 { margin-top: 12px; margin-bottom: 14px; }
main > .lead { margin-top: 0; margin-bottom: 28px; }
main > section { margin-block: 44px; }
main > section:first-of-type { margin-top: 36px; }
main > section > h2:first-child { margin: 0 0 18px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
  gap: 16px;
  border: 0;
  align-items: stretch;
}
.grid:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid:has(> :nth-child(8):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid:has(> :only-child) { grid-template-columns: 1fr; }

.panel {
  background: color-mix(in srgb, var(--ui-sheet) 97%, var(--ui-blue) 3%);
  border: 1px solid var(--ui-line);
  box-shadow: 0 8px 22px #15231a0a;
  padding: 22px;
}
.grid > .panel { min-width: 0; }
.tool {
  min-height: 0;
  display: flex;
  flex-direction: column;
  color: var(--ui-ink);
  border-top: 3px solid var(--ui-blue);
  transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}
.tool h2, .tool h3 { margin: 0; font-size: 1.05rem; line-height: 1.3; overflow-wrap: anywhere; }
.tool p { margin: 12px 0 0; color: var(--ui-muted); line-height: 1.55; }
.tool::after { margin-top: auto; padding-top: 18px; font-size: .9rem; }
.tool:hover { background: #fff; border-color: var(--ui-blue); box-shadow: 0 10px 28px #15231a14; }
.grid:has(> :only-child) > .tool {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr) auto;
  gap: 20px;
  align-items: center;
  width: 100%;
  padding-block: 18px;
}
.grid:has(> :only-child) > .tool p,
.grid:has(> :only-child) > .tool::after { margin: 0; padding: 0; }

.category-nav { margin: 26px 0 36px; padding: 8px; border: 1px solid var(--ui-line); background: #e9ede8; }
.category-nav a { border: 1px solid transparent; text-decoration: none; }
.category-nav a:hover { background: var(--ui-sheet); border-color: var(--ui-line); }
.content-grid { margin-block: 48px; border-color: var(--ui-line-strong); }
.content-grid aside { border: 1px solid var(--ui-line); border-left: 4px solid var(--ui-blue); }
.note { border-left-color: var(--ui-blue); background: #eef3ff; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--ui-lime);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px var(--ui-ink);
}
a:not(:focus-visible), button:not(:focus-visible), input:not(:focus-visible), select:not(:focus-visible) { outline: 0; }

/* Calculator results are a production decision surface: keep their contrast independent of earlier panel rules. */
.calculator > .result {
  --result-surface: #1f2933;
  --result-ink: #f7faf7;
  --result-muted: #e4ebe5;
  background: var(--result-surface);
  color: var(--result-ink);
  border: 1px solid #344454;
  border-top: 4px solid var(--ui-lime);
  box-shadow: 0 8px 22px #15231a14;
  display: flex;
  flex-direction: column;
  padding: 24px;
}
.calculator > .result strong {
  display: block;
  color: var(--ui-lime);
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.calculator > .result p {
  color: var(--result-muted);
  line-height: 1.6;
  margin: 14px 0 0;
}
.result-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #ffffff3d;
}
.result-actions[hidden] { display: none; }
.result-actions .copy {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: 8px 12px;
  background: #edf1ec;
  border: 1px solid #bcc8bf;
  box-shadow: none;
  color: #202725;
  font-size: .72rem;
}
.calculator > .result:has(.error) {
  background: #35171b;
  border-color: #8a3d45;
  border-top-color: #ffb4a2;
}
.calculator > .result .error {
  margin: 0;
  padding: 12px 14px;
  background: #4a1d23;
  border-left: 4px solid #ffb4a2;
  color: #fff7f7;
  font-weight: 700;
}

@media (max-width: 768px) {
  .calculator > .result { padding: 20px; }
  .calculator > .result strong { font-size: clamp(1.9rem, 11vw, 2.5rem); }
  .result-actions { margin-top: 14px; padding-top: 10px; }
}

/* Keep the owner-managed directory badges in place while allowing them to wrap on narrow screens. */
body > .footer + div[style*="min-width:1280px"] {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 1280px !important;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}
body > .footer + div[style*="min-width:1280px"] a { margin: 0 !important; max-width: 100%; }
body > .footer + div[style*="min-width:1280px"] img { max-width: 100%; }

@media (max-width: 1100px) {
  .grid,
  .grid:has(> :nth-child(3):last-child),
  .grid:has(> :nth-child(6):last-child),
  .grid:has(> :nth-child(8):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  main { padding: 24px 16px 48px; }
  main > section { margin-block: 34px; }
  .grid,
  .grid:has(> :nth-child(2):last-child),
  .grid:has(> :nth-child(3):last-child),
  .grid:has(> :nth-child(4):last-child),
  .grid:has(> :nth-child(6):last-child),
  .grid:has(> :nth-child(8):last-child) { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .grid:has(> :only-child) > .tool { display: flex; gap: 0; }
  .grid:has(> :only-child) > .tool p { margin-top: 10px; }
  .grid:has(> :only-child) > .tool::after { margin-top: auto; padding-top: 14px; }
  .content-grid { margin-block: 36px; }
}
