:root {
  --green: #173f36;
  --line: #d9dfd7;
  --muted: #53645b;
  --canvas: #f4f6f0;
  --ink: #1e3029;
  --card: #fffefa;
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
}
body > header {
  padding: .85rem max(calc((100vw - 69rem) / 2), 5vw);
  background: #143b32;
  border-bottom: 3px solid #b1c89e;
  min-height: 4.3rem;
}
body > header .brand {
  font-size: 1.55rem;
  letter-spacing: -.035em;
  display: inline-flex;
  gap: .5rem;
  align-items: center;
}
body > header .brand::before { margin-right: .12rem; }
body > header .brand span { font-size: .85rem; letter-spacing: 0; }
body > header .plain { background: #ffffff14; color: white; box-shadow: inset 0 0 0 1px #ffffff48; }
main { max-width: 69rem; padding: clamp(1.8rem,5vw,4.4rem) clamp(1rem,4.8vw,2.8rem) 4rem; }
main > h1, .login h1, .viewer > h1 {
  margin: .45rem 0 1.45rem;
  font-weight: 500;
  letter-spacing: -.055em;
  text-wrap: balance;
}
main > small, .login > small, .viewer > small { color: #456453; font-size: .78rem; }
main > section, .login {
  padding: clamp(1.12rem,3.2vw,2.25rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 2px 4px #193a2806, 0 9px 35px #193a2805;
}
main > section > h2, main > section > details > summary { letter-spacing: -.025em; }
main > section > h2 { font-size: clamp(1.55rem,3.5vw,2.1rem); font-weight: 500; }
main > section p, .login p, .viewer > p { color: var(--muted); }
a { text-underline-offset: .2em; text-decoration-thickness: 1px; }
button, input, textarea, select { font: inherit; }
input:not([type=checkbox]):not([type=radio]), textarea, select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 2.8rem;
  padding: .66rem .82rem;
  border: 1px solid #a7b7ab;
  border-radius: .55rem;
  background-color: white;
  color: var(--ink);
}
select { appearance: auto; }
textarea { resize: vertical; line-height: 1.4; }
input[type=file] { font-size: .94rem; }
input[type=file]::file-selector-button {
  background: #e9efe6;
  border: 0;
  border-radius: .33rem;
  color: var(--green);
  padding: .35rem .55rem;
  margin-right: .55rem;
}
input[type=checkbox], input[type=radio] { width: 1.15rem; height: 1.15rem; accent-color: var(--green); }
label:has(> input[type=checkbox]) { display: flex; align-items: center; }
button {
  min-height: 2.75rem;
  padding: .65rem 1rem;
  border-radius: .6rem;
  font-weight: 650;
  line-height: 1.25;
  transition: background-color .15s, box-shadow .15s;
}
button:hover:not(:disabled) { box-shadow: inset 0 0 0 100px #00000010; }
:where(a, button, input, textarea, select, summary):focus-visible { outline: 3px solid #538667; outline-offset: 3px; }
button[name=action][value^=delete], button[name=action][value="retire"] { background: #80382f; color: white; }
.actions button[value="remove"] { background: #faebe6; color: #823b33; }
summary { padding-block: .4rem; font-weight: 650; }
summary::marker { color: #597762; }
details > form { margin-block-start: .8rem; }
fieldset { margin: .8rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: .7rem; min-width: 0; }
legend { font-weight: 700; padding: 0 .35rem; }
.login {
  position: relative;
  width: min(100%, 29rem);
  max-width: none;
  margin: clamp(1.2rem,9vh,6rem) auto;
  border-top: .32rem solid #72926f;
}
.login label { margin-bottom: 1.1rem; }
.login button { margin-top: .25rem; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 0;
  border: 0;
  background: var(--green);
}
.metrics div {
  padding: 0 clamp(.38rem,2vw,1.3rem);
  border-left: 1px solid #ffffff38;
  color: #d4e6da;
  line-height: 1.2;
}
.metrics div:first-child { border: 0; padding-inline-start: 0; }
.metrics strong { margin-bottom: .35rem; color: #fffbee; font-size: clamp(1.7rem,4.6vw,3rem); }
.item, .page-row, .qr { padding: 1.05rem 0; gap: 1rem; }
.item { color: var(--ink); font-weight: 650; text-decoration: none; }
.item > span { color: var(--green); font-size: .9rem; text-decoration: underline; }
.item:hover > span { text-decoration-thickness: 2px; }
.page-row > img { background: #f1f1e9; border: 1px solid var(--line); border-radius: .2rem; }
.page-row p { margin: .25rem 0 .65rem; }
.qr > div { min-width: 0; }
.qr > img { aspect-ratio: 1; padding: .4rem; border: 1px solid var(--line); border-radius: .7rem; background: white; }
.qr h3 { margin: .25rem 0; }
.scroll { overscroll-behavior-x: contain; }
th { background: #f1f4ec; color: #415347; font-size: .85rem; font-weight: 700; }
td, th { padding: .78rem .65rem; vertical-align: top; }
[role=alert] { background: #fff0cf; border: 1px solid #ddc9a1; border-radius: .6rem; }
.viewer > h1 { font-size: clamp(2rem,5vw,3.4rem); }
.viewer #book { box-shadow: 0 .7rem 2.5rem #233d2a23; }
.viewer #controls { margin: 1.25rem auto .3rem; gap: .65rem; }
.viewer #counter { min-width: 5.3em; font-variant-numeric: tabular-nums; }
.viewer #full { font-size: .94rem; }

.theme-options {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,9rem),1fr));
  gap: .65rem;
  min-width: 0;
  margin: .8rem 0 1rem;
}
.theme-option {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: end;
  align-items: center;
  min-width: 0;
  min-height: 5.25rem;
  gap: .45rem;
  margin: 0;
  padding: 1.15rem .72rem .68rem;
  border: 1px solid var(--rule, var(--line));
  border-radius: .65rem;
  border-top: .4rem solid var(--accent, var(--green));
  color: var(--print,var(--ink));
  background: var(--paper,var(--card));
  font: 650 1.05rem/1.25 var(--display,system-ui,sans-serif);
  text-align: left;
  cursor: pointer;
}
.theme-option:has(input:checked) { outline: 2px solid var(--green); outline-offset: 2px; }
.theme-option small { font: 500 .83rem/1.3 system-ui,sans-serif; text-transform: none; letter-spacing: 0; }
@media (max-width: 37rem) {
  body > header { padding-inline: 1rem; }
  body > header .brand span { font-size: .78rem; }
  .row { gap: .65rem; }
  .row > label { flex-basis: 100%; }
  .row > button { margin-top: .3rem; }
  .qr > img { width: min(12rem, 100%); }
  .page-row { align-items: flex-start; gap: .65rem; }
  .actions { gap: .4rem; }
  .actions button { padding-inline: .65rem; }
  main:has(.viewer) { padding-inline: .65rem; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
.theme-picker { border: 0; padding: 0; }
.theme-picker legend { padding: 0; }
.new-menu-form > label:has(input[name="currency"]), details > form > label:has(input[name="currency"]) { max-width: 14rem; }
.item-editor { padding: clamp(.8rem,2.5vw,1.45rem); background: #f8faf5; }
.item-editor legend { color: var(--green); }
.portion-editor {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr)) auto;
  gap: .6rem;
  align-items: end;
  padding: .8rem 0;
  border-top: 1px solid var(--line);
}
.portion-editor label { margin: 0; }
.portion-editor button { align-self: end; }
.portion-list { margin: .9rem 0; }
.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: .55rem 1rem;
  border-radius: .55rem;
  background: var(--green);
  color: white;
  text-decoration: none;
  font-weight: 650;
}
@media (max-width: 40rem) {
  .portion-editor { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .portion-editor button { padding-inline: .4rem; font-size: .92rem; }
}
.theme-option::before {
  content: "";
  display: block;
  flex: 0 0 100%;
  height: 1rem;
  margin-bottom: .22rem;
}
.theme-option[data-theme="atelier"]::before {
  background: linear-gradient(var(--accent),var(--accent)) center 35% / 88% 1px no-repeat,
              linear-gradient(var(--accent),var(--accent)) center 67% / 62% 1px no-repeat;
}
.theme-option[data-theme="garden"]::before {
  background: repeating-linear-gradient(130deg,transparent 0 6px,var(--accent) 6px 8px, transparent 8px 12px)
              left center / 2.8rem .8rem no-repeat;
}
.theme-option[data-theme="ember"]::before {
  background: repeating-linear-gradient(90deg,var(--accent) 0 6px,transparent 6px 10px)
              left center / 3.9rem .38rem no-repeat;
}
.theme-option[data-theme="coast"]::before {
  background: repeating-linear-gradient(0deg,var(--accent) 0 1px,transparent 1px 4px)
              left center / 4.6rem .8rem no-repeat;
}
.theme-option[data-theme="upload"]::before {
  width: 2rem;
  background: linear-gradient(var(--muted),var(--muted)) left center / 2rem 1px no-repeat;
}

.portion-editor .portion-choice { grid-column: 1 / -1; }
.portion-editor label[hidden] { display: none; }
