/*
 * EXOS design system, applied. See docs/design-system.md.
 *
 * Calm, information-dense, one anchor colour used sparingly. No gradients, no shadows, no
 * glassmorphism, no giant rounded rectangles. Self-hosted fonts only; nothing here loads from a
 * third party.
 */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-400-77bc026706571f32f04889dae5e7e5b2.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-500-f7016cd446d2006a17eba99535d1b04e.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-600-196e3cbc5fee6ac2587c6bb72eac7f6b.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/inter-600-2ede57db1a3a5f41f40467e7a43a1dd4.woff2") format("woff2");
}

:root {
  --colour-primary: #184d2f;
  --colour-background: #f5f0ea;
  --colour-surface: #ffffff;
  --colour-text: #1c1a17;
  --colour-muted: #6b6459;
  --colour-border: #ded6c9;
  --colour-danger: #7a3b2e;
  --colour-heatmap-0: #e7e1d6;
  --colour-heatmap-1: #a9c4b3;
  --colour-heatmap-2: #4f7d63;
  --colour-heatmap-3: var(--colour-primary);
  --radius: 6px;
  --gutter: 16px;

  /* Spacing scale, base 4px (docs/design-system.md). Every margin, padding and gap uses one of
     these, or an em value that tracks its own font size. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  /* Control heights: default for anything deliberately tapped, compact for dense rows. */
  --control-h: 44px;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-brand: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--colour-background);
  color: var(--colour-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--colour-primary);
}

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

h1,
h2,
h3 {
  font-weight: 600;
  margin: 0 0 0.5em;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

h3 {
  font-size: 15px;
  line-height: 1.3;
}

/* Type scale (docs/design-system.md). A page title and a subsection heading are the two roles a
   template should reach for; .section-label stays for the small uppercase anchor labels. */
.page-title {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--space-2);
}

.subsection-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin: var(--space-6) 0 var(--space-2);
}

p {
  margin: 0 0 1em;
}

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

/* The page starts one step below the header rule, so the first label is not flush against it. */
main.container {
  padding-top: var(--space-6);
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--colour-border);
  background: var(--colour-background);
}

.site-header__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-3) var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--colour-text);
  text-decoration: none;
  margin-right: auto;
}

.nav {
  display: flex;
  gap: var(--space-4);
}

.nav__link {
  position: relative;
  color: var(--colour-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
}

.nav__link:hover {
  color: var(--colour-text);
}

.nav__link--active {
  color: var(--colour-primary);
  border-bottom-color: var(--colour-primary);
}

.site-header__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  color: var(--colour-muted);
}

/* Buttons and links styled as buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  border: 1px solid var(--colour-border);
  background: var(--colour-surface);
  color: var(--colour-text);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.button:hover {
  border-color: var(--colour-primary);
}

.button--primary {
  background: var(--colour-primary);
  border-color: var(--colour-primary);
  color: var(--colour-background);
}

.button--primary:hover {
  opacity: 0.92;
}

.button--danger {
  color: var(--colour-danger);
  border-color: var(--colour-danger);
  background: var(--colour-surface);
}

.link-button {
  position: relative;
  background: none;
  border: none;
  padding: 2px 0;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--colour-muted);
  text-decoration: underline;
  cursor: pointer;
}

.link-button:hover {
  color: var(--colour-text);
}

/* Quiet text controls stay quiet: no border, no fill. The invisible 44px zone is the same
   technique as .tick and .timeline__mark, so a thumb can land on them without the row growing.
   Only inside a flex row or a bar, where neighbours sit beside rather than above: a zone on a
   link that stands under another link would cover that link's lower half. */
.record-row__head .link-button::after,
.site-header .link-button::after,
.record-row__head a.tag::after,
.calendar-nav a::after,
.nav__link::after,
.tab-bar__link::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 44px);
  height: 44px;
  transform: translate(-50%, -50%);
}

/* A quiet link standing on its own line under a title (Write what made it good, Show archived,
   Remove a picture) gets a real box rather than an invisible zone, so it cannot reach into the
   line above. */
