@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/font/instrument-serif/regular-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/font/Fira_Sans/woff2/FiraSans-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/font/Fira_Sans/woff2/FiraSans-Medium.woff2") format("woff2");
}

@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/font/Fira_Sans/woff2/FiraSans-SemiBold.woff2") format("woff2");
}

:root,
[data-theme="light"] {
  --paper: #f8f8fa;
  --ink: #18181b;
  --muted: #52525b;
  --line: #e4e4e7;
  --quiet: #f0f0f2;
  --card: #ffffff;
  --track: #e4e4e7;
  --skip: #b42318;
  --estimate: #157347;
  --truth: #18181b;
  --party: #18181b;
  --party-text: #f8f8fa;
  --party-muted: #d4d4d8;
  --party-rule: rgba(248, 248, 250, 0.22);
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #0f0f14;
  --ink: #e4e4ea;
  --muted: #9a9aa6;
  --line: #2a2a34;
  --quiet: #232329;
  --card: #1b1b21;
  --track: #3a3a46;
  --skip: #f07167;
  --estimate: #3dd68c;
  --truth: #e4e4ea;
  --party: #232329;
  --party-text: #e4e4ea;
  --party-muted: #9a9aa6;
  --party-rule: rgba(228, 228, 234, 0.16);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: transparent;
}

body {
  font-family: "Fira Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  padding: 22px 22px 18px;
}

.figure {
  max-width: 640px;
}

.kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0 0 18px;
  font-family: "Instrument Serif", "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.week {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 10px;
  margin-bottom: 18px;
}

.ordinary,
.party {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.ordinary {
  padding: 12px 14px 11px;
}

.ordinary span,
.party span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ordinary strong,
.party strong {
  display: block;
  margin-top: 4px;
  font-family: "Instrument Serif", Palatino, Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.ordinary em {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-size: 13px;
  color: var(--muted);
}

.party {
  padding: 12px 14px 10px;
  background: var(--party);
  color: var(--party-text);
  border-color: var(--party);
}

.party span { color: var(--party-muted); }

.party .written {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--party-rule);
  font-size: 13px;
  color: var(--party-muted);
}

.party .written b {
  font-weight: 600;
  color: var(--party-text);
}

.controls {
  display: grid;
  gap: 14px;
  margin-bottom: 8px;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: baseline;
}

.control label {
  font-size: 14px;
  font-weight: 500;
}

.control output {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 6px 0 0;
  appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 8px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--track);
  border-radius: 99px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
}

input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--track);
  border: 0;
  border-radius: 99px;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.presets button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  cursor: pointer;
}

.presets button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.presets button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.ledger {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: baseline;
}

.row .name {
  font-size: 14px;
  color: var(--muted);
}

.row .kcal {
  font-family: "Instrument Serif", Palatino, Georgia, serif;
  font-size: 30px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.row .gap {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
}

.row .track {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 99px;
  background: var(--quiet);
  overflow: hidden;
}

.row .fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: currentColor;
}

.row.truth .kcal { color: var(--truth); }
.row.skip { color: var(--skip); }
.row.skip .name { color: var(--muted); }
.row.skip .fill { background: var(--skip); }
.row.estimate { color: var(--estimate); }
.row.estimate .name { color: var(--muted); }
.row.estimate .fill {
  background-color: color-mix(in srgb, var(--estimate) 28%, var(--quiet));
  background-image: repeating-linear-gradient(
    -45deg,
    var(--estimate),
    var(--estimate) 3px,
    transparent 3px,
    transparent 6px
  );
}
.row.estimate.worse { color: var(--skip); }
.row.estimate.worse .fill {
  background-color: color-mix(in srgb, var(--skip) 28%, var(--quiet));
  background-image: repeating-linear-gradient(
    -45deg,
    var(--skip),
    var(--skip) 3px,
    transparent 3px,
    transparent 6px
  );
}

.sentence {
  margin: 16px 0 0;
  font-family: "Instrument Serif", Palatino, Georgia, serif;
  font-size: 22px;
  line-height: 1.25;
}

.footnote {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 460px) {
  body { padding: 16px 14px 14px; }
  h1 { font-size: 28px; }
  .week { grid-template-columns: 1fr; }
  .row .kcal { font-size: 26px; }
  .sentence { font-size: 20px; }
}

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