/* Survival Next Door calculators. Relies on the site's :root tokens. Dark card on --deep, lamp gold only on dark grounds. */
.snd-tool {
  --snd-field: #6f7f8f; /* input border: 3:1+ against --night and --dusk */
  background: var(--dusk);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: clamp(1.1rem, 4vw, 2rem);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.5;
  max-width: 46rem;
  margin-inline: auto;
  overflow-wrap: anywhere;
}
.snd-tool *, .snd-tool *::before, .snd-tool *::after { box-sizing: border-box; }
.snd-tool [hidden] { display: none !important; }
.snd-tool__title, .snd-result__h {
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 1.25rem;
}
.snd-tool__title { font-size: clamp(1.5rem, 5vw, 2rem); }
.snd-result__h { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }

.snd-form { display: grid; gap: 1.25rem; margin: 0; }
.snd-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); }
.snd-field { display: grid; gap: .4rem; min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.snd-field { gap: .6rem; }
.snd-field > label, .snd-field > legend, .snd-person > legend {
  font-weight: 700;
  color: var(--paper);
  padding: 0;
}
.snd-field > legend { margin-bottom: .6rem; font-family: var(--display); font-size: 1.15rem; font-weight: 800; }
.snd-sublabel { color: var(--mist); font-size: .95rem; margin: .25rem 0 0; }
.snd-note { color: var(--mist); font-size: .95rem; margin: 0; }
.snd-note:empty { display: none; }

.snd-tool input[type="number"], .snd-tool input[type="text"], .snd-tool select {
  width: 100%;
  min-height: 48px;
  padding: .6rem .8rem;
  font: inherit;
  font-size: 1.0625rem; /* 17px: stops iOS zoom on focus */
  color: var(--paper);
  background: var(--night);
  border: 2px solid var(--snd-field);
  border-radius: calc(var(--r) - 6px);
}
.snd-tool select {
  appearance: none;
  padding-right: 2.5rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--mist) 50%), linear-gradient(135deg, var(--mist) 50%, transparent 50%);
  background-position: calc(100% - 1.2rem) 50%, calc(100% - .85rem) 50%;
  background-size: .35rem .35rem;
  background-repeat: no-repeat;
}
.snd-tool input:disabled { opacity: .55; cursor: not-allowed; }
.snd-tool ::placeholder { color: var(--mist); opacity: .8; }

.snd-tool :is(input, select, button):focus-visible {
  outline: 3px solid var(--lamp);
  outline-offset: 2px;
}

/* chips (presets) */
.snd-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.snd-chip, .snd-btn {
  min-height: 48px;
  padding: .55rem 1rem;
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.snd-chip { color: var(--paper); background: transparent; border: 2px solid var(--snd-field); }
.snd-chip:hover { border-color: var(--mist); }
.snd-chip[aria-pressed="true"] { background: var(--lamp); color: var(--night); border-color: var(--lamp); }
.snd-btn { color: var(--night); background: var(--lamp); border: 2px solid var(--lamp); }
.snd-btn:hover { background: var(--paper); border-color: var(--paper); }
.snd-btn--ghost { color: var(--paper); background: transparent; border-color: var(--snd-field); }
.snd-btn--ghost:hover { background: var(--deep); border-color: var(--mist); }

/* checkbox rows */
.snd-check { display: flex; align-items: center; gap: .75rem; min-height: 48px; cursor: pointer; font-weight: 400; }
.snd-check input { width: 1.6rem; height: 1.6rem; flex: none; margin: 0; accent-color: var(--tick); cursor: pointer; }

/* editable rows (power devices, food mix) */
.snd-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.snd-row {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 7rem), 1fr));
  align-items: end;
  padding: 1rem;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 4px);
}
.snd-row__name, .snd-row__mode { grid-column: 1 / -1; }
.snd-row__wh { grid-column: 1 / -1; margin: 0; color: var(--tick); font-weight: 700; }
.snd-row__rm { justify-self: start; }
@media (min-width: 40rem) {
  .snd-row { grid-template-columns: 2fr 2fr 1fr 1fr; }
  .snd-row__name, .snd-row__mode { grid-column: auto; }
  .snd-row__wh { grid-column: 1 / 4; align-self: center; }
  .snd-row__rm { grid-column: 4; justify-self: end; }
  .snd-row--food { grid-template-columns: 3fr 1fr 1fr; }
}

