:root {
  --bg: #f4f0e6;
  --fg: #1f2a1f;
  --muted: #4f5d4f;
  --panel: #fffdf7;
  --line: #e2dccb;
  --accent: #2e6b2e;
  --meter: #3f8a30; /* 3.3:1 on --track (WCAG 1.4.11) */
  --track: #e6e0cf;
  --bubble-bg: #ffffff;
  --bubble-fg: #1f2a1f;
  --shadow: 0 1px 2px rgb(40 50 30 / 0.12), 0 12px 32px -8px rgb(40 50 30 / 0.28);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121812;
    --fg: #e6ece2;
    --muted: #b3bfae;
    --panel: #1a221a;
    --line: #2c382c;
    --accent: #8fd18f;
    --meter: #7cc36a;
    --track: #2c382c;
    --bubble-bg: #f4f1e8;
    --bubble-fg: #141a14;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 36px -8px rgb(0 0 0 / 0.6);
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem;
}

h1, h2 {
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  font-size: 2.1rem;
  margin: 0.75rem 0 1rem;
}

h2 {
  font-size: 1.3rem;
  margin: 1.75rem 0 0.6rem;
}

/* The pond: a rounded card, wider than the text column on big screens. */
.scene {
  position: relative;
  width: min(72rem, 100vw - 2rem);
  margin-left: calc(50% - min(36rem, 50vw - 1rem));
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 5; /* pond-layout.js ASPECT: the 3D frame is made for this shape */
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: linear-gradient(#cfe9f5 0 30%, #7fb556 30%); /* before the 3D view draws, or with JS off */
}

/* His speech: a bubble over the sky, with a tail down to the pond. */
.bubble {
  position: absolute;
  top: 0.9rem;
  left: 1rem;
  max-width: min(100% - 2rem, 30rem);
  margin: 0;
  padding: 0.6rem 0.9rem;
  border-radius: 1.1rem;
  background: var(--bubble-bg);
  color: var(--bubble-fg);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.25);
  overflow-wrap: anywhere;
}

.bubble::after {
  content: "";
  position: absolute;
  left: 1.6rem;
  bottom: -0.45rem;
  width: 0.9rem;
  height: 0.9rem;
  background: inherit;
  transform: rotate(45deg);
  border-radius: 0 0 0.2rem 0;
}

.bubble[hidden] {
  display: none;
}

/* A soft vignette over the picture (the bubble sits above it). */
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  pointer-events: none;
  box-shadow: inset 0 0 70px rgb(10 20 10 / 0.28);
}

.scene .bubble {
  z-index: 1;
}

/* On a phone the picture is short: the bubble goes above it, and the tail points down at it. */
@media (max-width: 40rem) {
  .scene {
    width: auto;
    margin-left: 0;
    display: flex;
    flex-direction: column;
  }

  .bubble {
    position: relative;
    top: auto;
    left: auto;
    max-width: none;
    margin-bottom: 0.7rem;
    order: -1; /* above the picture, which comes first in the page */
  }

  .scene::after {
    display: none;
  }

  canvas {
    border-radius: 14px;
  }
}

#now {
  margin: 0.9rem 0 0;
  color: var(--muted);
}

.needs {
  list-style: none;
  margin: 0;
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem 0.9rem;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.needs li {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
}

.needs .label {
  font-weight: 600;
}

.needs meter {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 4rem;
  height: 0.7rem;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.needs meter::-webkit-meter-bar {
  background: var(--track);
  border: 0;
  border-radius: 999px;
  height: 0.7rem;
}

.needs meter::-webkit-meter-optimum-value {
  background: var(--meter);
  border-radius: 999px;
}

.needs meter::-moz-meter-bar {
  background: var(--meter);
  border-radius: 999px;
}

.needs .word {
  color: var(--muted);
}

#thought {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--meter);
  border-radius: 14px;
  font-family: var(--serif);
  font-size: 1.1rem;
}

#events {
  padding-left: 1.5rem;
  color: var(--muted);
}

#events li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
}

time {
  font-variant-numeric: tabular-nums;
  margin-right: 0.25rem;
}

.thinking {
  color: var(--muted);
  font-style: italic;
}

footer {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--muted);
}

nav a[aria-current="page"] {
  font-weight: bold;
}

.day {
  list-style: none;
  padding-left: 0;
}

.day .thought {
  font-style: italic;
}

.day .intent-failed {
  color: var(--accent);
}

nav.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.25rem 0 0.5rem;
}

nav.site a {
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--panel);
}

nav.site a:hover,
nav.site a:focus-visible {
  text-decoration: underline;
}

.mems {
  list-style: none;
  padding-left: 0;
}

.mem {
  padding: 0.25rem 0 0.25rem 0.5rem;
  border-left: 3px solid transparent;
}

/* Core memories have a gold rule. Faded memories fade the bar, never the text (contrast stays 4.5:1 or more). */
.mem.core {
  border-left-color: #c9a227;
}

.mem small,
.entry small {
  color: var(--muted);
}

table {
  border-collapse: collapse;
  margin: 1rem 0;
}

th,
td {
  padding: 0.25rem 0.75rem 0.25rem 0;
  text-align: left;
}

/* High contrast: the system colours would hide the styled bar, so give back the native meter. */
@media (forced-colors: active) {
  .needs meter {
    -webkit-appearance: auto;
    appearance: auto;
  }
}

/* /pond (M11-11): the time-lapse controls. */
.player .controls input[type="range"] {
  width: min(20rem, 55vw);
  vertical-align: middle;
}
