:root {
  color-scheme: light;
  font-family: "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  color: #202a25;
  background: #f6f6ef;
  --surface: #fffefa;
  --line: #e4e7dc;
  --muted: #59665c;
  --green: #214d3b;
  --green-deep: #163b2c;
  --sage: #e8eee2;
  --mint: #e4efe4;
  --amber: #f8eddb;
  --blue: #e4edf1;
  --danger: #a02e29;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid #397356; outline-offset: 3px; }
[hidden] { display: none !important; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p { margin: 0; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.auth-shell { display: grid; min-height: 100dvh; place-items: center; padding: 20px 14px; }
.auth-card { width: min(100%, 424px); padding: clamp(20px, 5vw, 34px); box-shadow: 0 12px 45px #214d3b0c; }
.auth-brand { margin: 0 0 24px; }
.auth-card h1 { font-size: 1.65rem; }
.auth-description { margin-top: 6px; color: var(--muted); font-size: .86rem; line-height: 1.6; }
.auth-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 19px 0 17px; background: #eef1e9; border-radius: 9px; }
.auth-switch .button { min-height: 38px; }
.auth-switch [aria-pressed="true"] { background: var(--surface); border-color: var(--line); box-shadow: 0 1px 2px #214d3b14; }
.auth-fields.fields { grid-template-columns: 1fr; }
.auth-status { margin-top: 12px; }
#auth-submit, #passkey-login, .auth-demo .button { width: 100%; }
#auth-submit { margin-top: 16px; }
#passkey-login { margin-top: 8px; }
.auth-demo { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }

.layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { display: flex; flex-direction: column; position: sticky; top: 0; align-self: start; min-height: 100dvh; padding: 29px 16px 20px; background: #eeefe6; border-right: 1px solid #e0e4d8; }
.brand { display: flex; align-items: center; gap: 12px; margin: 2px 9px 50px; color: #203e31; font-weight: 800; font-size: 1.27rem; letter-spacing: .035em; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: #fff; background: var(--green); flex: none; }
.brand-mark .icon { width: 25px; height: 25px; }
.brand small { display: block; color: var(--muted); font-size: .68rem; font-weight: 600; margin-top: 1px; white-space: nowrap; }
.nav { display: grid; gap: 5px; }
.nav-label { color: var(--muted); font-size: .73rem; font-weight: 700; padding: 0 12px 9px; letter-spacing: .06em; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 12px 13px; border-radius: 9px; font-size: .89rem; font-weight: 650; color: #44554a; }
.nav a:hover { background: #e7ebe0; }
.nav a[aria-current="page"] { color: var(--green-deep); background: #dae7d9; font-weight: 800; }
.sidebar-note { display: grid; gap: 9px; margin: auto 3px 0; padding: 15px 12px 2px; border-top: 1px solid #dce1d5; color: var(--muted); }
.sidebar-note .icon { color: var(--green); }
.sidebar-note p { font-size: .72rem; line-height: 1.8; }

.main { max-width: 1500px; width: 100%; margin-inline: auto; padding: 25px clamp(24px, 3.4vw, 52px) 40px; }
.topline { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid #e0e4d9; padding: 0 0 18px; color: var(--muted); font-size: .8rem; font-weight: 700; }
#today { display: flex; align-items: center; gap: 7px; white-space: nowrap; flex: none; }
#today .icon { width: 17px; height: 17px; color: #607463; }
#open-settings { min-height: 36px; padding: 5px 12px; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 31px 0 26px; }
.page-header h1 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); letter-spacing: .035em; line-height: 1.2; font-weight: 800; }
.page-header h1:focus { outline: none; }
.page-header p { color: var(--muted); font-size: .88rem; margin-top: 10px; line-height: 1.65; }
.demo-banner { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 9px 13px; margin-top: 15px; border: 1px solid #ebdfc8; border-radius: 8px; color: #724c17; background: #fbf2e1; font-size: .76rem; font-weight: 750; }
.demo-banner span { font-weight: 550; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: none; padding: 9px 14px; min-height: 42px; border-radius: 8px; border: 1px solid transparent; font-size: .83rem; font-weight: 750; white-space: nowrap; }
.button .icon { width: 17px; height: 17px; }
.primary { background: var(--green); color: #fff; border-color: var(--green); }
.primary:hover:not(:disabled) { background: var(--green-deep); }
.secondary { background: var(--surface); border-color: #dce2d6; color: var(--green); }
.secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: var(--sage); }
.quiet { background: transparent; color: var(--green); }
.danger-text { color: var(--danger); }
.destructive { background: #a02e29; color: #fff; }
.destructive:hover:not(:disabled) { background: #81221e; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 23px; }
.stat { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; padding: 17px 19px 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.stat:hover { border-color: #a3b5a5; }
.stat-top { display: flex; align-items: center; justify-content: space-between; width: 100%; color: #62746b; }
.stat-top > .icon { width: 16px; height: 16px; }
.tile { display: inline-grid; place-items: center; border-radius: 9px; width: 40px; height: 40px; flex: none; }
.mint.tile, .mint .tile, .tile.food { background: var(--mint); color: #305a43; }
.amber.tile, .amber .tile { background: var(--amber); color: #815115; }
.blue.tile, .blue .tile, .tile.water { background: var(--blue); color: #315f73; }
.plain.tile, .tile.daily { background: #eeeae0; color: #665b43; }
.tile.other { background: #ede7ef; color: #655070; }
.danger.tile { background: #f8e7e4; color: var(--danger); }
img.tile { display: block; object-fit: cover; }
.stat-title { color: #37483d; font-weight: 750; font-size: .88rem; margin-top: 12px; }
.stat strong { display: block; font-size: 2.12rem; font-variant-numeric: tabular-nums; line-height: 1.24; letter-spacing: -.035em; }
.stat strong span { color: var(--muted); font-weight: 650; font-size: .75rem; margin-left: 7px; letter-spacing: 0; }
.stat small { margin-top: 4px; font-size: .73rem; color: var(--muted); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(270px, 1fr); align-items: start; gap: 19px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 20px 19px 15px; }
.panel-header h2 { font-size: 1.14rem; line-height: 1.3; }
.panel-header p { margin-top: 5px; color: var(--muted); font-size: .76rem; }
.search { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 198px; padding: 0 9px; border: 1px solid #e0e4d9; border-radius: 8px; background: #f8f9f4; color: var(--muted); }
.search .icon { width: 17px; height: 17px; }
.search input { width: 100%; min-width: 0; padding: 8px 0; border: 0; background: transparent; color: #25352c; font-size: .78rem; }
.search:focus-within { outline: 2px solid #397356; outline-offset: 2px; }
.search input:focus-visible { outline: none; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 19px 13px; }
.filters button { padding: 6px 10px; color: var(--muted); background: transparent; border: 1px solid #e5e8de; border-radius: 7px; font-size: .76rem; font-weight: 700; }
.filters button[aria-pressed="true"] { color: var(--green); background: var(--mint); border-color: #cfe1ce; }
.filters button:hover { border-color: #a6b7a6; }
.rows { padding: 0 19px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 9px 0; border-top: 1px solid #ebede5; }
.row-link { flex: 1; display: flex; align-items: center; text-align: left; gap: 10px; min-width: 0; padding: 0; color: inherit; background: none; border: none; }
.row-link:hover strong { color: #21604a; text-decoration: underline; text-underline-offset: 3px; }
.row .tile { width: 35px; height: 35px; }
.row .tile .icon { width: 18px; height: 18px; }
.row-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-copy strong, .row-copy small, .quantity strong, .quantity small, .list-expiry strong, .list-expiry small { display: block; }
.row-copy strong { font-size: .86rem; }
.row-copy small, .quantity small, .list-expiry small { color: var(--muted); font-size: .7rem; margin-top: 3px; }
.separator { margin-inline: 2px; }
.quantity { min-width: 66px; max-width: 9rem; text-align: right; overflow-wrap: anywhere; }
.quantity strong { font-size: .91rem; }
.unit { font-size: .8em; font-weight: 600; }
.list-expiry { min-width: 81px; text-align: right; }
.list-expiry strong { font-size: .75rem; }
.row-arrow { padding: 7px 2px; min-height: 34px; }
.panel-footer { padding: 14px 19px 16px; border-top: 1px solid #ebede5; }
.panel-footer a { display: inline-flex; gap: 7px; align-items: center; color: var(--green); font-size: .78rem; font-weight: 750; }
.panel-footer a:hover { text-decoration: underline; }
.panel-footer .icon { width: 15px; height: 15px; }
.tag { border-radius: 6px; white-space: nowrap; font-weight: 750; padding: 5px 7px; font-size: .72rem; flex: none; }
.tag.amber { background: var(--amber); color: #744914; }
.tag.plain { background: #edf0e8; color: #4b5d51; }
.tag.mint { background: var(--mint); color: var(--green); }
.tag.danger { background: #f8e7e4; color: var(--danger); }
.guide-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 0 19px 16px; }
.guide-controls label { display: flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 750; }
.guide-controls input { width: 4.6rem; min-height: 38px; border: 1px solid #dbe2d7; border-radius: 7px; padding: 6px 9px; color: #24382d; background: #fff; font-weight: 650; text-align: right; }
.guide-controls .filters { padding: 0; }
.guide-heading { padding: 15px 19px 9px; border-top: 1px solid #ebede5; font-size: .86rem; }
.guide-heading small { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; font-weight: 550; }
.guide-row .quantity { max-width: none; white-space: nowrap; }
.guide-row .button { min-width: 88px; min-height: 36px; padding: 6px 9px; font-size: .76rem; }
.guide-footer { display: grid; gap: 7px; }
.guide-footer a { display: inline; text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 1024px) {
  /* On a PC the official and general groups sit side by side, each with its own heading. */
  #guide-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; border-top: 1px solid #ebede5; }
  #guide-rows .guide-heading { border-top: 0; }
  .guide-group + .guide-group { align-self: stretch; border-left: 1px solid #ebede5; }
}
.text-link { color: var(--green); font-size: .78rem; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.history-quantity { min-width: 58px; max-width: 9rem; text-align: right; overflow-wrap: anywhere; }
.empty { display: grid; justify-items: center; gap: 9px; padding: 26px 19px 32px; text-align: center; }
.empty h3 { font-size: .92rem; }
.empty p, .loading, .muted { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.empty .button { margin-top: 3px; }
.loading { padding: 18px 0; }

dialog { width: min(100% - 24px, 555px); max-height: calc(100dvh - 28px); padding: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: inherit; box-shadow: 0 24px 65px #172a2540; }
dialog::backdrop { background: #172a2570; }
.dialog-inner { padding: 23px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.dialog-header > div { min-width: 0; overflow-wrap: anywhere; }
.dialog-header h2 { font-size: 1.27rem; }
.dialog-header p { font-size: .8rem; line-height: 1.65; color: var(--muted); margin-top: 5px; }
.dialog-header .quiet { padding: 6px; min-width: 38px; min-height: 38px; margin: -6px -6px 0 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.fields label { display: block; overflow-wrap: anywhere; font-size: .8rem; font-weight: 750; }
.fields label.full { grid-column: 1 / -1; }
.fields small { color: var(--muted); font-weight: 550; }
.fields input, .fields select { display: block; width: 100%; min-width: 0; min-height: 41px; margin-top: 5px; border: 1px solid #dbe2d7; border-radius: 7px; padding: 8px 9px; color: #24382d; background: #fff; font-weight: 550; }
/* iOS applies its own minimum width and box sizing to native date fields. */
.fields input[type="date"] { appearance: none; }
.fields select:disabled { background: #f1f2ed; opacity: 1; }
.form-footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.form-error { color: var(--danger); font-size: .8rem; margin-top: 12px; }
#settings-dialog { width: min(100% - 24px, 460px); }
#confirm-dialog { width: min(100% - 24px, 380px); }
#settings-back { display: block; min-height: 32px; margin: -6px 0 5px -6px; }
.settings-profile { display: grid; gap: 12px; margin: 0 0 16px; padding: 12px 14px; background: #eef3ea; border-radius: 9px; }
.settings-profile dt { font-size: .75rem; color: var(--muted); }
.settings-profile dd { margin: 2px 0 0; overflow-wrap: anywhere; font-size: .9rem; font-weight: 650; }
.settings-links { display: grid; gap: 8px; }
.settings-links + .settings-links, #expiry-notification-form { margin-top: 8px; }
.settings-links .button { justify-content: space-between; }
.settings-feedback { margin: 0 0 14px; }
#password-help { grid-column: 1 / -1; margin-top: -8px; }
.password-session-note { margin-top: 12px; }
#passkey-list { margin-bottom: 16px; }
.passkey-list { display: grid; gap: 8px; padding: 0; list-style: none; }
.passkey-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.passkey-row div { min-width: 0; overflow-wrap: anywhere; }
.passkey-row small { display: block; }
#expiry-notification-devices { margin-top: 22px; }
#expiry-notification-devices h3 { margin-bottom: 8px; font-size: .9rem; }
.push-device-list { display: grid; gap: 8px; padding: 0; list-style: none; }
.push-device { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.push-device strong { overflow-wrap: anywhere; }
.push-device-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.push-device-actions .button { min-height: 36px; padding: 5px 10px; font-size: .8rem; }
.push-device details { border-top: 1px solid var(--line); padding-top: 8px; }
.push-device summary { width: fit-content; cursor: pointer; font-size: .8rem; font-weight: 650; }
.push-device form { margin-top: 10px; }
.detail-photo { margin: 0 0 14px; }
.detail-photo img, .photo-preview { display: block; width: 100%; height: auto; max-height: min(52dvh, 360px); object-fit: contain; border-radius: 9px; background: #eef3ea; }
.photo-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; margin-top: 6px; }
.photo-actions .button { padding: 5px 8px; min-height: 35px; font-size: .75rem; }
.detail-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border-radius: 9px; background: #eef3ea; padding: 12px; }
.detail-summary > div { min-width: 0; overflow-wrap: anywhere; }
.detail-summary small { display: block; color: var(--muted); font-size: .72rem; }
.detail-summary strong { font-size: 1.18rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 19px; }
.lot-heading { font-size: .86rem; margin-bottom: 8px; }
.lots { padding: 0; }
.lots .row { min-height: 52px; gap: 7px; flex-wrap: wrap; }
.lot-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; }
.lot-actions .button { padding: 5px; min-height: 35px; font-size: .73rem; }
.toast { position: fixed; bottom: 18px; right: 18px; max-width: calc(100% - 36px); padding: 11px 15px; border-radius: 8px; background: var(--green-deep); color: white; font-size: .83rem; opacity: 0; pointer-events: none; }
.toast.visible { opacity: 1; }

@media (any-pointer: coarse) {
  /* iOS Safari can zoom when a field with text smaller than 16px receives focus. */
  .search input, .fields input, .fields select, .guide-controls input { font-size: max(16px, 1rem); }
}

@media (max-width: 1140px) {
  .layout { grid-template-columns: 195px minmax(0, 1fr); }
  .main { padding-inline: 24px; }
  .overview-grid .list-expiry { display: none; }
}

@media (max-width: 920px) {
  .overview-grid { grid-template-columns: 1fr; }
  .overview-grid .list-expiry { display: block; }
}

@media (max-width: 740px) {
  .layout { display: block; }
  .sidebar { position: static; min-height: auto; padding: 11px 14px 0; border: 0; border-bottom: 1px solid #e0e4d8; }
  .brand { width: fit-content; margin: 0 0 9px; gap: 8px; font-size: 1.02rem; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  .brand-mark .icon { width: 20px; height: 20px; }
  .brand small { font-size: .58rem; }
  .nav { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; margin-inline: -7px; }
  .nav a { flex-direction: column; gap: 4px; padding: 7px 1px; margin-bottom: 5px; font-size: clamp(.58rem, 2.65vw, .72rem); }
  .nav .icon { width: 16px; height: 16px; }
  .nav-label, .sidebar-note { display: none; }
  .main { padding: 16px 13px 27px; }
  .topline { padding-bottom: 10px; font-size: .72rem; }
  .page-header { align-items: flex-start; gap: 9px; margin: 19px 0 16px; }
  .page-header h1 { font-size: 1.5rem; }
  .page-header p { font-size: .76rem; margin-top: 6px; }
  #add-item { padding-inline: 9px; font-size: .74rem; min-height: 38px; gap: 3px; }
  #add-item .icon { width: 14px; height: 14px; }
  .stats { gap: 6px; margin-bottom: 14px; }
  .stat { padding: 9px 7px 10px; }
  .stat .tile { width: 28px; height: 28px; }
  .stat .tile .icon { width: 16px; height: 16px; }
  .stat-top > .icon { width: 12px; height: 12px; }
  .stat-title { font-size: .7rem; margin-top: 6px; }
  .stat strong { font-size: 1.58rem; }
  .stat strong span { font-size: .62rem; margin-left: 3px; }
  .stat small { font-size: .62rem; }
  .overview-grid { gap: 14px; }
  .panel-header { padding: 14px 11px 12px; }
  .panel-header h2 { font-size: 1.02rem; }
  .search { max-width: 45%; }
  .filters { padding: 0 11px 10px; gap: 4px; }
  .filters button { font-size: .68rem; padding: 5px 7px; }
  .rows { padding-inline: 11px; }
  .guide-controls, .guide-heading { padding-inline: 11px; }
  .guide-row .button { min-width: 0; }
  .row { gap: 7px; }
  .row-link { gap: 7px; }
  .row .tile { width: 29px; height: 29px; }
  .row .tile .icon { width: 16px; height: 16px; }
  .row-copy strong { font-size: .8rem; }
  .quantity { min-width: 51px; max-width: 5rem; }
  .list-expiry, .overview-grid .list-expiry { display: none; }
  .dialog-inner { padding: 16px; }
  .lots { padding: 0; }
}

@media (max-width: 400px) {
  .fields label:has(> input[type="date"]) { grid-column: 1 / -1; }
}
