:root {
  --ink: #121820;
  --mute: #5a6774;
  --paper: #d8e0e8;
  --sheet: #f5f7fa;
  --line: #b7c4d1;
  --navy: #1e3a5f;
  --stamp: #2457c5;
  --stamp-deep: #183d8f;
  --ruler: #8a7148;
  --ruler-edge: #c4a86a;
  --ok: #1f6b4a;
  --font: "Work Sans", system-ui, sans-serif;
  --display: "Young Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background-color: var(--paper);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 28%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(30, 58, 95, 0.07) 27px,
      rgba(30, 58, 95, 0.07) 28px
    );
  min-height: 100vh;
}

a {
  color: var(--stamp);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--stamp-deep);
}

.desk {
  width: min(1120px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.rail {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 2px solid var(--navy);
}

.brand {
  color: inherit;
  text-decoration: none;
}

.brand strong {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand small {
  display: block;
  margin-top: 0.2rem;
  color: var(--mute);
  font-size: 0.82rem;
  font-weight: 500;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.nav a {
  color: var(--navy);
  text-decoration: none;
}

.nav a:hover {
  color: var(--stamp);
}

/* —— hero: ledger header + copper ruler —— */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.75fr);
  gap: 1.25rem 1.75rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
}

.hero-copy {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  padding: 1.35rem 1.4rem 1.45rem;
  box-shadow: 0 10px 0 rgba(18, 24, 32, 0.04);
}

.hero-copy h1 {
  margin: 0 0 0.7rem;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.4vw, 2.55rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--navy);
}

.lead {
  margin: 0;
  max-width: 38rem;
  color: var(--mute);
  font-size: 1.02rem;
}

.lead b {
  color: var(--ink);
  font-weight: 600;
}

.ruler-block {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100%;
}

.ruler {
  background: linear-gradient(180deg, #d8bc7c, var(--ruler-edge) 38%, var(--ruler));
  border: 1px solid #6f5934;
  border-radius: 2px;
  padding: 0.55rem 0.7rem 0.65rem;
  color: #2a2114;
  box-shadow: 0 8px 18px rgba(18, 24, 32, 0.12);
  transform: rotate(-1.5deg);
}

.ruler .ticks {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.ruler .big {
  font-family: var(--display);
  font-size: 2.2rem;
  line-height: 1;
}

.ruler .sub {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
}

/* —— norm sheet —— */
.sheet-block {
  background: var(--sheet);
  border: 1px solid var(--line);
  margin-bottom: 1.35rem;
  padding: 1.2rem 1.25rem 1.35rem;
}

.sheet-block h2,
.day-block h2,
.table-block h2,
.limits h2 {
  margin: 0 0 0.45rem;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  font-weight: 400;
  color: var(--navy);
}

.sheet-block > p,
.day-block > p,
.table-block > p,
.limits > p {
  margin: 0 0 1rem;
  color: var(--mute);
  max-width: 42rem;
}

.norm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(240px, 0.9fr);
  gap: 1.1rem;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mute);
}

.field.wide {
  grid-column: 1 / -1;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  padding: 0.55rem 0.65rem;
  border-radius: 0;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--stamp);
  outline-offset: 1px;
}

.stamp {
  border: 2px dashed var(--stamp);
  background:
    radial-gradient(circle at 12% 18%, rgba(36, 87, 197, 0.08), transparent 42%),
    #eef2f8;
  padding: 1rem 1.05rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 100%;
}

.stamp .lbl {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stamp);
}

.stamp .val {
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 3.2rem);
  line-height: 0.95;
  color: var(--navy);
}

.stamp .val small {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  margin-left: 0.25rem;
  color: var(--mute);
}

.stamp ul {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.stamp li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  border-top: 1px solid rgba(36, 87, 197, 0.18);
  padding-top: 0.35rem;
}

.stamp li span {
  color: var(--mute);
}

.stamp li b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.88rem;
}

/* —— day timeline —— */
.day-block {
  margin-bottom: 1.35rem;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  padding: 0.85rem;
}

.meal {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.85rem 0.8rem 0.95rem;
  min-height: 100%;
}

.meal-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}

.meal-top h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--navy);
}

.meal-top b {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ok);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #f0f3f7;
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  padding: 0.38rem 0.55rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.chip .k {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--mute);
}

.chip[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.chip[aria-pressed="true"] .k {
  color: #c9d7ea;
}

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

.day-sum {
  margin-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--navy);
  color: #fff;
  padding: 0.75rem 1rem;
}

.day-sum span {
  font-size: 0.88rem;
  opacity: 0.85;
}

.day-sum b {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 400;
}

/* —— foods table —— */
.table-block {
  margin-bottom: 1.35rem;
}

.food-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--sheet);
  border: 1px solid var(--line);
  font-size: 0.95rem;
}

.food-table th,
.food-table td {
  padding: 0.65rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.food-table th {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
  background: #e9eef4;
  font-weight: 700;
}

.food-table tr:last-child td {
  border-bottom: 0;
}

.food-table button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--stamp);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.food-table button:hover {
  color: var(--stamp-deep);
}

.food-table .kcal {
  font-family: var(--mono);
  font-weight: 500;
}

.picked {
  margin-top: 0.7rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.85rem;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.picked b {
  font-family: var(--mono);
  font-weight: 500;
}

/* —— limits —— */
.limits {
  margin-bottom: 1.5rem;
  padding: 1.1rem 1.2rem 1.2rem;
  border: 1px solid var(--line);
  background: rgba(245, 247, 250, 0.72);
}

.limits dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.limits dt {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.limits dd {
  margin: 0;
  color: var(--mute);
  font-size: 0.92rem;
}

/* —— footer / cookie —— */
.foot {
  border-top: 2px solid var(--navy);
  padding-top: 1rem;
  color: var(--mute);
  font-size: 0.88rem;
}

.foot p {
  margin: 0 0 0.45rem;
  max-width: 52rem;
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 0.65rem;
}

.prose {
  background: var(--sheet);
  border: 1px solid var(--line);
  padding: 1.25rem 1.3rem 1.4rem;
  margin-bottom: 1.25rem;
}

.prose h1,
.prose h2 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-weight: 400;
  color: var(--navy);
}

.prose p {
  margin: 0 0 0.75rem;
  max-width: 42rem;
}

.cookie {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 520px;
  margin: 0 auto;
  background: var(--ink);
  color: #edf1f5;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 12px 30px rgba(18, 24, 32, 0.28);
}

.cookie[hidden] {
  display: none;
}

.cookie p {
  margin: 0;
}

.cookie button {
  appearance: none;
  border: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .hero,
  .norm-grid,
  .timeline,
  .limits dl {
    grid-template-columns: 1fr;
  }

  .rail {
    flex-direction: column;
    align-items: flex-start;
  }

  .ruler {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