p > .link-button:only-child {
  display: inline-block;
  padding: var(--space-2) 0;
}

/* Forms */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  max-width: 420px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--colour-muted);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
  color: var(--colour-text);
}

.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select {
  min-height: var(--control-h);
}

.field textarea {
  resize: vertical;
  min-height: 64px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.form-error {
  color: var(--colour-danger);
  font-size: 13px;
  margin: var(--space-2) 0 0;
}

.form-note {
  font-size: 13px;
  color: var(--colour-muted);
  margin: -6px 0 var(--space-4);
}

/* Detail pages stack forms and labels directly; give a following label or form one step of air
   so a 44px button never touches the next block. */
form + .section-label,
p + .section-label {
  margin-top: var(--space-6);
}

form + form {
  margin-top: var(--space-2);
}

form + p {
  margin-top: var(--space-4);
}

/* Section labels, per the design system: the anchor colour, sparingly */

.section-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 600;
  color: var(--colour-primary);
  margin: 0 0 var(--space-3);
}

/* Habit glance: one quiet, informational line about moments -- ADR 0016. */

.habit-glance {
  font-size: 13px;
  color: var(--colour-muted);
  text-decoration: none;
}

.habit-glance:hover {
  color: var(--colour-primary);
}

/* Habit list */

.habit-list {
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: 0;
  border-top: 1px solid var(--colour-border);
}

.habit-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  border-bottom: 1px solid var(--colour-border);
  padding: var(--space-3) 0;
}

.habit-row--archived {
  opacity: 0.6;
}

.habit-row__body {
  flex: 1 1 auto;
  min-width: 0;
}

.habit-row__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.habit-row__name {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  text-decoration: none;
  color: var(--colour-text);
}

.habit-row__name:hover {
  color: var(--colour-primary);
}

.habit-row__meta {
  margin: 2px 0 0;
  color: var(--colour-muted);
  font-size: 13px;
  font-weight: 500;
}

.tag {
  position: relative;
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--colour-muted);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  padding: 2px var(--space-2);
}

/* The today tick box: a plain checkbox, restyled square, filled with the anchor colour when
   done. Reflects state through `aria-checked` rather than a class, so app.js only ever has to
   set one attribute. The visible box stays a modest 24px so the row does not turn clumsy on
   desktop; a ::after pseudo-element enlarges the actual tap target to 44px without affecting
   layout, per WCAG 2.5.8 and the 44px touch guidance. */
.tick {
  position: relative;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--colour-border);
  border-radius: 4px;
  background: var(--colour-background);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tick::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}

.tick[aria-checked="true"] {
  background: var(--colour-primary);
  border-color: var(--colour-primary);
}

.tick__mark {
  display: none;
  width: 10px;
  height: 6px;
  margin-bottom: 2px;
  border-left: 2px solid var(--colour-background);
  border-bottom: 2px solid var(--colour-background);
  transform: rotate(-45deg);
}

.tick[aria-checked="true"] .tick__mark {
  display: block;
}

/* Keeps an archived row's name aligned with the tick column above and below it. */
.tick-spacer {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.habit-stats {
  font-size: 13px;
  color: var(--colour-muted);
  margin: var(--space-3) 0 var(--space-2);
}

.habit-stats strong {
  color: var(--colour-text);
  font-weight: 600;
}

/* Heatmap */

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.heatmap {
  display: inline-flex;
  flex-direction: column;
  gap: var(--space-1);
}

.heatmap__months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 14px;
  gap: 3px;
  font-size: 11px;
  color: var(--colour-muted);
  height: 14px;
  margin-left: 20px;
}

.heatmap__body {
  display: flex;
  gap: 3px;
}

.heatmap__weekday-labels {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 3px;
  font-size: 10px;
  color: var(--colour-muted);
  width: 16px;
  text-align: right;
  padding-right: var(--space-1);
}

.heatmap__week {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 3px;
}

.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--colour-heatmap-0);
  padding: 0;
  border: none;
  display: block;
}

.heatmap-cell[data-clickable="true"] {
  cursor: pointer;
}

