:root {
  --paper: #f7f3ea;
  --paper-2: #efe9dc;
  --ink: #1f1b16;
  --ink-2: #463f35;
  --muted: #675e4f;
  --rule: #d9cfbd;
  --line: #e3dbca;
  --accent: #9a3a22;
  --on-accent: #fff8ee;
  --mark: #f2dca4;
  --focus: #9a3a22;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 42rem;
  --gutter: 1.5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16140f;
    --paper-2: #1f1c16;
    --ink: #ece5d6;
    --ink-2: #d2c9b7;
    --muted: #a59c89;
    --rule: #3a352b;
    --line: #29251e;
    --accent: #e2906f;
    --on-accent: #1a120d;
    --mark: #5b4a20;
    --focus: #e2906f;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #16140f;
  --paper-2: #1f1c16;
  --ink: #ece5d6;
  --ink-2: #d2c9b7;
  --muted: #a59c89;
  --rule: #3a352b;
  --line: #29251e;
  --accent: #e2906f;
  --on-accent: #1a120d;
  --mark: #5b4a20;
  --focus: #e2906f;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

main { flex: 1; outline: none; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); }

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

[hidden] { display: none !important; }

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

.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font: 600 0.875rem/1.2 var(--sans);
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* Masthead */

.masthead { padding: 1.5rem var(--gutter) 0; }

.masthead-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  margin-right: auto;
  line-height: 1;
  padding: 0.5rem 0;
}

.nav { display: flex; gap: 0.25rem; }

.nav a,
.theme-toggle {
  font: 600 0.75rem/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 0.75rem 0.65rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.theme-toggle {
  gap: 0.45rem;
  background: none;
  border-top: 0; border-left: 0; border-right: 0;
  cursor: pointer;
  margin-left: 0.25rem;
}
.theme-toggle:hover { color: var(--ink); }

/* Shared type */

.view {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) 4rem;
}

.kicker,
.section-label,
.field-label,
legend,
.dateline,
.stat dt {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.kicker { color: var(--accent); margin: 2.75rem 0 0.9rem; }

.page-title {
  font-weight: 500;
  font-size: clamp(2.1rem, 1.6rem + 2vw, 2.9rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 3rem 0 1rem;
  outline: none;
}

.lede {
  font-size: 1.1875rem;
  color: var(--ink-2);
  margin: 0 0 1.5rem;
}

.prose p { margin: 0 0 1em; }
.prose h2 {
  scroll-margin-top: 1.5rem;
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1.25;
  margin: 2.5rem 0 0.6rem;
}

.status-line {
  font: 0.875rem/1.5 var(--sans);
  color: var(--ink-2);
  min-height: 1.5em;
  margin: 0.75rem 0 0;
}

.hint {
  font: 0.8125rem/1.5 var(--sans);
  color: var(--muted);
  margin: 0.4rem 0 0;
}

/* Buttons and fields */

.btn {
  font: 600 0.875rem/1.2 var(--sans);
  letter-spacing: 0.01em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0.7rem 1.1rem;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--paper-2); color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-small { padding: 0.5rem 0.9rem; font-size: 0.8125rem; }
.btn-quiet { border-color: var(--rule); color: var(--ink-2); }
.btn-danger:hover { border-color: var(--accent); color: var(--accent); background: transparent; }

.text-button {
  font: 600 0.8125rem/1 var(--sans);
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0.75rem 0;
  min-height: 44px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
.text-button:hover { color: var(--accent); }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid;
  place-items: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--rule); }
.icon-btn:disabled { color: var(--rule); cursor: default; border-color: transparent; }

.field {
  font: 1rem/1.4 var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--muted);
  border-radius: 2px;
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  width: 100%;
}
textarea.field { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.5; resize: vertical; }
.field-time { width: auto; }

.field-label { display: block; margin-bottom: 0.5rem; }
.field-label.inline { display: inline; margin: 0; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.check, .choice {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.check input, .choice input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent); }

/* Today */

.dateline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.75rem;
  padding: 0.7rem 0 0.6rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.dateline #issue { color: var(--ink); }

.intro {
  margin: 1.75rem 0 0;
  padding: 0.9rem 1.1rem 0.4rem;
  background: var(--paper-2);
  border-left: 3px solid var(--accent);
}
.intro p { margin: 0; font-size: 1.0625rem; color: var(--ink-2); }

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 1.5rem 0 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  font: 0.9375rem/1.4 var(--sans);
}
.notice p { margin: 0; flex: 1 1 16rem; }

.question {
  font-weight: 500;
  font-size: clamp(2rem, 1.3rem + 3vw, 3.3rem);
  line-height: 1.12;
  letter-spacing: -0.018em;
  margin: 0 0 2.5rem;
  text-wrap: balance;
  outline: none;
  min-height: 1.12em;
}

