* {
  box-sizing:border-box
}
body {
  margin: 0;
  background: #eff4f1;
  color: #203b34;
  font: 15px/1.6 system-ui,-apple-system,'Microsoft YaHei',sans-serif;
}
main {
  max-width: 780px;
  margin: auto;
  padding: 20px 16px 100px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
h1 {
  font-size: 29px;
  margin: 0;
}
h2 {
  font-size: 21px;
  margin: 0 0 12px;
}
h3 {
  font-size: 16px;
  margin: 12px 0 6px;
}
p {
  margin:6px 0
}
small,.muted {
  color: #60746b;
  font-size: 12px;
}
.card {
  background: white;
  border: 1px solid #dce6df;
  border-radius: 20px;
  padding: 18px;
  margin: 14px 0;
  box-shadow: 0 3px 12px #203b3407;
}
button,input,select,textarea {
  font:inherit
}
button {
  cursor: pointer;
  border: 1px solid #cadbd0;
  border-radius: 12px;
  padding: 9px 14px;
  background: white;
  color: #284e42;
}
button.primary {
  background: #286b58;
  color: white;
  border-color: #286b58;
}
button.danger {
  color:#a03a38
}
button:focus-visible,input:focus-visible,select:focus-visible {
  outline:3px solid #88b9a6
}
input,select,textarea {
  width: 100%;
  border: 1px solid #cddbd2;
  border-radius: 10px;
  padding: 9px;
  background: #fff;
  color: inherit;
}
label {
  display: block;
  margin: 10px 0 4px;
  font-weight: 600;
}
textarea {
  resize:vertical
}
nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  background: #fff;
  border-top: 1px solid #dce6df;
  padding: 9px 3px max(9px,env(safe-area-inset-bottom));
  z-index: 9;
}
nav button {
  flex: 1;
  max-width: 140px;
  border: 0;
  font-size: 12px;
  padding: 7px 2px;
}
nav button.on {
  background: #e1f0e8;
  color: #286b58;
  font-weight: 700;
}
section[hidden],div[hidden] {
  display:none!important
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.row>* {
  flex: 1;
  min-width: 0;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
}
.stat {
  padding: 12px;
  background: #f0f6f2;
  border-radius: 12px;
}
.num {
  font-size: 28px;
  font-weight: 700;
}
.stools {
  display: grid;
  grid-template-columns: repeat(2,1fr);
  gap: 8px;
}
.stool {
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 76px;
  padding: 7px;
}
.stool svg {
  width: 76px;
  min-width: 55px;
}
.stool.chosen {
  background: #e1f0e8;
  border: 2px solid #438f78;
}
.stool span {
  font-size:12px
}
.alert {
  border-radius: 13px;
  padding: 12px;
  background: #f0f5f2;
  margin: 8px 0;
}
.l1 {
  background: #fff3d9;
  color: #795311;
}
.l2 {
  background: #ffebd9;
  color: #913c10;
}
.l3 {
  background: #fce5e3;
  color: #9d2824;
}
.entry {
  border-top: 1px solid #e5ece7;
  padding: 10px 0;
}
.tag {
  display: inline-block;
  border-radius: 20px;
  padding: 3px 9px;
  background: #edf3ef;
  font-size: 12px;
  margin: 2px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.check input {
  width: auto;
  accent-color: #286b58;
}
.calendar {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  gap: 5px;
}
.day {
  font-size: 12px;
  min-height: 49px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.day.selected {
  outline:2px solid #286b58
}
.split {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
a {
  color:#286b58
}
details {
  margin:8px 0
}
summary {
  cursor:pointer
}
#toast {
  position: fixed;
  bottom: 75px;
  left: 50%;
  transform: translateX(-50%);
  background: #203b34;
  color: white;
  padding: 10px 18px;
  border-radius: 12px;
  z-index: 12;
  max-width: 90%;
  font-size: 13px;
}
@media(min-width:650px) {
  .stools {
    grid-template-columns:repeat(3,1fr)
  }
}
dialog {
  border: 1px solid #dce6df;
  border-radius: 22px;
  width: min(680px,calc(100% - 24px));
  max-height: 88dvh;
  padding: 0;
  color: #203b34;
  background: #fff;
  box-shadow: 0 12px 60px #203b3430;
}
dialog::backdrop {
  background:#162c2480
}
.dialoghead {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 16px 18px;
  border-bottom: 1px solid #dce6df;
  z-index: 1;
}
.dialogbody {
  padding:0 18px 18px
}
.risklink {
  width: 100%;
  text-align: left;
  background: #f0f6f2;
  border: 1px solid #dce6df;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.timeline {
  border-left: 2px solid #b6d4c4;
  padding-left: 14px;
  margin: 12px 0 12px 6px;
}
.step {
  position: relative;
  padding: 5px 0 14px;
  overflow-wrap: anywhere;
}
.step:before {
  content: '';
  position: absolute;
  left: -20px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #438f78;
  border: 2px solid white;
}
.step p {
  white-space:pre-wrap
}
.stepedit {
  padding: 12px;
  border: 1px solid #dce6df;
  border-radius: 12px;
  margin: 8px 0;
}
.caseblock {
  border: 1px solid #dce6df;
  border-radius: 15px;
  padding: 12px;
  margin: 12px 0;
}
.risklink:hover {
  border-color:#438f78
}
.factor-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 12px 0;
}
.factor-legend span::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: #397c68;
  margin-right: 5px;
}
.factor-legend span + span::before,
.factor-recorded {
  background: #b5c8be;
}
.factor-history {
  margin: 0;
  border-top: 1px solid #e5ece7;
}
.factor-history summary {
  min-height: 48px;
  padding: 9px 0;
}
.factor-heading {
  display: inline-flex;
  vertical-align: middle;
  width: calc(100% - 24px);
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.factor-heading small { flex-shrink: 0; }
.factor-bar {
  display: flex;
  height: 7px;
  margin: 6px 0 2px 16px;
  background: #edf3ef;
  border-radius: 8px;
  overflow: hidden;
}
.factor-matched { background: #397c68; }
.food-category h4 {
  margin: 14px 0 6px;
  font-size: 14px;
}
.food-bar-alert { --food-bar: #906529; }
.food-bar-quiet { --food-bar: #397c68; }
.food-bar-unknown { --food-bar: #a9b5af; }
.factor-bar > [class^="food-bar-"],
.food-legend span[class^="food-bar-"]::before { background: var(--food-bar); }
.factor-dates ol {
  list-style: none;
  padding: 0 0 0 16px;
  margin: 0 0 12px;
}
.factor-dates button {
  width: 100%;
  min-height: 44px;
  margin: 3px 0;
  text-align: left;
}
.factor-dates button span {
  display: block;
  font-size: 13px;
}
.food-edit {
  border: 1px solid #dce6df;
  border-radius: 12px;
  padding: 0 10px;
  background: #f0f6f2;
}
.food-edit summary {
  min-height: 44px;
  padding: 10px 0;
}
.food-edit summary small { margin-left: 4px; }
.trendranges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.trendranges button {
  flex: 1;
  min-width: 44px;
  padding: 8px 5px;
  font-size: 13px;
}
.trendranges button.active {
  background: #286b58;
  color: white;
  border-color: #286b58;
}
#trendDaySlider {
  accent-color: #286b58;
  padding: 0;
}
#trendSvg {
  margin-top:8px
}
#trendSelected p {
  margin:2px 0
}
@media(max-width:420px) {
  #trendSelected .split {
    align-items: flex-start;
    flex-direction: column;
  }
  #trendstats .num {
    font-size:22px
  }
}

[hidden] { display: none !important; }
html { overflow-wrap: anywhere; }
main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
header { gap: 8px; }
nav button { min-width: 0; min-height: 44px; }
button { max-width: 100%; }
:focus-visible { outline: 3px solid #438f78; outline-offset: 2px; }
button:disabled { opacity: .68; cursor: default; }
input, textarea, select, .split > *, .stool > * { min-width: 0; }
input[type="checkbox"] { min-width: 20px; min-height: 20px; }
.check { min-height: 38px; cursor: pointer; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stools { grid-auto-columns: minmax(0, 1fr); }
.stool svg { width: 45%; max-width: 76px; min-width: 39px; flex: 0 0 auto; }
.stools button { min-width: 0; }
.day { min-height: 44px; }
.calendar { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day-index { font-weight: 700; }
.day small { color: inherit; line-height: 1.15; white-space: nowrap; }
.day.unknown { background: #f5f5f5; color: #55655d; }
.day.l0 { background: #e1f0e8; }
.day small + small { font-size: 10px; }
#startup, #storageError, #pwaBanner { margin: 12px 0; }
#toast { bottom: calc(76px + env(safe-area-inset-bottom)); width: max-content; white-space: pre-line; }
#trendDaySlider { min-height: 32px; }
.entry p, .caseblock p { white-space: pre-line; }
.risklink small { flex: 0 1 auto; }
fieldset { border: 0; padding: 0; margin: 10px 0; min-width: 0; }
legend { font-weight: 600; padding: 0; }
#riskDialog [data-action="closeRisk"] { flex-shrink: 0; }
@media (max-width: 420px) {
  .day small { font-size: 10px; }
}
@media (max-width: 380px) {
  main { padding-left: 10px; padding-right: 10px; }
  .card { padding: 13px; }
  .stat { padding: 8px; }
  .calendar { gap: 3px; }
  .day { padding: 2px; }
}
