:root {
  --paper: #f4f1ea;
  --card: #fffdf8;
  --ink: #16130f;
  --muted: #6b645a;
  --line: #ddd6c8;
  --line-strong: #8a8275;
  --accent: #ff5a1f;
  --accent-ink: #16130f;
  --focus-ring: var(--accent);
  --app-accent: var(--accent);
  --fs-sm: 0.9rem;
  --dur-fast: 0.15s;
  --radius-card: 18px;
  --radius-pill: 999px;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --gutter: 32px;
  --shadow-card: 0 1px 0 rgb(0 0 0 / 0.03), 0 8px 24px -12px rgb(40 30 10 / 0.12);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131210;
    --card: #1c1a17;
    --ink: #f1ece2;
    --muted: #a39b8d;
    --line: #34302a;
    --line-strong: #7a7266;
    --accent: #ff6b35;
    --accent-ink: #160b05;
    --shadow-card: 0 1px 0 rgb(0 0 0 / 0.2), 0 8px 24px -12px rgb(0 0 0 / 0.5);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: -999px;
}

.skip:focus {
  left: 16px;
  top: 8px;
  z-index: 30;
  background: var(--card);
  padding: 4px 10px;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in oklch, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand {
  font: 700 1.125rem var(--mono);
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lang {
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
  font: 0.8rem var(--mono);
  color: var(--muted);
  text-decoration: none;
}

.lang:hover {
  color: var(--ink);
  background: var(--card);
}

.hero {
  padding: 72px 0 40px;
  max-width: 720px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 56ch;
}

.tools {
  display: grid;
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.toolcard {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 20px 24px 20px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: border-color 0.15s;
}

.toolcard:hover,
.toolcard:focus-visible {
  border-color: var(--accent);
}

.toolcard-tile {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.toolcard-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toolcard-text strong {
  font-size: 1.125rem;
}

.toolcard-text span {
  color: var(--muted);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px;
  font: 600 0.95rem var(--sans);
  text-decoration: none;
  white-space: nowrap;
}

.toolcard:hover .btn {
  border-color: var(--ink);
}

button.btn {
  background: none;
  color: inherit;
  cursor: pointer;
}

.btn-ghost:hover {
  border-color: var(--ink);
}

.btn-primary,
button.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.notfound {
  margin: 96px auto;
  max-width: 480px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.notfound-code {
  font: 4.5rem/1 var(--mono);
  letter-spacing: -0.05em;
  color: var(--accent);
}

.notfound p {
  margin: 0;
}

.notfound .alt {
  color: var(--muted);
  font-size: 0.9rem;
}

.foot {
  margin-top: 64px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.foot .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-top: 24px;
  padding-bottom: 40px;
}

.foot p {
  margin: 0;
}

.prose {
  max-width: 68ch;
  padding: 56px 0 0;
}

.prose h1 {
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
}

.prose h2 {
  margin: 32px 0 8px;
  font-size: 1.25rem;
}

.prose .updated {
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* Dialogs */
.dlg {
  width: min(440px, calc(100vw - 32px));
  padding: clamp(16px, 5vw, 24px);
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
  color: var(--ink);
}
.dlg::backdrop {
  background: rgb(0 0 0 / 0.45);
}
.dlg h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}
.dlg p {
  margin: 0 0 10px;
}
.dlg-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 720px) {
  :root {
    --gutter: 16px;
  }

  .hero {
    padding: 40px 0 24px;
  }

  .toolcard {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 16px;
  }

  .toolcard > .btn {
    grid-column: 1 / -1;
  }

  .toolcard-tile {
    width: 52px;
    height: 52px;
  }

  .a11y-open-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .dlg-actions {
    flex-wrap: nowrap;
  }

  .dlg-actions > * {
    flex: 1;
  }

  .prose {
    padding-top: 32px;
  }

  .notfound {
    margin: 48px auto;
    padding: 32px 20px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="on"]) *,
  html:not([data-motion="on"]) *::before,
  html:not([data-motion="on"]) *::after {
    /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
    animation-duration: 0.01ms !important;
    /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
    animation-iteration-count: 1 !important;
    /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
    transition-duration: 0.01ms !important;
    /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
    scroll-behavior: auto !important;
  }
}

/* Accessibility preferences (header panel), shared by every tools.codes app */
html[data-text="115"] {
  font-size: 115%;
}
html[data-text="130"] {
  font-size: 130%;
}
html[data-text="150"] {
  font-size: 150%;
}

/* High contrast */
html[data-contrast="high"] {
  --paper: #ffffff;
  --card: #ffffff;
  --ink: #000000;
  --muted: #222222;
  --line: #000000;
  --line-strong: #000000;
  --accent: #000000;
  --accent-ink: #ffffff;
  --focus-ring: #000000;
}
@media (prefers-color-scheme: dark) {
  html[data-contrast="high"] {
    --paper: #000000;
    --card: #000000;
    --ink: #ffffff;
    --muted: #e0e0e0;
    --line: #ffffff;
    --line-strong: #ffffff;
    --accent: #ffd400;
    --accent-ink: #000000;
    --focus-ring: #ffd400;
  }
}
html[data-contrast="high"] :focus-visible {
  outline-width: 3px;
}

/* Readable font */
html[data-readable="on"] body {
  --sans: "Atkinson Hyperlegible", system-ui, sans-serif;
  letter-spacing: 0.03em;
  word-spacing: 0.12em;
  line-height: 1.8;
}

html[data-links="underline"] a {
  text-decoration: underline;
}

html[data-cursor="big"],
html[data-cursor="big"] * {
  cursor:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path d='M4 2l15 9.5-6.6 1.5 3.8 7-2.9 1.6-3.8-7.1L4 19z' fill='%23000' stroke='%23fff' stroke-width='1.4' stroke-linejoin='round'/></svg>")
    8 4,
    auto;
}
html[data-cursor="big"]
  :is(a, button, label, summary, select, [role="button"], input[type="checkbox"], input[type="radio"]) {
  cursor:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path d='M4 2l15 9.5-6.6 1.5 3.8 7-2.9 1.6-3.8-7.1L4 19z' fill='%23ffd400' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'/></svg>")
    8 4,
    pointer;
}
html[data-cursor="big"] :is(input:not([type="checkbox"], [type="radio"], [type="color"]), textarea) {
  cursor: text;
}

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
  /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
  animation-duration: 0.01ms !important;
  /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
  animation-iteration-count: 1 !important;
  /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
  transition-duration: 0.01ms !important;
  /* biome-ignore lint/complexity/noImportantStyles: reduced motion must beat every component transition */
  scroll-behavior: auto !important;
}

.reading-guide {
  position: fixed;
  inset: 0 0 auto;
  height: 2.75rem;
  transform: translateY(calc(var(--guide-y, 0px) - 50%));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-block: 2px solid var(--accent);
  pointer-events: none;
  z-index: 1000;
}

/* Panel */
.a11y-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.a11y-open:hover {
  color: var(--ink);
  background: var(--card);
}
.a11y-open svg {
  width: 1.15em;
  height: 1.15em;
}
.a11y fieldset {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.a11y legend {
  padding: 0;
  margin-bottom: 8px;
  font-weight: 600;
}
.a11y-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.a11y-sizes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 2.25rem;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.a11y-sizes label:has(:checked) {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  font-weight: 600;
}
.a11y-sizes input {
  margin: 0;
  accent-color: var(--app-accent);
}
.a11y-opt {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.a11y-opt label {
  cursor: pointer;
}
.a11y-hint {
  grid-column: 2;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.a11y-opt input {
  appearance: none;
  position: relative;
  width: 2.5rem;
  height: 1.5rem;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  cursor: pointer;
  transition: background var(--dur-fast);
}
.a11y-opt input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.5rem - 6px);
  height: calc(1.5rem - 6px);
  border-radius: 50%;
  background: var(--card);
  transition: transform var(--dur-fast);
}
.a11y-opt input:checked {
  background: var(--app-accent);
}
.a11y-opt input:checked::before {
  transform: translateX(1rem);
  background: var(--accent-ink);
}

html:not([lang="pt-BR"]) .a11y-libras {
  display: none;
}
.dlg .a11y-more {
  margin: 20px 0 0;
  text-align: center;
}
/* Desktop closes with the corner X; phones keep the full-width Close button within thumb reach */
.dlg-x {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.dlg-x:hover {
  background: var(--line);
}
.dlg-x svg {
  width: 22px;
  height: 22px;
}
.a11y h2 {
  padding-right: 48px;
}
@media (min-width: 721px) {
  .a11y .dlg-close {
    display: none;
  }
  .a11y .dlg-actions {
    justify-content: center;
  }
}
@media (max-width: 720px) {
  .dlg-x {
    display: none;
  }
}