.writer {
  --lh: 2rem;
  border-left: 3px solid transparent;
  margin-left: -1.2rem;
  padding-left: calc(1.2rem - 3px);
  transition: border-color 0.2s;
}
.writer:focus-within { border-left-color: var(--accent); }

.answer {
  display: block;
  width: 100%;
  min-height: calc(var(--lh, 2rem) * 7);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  resize: none;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: var(--lh, 2rem);
  color: var(--ink);
  background-color: transparent;
  background-image: linear-gradient(to bottom, transparent calc(var(--lh, 2rem) - 1px), var(--line) calc(var(--lh, 2rem) - 1px));
  background-size: 100% var(--lh, 2rem);
  background-attachment: local;
  caret-color: var(--accent);
}
.answer:focus { outline: none; }
.answer::placeholder { color: var(--muted); font-style: italic; opacity: 1; }

.writer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem 1.5rem;
  margin-top: 0.75rem;
  font: 0.8125rem/1.4 var(--sans);
  color: var(--muted);
}
.writer-counts { margin: 0; }
.writer-counts .sep { margin: 0 0.35rem; }

.timer { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.timer .check { min-height: 44px; }
.timer-display { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.timer-display.is-up { color: var(--accent); font-weight: 600; }

.writer-actions { margin-top: 1.25rem; }

.countdown {
  margin: 2.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font: 0.8125rem/1.4 var(--sans);
  color: var(--muted);
  text-align: center;
}
.countdown-time { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* Done */

.done {
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 3px double var(--ink);
}

.done-title {
  font-style: italic;
  font-weight: 500;
  font-size: 2rem;
  line-height: 1.1;
  margin: 0;
  outline: none;
}
.done-note { margin: 0.4rem 0 0; color: var(--ink-2); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 1.75rem 0 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.stat { padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; }
.stat + .stat { border-left: 1px solid var(--rule); }
.stat:first-child { padding-left: 0; }
.stat dt { margin-bottom: 0.2rem; }
.stat dd { margin: auto 0 0; color: var(--ink-2); font-size: 1rem; }
.stat .num {
  font-size: 2.25rem;
  line-height: 1.1;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: lining-nums;
}

.section-label { margin: 2.5rem 0 1rem; }

.year-ago-meta { font: 0.8125rem/1.4 var(--sans); color: var(--muted); margin: -0.5rem 0 0.75rem; }
.year-ago-text {
  border-left: 1px solid var(--ink);
  padding-left: 1.1rem;
  color: var(--ink-2);
  font-size: 1.0625rem;
}
.year-ago-text p { margin: 0 0 0.8em; white-space: pre-wrap; }
.year-ago-more { font: 0.875rem/1.5 var(--sans); margin: 0.5rem 0 0; }

.share .status-line:empty { margin: 0; }

.share-row,
.card-maker summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.share-copy { display: block; min-width: 0; }
.share-name { display: block; margin: 0; font-weight: 600; font-size: 1.0625rem; line-height: 1.3; }
.share-desc { display: block; margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.45; }
.share-preview { font-family: var(--sans); font-size: 0.8125rem; color: var(--ink-2); overflow-wrap: anywhere; }

.card-maker { border-bottom: 1px solid var(--rule); }
.card-maker summary { list-style: none; cursor: pointer; }
.card-maker summary::-webkit-details-marker { display: none; }
.card-maker summary:hover .summary-btn { background: var(--paper-2); }
.card-maker[open] summary .summary-btn { background: var(--ink); color: var(--paper); }

.card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1.75rem;
  padding: 0.5rem 0 1.5rem;
}
.card-options fieldset { border: 0; margin: 0 0 1.25rem; padding: 0; min-width: 0; }
.card-options legend { padding: 0; margin-bottom: 0.4rem; }
.card-options .choice { display: flex; min-height: 44px; font-size: 1rem; line-height: 1.3; }
.excerpt-field { margin: 0 0 1.25rem; }

.card-preview { min-width: 0; }
.card-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 22rem;
  margin: 0 auto;
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 var(--rule), 0 12px 28px -18px rgba(31, 27, 22, 0.45);
}
.card-canvas.is-wide { max-width: 100%; }
.card-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin-top: 1rem; }

/* Archive */

.view-archive { max-width: calc(64rem + 2 * var(--gutter)); }

.archive-layout {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "calendar reader" "search reader";
  column-gap: 3.5rem;
  align-items: start;
  margin-top: 2rem;
}
.archive-layout .calendar { grid-area: calendar; }
.archive-layout .reader { grid-area: reader; }
.archive-layout .search { grid-area: search; }

.calendar { border-top: 1px solid var(--ink); padding-top: 0.5rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-title { font-weight: 500; font-size: 1.25rem; margin: 0; }

.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 0.5rem; }
.cal-table th {
  font: 600 0.6875rem/1 var(--sans);
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 0.5rem 0;
}
.cal-table td { padding: 1px; text-align: center; }

.day {
  position: relative;
  width: 100%;
  min-height: 44px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font: 500 0.9375rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: none;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
}
.day:hover { border-color: var(--rule); }
.day:disabled { color: var(--muted); opacity: 0.55; cursor: default; }
.day:disabled:hover { border-color: transparent; }
.day::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 6px; height: 6px;
  margin-left: -3px;
  border-radius: 50%;
}
.day.is-done::after { background: var(--ink); }
.day.is-late::after { border: 1.5px solid var(--muted); }
.day.is-today { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.day[aria-current="date"] { }
.day.is-selected { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.day.is-selected.is-done::after { background: var(--paper); }
.day.is-selected.is-late::after { border-color: var(--paper); }

.legend {
  display: flex;
  gap: 1.25rem;
  font: 0.8125rem/1.4 var(--sans);
  color: var(--muted);
  margin: 0.75rem 0 0;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.45rem; }
.mark { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.mark-done { background: var(--ink); }
.mark-late { border: 1.5px solid var(--muted); }

.search { margin-top: 2.5rem; }
.results { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.results li { border-top: 1px solid var(--rule); }
.results a {
  display: block;
  padding: 0.75rem 0;
  text-decoration: none;
  min-height: 44px;
}
.results a:hover .result-q { color: var(--accent); }
.result-date { display: block; font: 600 0.6875rem/1.4 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.result-q { display: block; font-weight: 500; line-height: 1.3; margin: 0.15rem 0; }
.result-snippet { display: block; font-size: 0.9375rem; color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; padding: 0 0.1em; }

.reader { min-width: 0; border-top: 1px solid var(--ink); padding-top: 1.1rem; }
.reader .dateline-small { font: 600 0.75rem/1.4 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0; }
.reader .kicker { margin: 1.5rem 0 0.6rem; }
.reader-question {
  font-weight: 500;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0 0 1.25rem;
  text-wrap: balance;
  outline: none;
}
.reader-status { font: 0.875rem/1.5 var(--sans); color: var(--muted); margin: 0 0 1.25rem; }
.reader-status .late-tag {
  display: inline-block;
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--muted);
  border-radius: 2px;
  padding: 0.15rem 0.4rem;
  margin-right: 0.4rem;
}
.reader-text p { margin: 0 0 1em; white-space: pre-wrap; overflow-wrap: break-word; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.reader-empty { color: var(--ink-2); }
.reader .writer { margin-top: 0.5rem; }

/* About */

.about { margin-top: 0; }
.about .button-row { margin-top: 1rem; }
.reminder-row { gap: 0.75rem 1rem; }

/* Footer */

.site-footer { padding: 0 var(--gutter) 2.5rem; }
.footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  font: 0.8125rem/1.5 var(--sans);
  color: var(--muted);
}
.footer-inner p { margin: 0; }
.footer-inner a { color: var(--ink-2); }
.footer-inner a:hover { color: var(--accent); }

/* Small screens */

@media (max-width: 860px) {
  .archive-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "calendar" "reader" "search"; row-gap: 2.5rem; }
  .search { margin-top: 0; }
  .calendar { max-width: 26rem; }
  .card-body { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  :root { --gutter: 1rem; }
  body { font-size: 1rem; }
  .masthead { padding-top: 0.75rem; }
  .masthead-inner { gap: 0 0.5rem; }
  .wordmark { font-size: 1.35rem; }
  .nav { order: 3; width: 100%; margin-left: -0.65rem; }
  .theme-toggle { margin-left: 0; }
  .dateline { margin-top: 0.75rem; }
  .kicker { margin-top: 2rem; }
  .question { margin-bottom: 2rem; }
  .writer { margin-left: -0.75rem; padding-left: calc(0.75rem - 3px); }
  .answer { font-size: 1.125rem; }
  .field, textarea.field { font-size: 16px; }
  .stat { padding: 0.75rem 0.6rem 0.85rem; }
  .stat .num { font-size: 1.75rem; }
  .stat dt { font-size: 0.625rem; letter-spacing: 0.1em; }
  .share-row, .card-maker summary { flex-direction: column; align-items: flex-start; }
  .share-row .btn, .card-maker summary .btn { width: 100%; }
  .card-actions .btn { flex: 1 1 auto; }
  .btn { white-space: normal; text-align: center; }
  .page-title { margin-top: 2rem; }
  .legend { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
