/* Apply data-theme="field-notes" to the document or to one subtree. */
[data-theme="field-notes"] {
  color-scheme: light dark;
  --fn-canvas: light-dark(#d4cdc0, #27231f);
  --fn-surface: light-dark(#eee7d9, #302b26);
  --fn-ink: light-dark(#24221e, #ddd1c1);
  --fn-muted: light-dark(#514b42, #b8a99a);
  --fn-line: light-dark(#62594d, #918172);
  --fn-accent: light-dark(#883d24, #d89a7b);
  --fn-on-accent: light-dark(#fff7ea, #251a14);
  --fn-panel: light-dark(#e0d6c7, #373029);
  --fn-rim: light-dark(#fff6e6, #42382f);
  --fn-recess: light-dark(#c3b6a4, #191510);
  --fn-shade: light-dark(#9b8e7e, #191510);
  --fn-action-end: light-dark(#71311d, #bc8267);
  --fn-hero-gradient: linear-gradient(145deg, var(--fn-rim), var(--fn-canvas));
  --fn-readout-gradient: linear-gradient(155deg, var(--fn-surface), var(--fn-panel));
  --fn-focus: var(--fn-accent);
  --fn-display: "Arial Black", system-ui, sans-serif;
  --fn-body: system-ui, sans-serif;
  --fn-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --fn-text-small: 0.875rem;
  --fn-text-body: 1rem;
  --fn-text-heading: clamp(1.5rem, 3vw, 2.25rem);
  --fn-text-display: clamp(2.75rem, 7.5vw, 6.5rem);
  --fn-space-1: 0.25rem;
  --fn-space-2: 0.5rem;
  --fn-space-3: 0.75rem;
  --fn-space-4: 1rem;
  --fn-space-6: 1.5rem;
  --fn-space-8: 2rem;
  --fn-space-12: 3rem;
  --fn-content: 76rem;
  --fn-radius: 0;
  --fn-control-size: 2.75rem;
  --fn-structural: light-dark(#24221e, #918172);
  --fn-action-shadow: light-dark(#24221e, #17130f);
  --fn-grain-opacity: .13;
  --fn-rail: 4px solid var(--fn-structural);
  --fn-rule: 1px solid var(--fn-line);

  background-color: var(--fn-canvas);
  color: var(--fn-ink);
  font: 400 var(--fn-text-body) / 1.55 var(--fn-body);
}
[data-theme="field-notes"][data-mode="light"],
html[data-theme="field-notes"]:has(.fn-appearance input[value="light"]:checked) {
  color-scheme: light;
  --fn-grain-opacity: .13;
}
[data-theme="field-notes"][data-mode="dark"],
html[data-theme="field-notes"]:has(.fn-appearance input[value="dark"]:checked) {
  color-scheme: dark;
  --fn-grain-opacity: .09;
}
@media (prefers-color-scheme: dark) {
  [data-theme="field-notes"]:not([data-mode="light"]) { --fn-grain-opacity: .09; }
}

[data-theme="field-notes"] :where(a) { color: var(--fn-accent); }
[data-theme="field-notes"] :where(button, input, select, textarea) {
  color: inherit;
  font: inherit;
}
[data-theme="field-notes"] :focus-visible {
  outline: 3px solid var(--fn-focus);
  outline-offset: 3px;
}

/* Choose a finish per surface. Content and controls sit above the texture. */
[data-theme="field-notes"] :where(.fn-hero, .fn-readout) {
  position: relative;
  isolation: isolate;
  background: var(--fn-surface);
}
[data-theme="field-notes"] :where(.fn-hero) {
  background-image: var(--fn-hero-gradient);
}
[data-theme="field-notes"] :where(.fn-readout) {
  background-image: var(--fn-readout-gradient);
}
[data-theme="field-notes"] :where(.fn-hero, .fn-readout)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
[data-theme="field-notes"] :where(.fn-hero)::before {
  /* Embedded SVG keeps the gradient usable without a texture request. */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='grain' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath d='M0 0H160V160H0Z' filter='url(%23grain)'/%3E%3C/svg%3E") repeat;
  mix-blend-mode: soft-light;
  opacity: var(--fn-grain-opacity);
}
[data-theme="field-notes"] :where(.fn-readout)::before {
  background: repeating-linear-gradient(0deg, transparent 0 3px, currentColor 3px 4px);
  mask-image: linear-gradient(110deg, transparent, #000 85%);
  opacity: .07;
}
[data-theme="field-notes"] :where(.fn-action) {
  display: inline-flex;
  align-items: center;
  gap: var(--fn-space-3);
  min-block-size: var(--fn-control-size);
  padding: var(--fn-space-2) var(--fn-space-4);
  border: 1px solid var(--fn-action-shadow);
  border-radius: var(--fn-radius);
  background: var(--fn-accent);
  box-shadow: 0 3px 0 var(--fn-action-shadow);
  color: var(--fn-on-accent);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  transition: transform 85ms ease-out, box-shadow 85ms ease-out;
}
[data-theme="field-notes"] :where(.fn-action--gradient) {
  background-image: linear-gradient(145deg, var(--fn-accent), var(--fn-action-end));
}
[data-theme="field-notes"] :where(.fn-action:hover) { text-decoration: underline; }
[data-theme="field-notes"] :where(.fn-action:active) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--fn-action-shadow);
}
[data-theme="field-notes"] :where(.fn-meter) {
  display: block;
  appearance: none;
  inline-size: 100%;
  block-size: 1rem;
  color: var(--fn-accent);
  border: 1px solid var(--fn-line);
  background: var(--fn-recess);
  box-shadow: inset 1px 2px 0 var(--fn-shade);
}
[data-theme="field-notes"] :where(.fn-meter)::-webkit-progress-bar { background: transparent; }
[data-theme="field-notes"] :where(.fn-meter)::-webkit-progress-value { background: var(--fn-accent); }
[data-theme="field-notes"] :where(.fn-meter)::-moz-progress-bar { background: var(--fn-accent); }
@media (prefers-reduced-motion: reduce) {
  [data-theme="field-notes"] :where(.fn-action) { transition: none; }
}
@media (forced-colors: active) {
  [data-theme="field-notes"] :where(.fn-hero, .fn-readout, .fn-action) { background-image: none; }
  [data-theme="field-notes"] :where(.fn-hero, .fn-readout)::before { display: none; }
  [data-theme="field-notes"] :where(.fn-meter) { appearance: auto; }
}

/* Compact landing layout. */
[data-theme="field-notes"] :where(.fn-landing) {
  display: grid;
  grid-template-rows: auto 1fr auto;
  box-sizing: border-box;
  min-block-size: 100vh;
  min-block-size: 100dvh;
  margin: 0 auto;
  max-inline-size: var(--fn-content);
  padding-inline: var(--fn-space-4);
}
[data-theme="field-notes"] :where(.fn-landing > header, .fn-landing > footer) {
  padding-block: var(--fn-space-6);
}
[data-theme="field-notes"] :where(.fn-landing > header svg) {
  display: block;
  inline-size: min(10rem, 100%);
  block-size: auto;
}
[data-theme="field-notes"] :where(.fn-landing .fn-hero) {
  border: var(--fn-rule);
  border-block-start: var(--fn-rail);
  padding: clamp(var(--fn-space-4), 6vw, var(--fn-space-12));
}
[data-theme="field-notes"] :where(.fn-landing h1) {
  margin: 0;
  max-inline-size: 17ch;
  font: 800 clamp(2rem, 6vw, 5rem) / 1.05 var(--fn-display);
  letter-spacing: -.05em;
  overflow-wrap: anywhere;
}
[data-theme="field-notes"] :where(.fn-landing .fn-hero p) {
  max-inline-size: 46ch;
  margin-block: var(--fn-space-6);
}
[data-theme="field-notes"] :where(.fn-landing-details) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: var(--fn-space-4);
  margin-block: var(--fn-space-4);
}
[data-theme="field-notes"] :where(.fn-landing-details > section) {
  background-color: var(--fn-surface);
  border: var(--fn-rule);
  padding: clamp(var(--fn-space-4), 4vw, var(--fn-space-8));
}
[data-theme="field-notes"] :where(.fn-landing-details > .fn-readout) {
  border-block-start-color: var(--fn-accent);
  box-shadow: inset 0 2px 0 var(--fn-accent);
}
[data-theme="field-notes"] :where(.fn-landing-details h2, .fn-landing-example h2) {
  margin: 0;
  font: 750 var(--fn-text-heading) / 1.15 var(--fn-display);
}
[data-theme="field-notes"] :where(.fn-landing-details ul) {
  padding-inline-start: var(--fn-space-6);
}
[data-theme="field-notes"] :where(.fn-landing-example) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 25rem), 1fr));
  align-items: center;
  gap: var(--fn-space-6);
  margin-block: var(--fn-space-4);
  padding: clamp(var(--fn-space-4), 4vw, var(--fn-space-8));
  border: var(--fn-rule);
  background: var(--fn-surface);
}
[data-theme="field-notes"] :where(.fn-landing-example p) {
  max-inline-size: 48ch;
  margin-block-end: 0;
}
[data-theme="field-notes"] :where(.fn-landing-example figure) {
  min-inline-size: 0;
  margin: 0;
  border: var(--fn-rule);
}
[data-theme="field-notes"] :where(.fn-landing-example figcaption, .fn-landing-example dl > div) {
  padding: var(--fn-space-2) var(--fn-space-3);
}
[data-theme="field-notes"] :where(.fn-landing-example figcaption, .fn-landing-example dt) {
  font: 600 var(--fn-text-small) / 1.4 var(--fn-mono);
}
[data-theme="field-notes"] :where(.fn-landing-example figcaption) {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--fn-space-1) var(--fn-space-3);
  background: var(--fn-accent);
  color: var(--fn-on-accent);
}
[data-theme="field-notes"] :where(.fn-signal-diff) {
  display: grid;
  grid-template-columns: max-content max-content max-content;
  grid-template-areas: "was . now" "before arrow after";
  align-items: center;
  gap: var(--fn-space-1) clamp(.25rem, 2vw, 1rem);
  padding-block: var(--fn-space-2);
  font: 600 var(--fn-text-small) / 1.2 var(--fn-mono);
}
[data-theme="field-notes"] :where(.fn-signal-diff > :first-child) { grid-area: was; }
[data-theme="field-notes"] :where(.fn-signal-diff > :nth-child(2)) { grid-area: before; }
[data-theme="field-notes"] :where(.fn-signal-arrow) { grid-area: arrow; }
[data-theme="field-notes"] :where(.fn-signal-diff > :nth-child(4)) { grid-area: now; }
[data-theme="field-notes"] :where(.fn-signal-diff > :last-child) { grid-area: after; }
[data-theme="field-notes"] :where(.fn-signal-diff strong, .fn-signal-arrow) {
  color: var(--fn-ink);
  font: 800 clamp(1.125rem, 3vw, 2rem) / 1 var(--fn-display);
}
[data-theme="field-notes"] :where(.fn-landing-example dl, .fn-landing-example dd) {
  margin: 0;
}
[data-theme="field-notes"] :where(.fn-landing-example dl > div) {
  border-block-start: var(--fn-rule);
}
[data-theme="field-notes"] :where(.fn-landing-example dd) {
  color: var(--fn-muted);
}
[data-theme="field-notes"] :where(.fn-landing > footer) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--fn-space-3) var(--fn-space-6);
  padding: var(--fn-space-2) 0;
  border-block-start: var(--fn-rule);
  color: var(--fn-muted);
}
[data-theme="field-notes"] :where(.fn-footer-identity) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 var(--fn-space-3);
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
[data-theme="field-notes"] :where(.fn-footer-identity svg) {
  display: block;
  inline-size: 5.25rem;
  block-size: auto;
  padding-inline-end: var(--fn-space-3);
  border-inline-end: var(--fn-rule);
  color: var(--fn-ink);
}
[data-theme="field-notes"] :where(.fn-footer-identity a) {
  color: var(--fn-muted);
  font-size: var(--fn-text-small);
  text-decoration-color: var(--fn-line);
  text-underline-offset: .2em;
}
[data-theme="field-notes"] :where(.fn-footer-identity a:hover, .fn-footer-identity a:focus-visible) {
  color: var(--fn-accent);
  text-decoration-color: currentColor;
}
[data-theme="field-notes"] :where(.fn-appearance) {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
[data-theme="field-notes"] :where(.fn-appearance legend, .fn-appearance input) {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
[data-theme="field-notes"] :where(.fn-appearance label) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  cursor: pointer;
}
[data-theme="field-notes"] :where(.fn-appearance svg) {
  inline-size: 1rem;
  block-size: 1rem;
}
[data-theme="field-notes"] :where(.fn-appearance label:hover, .fn-appearance label:has(input:checked)) {
  background: var(--fn-panel);
  color: var(--fn-ink);
}
[data-theme="field-notes"] :where(.fn-appearance label:has(input:focus-visible)) {
  outline: 2px solid var(--fn-focus);
  outline-offset: -2px;
}
@media (forced-colors: active) {
  [data-theme="field-notes"] :where(.fn-appearance label:has(input:checked)) {
    box-shadow: none;
    outline: 1px solid Highlight;
    outline-offset: -1px;
  }
}