/* The per-habit grid's two-tap gate on a coarse (touch) pointer: a first tap selects a cell
   (shown here) and shows its value in the live label; a second tap on the same cell toggles it.
   An outer ring, distinct from the inset ring that marks today, so both can show at once. */
.heatmap-cell--selected {
  box-shadow: 0 0 0 2px var(--colour-primary);
}

.heatmap-cell.level-1 {
  background: var(--colour-heatmap-1);
}

.heatmap-cell.level-2 {
  background: var(--colour-heatmap-2);
}

.heatmap-cell.level-3 {
  background: var(--colour-heatmap-3);
}

.heatmap-cell--future {
  background: transparent;
  border: 1px solid var(--colour-border);
}

.heatmap-cell--today {
  /* An inset ring rather than an outline, so it does not cancel the focus outline above. */
  box-shadow: inset 0 0 0 1px var(--colour-primary);
}

/* A key under each grid: a few swatches and plain words, quiet and muted. The swatches reuse the
   grid's own level classes so a key cannot drift from the shading. */
.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin: var(--space-2) 0 0;
  font-size: 12px;
  color: var(--colour-muted);
}

.heatmap-legend .heatmap-cell {
  width: 12px;
  height: 12px;
}

/* The live label under each grid: names the date and value of the cell last hovered or
   focused, since `title` never fires on touch. */
.heatmap-live {
  min-height: 1.4em;
  margin: var(--space-2) 0 0;
  font-size: 12px;
  color: var(--colour-muted);
}

/* An inline write error, quiet rather than a browser alert(). A <span> so it can nest inside a
   <p> without invalid markup; display: block makes it still read as its own line. Shares the
   danger tone used elsewhere but never a coloured background. */
.inline-error {
  display: block;
  color: var(--colour-danger);
  font-size: 13px;
  margin: var(--space-2) 0 0;
}

/* Entries table */

.entries-list {
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: 0;
  border-top: 1px solid var(--colour-border);
}

.entries-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--colour-border);
  font-size: 14px;
}

.entries-list__date {
  color: var(--colour-muted);
  min-width: 100px;
}

.entries-list__count {
  font-weight: 600;
  min-width: 24px;
}

.entries-list__note {
  color: var(--colour-text);
}

/* Disclosure */

/* A disclosure straight after the tab bar would draw a second rule under the bar's own. */
.tab-bar + details.disclosure {
  border-top: none;
}

details.disclosure {
  border-top: 1px solid var(--colour-border);
  padding: var(--space-3) 0;
}

details.disclosure > summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--colour-primary);
  list-style: none;
}

details.disclosure > summary::-webkit-details-marker {
  display: none;
}

details.disclosure > summary::before {
  content: "+ ";
}

details.disclosure[open] > summary::before {
  content: "− ";
}

/* Login page */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
}

.login-card {
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  padding: var(--space-8) var(--space-6);
  background: var(--colour-surface);
}

.login-card .wordmark {
  display: block;
  text-align: center;
  margin: 0 0 var(--space-6);
}

.login-message {
  font-size: 13px;
  color: var(--colour-muted);
  margin: 0 0 var(--space-4);
  text-align: center;
}

.login-message--error {
  color: var(--colour-danger);
}

/* Error pages */

.error-page {
  max-width: 480px;
  margin: var(--space-12) auto;
  padding: 0 var(--gutter);
  text-align: center;
}

.error-page__code {
  font-family: var(--font-brand);
  font-size: 48px;
  font-weight: 600;
  color: var(--colour-primary);
  margin: 0;
}

/* Small screens */

@media (max-width: 560px) {
  .site-header__inner {
    padding: var(--space-3) var(--gutter);
  }

  .habit-row__head {
    gap: var(--space-2);
  }

  .login-card .form-actions .button {
    width: 100%;
  }
}

/* Goals and the bucket list, on one page (NOTES.md, "Goals + bucket list") */

.record-list {
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: 0;
  border-top: 1px solid var(--colour-border);
}

