/* Design tokens — the per-tool theme is these variables; leave the rest alone. */
:root {
  color-scheme: light dark; /* native dark form controls + canvas in Safari/Chrome */
  --color-bg: #ffffff;
  --color-text: #1a1a2e;
  --color-muted: #5c6470;
  --color-accent: #2563eb;   /* brand blue: readout, links, focus (5.2:1 on white) */
  --color-surface: #f4f6f8;
  --color-border: #d8dee5;        /* decorative: gridlines, panel edge */
  --color-input-border: #848b94;  /* form-control boundary: ≥3:1 non-text (WCAG 1.4.11) */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --space: 1rem;
  --radius: 8px;
  --max-width: 44rem;
}

/* Dark mode: same tokens, dark values — follows the system setting. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #14161a;
    --color-text: #e6e8eb;
    --color-muted: #a2abb5;
    --color-accent: #7cacf8;  /* 7.9:1 on dark bg */
    --color-surface: #1e2126;
    --color-border: #3a4149;
    --color-input-border: #656d76;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space);
}

h1 { margin: 0.5rem 0 0; }
.tagline { color: var(--color-muted); margin-top: 0.25rem; }
a { color: var(--color-accent); } /* token-driven so links adapt in dark mode */

#tool {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space);
  margin: var(--space) 0;
}

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }

input, select {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius);
  max-width: 100%;
}

:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* Calculator form */
fieldset.species {
  border: none;
  margin: 0;
  padding: 0;
}
fieldset.species legend { font-weight: 600; padding: 0; }
fieldset.species label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 1.25rem 0 0;
  padding: 0.6rem 0.25rem; /* ~44px tap target for the primary Dog/Cat control */
}
.fields { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.fields > div { min-width: 8rem; }
#years { width: 8rem; }

#result { min-height: 8.5rem; padding: 0.25rem 0; } /* tallest state: 3-line dog result */
#result p { margin: 0.25rem 0; }
.result-num { font-size: 1.5rem; }
.result-num strong { font-size: 2.25rem; color: var(--color-accent); }
.result-alt, .result-hint { color: var(--color-muted); }

/* Share + meme card (js/share.js) */
#share { margin-top: var(--space); border-top: 1px solid var(--color-border); padding-top: 0.75rem; }
.share-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
button {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-accent);
  cursor: pointer;
}
button:disabled { color: var(--color-muted); cursor: not-allowed; }
/* summary styled as the primary CTA; native disclosure semantics kept */
#card-builder summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-bg);
  margin: 0.25rem 0 0.5rem;
}
#card-builder summary::-webkit-details-marker { display: none; }
#card-builder[open] summary {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-input-border);
}
#card-canvas { display: block; max-width: min(100%, 24rem); height: auto; border-radius: var(--radius); margin: 0.5rem 0; }
#card-name { width: 12rem; }
.shared-note {
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
}

/* Charts */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: var(--space) 0; }
caption { text-align: left; color: var(--color-muted); font-size: 0.875rem; padding-bottom: 0.5rem; }
th, td { border: 1px solid var(--color-border); padding: 0.35rem 0.6rem; text-align: right; }
thead th { background: var(--color-surface); text-align: right; }
tbody th { font-weight: 600; background: var(--color-surface); }

footer { color: var(--color-muted); font-size: 0.875rem; }
footer a { color: inherit; }
