:root {
  --ink: #2a2118;
  --muted: #5c5146;
  --paper: #faf6f0;
  --card: #fffdf9;
  --accent: #b13b2e;
  --accent-strong: #952f24;
  --accent-ink: #fffdf9;
  --line: #e4d8c8;
  /* Form field edges: at least 3:1 against paper and card (WCAG 1.4.11). */
  --field-border: #8a7a68;
  --focus: #1f6f8b;
  --fallback-bg: #f3e6c8;
  --selected-bg: #fbeee4;
}

/* Warm dark palette, used when the reader's system prefers dark. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f3e9dc;
    --muted: #c9baa8;
    --paper: #1c1612;
    --card: #251d17;
    --accent: #f08573;
    --accent-strong: #e56f5c;
    --accent-ink: #1c1612;
    --line: #3e3229;
    --field-border: #8f7d6a;
    --focus: #5db7d5;
    --fallback-bg: #3a2c1b;
    --selected-bg: #35241c;
  }
}

[hidden] {
  display: none !important;
}

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

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

main {
  width: min(50rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
}

.brand {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

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

.tagline {
  margin: -1rem 0 1.5rem;
  font-size: 1.05rem;
  font-style: italic;
  color: var(--muted);
}

.site-footer {
  width: min(50rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 0;
}

.site-footer p + p {
  margin-top: 0.4rem;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.8rem, 5vw, 2.35rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 2rem;
  color: var(--muted);
}

form {
  display: grid;
  gap: 0.6rem;
  padding: 1.4rem 1.4rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 1px 0 rgba(42, 33, 24, 0.04);
}

label {
  font-weight: 600;
}

input[type="date"],
input[type="text"],
select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--field-border);
  border-radius: 0.6rem;
}

input[type="date"]:focus,
input[type="text"]:focus,
select:focus,
a:focus-visible,
button:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button {
  margin-top: 0.4rem;
  justify-self: start;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 650;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  min-height: 2.75rem;
}

button:hover {
  background: var(--accent-strong);
}

/* A same-origin link that looks like the primary button, for pages with no form. */
a.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.4rem;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 650;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  text-decoration: none;
  min-height: 2.75rem;
}

a.button-link:hover {
  color: var(--accent-ink);
  background: var(--accent-strong);
}

.result {
  min-height: 1.5em;
  margin: 1.5rem 0 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.result:empty {
  margin: 0;
}

.fallback {
  margin: 0 0 1.5rem;
  padding: 0.9rem 1rem;
  background: var(--fallback-bg);
  border-radius: 0.75rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#milestones {
  margin: 2.25rem 0 0;
}

#milestones[hidden] {
  display: none;
}

#milestones h2 {
  margin: 0 0 0.85rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 1px 0 rgba(42, 33, 24, 0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

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

th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--card);
  position: sticky;
  top: 0;
}

tr.milestone-past {
  color: var(--muted);
}

tr.milestone-today {
  background: var(--fallback-bg);
  font-weight: 650;
}

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

tr.milestone-selected {
  background: var(--selected-bg);
}

tr.milestone-selected td:first-child {
  box-shadow: inset 4px 0 0 var(--accent);
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}

.note {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.note:empty {
  margin: 0;
}

#share {
  margin: 2.25rem 0 0;
}

#share h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

#share > p:first-of-type {
  margin: 0 0 1rem;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 0.4rem;
  margin: 1rem 0 0;
}

.field button {
  margin-top: 0.2rem;
}

.share-card {
  display: block;
  width: 100%;
  height: auto;
  margin: 1rem 0 0;
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.75rem 0 0;
}

.actions[hidden] {
  display: none;
}

.actions button {
  margin-top: 0;
}

.button-quiet {
  margin-top: 0;
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
  min-height: 2.25rem;
  white-space: nowrap;
  color: var(--accent);
  background: transparent;
  border: 1px solid currentColor;
}

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

.surprise h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.surprise > p:first-of-type {
  margin: 0 0 1rem;
  color: var(--muted);
}

.surprise h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
}

.ideas {
  margin: 0;
  padding-left: 1.25rem;
}

.ideas li + li {
  margin-top: 0.35rem;
}

.button-quiet:hover {
  color: var(--accent-ink);
  background: var(--accent);
}

/* Keep a row clear of the sticky header when a link jumps to it. */
tr[id] {
  scroll-margin-top: 3rem;
}

tr:target td {
  background: var(--selected-bg);
}

/* Generated milestone pages. */
main > section,
main > nav {
  margin: 2.25rem 0 0;
}

main > section h2,
main > nav h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.nearby {
  margin: 0;
  padding-left: 1.25rem;
}

.nearby li + li {
  margin-top: 0.35rem;
}

/* Famous kilodays page. */
.famous-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.famous-row {
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.famous-row + .famous-row {
  margin-top: 0.75rem;
}

.famous-row p {
  margin: 0;
}

.famous-date {
  font-weight: 650;
}

.famous-line {
  margin-top: 0.2rem;
}

.famous-tags {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.famous-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin-top: 0.6rem;
}

a.button-quiet {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  text-decoration: none;
}

@media (max-width: 36rem) {
  body {
    font-size: 1.0625rem;
  }

  main {
    width: calc(100% - 2rem);
    padding: 2rem 0 3rem;
  }

  .site-footer {
    width: calc(100% - 2rem);
  }

  form {
    padding: 1.1rem;
  }

  form button {
    justify-self: stretch;
  }

  a.button-link {
    display: flex;
  }

  .result {
    font-size: 1.1rem;
  }

  table {
    font-size: 0.92rem;
  }

  th,
  td {
    padding: 0.55rem 0.6rem;
  }

  .actions button {
    flex: 1 1 auto;
  }
}