.record-row {
  border-bottom: 1px solid var(--colour-border);
  padding: var(--space-4) 0;
}

.record-list--muted .record-row {
  opacity: 0.6;
}

.record-row__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* The title reads as a title, not a link: text colour, no underline, primary on hover. Shared
   by to-do, moment, goal and memory rows. */
.record-row__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--colour-text);
  text-decoration: none;
}

.record-row__title:hover {
  color: var(--colour-primary);
}

.record-row__date {
  color: var(--colour-muted);
  font-size: 13px;
  font-weight: 500;
}

.record-row__description {
  margin: var(--space-2) 0 0;
  color: var(--colour-muted);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The Completed section reads as a plain record, not a score: no select, the reflection sits
   underneath as an ordinary line rather than a quote or a card. */

.record-row__reflection {
  margin: var(--space-2) 0 0;
  color: var(--colour-text);
  font-size: 14px;
}

/* A Memories row's thumbnail (ADR 0018): a small square to the left, row layout otherwise
   unchanged; absent rows (no picture, or attachments off) keep the plain row above. */

.record-row__layout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.record-row__thumbnail {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
}

.record-row__body {
  min-width: 0;
  flex: 1 1 auto;
}

.tag--warn {
  color: var(--colour-danger);
  border-color: var(--colour-danger);
}

/* Choosing "Completed" in the quick select reveals this instead of submitting immediately
   (static/js/app.js#wireStatusSelects), so the date is never recorded without a chance to add
   the one line that goes with it. */

/* The Add disclosure's type choice: plain radios. Whichever form does not match the checked
   radio is hidden by the sibling combinator below, in browsers that support :has(). Elsewhere,
   static/js/app.js#wireAddTypeSwitch is the fallback: it toggles the `hidden` attribute on the
   two forms on the radios' `change` event, so the goal form stays reachable without :has(). The
   rule right after the base `display: none` lets that attribute win over it once :has() is not
   there to settle things; the :has() rules below outrank both regardless of `hidden`. */
.type-switch {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 14px;
}

.type-switch label {
  margin-right: var(--space-1);
}

.type-switch__form--goal {
  display: none;
}

.type-switch__form--goal:not([hidden]) {
  display: block;
}

.type-switch:has(#add-type-goal:checked) ~ .type-switch__form--moment {
  display: none;
}

.type-switch:has(#add-type-goal:checked) ~ .type-switch__form--goal {
  display: block;
}

.disclosure--muted > summary {
  color: var(--colour-muted);
}

.empty-state {
  color: var(--colour-muted);
  font-size: 14px;
  padding: var(--space-3) 0;
}

/* Milestones (docs/adr/0016-moments-timeline.md, docs/adr/0017-milestones-two-tabs.md). Reuses
   .record-list, .record-row, .tag, .disclosure, .empty-state, .type-switch, .field, .button and
   .inline-error from above; only what is new to these pages follows. */

/* The Plans/Memories tab bar under the page heading, styled like the header's own nav: plain
   text, the active tab picked out with the primary green underline. */
.tab-bar {
  display: flex;
  gap: var(--space-4);
  margin: 0 0 var(--space-6);
  border-bottom: 1px solid var(--colour-border);
}

.tab-bar__link {
  position: relative;
  display: inline-block;
  padding: var(--space-2) 0;
  margin-bottom: -1px;
  color: var(--colour-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}

.tab-bar__link:hover {
  color: var(--colour-text);
}

.tab-bar__link--active {
  color: var(--colour-primary);
  border-bottom-color: var(--colour-primary);
}

/* A muted line under a row's title: a moment's place/country, a goal's linked habits and their
   streaks. Not truncated like .record-row__description — a habit list can run longer. */
.record-row__meta {
  margin: var(--space-2) 0 0;
  color: var(--colour-muted);
  font-size: 13px;
  font-weight: 500;
}

.record-row__countdown {
  color: var(--colour-primary);
  font-size: 13px;
  font-weight: 500;
}

.it-happened-form {
  margin-left: auto;
}

/* A checkbox group inside a form (the habits a goal links to), styled to match .field without
   being one: a <fieldset>/<legend> rather than a <label>/<input> pair. */
.field--checkboxes {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-4);
}

.field--checkboxes legend {
  font-size: 13px;
  font-weight: 500;
  color: var(--colour-muted);
  padding: 0;
  margin: 0 0 var(--space-1);
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  padding: var(--space-1) 0;
  cursor: pointer;
}

.checkbox-option input {
  /* 24px is the smallest target worth offering a thumb; the row's padding adds the rest. */
  width: 24px;
  height: 24px;
}

/* Timeline: twelve thin month rows, phone-first (a row per month, not a column, so nothing forces
   horizontal scroll). Geometry -- leftPercent/widthPercent per mark -- comes from TimelineView in
   Java; this only positions what it is given. */

.timeline {
  border-top: 1px solid var(--colour-border);
  margin: 0 0 var(--space-6);
}

.timeline__month {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--colour-border);
}

