/* Pasturebook:
   Big Shoulders Display (headings), Literata (text), IBM Plex Mono (labels);
   cream paper, ink-green bands, flame orange and straw gold. */

:root {
  /* Pasturebook palette */
  --paper: #f7f2e6; --paper-2: #efe6d1; --fg: #1f2523; --muted: #5b605a; --line: #d9ccb0;
  --flame: #c8471f; --flame-ink: #a63a17; --straw: #e3b94f; --chip: #f1e3bd; --chip-fg: #5a4410;
  --band: #1c2422; --band-2: #2a3532; --on-band: #f5efe1; --on-band-muted: #bfc3b8;
  --warn: #b3261e; --blue: #2f6f8f;
  --display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --body: "Literata", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 4px;
  --accent-ink: #fff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161c1a; --paper-2: #1d2522; --fg: #ece5d4; --muted: #a7aa9f; --line: #34403b;
    --flame: #ef6a3c; --flame-ink: #f08257; --straw: #e8c25e; --chip: #3a3220; --chip-fg: #f1d58c;
    --band: #0f1413; --band-2: #1a2220; --warn: #ff8f80; --blue: #8cc4dc;
    --accent-ink: #1b120d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #161c1a; --paper-2: #1d2522; --fg: #ece5d4; --muted: #a7aa9f; --line: #34403b;
  --flame: #ef6a3c; --flame-ink: #f08257; --straw: #e8c25e; --chip: #3a3220; --chip-fg: #f1d58c;
  --band: #0f1413; --band-2: #1a2220; --warn: #ff8f80; --blue: #8cc4dc;
  --accent-ink: #1b120d; color-scheme: dark;
}
/* names the app's markup uses, mapped onto the palette */
:root {
  --bg: var(--paper); --card: var(--paper-2); --ink: var(--fg);
  --accent: var(--flame); --accent-soft: color-mix(in srgb, var(--flame) 14%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 15%, transparent);
  --gold: var(--chip-fg); --gold-soft: var(--chip);
  --blue-soft: color-mix(in srgb, var(--blue) 16%, transparent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--fg);
  font-family: var(--body); font-size: 16px; line-height: 1.5;
  padding-bottom: calc(61px + env(safe-area-inset-bottom));  /* phones: just the height of the bottom menu, so the footer ends right above it */
}
a { color: var(--flame-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--straw); outline-offset: 2px; }
h1, h2 { font-family: var(--display); text-transform: uppercase; line-height: 1; letter-spacing: .01em; text-wrap: balance; }
h1 { font-size: clamp(2rem, 6vw, 2.9rem); font-weight: 900; margin: 0 0 .25rem; }
h2 { font-size: 1.55rem; font-weight: 800; margin: 0 0 .7rem; }
h3 {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 1.1rem 0 .45rem;
}
code { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 1rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- header / nav: the dark "band" */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem;
  background: var(--band); color: var(--on-band); padding: .6rem 1rem;
  padding-top: calc(.6rem + env(safe-area-inset-top));
  border-bottom: 3px solid var(--flame);
}
.brand {
  color: var(--on-band); font-family: var(--display); font-weight: 800; font-size: 1.3rem;
  letter-spacing: .06em; text-transform: uppercase; display: flex; align-items: center; gap: .55rem; min-width: 0;
}
.brand:hover { text-decoration: none; color: var(--straw); }
/* a farm's name can be long: it ends in "…" rather than pushing the menu off the screen (the full name is its tooltip) */
.brand .bt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* between phone and wide screens the menu needs the room: just the crest (its alt text names it) */
@media (min-width: 800px) and (max-width: 1149px) { .brand .bt { display: none; } }
.brand img { flex: none; width: 40px; height: 40px; margin: -6px 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.tabs { display: flex; gap: .15rem; margin-left: auto; flex: none; }
.tabs a {
  color: var(--on-band-muted); padding: .45rem .6rem; border-radius: 2px; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  display: flex; align-items: center; gap: .4rem;
}
.tabs a:hover { color: var(--straw); text-decoration: none; }
.tabs a.on { color: var(--straw); box-shadow: inset 0 -2px 0 var(--straw); }
.tabs .ic { font-size: 1.05rem; letter-spacing: 0; }
@media (max-width: 799px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 6; gap: 0;
    background: var(--band); border-top: 3px solid var(--flame); justify-content: space-around;
    padding: .3rem .15rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .tabs a { flex-direction: column; gap: 1px; font-size: 9.5px; letter-spacing: .06em; padding: .25rem .2rem; }
  .tabs a.on { box-shadow: none; background: color-mix(in srgb, var(--straw) 14%, transparent); }
  .tabs .ic { font-size: 1.3rem; line-height: 1.2; }
  .tabs .extra, .tabs .nvx { display: none; }
}
@media (min-width: 800px) { body { padding-bottom: 0; } }  /* the footer ends the page, as on the main site */

main { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem; }

/* ---------- building blocks */
.card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; margin-bottom: 1rem; min-width: 0;
}
/* "dense": a later box fills any gap a wide box leaves, instead of leaving a hole */
.cols { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); align-items: start; grid-auto-flow: row dense; }
.cols > .card { margin-bottom: 0; }
/* a card that takes two columns where there's room */
@media (min-width: 760px) { .cols > .card.span2 { grid-column: span 2; } }
.cols > .card.span3 { grid-column: 1 / -1; }  /* the full width of the row */

