:root {
  color-scheme: light;
  --ink: #14221e;
  --muted: #465b53;
  --paper: #f2f5ee;
  --line: #d5ded5;
  --mint: #d9ecd8;
  --green: #204f3f;
  font-family: system-ui, "Noto Sans Thai", Tahoma, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.shell { width: min(100% - 32px, 760px); margin-inline: auto; }
.mast { background: var(--ink); color: #fff; }
.mast-inner { display: flex; align-items: center; gap: 14px; padding-block: 23px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; background: #cdecce; border-radius: 13px; color: var(--ink); font-size: 26px; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.35rem; line-height: 1.4; }
h2 { font-size: 1.18rem; line-height: 1.45; }
nav, .filters, .footer-actions { display: flex; gap: 8px; }
nav { margin-block: 20px 14px; background: #e4ebe3; padding: 4px; border-radius: 13px; }
nav button { flex: 1; }
button, input, select { font: inherit; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 10px; min-height: 44px; padding: 8px 14px; font-weight: 650; background: transparent; color: var(--green); }
button:disabled { opacity: .55; cursor: default; }
nav button[aria-pressed=true] { background: white; box-shadow: 0 1px 3px #14221e18; color: var(--ink); }
:focus-visible { outline: 3px solid #18704d; outline-offset: 3px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: clamp(16px, 4vw, 28px); margin-bottom: 12px; }
form { margin-top: 16px; }
label { display: block; font-weight: 650; font-size: .9rem; }
input, select { display: block; min-width: 0; width: 100%; border: 1px solid #b9c8be; border-radius: 9px; padding: 9px 10px; margin-top: 5px; color: var(--ink); min-height: 44px; background: white; font-size: 1rem; }
.weight-field { display: flex; align-items: center; background: #f8faf7; border: 1px solid #a6baaa; border-radius: 12px; margin-top: 5px; }
.weight-field:focus-within { outline: 2px solid #18704d; }
.weight-field input { border: 0; margin: 0; padding: 9px 12px; font-size: clamp(1.7rem, 7vw, 2.5rem); font-weight: 700; font-variant-numeric: tabular-nums; background: transparent; outline: none; }
.weight-field input::placeholder { color: #687c71; }
.weight-field span { padding: 0 13px; font-weight: 700; white-space: nowrap; color: var(--green); }
.hint, footer, .meta, .empty { color: var(--muted); font-size: .86rem; line-height: 1.55; }
.photo-area { margin-bottom: 12px; }
#photo-status:not(:empty) { margin-top: 6px; }
#photo-preview { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
#photo-thumb { display: block; max-width: min(100%, 200px); max-height: 160px; border-radius: 8px; }
#photo-dialog { width: min(calc(100% - 24px), 680px); max-height: calc(100% - 24px); border: 1px solid var(--line); border-radius: 14px; padding: 10px; color: var(--ink); }
#photo-dialog::backdrop { background: #14221ed9; }
.dialog-actions { text-align: right; }
#saved-photo { display: block; width: auto; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 8px; object-fit: contain; }
#photo-caption { margin-top: 8px; text-align: center; }
.time { margin-top: 8px; }
details { margin: 12px 0; }
summary { cursor: pointer; font-size: .9rem; font-weight: 650; color: var(--green); padding: 8px 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fields { margin-block: 8px 12px; }
.wide { width: 100%; }
.primary { background: var(--green); color: #fff; min-height: 51px; }
.secondary { border-color: #9fb5a7; }
.quiet:hover, .secondary:hover, .filters button:hover { background: #e9f2e8; }
.primary:hover:not(:disabled) { background: #143d2f; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-head .quiet { padding-inline: 7px; }
.records { list-style: none; padding: 0; margin: 4px 0 0; }
.record { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.record b { display: block; overflow-wrap: anywhere; }
.record .meta { overflow-wrap: anywhere; }
.record .photo-link { padding-inline: 0; font-size: .86rem; text-decoration: underline; }
.record-actions { display: flex; flex-shrink: 0; }
.record-actions button { padding-inline: 8px; font-size: .83rem; }
.record-actions .danger { color: #9b302a; }
.empty { padding-block: 12px 3px; }
.filters { flex-wrap: wrap; margin: 12px 0; }
.filters button { border-color: var(--line); padding-inline: 10px; }
.filters button[aria-pressed=true] { background: var(--mint); border-color: #94ad98; }
.kind-filter { margin-bottom: 12px; }
.total { background: var(--mint); border-radius: 13px; padding: 14px; color: #244837; overflow-wrap: anywhere; }
.total strong { font-size: clamp(1.9rem, 8vw, 3.2rem); color: var(--ink); }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-block: 12px; }
.metrics > div { background: var(--paper); border-radius: 10px; padding: 10px; }
dt { color: var(--muted); font-size: .85rem; }
dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .88rem; }
th, td { text-align: right; border-bottom: 1px solid var(--line); padding: 7px 2px; overflow-wrap: anywhere; }
th:first-child, td:first-child { text-align: left; }
footer { padding: 6px 4px 18px; }
.footer-actions { flex-wrap: wrap; }
.toast { position: fixed; bottom: 16px; left: 50%; translate: -50% 0; width: max-content; max-width: calc(100% - 24px); background: var(--ink); color: #fff; padding: 10px 15px; border-radius: 10px; z-index: 2; pointer-events: none; }
.toast:empty { clip-path: inset(50%); }
.error { color: #9b302a; margin-block: 7px; }
@media (max-width: 350px) { #optional .grid { grid-template-columns: 1fr; } }