.timeline__month-label {
  flex: 0 0 32px;
  font-size: 11px;
  font-weight: 500;
  color: var(--colour-muted);
}

.timeline__track {
  position: relative;
  flex: 1 1 auto;
  height: 10px;
  background: var(--colour-heatmap-0);
  border-radius: 2px;
}

.timeline__mark {
  position: absolute;
  top: 0;
  min-width: 3px;
  height: 10px;
  border-radius: 2px;
  background: var(--colour-primary);
  display: block;
}

.timeline__mark::after {
  /* The visible mark stays a hairline; the thing a thumb lands on is 28px tall. */
  content: "";
  position: absolute;
  inset: -9px -10px;
}

.timeline__mark--future {
  background: transparent;
  border: 1px solid var(--colour-primary);
}

.timeline__today {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 14px;
  background: var(--colour-primary);
}

/* Countries: derived, never stored (docs/data-model.md). A plain table, no decoration; the stat
   line above is the one count the design system welcomes on this page, per ADR 0016. */

.countries-stat {
  color: var(--colour-muted);
  font-size: 13px;
  margin: 0 0 var(--space-4);
}

.countries-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--space-6);
  font-size: 14px;
}

.countries-table td {
  font-weight: 500;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--colour-border);
}

.countries-table td:first-child {
  font-weight: 500;
}

.countries-table td:not(:first-child) {
  color: var(--colour-muted);
  text-align: right;
  padding-left: var(--space-3);
}

/* Detail pages (docs/adr/0017-milestones-two-tabs.md): a moment's or goal's own page. Reuses
   .form-note, .tag, .tag--warn, .record-row__countdown, .record-row__meta, .field, .button and
   .section-label from above; only the facts line's layout is new. */

.detail-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* Pictures on a moment (ADR 0018): a plain grid, hairline borders, no shadows. The file input
   behind "Add pictures" is visually hidden -- the <label class="button"> it targets is the
   control a person actually sees and clicks. */

.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;
}

.pictures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}

.picture-tile__img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
}

.picture-tile__caption {
  margin-top: var(--space-1);
}

.picture-tile__caption input {
  width: 100%;
  font: inherit;
  font-size: 12px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--colour-muted);
}

.picture-tile__caption input:hover,
.picture-tile__caption input:focus {
  border-color: var(--colour-border);
  background: var(--colour-surface);
  color: var(--colour-text);
}

.upload-control {
  margin: 0 0 var(--space-1);
}

/* Plans, To-do tab (ADR 0021, superseding the old Milestones Plans tab of ADR 0017): the
   always-visible add form (the most frequent write on the site, so no disclosure around it), and
   the "Reopen" control on a done row, pushed to the end of the row's head the same way
   .it-happened-form pushes "It happened". */

.todo-add-form {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--space-2);
  margin: 0 0 var(--space-6);
}

/* One contract for every control in the row: the same height, border, radius and side padding
   as .button, so a text box, a date, a select and the button read as one row whatever the
   browser's own select chrome does. */
.todo-add-form input,
.todo-add-form select {
  min-height: var(--control-h);
  font: inherit;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  padding: 0 var(--space-3);
  background: var(--colour-surface);
  color: var(--colour-text);
}