/* results */
.snd-result {
  margin-top: 1.75rem;
  padding: clamp(1rem, 4vw, 1.5rem);
  background: var(--night);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 4px);
}
.snd-stats { display: flex; flex-wrap: wrap; gap: 1rem 2rem; }
.snd-stat { margin: 0; display: grid; }
.snd-stat__n {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.5rem, 11vw, 3.75rem);
  line-height: 1;
  color: var(--lamp);
  font-variant-numeric: tabular-nums;
}
.snd-stat__l { color: var(--mist); font-size: .95rem; }
.snd-summary { margin: 1.25rem 0 0; font-size: 1.125rem; font-weight: 700; }
.snd-summary:empty { display: none; }
.snd-maths { margin: .75rem 0 0; padding: 0; list-style: none; color: var(--mist); font-size: .95rem; display: grid; gap: .25rem; }
.snd-shop { margin: 0 0 1rem; padding: 0; list-style: none; display: grid; gap: .5rem; }
.snd-shop__n { font-family: var(--display); font-weight: 900; font-size: 1.5rem; color: var(--lamp); font-variant-numeric: tabular-nums; }
.snd-shop__why { color: var(--mist); font-size: .9rem; }
.snd-result .snd-note + .snd-note { margin-top: .5rem; }

/* go-bag */
.snd-people { display: grid; gap: 1rem; margin-top: 1.5rem; }
.snd-person {
  margin: 0;
  padding: 1rem 1rem 1.25rem;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 4px);
  min-width: 0;
}
.snd-person > legend { font-family: var(--display); font-size: 1.25rem; font-weight: 800; padding: 0 .4rem; }
.snd-person__type { color: var(--mist); font-family: var(--body); font-size: 1rem; font-weight: 400; }
.snd-person__progress { margin: 0 0 .5rem; color: var(--tick); font-weight: 700; }
.snd-checklist { list-style: none; margin: 0 0 1rem; padding: 0; }
.snd-checklist li + li { border-top: 1px solid var(--line); }
.snd-actions { margin-top: 1.5rem; }
.snd-form[data-add] { margin-top: 1rem; }
.snd-form[data-add] .snd-btn { justify-self: start; }
.snd-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  .snd-chip, .snd-btn { transition: none; }
}

@media print {
  /* When printed from a tool's own button, hide everything on the page except that tool. */
  html.snd-print-mode body *:not(.snd-printing, .snd-printing *, :has(.snd-printing)) { display: none !important; }
  html.snd-print-mode, html.snd-print-mode body, html.snd-print-mode :has(.snd-printing) {
    background: #fff !important; color: #000 !important; margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important;
  }
  html.snd-print-mode { color-scheme: light; }
  .snd-tool { color-scheme: light; background: #fff; color: #000; border: 0; padding: 0; max-width: none; font-size: 11pt; }
  .snd-tool .snd-noprint { display: none !important; }
  .snd-tool__title, .snd-person > legend, .snd-person__type, .snd-person__progress, .snd-note { color: #000; }
  .snd-person { background: #fff; border: 1px solid #000; break-inside: avoid; margin-bottom: 1rem; }
  .snd-checklist li + li { border-top: 1px solid #ccc; }
  .snd-check { min-height: 0; padding: .2rem 0; }
  .snd-check input { accent-color: #000; width: 1rem; height: 1rem; }
  .snd-result { background: #fff; border: 1px solid #000; }
  .snd-stat__n, .snd-shop__n { color: #000; }
}