/* animal page: on wide screens a narrow left column (Details, Records, Breeding) and a wide right column
   (Pedigree, Photos, Offspring), each stacked tightly; on narrow screens one column in a sensible order */
.alay { display: flex; flex-direction: column; gap: 1rem; }
.alay .acol { display: contents; }
.alay .card { margin-bottom: 0; min-width: 0; }
.alay .o1 { order: 1; } .alay .o2 { order: 2; } .alay .o3 { order: 3; }
.alay .o4 { order: 4; } .alay .o5 { order: 5; } .alay .o6 { order: 6; }
@media (min-width: 900px) {
  .alay { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
  .alay .acol { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
}
.pagehead { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.pagehead .sp, footer .sp { flex: 1; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

button, .btn {
  font-family: var(--display); font-weight: 800; font-size: 1.02rem; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--line); background: var(--paper); color: var(--fg); line-height: 1.1;
  border-radius: 2px; padding: .5rem .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem;
  min-height: 40px;
}
button:hover, .btn:hover { border-color: var(--flame); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--flame); color: var(--accent-ink); border-color: var(--flame); }
.primary:hover { background: var(--flame-ink); border-color: var(--flame-ink); }
.danger { color: var(--warn); border-color: var(--warn); }
.ghost { border-color: transparent; background: transparent; }
button.sm, .btn.sm { padding: .25rem .6rem; min-height: 32px; font-size: .9rem; }

/* number tiles: ink panels with gold figures */
.tiles { display: grid; gap: 0; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 1rem;
  background: var(--band); border: 1px solid var(--band); border-radius: var(--radius); overflow: hidden; }
/* hairlines between tiles, drawn on each tile so a part-filled last row stays solid ink */
.tile { background: var(--band); color: var(--on-band); padding: .8rem .95rem; display: block; min-width: 0;
  box-shadow: inset -1px -1px 0 color-mix(in srgb, var(--on-band) 14%, transparent); }
a.tile:hover { text-decoration: none; background: var(--band-2); }
.tile .big { font-family: var(--display); font-size: 2.6rem; font-weight: 900; line-height: .95; color: var(--straw); font-variant-numeric: tabular-nums; }
.tile .lbl { color: var(--on-band-muted); font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin-top: .3rem; }
.tile .lbl .small { font-size: 10px; }
.tile .ico { font-size: 1.4rem; float: right; }

/* menu icons (main menu and tab switches) */
.nav-ic { width: 1.3em; height: 1.3em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -.3em; }
.tabs .ic { display: inline-flex; }
.tabs .ic .nav-ic { width: 1.25rem; height: 1.25rem; }
.seg button .nav-ic { width: 1.45em; height: 1.45em; margin: -.2em 0; }
.seg button.on .nav-ic { color: var(--straw); }
@media (max-width: 799px) { .tabs .ic .nav-ic { width: 1.55rem; height: 1.55rem; } }
/* "Feed & Medicine" needs about 90px more than "Feed": keep the short name until the top menu has room for it */
@media (max-width: 899px) { .tabs .nvx { display: none; } }

/* drawn species icons: line art that takes the surrounding text size; flame on paper, straw on ink */
.sp-ic { width: 1.3em; height: 1.3em; vertical-align: -.28em; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; color: var(--flame); flex: none; }
.sp-ic .dot { fill: currentColor; stroke: none; }
.tile .sp-ic, .chip.on .sp-ic, .toc .sp-ic { color: var(--straw); }
.item .ico .sp-ic { width: 2rem; height: 2rem; display: block; margin: 0 auto; }
.tile .ico .sp-ic { width: 2rem; height: 2rem; }
.pagehead .sp-ic { width: 3rem; height: 3rem; }
.chip .sp-ic { width: 1.5em; height: 1.5em; vertical-align: -.45em; margin: -.2em .1em -.2em -.2em; }

/* feed pictures and form section headings */
.feedpic { flex: none; display: block; line-height: 0; }
.feedpic .av, .feedpic .sp-ic { width: 3.2rem; height: 3.2rem; border-radius: var(--radius); }
.feedpic.big .sp-ic { width: 4.2rem; height: 4.2rem; }
.av.sq { border-radius: var(--radius); }
.thumb { position: relative; }
.thumb span { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; background: rgba(15,20,19,.75); color: #f5efe1;
  font-family: var(--mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsec { grid-column: 1 / -1; font-family: var(--display); font-weight: 800; font-size: 1.15rem; text-transform: uppercase;
  letter-spacing: .02em; color: var(--fg); border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .3rem; }

/* price / cut cost sheets */
.sheetrow { display: grid; grid-template-columns: minmax(0, 1fr) auto 3.6em; gap: .45rem; align-items: center; padding: .45rem 0; }
.sheetrow .nm {
  background: none; border: 0; padding: 0; min-height: 0; text-align: left; justify-content: flex-start; gap: .55rem;
  font-family: var(--body); font-weight: 400; font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--fg); min-width: 0;
}
.sheetrow .nm:hover b { color: var(--flame-ink); }
.sheetrow .nm span { display: flex; flex-direction: column; min-width: 0; }
.sheetrow .nm b { font-weight: 600; overflow-wrap: break-word; hyphens: auto; line-height: 1.25; }
.sheetrow .nm small { color: var(--muted); font-size: .8rem; }
.sheetrow .nm .sp-ic { width: 1.6rem; height: 1.6rem; }
.pricebox { display: flex; align-items: center; gap: .15rem; font-family: var(--display); font-weight: 800; font-size: 1.15rem; color: var(--muted); }
.pricebox input {
  width: 4.9rem; text-align: right; font-family: var(--display); font-size: 1.2rem; font-weight: 800; color: var(--flame);
  min-height: 38px; padding: .2rem .4rem; -moz-appearance: textfield; appearance: textfield;
}
.pricebox input::-webkit-outer-spin-button, .pricebox input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.per { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); line-height: 1.2; }
@media print { .pricebox input { border: 0; color: #000; } .seg, #add { display: none !important; } }

/* name / value rows (other nutrients) */
.pairs { display: grid; gap: .35rem; }
.pairrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; gap: .35rem; align-items: center; }
.pairrow button { min-height: 34px; padding: 0; justify-content: center; }

/* big figures inside cards (egg counts, feed on hand, head count) */
.stat { font-family: var(--display); font-size: 2.1rem; font-weight: 900; line-height: 1; color: var(--flame); font-variant-numeric: tabular-nums; }
.stat + .muted { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; margin-top: .25rem; }
.stat.warnc { color: var(--warn); }

.quick { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 1rem; }
.quick button { justify-content: center; min-height: 48px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.item { display: flex; gap: .75rem; align-items: center; padding: .7rem .1rem; color: var(--fg); cursor: pointer; width: 100%; }
a.item:hover { text-decoration: none; }
a.item:hover .t { color: var(--flame-ink); }
.item .ico { font-size: 1.5rem; width: 2.4rem; text-align: center; flex: none; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--muted); font-size: .85rem; }
.item .r { text-align: right; flex: none; font-size: .9rem; }

/* badges: the site's square "chips" */
.badge {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 2px; line-height: 1.4;
  background: var(--chip); color: var(--chip-fg); white-space: nowrap; vertical-align: middle;
}
.badge.warn { background: var(--flame); color: var(--accent-ink); }
.badge.gold { background: var(--straw); color: #2a2006; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.grey { background: var(--line); color: var(--muted); }

/* filter chips: the site's rounded pills */
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--fg); border-radius: 999px;
  padding: .3rem .85rem; white-space: nowrap; cursor: pointer; min-height: 36px;
  font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
}
.chip.on { background: var(--band); border-color: var(--band); color: var(--straw); }

.filters { display: grid; gap: .5rem; margin-bottom: .75rem; }
.filters .row > * { flex: 1; min-width: 130px; }
input, select, textarea {
  font-family: var(--body); font-size: 16px; /* 16px stops iOS zooming */ width: 100%; padding: .5rem .65rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--fg); min-height: 42px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--straw); outline-offset: 0; border-color: var(--straw); }
