/* Light theme. Other themes override these colors under :root[data-theme="..."] (set by js/theme.js). */
:root {
  color-scheme: light;
  --bg: #fdf8f3;
  --card: #ffffff;
  --ink: #2d2a32;
  --muted: #6f6a75;
  --accent: #e07a5f;
  --accent-hover: #c9654b;
  --accent-ink: #b5523a;
  --accent-soft: #fbe3da;
  --on-accent: #ffffff;
  --line: #ece4dc;
  --error: #b00020;
  --backdrop: rgba(45, 42, 50, 0.45);
  --radius: 14px;
  --shadow: 0 1px 3px rgba(45, 42, 50, 0.08), 0 4px 14px rgba(45, 42, 50, 0.05);
  --dialog-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1a1f;
  --card: #27242c;
  --ink: #ece7ef;
  --muted: #a39cab;
  --accent: #e8876c;
  --accent-hover: #f29b82;
  --accent-ink: #f0a58f;
  --accent-soft: #3e2c28;
  --on-accent: #1c1a1f;
  --line: #3a3541;
  --error: #ff6b81;
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  --dialog-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent-ink);
}

.site-header {
  padding: 2rem 1.25rem 1rem;
  text-align: center;
}

.site-header h1,
.site-name {
  margin: 0;
  font-weight: 700;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

/* ---- Tabs and share buttons ---- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 0 max(1.25rem, calc((100% - 1200px) / 2 + 1.25rem));
  border-bottom: 1px solid var(--line);
}

.tab-list {
  display: flex;
  gap: 0.25rem;
}

.tab {
  margin-bottom: -1px;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 0.45rem;
}

.action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.action.primary {
  min-width: 7.5rem;
  justify-content: center;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.action.primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

/* ---- Layout ---- */

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
}

/* ---- Controls ---- */

.controls {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.4rem 1.1rem;
}

.week-card {
  margin-bottom: 1.5rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(0, 320px);
  justify-content: center;
  align-items: start;
  gap: 1.25rem;
}

.settings-card .card-title {
  margin: 0.8rem 0 0;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.controls fieldset {
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 0.6rem 0 0.8rem;
}

.controls fieldset:last-child {
  border-bottom: 0;
}

.controls legend {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0;
  margin-bottom: 0.3rem;
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.15rem 0.9rem 0.15rem 0;
  cursor: pointer;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}

.week-reset {
  margin-left: 0.4rem;
  padding: 0.05rem 0.6rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.week-reset:hover {
  background: var(--accent);
  color: var(--on-accent);
}

input[type="radio"],
input[type="checkbox"],
input[type="range"] {
  accent-color: var(--accent);
}

.week-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.week-row input {
  flex: 1;
}

.step {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}

.step:hover {
  background: var(--accent);
  color: var(--on-accent);
}

#week-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.35rem 0 0;
  font-size: 1.1rem;
  font-weight: 600;
}

#week-months {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

#week-number {
  width: 3.6em;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  text-align: center;
}

.settings-card .field,
.settings-card .stack label {
  display: flex;
}

.settings-card .field {
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  margin: 0.4rem 0;
}

.settings-card input[type="number"],
.settings-card input[type="text"],
.settings-card input[type="date"],
.settings-card select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-card input[type="number"],
.settings-card input[type="date"] {
  max-width: 14rem;
}

.shared-note {
  max-width: calc(680px + 320px + 1.25rem);
  margin: 0 auto 1rem;
  padding: 0.6rem 1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  font-size: 0.92rem;
}

.hint {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- Results ---- */

.results .age {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 1rem 1.25rem;
}

.report-grid > * {
  grid-row: var(--row);
  grid-column: var(--col);
}

/* With one measure, keep the column as wide as in the two-column layout, centered. */
.results.single-column {
  max-width: calc((1200px - 2.5rem - 1.25rem) / 2);
  margin: 0 auto;
}

.intro {
  display: inline-block;
  margin: 0.25rem 0 0;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 1.2rem;
  font-weight: 600;
}

.section-phrase {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.comparison {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem 1rem;
}

.card-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.comparison h3,
.comparison h4 {
  margin: 0.2rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.comparison h4 {
  margin-top: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.comparison ul {
  margin: 0;
  padding-left: 1.1rem;
}

.comparison li {
  margin: 0.2rem 0;
}

.comparison li.with-sprite {
  list-style: none;
  margin-left: -1.1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.with-sprite img {
  width: 64px;
  height: 64px;
  margin: -12px -6px -12px -8px; /* default sprites have wide transparent padding */
  image-rendering: pixelated;
  flex: none;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.item-link {
  color: inherit;
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 3px;
}

.show-more {
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.item-link:hover {
  color: var(--accent);
}

.comparison li.more {
  list-style: none;
}

.show-more {
  color: var(--muted);
  text-decoration: none;
}

.show-more:hover {
  color: var(--accent);
}

.note,
.loading {
  color: var(--muted);
}

.error {
  color: var(--error);
}

/* ---- Detail dialog ---- */

.detail {
  width: min(640px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: var(--dialog-shadow);
}

.detail::backdrop {
  background: var(--backdrop);
}

.detail .close {
  position: sticky;
  top: 0;
  float: right;
  border: 0;
  background: none;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.detail h2 {
  margin: 0;
}

.subtitle {
  margin: 0.1rem 0 0.4rem;
  color: var(--muted);
}

.facts {
  margin: 0 0 0.75rem;
}

.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.gallery figure {
  margin: 0;
  text-align: center;
  max-width: 180px;
}

.gallery img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  image-rendering: pixelated;
}

.gallery figure:last-child img {
  image-rendering: auto;
}

.gallery figcaption {
  font-size: 0.8rem;
  color: var(--muted);
}

blockquote {
  margin: 0.5rem 0;
  padding: 0.5rem 0.9rem;
  border-left: 3px solid var(--accent);
  background: var(--bg);
  border-radius: 0 8px 8px 0;
}

blockquote p {
  margin: 0;
}

blockquote footer {
  font-size: 0.8rem;
  color: var(--muted);
}

.all-entries summary {
  cursor: pointer;
  margin: 0.5rem 0;
  color: var(--muted);
}

.spell-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 1rem;
  margin: 0.5rem 0 1rem;
}

.spell-facts dt {
  font-weight: 600;
}

.spell-facts dd {
  margin: 0;
}

.spell-text {
  white-space: pre-wrap;
}

.attribution {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- Sources page ---- */

.site-name a {
  color: inherit;
  text-decoration: none;
}

.prose {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
}

.prose h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  margin: 0 0 0.5rem;
}

.prose h2 {
  margin: 2rem 0 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.prose code {
  font-size: 0.9em;
  background: var(--accent-soft);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

.table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.prose th {
  background: var(--accent-soft);
}

.prose tr:last-child td {
  border-bottom: 0;
}

/* ---- Footer ---- */

.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

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

  .report-grid > * {
    grid-row: auto;
    grid-column: auto;
  }

  .report-grid .intro-cell:not(:first-child) {
    margin-top: 1.25rem;
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