.todo-add-form input[type="text"] {
  flex: 1 1 200px;
}

.todo-add-form input[type="date"],
.todo-add-form select {
  flex: 1 1 0;
  min-width: 140px;
}

.todo-add-form .button {
  flex: 0 0 auto;
}

@media (max-width: 480px) {
  .todo-add-form input[type="text"],
  .todo-add-form input[type="date"],
  .todo-add-form select {
    flex: 1 1 100%;
  }

  .todo-add-form .button {
    flex: 1 1 100%;
  }
}

.todo-reopen-form {
  margin-left: auto;
}

/* The month calendar (ADR 0021): seven equal columns, hairline borders, no shadows, no colour
   per kind beyond primary/grey. Every cell is a whole-cell link to that day (server-rendered, no
   client-side calendar code, per ADR 0011); an entry inside a cell is a preview only -- its own
   link lives in the selected day's list under the grid. One signal per state: has entries is the
   number's weight, today is the number's colour, hover is a tint, selected is an inset ring. */

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  font-size: 13px;
  font-weight: 500;
}

.calendar-nav a {
  position: relative;
  color: var(--colour-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-1);
}

.calendar-nav a:hover {
  color: var(--colour-primary);
}

.calendar-nav__label {
  font-weight: 600;
  color: var(--colour-text);
}

.calendar {
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 var(--space-4);
}

.calendar__weekdays,
.calendar__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar__weekdays {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--colour-muted);
  text-align: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--colour-border);
}

.calendar__week + .calendar__week {
  border-top: 1px solid var(--colour-border);
}

.calendar__day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--space-1);
  color: var(--colour-text);
  text-decoration: none;
  border-right: 1px solid var(--colour-border);
  overflow: hidden;
}

/* Wider than tall (5 / 4, an owner decision): the height follows the
   grid-computed width, so it survives a change to the container instead of going stale like a
   fixed px height would. */
@media (min-width: 721px) {
  .calendar__day {
    aspect-ratio: 5 / 4;
  }
}

/* Phone: a fixed 44px row that is also the tap target; dots only. */
@media (max-width: 720px) {
  .calendar__day {
    height: var(--control-h);
  }
}

.calendar__day:last-child {
  border-right: none;
}

.calendar__day:hover {
  background: var(--colour-surface);
}

.calendar__day-number {
  font-size: 12px;
  font-weight: 500;
}

.calendar__day--has-entries .calendar__day-number {
  font-weight: 600;
}

/* Out-of-month padding, per the design system: muted, never hidden -- a week must stay whole. */
.calendar__day--muted {
  color: var(--colour-muted);
}

.calendar__day--muted .calendar__day-number {
  color: var(--colour-muted);
}

/* Today marked on the number only, in the anchor colour -- never a filled cell. */
.calendar__day--today .calendar__day-number {
  color: var(--colour-primary);
  font-weight: 600;
}

/* The same inset ring the per-habit heatmap uses for its selected cell, and no longer the same
   rule as :hover. */
.calendar__day--selected {
  box-shadow: inset 0 0 0 2px var(--colour-primary);
}

.calendar__day-entries {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.calendar__day-entry-title {
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar__day-entry-title--done {
  color: var(--colour-muted);
  text-decoration: line-through;
}

.calendar__day-entry-dot {
  display: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--colour-primary);
}

.calendar__day-entry-dot--done {
  background: var(--colour-muted);
}

.calendar__day-overflow {
  font-size: 10px;
  font-weight: 500;
  color: var(--colour-muted);
}

/* Phone width: a title is too tight to read in a seven-column grid, so a dot per entry (max
   three) stands in for it; the day cell itself still carries the link to that day's own list. */
@media (max-width: 720px) {
  .calendar__day-entry-title,
  .calendar__day-overflow {
    display: none;
  }

  .calendar__day-entries {
    flex-direction: row;
    gap: 3px;
  }

  .calendar__day-entry-dot {
    display: block;
  }
}