input[type=checkbox] { width: 1.3rem; height: 1.3rem; min-height: 0; accent-color: var(--flame); }

/* segmented switch */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none; background: var(--paper); }
.seg button {
  border: 0; border-radius: 0; min-height: 38px; white-space: nowrap; padding: .5rem .75rem; background: transparent;
  font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .1em;
}
.seg button.on { background: var(--band); color: var(--straw); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding-top: .2rem; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th, .tbl td { padding: .55rem .45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-family: var(--mono); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; vertical-align: bottom; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--accent-soft); }
.tbl tfoot td { font-family: var(--display); font-weight: 800; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .02em; border-bottom: 0; }
.scroll { overflow-x: auto; }

.progress { height: 6px; border-radius: 0; background: var(--line); overflow: hidden; margin-top: .35rem; }
.progress > i { display: block; height: 100%; background: var(--flame); }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: .5rem; }
.bars > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bars i { display: block; width: 100%; max-width: 26px; background: var(--flame); border-radius: 2px 2px 0 0; min-height: 1px; }
.bars span { font-family: var(--mono); font-size: 9.5px; color: var(--muted); margin-top: 3px; }

.ped { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; font-size: .85rem; }
.ped > div { display: flex; flex-direction: column; justify-content: space-around; gap: .4rem; }
.ped .p { border: 1px solid var(--line); border-radius: 2px; padding: .35rem .5rem; background: var(--paper); min-height: 2.2rem; overflow-wrap: anywhere; }
.ped .p.m { border-left: 3px solid var(--straw); }
.ped .p.f { border-left: 3px solid var(--flame); }
.ped .ps { font-weight: 700; margin-right: .35em; }
.ped .p.m .ps { color: var(--straw); }
.ped .p.f .ps { color: var(--flame); }

