:root {
  font-family:
    -apple-system, BlinkMacSystemFont, "Noto Sans TC", "Microsoft JhengHei",
    sans-serif;
  color: var(--text);
  background: var(--paper);
  font-size: 18px;
  line-height: 1.65;
  --brand-primary: #145c50;
  --brand-secondary: #d5a743;
  --brand-leaf: #72a889;
  --text: #203d35;
  --paper: #f7faf8;
  --surface: #ffffff;
  --soft: #eaf3ee;
  --muted: #53675e;
  --border: #cedbd3;
  --input-border: #7c9285;
  --focus: #8b6518;
  --danger: #a13125;
  --danger-soft: #fff1ee;
  --danger-text: #82291e;
  --danger-border: #d5a8a2;
  --grain-soft: #f7efd9;
  --preview-surface: #edf2ee;
  --chart: var(--brand-primary);
  --overlay: #203d3570;
  --green: var(--brand-primary);
  --red: var(--danger);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button,
.button {
  border: 1px solid var(--green);
  background: var(--green);
  color: var(--surface);
  min-height: 50px;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  gap: 8px;
}
button.secondary,
.button.secondary {
  background: var(--surface);
  color: var(--green);
}
button.danger {
  background: var(--red);
  border-color: var(--red);
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
a {
  color: var(--green);
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}
h1,
h2,
h3,
p {
  margin: 0 0 16px;
}
h1 {
  font-size: 30px;
  line-height: 1.3;
}
h2 {
  font-size: 23px;
  line-height: 1.4;
}
h3 {
  font-size: 20px;
}
small,
.muted {
  color: var(--muted);
}
small {
  font-size: 15px;
}
label {
  display: block;
  font-weight: 650;
  margin: 14px 0 6px;
}
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
}
input[type="checkbox"],
input[type="radio"] {
  width: 23px;
  height: 23px;
  vertical-align: middle;
  accent-color: var(--green);
  flex-shrink: 0;
}
textarea {
  min-height: 115px;
  resize: vertical;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 16px 0;
}
legend {
  font-weight: 700;
}
form {
  max-width: 760px;
}
.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-weight: 400;
}
.topbar {
  height: 92px;
  padding: 18px max(24px, calc((100vw - 1380px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  font-weight: 800;
  font-size: 23px;
  line-height: 1.2;
}
.brand small {
  display: block;
  font-size: 13px;
  margin-top: 7px;
  letter-spacing: 0.08em;
}
.brand-mark {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex-shrink: 0;
}
#connection {
  font-size: 14px;
  color: var(--muted);
}
.shell {
  display: flex;
  max-width: 1380px;
  margin: auto;
  min-height: calc(100vh - 92px);
}
#nav {
  width: 210px;
  flex-shrink: 0;
  padding: 24px 18px;
}
#nav a {
  display: block;
  padding: 13px 16px;
  text-decoration: none;
  border-radius: 9px;
  margin-bottom: 5px;
  font-size: 17px;
  font-weight: 600;
}
#nav a.active {
  background: var(--green);
  color: var(--surface);
}
main {
  padding: 32px 36px 70px;
  width: 100%;
  min-width: 0;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 25px;
}
.page-head p {
  color: var(--muted);
  margin: 8px 0 0;
}
.section {
  background: var(--surface);
  padding: 25px;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 22px;
}
.section.flat {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: 25px 0;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
.grid > .section {
  margin: 0;
}
.stack {
  display: grid;
  gap: 14px;
}
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.notice {
  padding: 16px 18px;
  border-left: 4px solid var(--green);
  background: var(--soft);
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
}
.error {
  border-color: var(--red);
  background: var(--danger-soft);
  color: var(--danger-text);
}
.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--muted);
}
.loading {
  padding: 45px 20px;
  text-align: center;
}
.loading:before {
  content: "";
  display: block;
  margin: 0 auto 16px;
  width: 30px;
  height: 30px;
  border: 4px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.meal-plate {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  background: var(--surface);
  border: 7px solid var(--surface);
  border-radius: 28px;
  aspect-ratio: 1;
  max-width: 310px;
  overflow: hidden;
  margin: 10px auto;
  box-shadow: 0 0 0 2px var(--border);
}
.plate-part {
  background: var(--soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 18px;
  line-height: 1.5;
  padding: 10px 4px;
}
.plate-part span {
  max-width: 2em;
  overflow-wrap: anywhere;
}
.plate-part:nth-child(2n) {
  background: var(--grain-soft);
}
.plate-part b {
  font-size: 21px;
}
.hero {
  background: var(--soft);
  border: 0;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
  align-items: center;
  padding: 30px;
}
.metric {
  font-size: 38px;
  font-weight: 800;
  color: var(--green);
  line-height: 1.3;
}
.metric span {
  font-size: 17px;
  font-weight: 500;
}
.metrics {
  display: flex;
  gap: 25px;
  flex-wrap: wrap;
  margin: 22px 0;
}
.meal-row {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.meal-row:last-child {
  border: 0;
}
.row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 7px;
  background: var(--soft);
  font-size: 14px;
  color: var(--green);
}
.preview {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--preview-surface);
}
.choice {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.choice label {
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0;
  flex: 1;
  min-width: 90px;
}
.trend {
  display: flex;
  align-items: flex-end;
  height: 170px;
  gap: 9px;
  padding-top: 20px;
}
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: center;
  height: 100%;
  font-size: 13px;
}
.trend-bar {
  background: var(--chart);
  border-radius: 5px 5px 0 0;
  min-height: 2px;
}
.sources {
  font-size: 15px;
  overflow-wrap: anywhere;
}
.answer {
  overflow-wrap: anywhere;
}
.welcome {
  max-width: 770px;
  margin: auto;
}
.welcome h1 {
  font-size: 38px;
  margin-top: 12px;
}
.welcome .meal-plate {
  width: 230px;
}
.welcome-header {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 20px;
  align-items: center;
}
.skip {
  position: fixed;
  top: -60px;
  left: 20px;
  background: var(--surface);
  padding: 8px;
  z-index: 20;
}
.skip:focus {
  top: 8px;
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: 10px;
  z-index: 20;
  max-width: 90vw;
  display: none;
}
#toast.show {
  display: block;
}
dialog {
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  width: min(550px, calc(100vw - 30px));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 25px;
}
dialog::backdrop {
  background: var(--overlay);
}
.danger-zone {
  border-color: var(--danger-border);
}
.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}
progress {
  width: 100%;
  height: 14px;
  accent-color: var(--green);
}
.care-picker {
  max-width: 260px;
}
.mono {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 760px) {
  .topbar {
    height: 79px;
    padding: 12px 18px;
  }
  .brand {
    font-size: 20px;
  }
  .brand-mark {
    width: 44px;
    height: 44px;
  }
  #connection {
    max-width: 85px;
    text-align: right;
    font-size: 12px;
  }
  .shell {
    display: block;
  }
  main {
    padding: 24px 18px 115px;
  }
  #nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 10;
    padding: 7px 3px calc(7px + env(safe-area-inset-bottom));
  }
  #nav a {
    font-size: 14px;
    padding: 10px 7px;
    margin: 0;
    text-align: center;
  }
  #nav a.extra {
    display: none;
  }
  .grid,
  .hero,
  .welcome-header {
    grid-template-columns: 1fr;
  }
  .section {
    padding: 20px;
  }
  .hero {
    gap: 7px;
  }
  .hero .meal-plate {
    width: 235px;
  }
  .welcome-header .meal-plate {
    display: none;
  }
  .welcome h1 {
    font-size: 31px;
  }
  .page-head {
    display: block;
  }
  .page-head .care-picker {
    margin-top: 14px;
    max-width: none;
  }
  h1 {
    font-size: 27px;
  }
  .inline-fields {
    grid-template-columns: 1fr;
  }
  .row {
    flex-wrap: wrap;
  }
  .actions > button,
  .actions > .button {
    flex: 1 1 140px;
  }
  .metric {
    font-size: 33px;
  }
  #toast {
    bottom: 95px;
  }
  .plate-part {
    font-size: 18px;
  }
  .metrics {
    gap: 22px;
  }
  .choice label {
    font-size: 16px;
    padding: 10px 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

.date-filter {
  max-width: 235px;
  margin-bottom: 20px;
}
.date-filter label {
  font-size: 15px;
  margin: 0 0 5px;
}

.trend-col > span:last-child {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 760px) {
  .trend {
    gap: 5px;
  }
}
