:root {
  color-scheme: dark;

  --bg: #0c0c0e;
  --surface: #131316;
  --surface-raised: #191920;
  --surface-hover: #1f1f27;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text: #f3f3f4;
  --text-muted: rgba(243, 243, 244, 0.58);
  --ribbon: #9cc3d8;
  --ribbon-ink: #0c1114;
  --focus: #d8c9a3;
  --wave-muted: rgba(255, 255, 255, 0.24);

  --radius: 10px;
  --measure: 40rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(2rem, 8vw, 4rem) var(--gutter) 1.5rem;
}

.masthead__title {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", Palatino, Georgia, serif;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.masthead__tagline {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.bell {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.bell[hidden] {
  display: none;
}

.bell:hover {
  border-color: var(--ribbon);
  background: var(--surface-hover);
}

.bell__glyph {
  font-size: 0.95rem;
}

.ribbon {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 10vw, 6rem);
}

/* --- Filters and podcast mode --------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.toolbar[hidden],
.filters[hidden],
.podcast[hidden] {
  display: none;
}

.filters,
.podcast {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

/* A filter that is on reads as selected; off is quiet, not disabled. */
.chip[aria-pressed="true"] {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.chip:hover {
  border-color: var(--ribbon);
  color: var(--text);
}

.chip[hidden] {
  display: none;
}

.podcast__toggle,
.podcast__stop {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.podcast__toggle[aria-pressed="true"] {
  border-color: var(--ribbon);
  background: var(--surface-raised);
}

.podcast__stop {
  border-color: var(--border);
  color: var(--text-muted);
}

.podcast__toggle:hover,
.podcast__stop:hover {
  border-color: var(--ribbon);
  background: var(--surface-raised);
}

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

.podcast__progress {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.podcast__hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.75;
}

.podcast__progress[hidden],
.podcast__hint[hidden] {
  display: none;
}

.note[hidden] {
  display: none;
}

.status {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.status[hidden] {
  display: none;
}

.notice {
  margin: 0 0 1.25rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  font-size: 0.9rem;
}

.notice[hidden] {
  display: none;
}

.is-offscreen {
  position: absolute;
  top: 0;
  left: -9999px;
}

.notes {
  --ribbon-offset: 1.5rem;

  display: grid;
  gap: 0.9rem;
  margin: 0;
  padding: 0 0 0 var(--ribbon-offset);
  border-left: 1px solid var(--border);
  list-style: none;
}

.note {
  position: relative;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.note::before {
  content: "";
  position: absolute;
  top: 1.35rem;
  left: calc(-1 * var(--ribbon-offset) - 4.5px);
  width: 9px;
  height: 9px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg);
}

.note--new::before {
  border-color: var(--ribbon);
  background: var(--ribbon);
}

.note--playing {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.note--last-played {
  border-style: dashed;
}

.note--linked {
  border-color: var(--ribbon);
}

/* A photography site shows the photograph, not a crop of it: the frame is the point.
   Sizing is therefore intrinsic — the image keeps its own aspect ratio, capped by the
   card width and the viewport height, and centred when it is narrower than the card. */
.note__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto 0.9rem;
  border-radius: 8px;
  background-color: var(--surface-raised);
}

.note__head {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  justify-content: space-between;
}

.note__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.note__badge {
  flex: none;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--ribbon);
  color: var(--ribbon-ink);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.note__badge[hidden] {
  display: none;
}

.note__meta,
.note__prompt {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.note__prompt {
  color: var(--text);
  font-style: italic;
}

.note__prompt[hidden] {
  display: none;
}

.note__waveform {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 0.9rem;
}

.note__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}

.note__play,
.note__share {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.note__play {
  min-width: 5.5rem;
}

.note__share {
  border-color: var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.note__actions {
  display: flex;
  flex: none;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}

.note__play:hover,
.note__share:hover {
  border-color: var(--ribbon);
  background: var(--surface-raised);
}

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

.note__duration {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.note audio {
  display: none;
}

/* --- Colophon and long-form pages ----------------------------------------- */

.colophon {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(2rem, 6vw, 3.5rem);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.colophon p {
  margin: 1.5rem 0 0;
}

.colophon a,
.masthead__tagline a,
.prose a {
  color: var(--text);
  text-underline-offset: 2px;
}

/* A control, not a button-shaped thing: it should read as part of the small print. */
.colophon__reset {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.colophon__reset:hover {
  text-decoration-thickness: 2px;
}

.prose {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 10vw, 6rem);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.prose h2 {
  margin: 2rem 0 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.prose p,
.prose ul {
  margin: 0.75rem 0 0;
}

.prose ul {
  padding-left: 1.1rem;
}

.prose li + li {
  margin-top: 0.4rem;
}

.prose code {
  color: var(--text);
  font-size: 0.95em;
}

.prose__updated {
  margin-top: 2.5rem;
  font-size: 0.8rem;
  opacity: 0.85;
}

@media (max-width: 30rem) {
  .notes {
    --ribbon-offset: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bell,
  .chip,
  .podcast__toggle,
  .podcast__stop,
  .note__play,
  .note__share {
    transition: none;
  }
}