/* family tree: boxes joined by lines, growing downward (each generation is a row); scrolls sideways when wide */
.tree { overflow-x: auto; padding: .6rem 0 .6rem; }
.tree > .tn { width: max-content; min-width: 100%; }
.tn { display: flex; flex-direction: column; align-items: center; }
.tcell {
  display: flex; gap: .35rem; align-items: flex-start; flex: none; width: 9rem; padding: .35rem .5rem;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 2px; background: var(--paper); color: var(--fg);
  font-size: .84rem; line-height: 1.25; position: relative;
}
a.tcell:hover { text-decoration: none; border-color: var(--flame); }
.tcell b { font-weight: 600; display: block; overflow-wrap: break-word; }
.tcell small { display: block; color: var(--muted); font-size: .72rem; }
.tcell.m { border-left-color: var(--straw); } .tcell.f { border-left-color: var(--flame); }
.tcell .ps { font-weight: 700; } .tcell.m .ps { color: var(--straw); } .tcell.f .ps { color: var(--flame); }
.tcell.unknown { border-style: dashed; opacity: .7; }
.tcell.dup { background: color-mix(in srgb, var(--straw) 14%, var(--paper)); box-shadow: 0 0 0 1px var(--straw); }
.tcell .dupn { position: absolute; top: -.55rem; right: -.4rem; font-style: normal; font-family: var(--mono); font-size: 10px;
  background: var(--straw); color: #2a2006; border-radius: 2px; padding: 0 4px; }
/* the row below a box: a line down from the box, a bar across, and a line down to each box in the row */
.tkids { display: flex; justify-content: center; align-items: flex-start; position: relative; padding-top: .7rem; }
.tkids::before { content: ''; position: absolute; top: 0; left: 50%; height: .7rem; border-left: 2px solid var(--line); }
.tkids > .tn { position: relative; padding: .7rem .2rem 0; }
.tkids > .tn::before { content: ''; position: absolute; top: 0; left: 50%; height: .7rem; border-left: 2px solid var(--line); }
.tkids > .tn::after { content: ''; position: absolute; top: 0; left: 0; right: 0; border-top: 2px solid var(--line); }
.tkids > .tn:first-child::after { left: 50%; }
.tkids > .tn:last-child::after { right: 50%; }
.tkids > .tn:only-child::after { display: none; }

.empty { text-align: center; padding: 1.5rem .5rem; color: var(--muted); font-style: italic; }
.warnbox {
  background: var(--warn-soft); color: var(--fg); border-left: 4px solid var(--warn);
  padding: .65rem .85rem; border-radius: 2px; margin: .5rem 0; font-size: .92rem;
}
.warnbox b, .warnbox strong { color: var(--warn); }

/* ---------- dialog form */
dialog {
  border: 1px solid var(--line); padding: 0; border-radius: var(--radius); width: min(680px, 100vw - 1rem); max-height: calc(100dvh - 1rem);
  background: var(--paper); color: var(--fg); box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
dialog::backdrop { background: rgba(10, 14, 13, .6); }
.sheet { display: flex; flex-direction: column; max-height: calc(100dvh - 1rem); }
.sheet header { display: flex; align-items: center; padding: .9rem 1.1rem .6rem; gap: .5rem; border-bottom: 3px solid var(--flame); background: var(--band); color: var(--on-band); }
.sheet header h2 { margin: 0; flex: 1; font-size: 1.6rem; }
.sheet header .ghost { color: var(--on-band); }
.sheet .grid { overflow-y: auto; padding: 1rem 1.1rem; display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.sheet footer {
  display: flex; gap: .5rem; padding: .75rem 1.1rem; border-top: 1px solid var(--line); background: var(--paper-2);
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
}
.fld { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; color: var(--muted); min-width: 0; }
.fld > span { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.fld small { font-size: .78rem; font-style: italic; }
.feednote { margin-top: .35rem; padding: .5rem .65rem; border-left: 3px solid var(--straw); background: color-mix(in srgb, var(--straw) 12%, transparent); color: var(--fg); font-size: .85rem; line-height: 1.4; }
.feednote a { font-weight: 600; white-space: nowrap; }
.fld.wide, .fld.multi { grid-column: 1 / -1; }
.fld.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--fg); }
.fld.check > span { font-family: var(--body); font-size: .95rem; letter-spacing: 0; text-transform: none; }
.picks { display: flex; flex-wrap: wrap; gap: .4rem; }
.picks label {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); border-radius: 999px;
  padding: .3rem .75rem; color: var(--fg); cursor: pointer; background: var(--paper-2); font-size: .9rem;
}
.picks label:has(input:checked) { border-color: var(--flame); background: var(--accent-soft); }
.picks input { width: 1rem; height: 1rem; }
.picks.box { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; }
@media (max-width: 560px) {
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; border: 0; }
  .sheet { max-height: 100dvh; height: 100%; }
  .sheet header { padding-top: calc(.9rem + env(safe-area-inset-top)); }
  .sheet .grid { grid-template-columns: 1fr; flex: 1; }
}

#toast {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--band); color: var(--on-band); border-left: 4px solid var(--straw);
  padding: .6rem 1rem; border-radius: 2px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: calc(100vw - 2rem);
}
#toast.show { opacity: 1; }
#toast.err { border-left-color: var(--flame); }
/* inside an open form: just above its Cancel and Save buttons, clear of its title too */
dialog #toast { bottom: calc(4.6rem + env(safe-area-inset-bottom)); }

/* ---------- help page */
.help { max-width: 820px; margin: 0 auto 1rem; line-height: 1.65; }
.help h1 { font-size: clamp(2.2rem, 7vw, 3.2rem); }
.help h2 { font-size: 1.9rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); scroll-margin-top: 80px; }
.help h3 { font-family: var(--display); font-size: 1.25rem; font-weight: 800; letter-spacing: .02em; color: var(--fg); margin-top: 1.3rem; }
.help ul, .help ol { padding-left: 1.4rem; }
.help li { margin: .3rem 0; }
.help li::marker { color: var(--flame); }
.help code { background: var(--paper); border: 1px solid var(--line); border-radius: 2px; padding: 0 .3rem; overflow-wrap: anywhere; }
.help pre { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; overflow-x: auto; }
.help pre code { border: 0; padding: 0; background: none; overflow-wrap: normal; }
.help .tbl td:first-child { white-space: nowrap; font-weight: 600; }
.toc { font-size: .9rem; background: var(--band); color: var(--on-band-muted); border-radius: 2px; padding: .7rem .9rem; }
.toc b { font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--straw); }
.toc a { color: var(--on-band); }
.toc a:hover { color: var(--straw); }
@media print {
  .top, .tabs, .pagehead { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 0; }
  .tile { background: #fff; color: #000; } .tile .big { color: #000; }
}

/* ---------- photos */
.av { width: 2.4rem; height: 2.4rem; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto; background: var(--line); border: 2px solid var(--line); }
.av.big { width: 4.2rem; height: 4.2rem; border: 3px solid var(--straw); }
.thumbs { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.thumb { padding: 0; border: 0; min-height: 0; border-radius: 2px; overflow: hidden; aspect-ratio: 1; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox { height: calc(100dvh - 1rem); }
.lbimg { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; background: #000; }
.lbimg img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lbimg .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.5); color: #fff; border: 0; font-size: 1.8rem; border-radius: 50%; width: 44px; height: 44px; justify-content: center; }
.lbimg .prev { left: .5rem; } .lbimg .next { right: .5rem; }
@media (max-width: 560px) { .lightbox { height: 100dvh; } }

/* ---------- freezer */
.cutrow { display: grid; grid-template-columns: 1fr 70px 80px 80px 32px; gap: .35rem; margin-bottom: .35rem; align-items: center; }
.cutrow.head { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .15rem; }
.cutrow button { min-height: 32px; padding: 0; justify-content: center; }
@media (max-width: 560px) { .cutrow { grid-template-columns: 1fr 52px 62px 62px 30px; } .cutrow input { padding: .45rem .35rem; } }

.eggrow { display: grid; grid-template-columns: 1fr 110px; gap: .6rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.eggrow input { text-align: center; font-family: var(--display); font-size: 1.5rem; font-weight: 800; }
/* the egg log: farm fresh and hatching counts per flock, and the family the hatching eggs belong to */
.egghead, .eggrow2 { display: grid; grid-template-columns: minmax(0, 1fr) 78px 78px minmax(0, 1.1fr); gap: .45rem; align-items: center; }
.egghead { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: center; }
.eggrow2 { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.eggrow2 input { text-align: center; font-family: var(--display); font-size: 1.4rem; font-weight: 800; padding-inline: .2rem; }
.eggrow2 select { font-size: 14px; }
.eggstock .arow { flex-wrap: wrap; }
.eggstock .rowbtns { width: 100%; justify-content: flex-end; flex-direction: row; margin-top: -.3rem; }
@media (max-width: 520px) {  /* phones: the family goes on its own line under the counts */
  .egghead { grid-template-columns: minmax(0, 1fr) 70px 70px; }
  .egghead span:nth-child(4) { display: none; }
  .eggrow2 { grid-template-columns: minmax(0, 1fr) 70px 70px; }
  .eggrow2 select { grid-column: 2 / 4; }
}

/* ---------- tag IDs (Breeding → Tag IDs) */
.tagform { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.tagform .counts { grid-column: 1 / -1; display: grid; gap: .5rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tagform .counts input { font-family: var(--display); font-size: 1.35rem; font-weight: 800; text-align: center; }
.tagform details { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: .6rem; }
.tagform details .tagform { margin-top: .6rem; align-items: center; }
.tagform summary { cursor: pointer; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 560px) { .tagform { grid-template-columns: 1fr; } }
.tagkey { font-size: .85rem; color: var(--muted); margin: 0 0 .75rem; line-height: 1.7; }
.tagkey code { color: var(--fg); background: var(--paper); border: 1px solid var(--line); border-radius: 2px; padding: 0 .3rem; }
.tagids { list-style: none; margin: 0 0 .85rem; padding: 0; display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.tagids li {
  display: flex; align-items: center; gap: .5rem; min-width: 0; padding: .45rem .6rem;
  background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 2px;
}
.tagids li.m { border-left-color: var(--straw); }
.tagids li.f { border-left-color: var(--flame); }
.tagids li.dup { border-color: var(--warn); background: var(--warn-soft); }
.tagids code { flex: 1; min-width: 0; font-family: var(--mono); font-weight: 500; font-size: .95rem; overflow-wrap: anywhere; }
.tagids .sx { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.item .s code { font-size: .8rem; }
.tbtns { justify-content: flex-end; margin-top: .35rem; }
@media (min-width: 760px) { .cols > .card.tagside { position: sticky; top: 84px; } }
@media (max-width: 560px) {
  .tbitem { flex-wrap: wrap; }
  .tbitem .body { flex-basis: calc(100% - 3.2rem); }
  .tbitem .r { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-left: 3.15rem; }
  .tbitem .tbtns { margin-top: 0; }
}
.fld[hidden] { display: none; }
.tagedit { grid-column: 1 / -1; display: grid; gap: .35rem; }
.tagedit label {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "cb tag sx" "cb who who"; gap: 0 .55rem; align-items: center;
  padding: .45rem .6rem; background: var(--paper-2); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 2px; cursor: pointer; color: var(--fg);
}
.tagedit label.m { border-left-color: var(--straw); }
.tagedit label.f { border-left-color: var(--flame); }
.tagedit label:has(input:checked) { border-color: var(--warn); background: var(--warn-soft); }
.tagedit label:has(input:checked) code { text-decoration: line-through; }
.tagedit input { grid-area: cb; }
.tagedit code { grid-area: tag; font-family: var(--mono); font-weight: 500; overflow-wrap: anywhere; }
.tagedit .sx { grid-area: sx; font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tagedit .who { grid-area: who; font-size: .85rem; }

/* ---------- Edit / Delete on list rows (Animals list) */
.list > li.arow { display: flex; align-items: center; gap: .35rem; }
.arow > .item { flex: 1; min-width: 0; }
.rowbtns { display: flex; gap: .2rem; flex: none; }
.rowbtns button { min-width: 36px; padding: .25rem .4rem; }
@media (max-width: 560px) { .rowbtns { flex-direction: column; } }

/* a form button switched off for this record type (e.g. "Save & add another" outside Show records) */
.sheet footer button[hidden] { display: none; }

/* ---------- printing a family tree (body.ptree is set while printing; see "beforeprint" in app.js) */
.printhead { display: none; }
/* a pedigree chart that reads left to right: each box, then its parents (or offspring) stacked to its right */
body.ptree .tree { overflow: visible; padding: 0; }
body.ptree .tree > .tn { min-width: 0; }
body.ptree .tn { flex-direction: row; align-items: center; }
body.ptree .tkids { flex-direction: column; align-items: flex-start; padding: 0 0 0 .9rem; }
body.ptree .tkids::before { top: 50%; left: 0; width: .9rem; height: 0; border-left: 0; border-top: 1.5px solid #777; }
body.ptree .tkids > .tn { padding: .12rem 0 .12rem .9rem; }
body.ptree .tkids > .tn::before { top: 50%; left: 0; width: .9rem; height: 0; border-left: 0; border-top: 1.5px solid #777; }
body.ptree .tkids > .tn::after { top: 0; bottom: 0; left: 0; right: auto; border-top: 0; border-left: 1.5px solid #777; }
body.ptree .tkids > .tn:first-child::after { top: 50%; left: 0; }
body.ptree .tkids > .tn:last-child::after { bottom: 50%; right: auto; }
body.ptree .tcell { width: 11rem; }
@media print {
  body.ptree .noprint, body.ptree main > .cols, body.ptree .top, body.ptree #nav, body.ptree #toast { display: none !important; }
  body.ptree main { padding: 0; margin: 0; max-width: none; }
  body.ptree main > .card { border: 0; padding: 0; margin: 0; background: #fff; box-shadow: none; }
  body.ptree .printhead { display: block; color: #000; font-size: 10pt; line-height: 1.35; margin: 0 0 .5rem; padding-bottom: .4rem; border-bottom: 1.5px solid #000; }
  body.ptree .printhead .ph-title { font-family: var(--display); font-size: 18pt; font-weight: 800; text-transform: uppercase; }
  body.ptree .tcell { background: #fff; color: #000; border-color: #999; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.ptree .tcell.m { border-left-color: #b8901f; } body.ptree .tcell.f { border-left-color: #c8471f; }
  body.ptree .tcell.m .ps { color: #8a6a10; } body.ptree .tcell.f .ps { color: #c8471f; }
  body.ptree .tcell small { color: #444; }
  body.ptree .tcell.unknown { opacity: 1; color: #777; }
  body.ptree .tcell.dup { background: #fbf1cf; box-shadow: none; border-color: #b8901f; }
}

/* record type buttons with no records of that type (Records / History pages) */
.chip.none { opacity: .5; }

/* band colors: a swatch like a leg band, the key on the Animals list, and the picker in forms */
.band { display: inline-block; width: .95em; height: .95em; border-radius: 50%; background: var(--bc); vertical-align: -.12em;
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .35); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.band.big { width: 1.9rem; height: 1.9rem; }
.bandkey { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: 0 0 .75rem; }
.bandkey .chip .muted { font-weight: 400; }
/* the band picker in forms: the chosen band's swatch beside it (a dashed ring when there's none) */
.bandpick { display: flex; align-items: center; gap: .5rem; }
.bandpick select { flex: 1; min-width: 0; }
.band.none { background: none; box-shadow: none; border: 1.5px dashed var(--muted); box-sizing: border-box; }
.bandpick .band, .bandcols .band { flex: none; }
/* picking a band's colors: a preview dot and up to 3 color-name drop-downs */
.bandcols { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.bandcols select { width: auto; min-width: 0; flex: 1 1 6.5rem; }
@media print {
  .noprint { display: none !important; }
  .bandcard { break-inside: avoid; }
  .bandcard .list li { border-color: #999; }
}

/* the footer shared with the public page (api.php builds it): logo and copyright on the left, Facebook on the right */
.sitefoot { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-block: 28px; color: var(--muted); font-size: 14px; }
.sitefoot .wrap { max-width: 1120px; margin: 0 auto; padding: 0 1rem; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.sitefoot .f { display: flex; gap: 12px; align-items: center; }
.sitefoot img { width: 44px; height: 44px; }
.sitefoot a { color: var(--flame-ink); }
@media print { .sitefoot { display: none !important; } }

/* narrow desktop widths: a little less room around each menu item, so all eight fit beside the crest */
@media (min-width: 800px) and (max-width: 899px) { .tabs a { padding-inline: .35rem; letter-spacing: .06em; } }

/* ---------- accounts: sign in / sign up / join, the farm's look, people */
.auth { max-width: 440px; margin: 2rem auto; }
.demobar { background: var(--chip); color: var(--chip-fg); text-align: center; font-size: .92rem; padding: .5rem 1rem; border-bottom: 1px solid var(--line); }
.demobar p { margin: 0; }
.demobar .demolocked { font-size: .82rem; margin-top: .15rem; }
/* fields the demo farm keeps as they are: shown, but not for typing in */
.fld.locked input, .fld.locked img { opacity: .6; cursor: not-allowed; }
.fld.locked input:focus { outline: none; border-color: var(--line); }
.locknote { margin: .5rem 0 0; }
button:disabled[title] { cursor: not-allowed; }
.demobar a { color: var(--flame-ink); font-weight: 600; white-space: nowrap; }
@media print { .demobar { display: none; } }
/* the pages before signing in are short: keep the footer at the bottom of the screen, not halfway up with empty space below */
.authpage { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.authpage main { flex: 1 0 auto; width: 100%; }
.auth .card { padding: 1.4rem 1.4rem 1.1rem; }
.authhead { display: grid; justify-items: center; gap: .4rem; margin-bottom: 1rem; text-align: center; }
/* the app's name under its barn icon, until a Pasturebook wordmark image is made */
.authhead .wordmark { display: grid; justify-items: center; gap: .2rem; }
.authhead .wordmark img { width: 96px; height: 96px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.authhead .wordmark span { font-family: var(--display); font-weight: 900; font-size: 2.4rem; line-height: 1; letter-spacing: .02em; text-transform: uppercase; color: var(--flame-ink); }
.authhead h1 { font-size: 2rem; margin: 0; }
.appname { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.authform { display: flex; flex-direction: column; gap: .8rem; margin: 1rem 0; }
.authform input:not([type=checkbox]) { width: 100%; }
.authform button[type=submit] { align-self: flex-start; min-width: 9rem; }
.authform .warnbox { margin: 0; }
.authalt { margin: .4rem 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }  /* a field only form-filling robots fill in */
.brand img.own { filter: none; object-fit: contain; border-radius: 4px; }
.farmhead { display: flex; gap: .8rem; align-items: center; margin-bottom: .6rem; overflow-wrap: anywhere; }
.farmhead img, .logopick img { width: 56px; height: 56px; object-fit: contain; flex: none; border-radius: 4px; }
.logopick { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.logopick img { width: 64px; height: 64px; border: 1px solid var(--line); background: var(--paper); padding: 2px; }
.swatches { display: flex; gap: .3rem; margin-top: .3rem; }
.sw { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid var(--line); vertical-align: middle; }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; }
.preset { display: inline-flex; align-items: center; gap: .25rem; }
.preset .sw:nth-child(2) { margin-left: -.55rem; margin-right: .2rem; }
.colorpick { display: flex; gap: .4rem; align-items: center; }
.colorpick input[type=color] { width: 3rem; height: 2.4rem; padding: 2px; flex: none; cursor: pointer; }
.colorpick input:not([type=color]) { flex: 1; min-width: 0; font-family: var(--mono); }
.tabs:empty { display: none; }  /* signed out: no menu */
body:has(.tabs:empty) { padding-bottom: 0; }
.logopick [hidden] { display: none; }

/* the forums (hosted): threads, posts and votes */
h1.ftitle { font-size: clamp(1.6rem, 4.5vw, 2.3rem); overflow-wrap: anywhere; }
.fbar { margin: .4rem 0 1rem; align-items: center; }
.fwrap { white-space: normal; overflow-wrap: anywhere; }
.item .ico.fvotes { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1rem; line-height: 1.1;
  border: 1px solid var(--line); border-radius: 2px; padding: .25rem 0; width: 3.2rem; }
.item .ico.fvotes b { font-size: 1.2rem; }
.item .ico.fvotes small { color: var(--muted); font-size: .7rem; white-space: nowrap; }
.fpost .fhead { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.fpost.team { border-left: 4px solid var(--flame); }
.fbody { overflow-wrap: anywhere; }
.fbody p { margin: .6rem 0 0; }
#freply { min-height: 7rem; }
.fpost .fhead .sp, .fpost + .card .row .sp, .card > .row .sp { flex: 1; }
/* the admin pages' tabs (an admin who also has a farm): links that look like the .seg buttons */
.seg a.btn { border: 0; border-radius: 0; min-height: 38px; white-space: nowrap; padding: .5rem .75rem; background: transparent; color: var(--fg);
  font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .1em; display: inline-flex; align-items: center; text-decoration: none; box-shadow: none; }
.seg a.btn.on { background: var(--band); color: var(--straw); }
