:root {
  color-scheme: light;
  --bg: #e4e9e6;
  --surface: #f5f7f4;
  --raise: #fff;
  --ink: #1f2a30;
  --muted: #5f6e76;
  --line: #d3dad6;
  --slate: #2e4a57;
  --slate-ink: #f4f7f5;
  --ok: #3f7d63;
  --soon: #a86b12;
  --over: #b5472f;
  --c-bg: #dce6ea;
  --c-fg: #2e4a57;
  --f-bg: #fce1d8;
  --f-fg: #994c3d;
  --s-bg: #d8eadf;
  --s-fg: #2a5c48;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1417;
  --surface: #172026;
  --raise: #1f2a31;
  --ink: #e6ecea;
  --muted: #92a0a7;
  --line: #2b373e;
  --slate: #8fb4c4;
  --slate-ink: #10181c;
  --ok: #6dbb9a;
  --soon: #e0a94a;
  --over: #e58a74;
  --c-bg: #243742;
  --c-fg: #a9cbda;
  --f-bg: #4a302b;
  --f-fg: #ffc0ab;
  --s-bg: #213d31;
  --s-fg: #9fd3b8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1417;
    --surface: #172026;
    --raise: #1f2a31;
    --ink: #e6ecea;
    --muted: #92a0a7;
    --line: #2b373e;
    --slate: #8fb4c4;
    --slate-ink: #10181c;
    --ok: #6dbb9a;
    --soon: #e0a94a;
    --over: #e58a74;
    --c-bg: #243742;
    --c-fg: #a9cbda;
    --f-bg: #4a302b;
    --f-fg: #ffc0ab;
    --s-bg: #213d31;
    --s-fg: #9fd3b8;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    15px/1.6 "PingFang SC",
    "Microsoft YaHei",
    system-ui,
    sans-serif;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid var(--slate);
  outline-offset: 3px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3 {
  font-family: "Songti SC", "Noto Serif SC", serif;
}
h1 {
  font-size: 30px;
}
h2 {
  font-size: 20px;
  margin-bottom: 13px;
}
h3 {
  font-size: 17px;
  margin: 18px 0 8px;
}
small,
.muted {
  color: var(--muted);
}
.shell {
  max-width: 1080px;
  margin: auto;
  min-height: 100dvh;
  background: var(--surface);
  padding: 30px 34px 120px;
}
.appbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.identity {
  text-align: right;
  font-size: 13px;
}
.btn {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 8px 16px;
  background: var(--surface);
  min-height: 40px;
  font-size: 14px;
}
.btn:hover {
  border-color: var(--slate);
}
.pri {
  background: var(--slate);
  border-color: var(--slate);
  color: var(--slate-ink);
}
.danger {
  color: var(--over);
  border-color: var(--over);
}
.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 26px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--raise);
  padding: 16px 3px;
  color: var(--muted);
}
.stat b {
  display: block;
  font:
    700 32px/1.3 Georgia,
    serif;
}
.stat span {
  font-size: 13px;
}
.stat.active {
  border-color: var(--slate);
}
.stock b,
.frozen b {
  color: var(--soon);
}
.expiry b {
  color: var(--over);
}
.subscription b {
  color: var(--ok);
}
.columns {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 26px;
}
.section {
  margin-bottom: 28px;
}
.stack {
  display: grid;
  gap: 10px;
}
.card,
.panel {
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.cardhead {
  display: flex;
  gap: 12px;
  align-items: start;
}
.cardhead .text {
  flex: 1;
  min-width: 0;
}
.title {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.category-tag {
  display: inline-block;
  flex: none;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  background: var(--c-bg);
  color: var(--c-fg);
}
.category-tag.food {
  background: var(--f-bg);
  color: var(--f-fg);
}
.category-tag.subscription {
  background: var(--s-bg);
  color: var(--s-fg);
}
.acts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.l1 .reminder {
  color: var(--soon);
}
.l2 .reminder {
  color: var(--over);
}
.empty {
  padding: 26px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  color: var(--muted);
}
.link {
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline li {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  padding: 10px 0;
}
.timeline .event {
  border-left: 2px solid var(--line);
  padding-left: 14px;
}
.timeline time {
  font-size: 13px;
  color: var(--muted);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 16px 4px;
}
.row .text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.row .right {
  text-align: right;
  white-space: nowrap;
}
.search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--raise);
  padding: 12px 18px;
  border-radius: 24px;
  margin-bottom: 12px;
}
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: transparent;
  padding: 7px 14px;
  min-height: 38px;
}
.chip[aria-pressed="true"] {
  background: var(--slate);
  color: var(--slate-ink);
  border-color: var(--slate);
}
.filters select {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--raise);
  padding: 7px 12px;
}
.nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 1080px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr 70px 1fr 1fr;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--raise);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  z-index: 5;
}
.nav button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 0;
  font-size: 13px;
}
.nav button[aria-current="page"] {
  color: var(--slate);
  font-weight: 700;
}
.nav .add {
  border-radius: 18px;
  background: var(--slate);
  color: var(--slate-ink);
  font-size: 28px;
  line-height: 28px;
  margin: 0 8px;
}
.nav svg {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0 auto 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}
.number {
  font:
    700 32px Georgia,
    serif;
}
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.history {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.history small {
  display: block;
}
.login {
  max-width: 400px;
  margin: 12vh auto;
  padding: 26px;
}
.login h1 {
  margin-bottom: 8px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  width: calc(100% - 24px);
  max-width: 550px;
  max-height: 90dvh;
  padding: 24px;
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: #0f161a88;
}
.dialoghead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.dialoghead h2 {
  margin: 0;
}
.field {
  display: block;
  margin: 14px 0;
  font-size: 14px;
}
.field input,
.field select {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: var(--raise);
  min-height: 46px;
}
.field input[type="checkbox"] {
  width: auto;
  display: inline;
  margin-right: 8px;
  min-height: auto;
}
.formerror,
.error {
  color: var(--over);
  margin: 12px 0;
  overflow-wrap: anywhere;
}
.note {
  padding: 12px;
  background: var(--raise);
  border-left: 3px solid var(--soon);
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0;
}
.detailgrid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  margin: 20px 0;
}
.detailgrid dt {
  color: var(--muted);
}
.detailgrid dd {
  margin: 0;
  overflow-wrap: anywhere;
}
#toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  border-radius: 12px;
  max-width: 90%;
  padding: 12px 18px;
  z-index: 20;
  display: none;
}
#toast.show {
  display: block;
}
[hidden] {
  display: none !important;
}
@media (max-width: 650px) {
  .shell {
    padding: 20px 16px 110px;
  }
  .appbar {
    margin-bottom: 18px;
  }
  h1 {
    font-size: 27px;
  }
  .columns {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .stats {
    gap: 7px;
  }
  .stat {
    padding: 11px 2px;
  }
  .stat b {
    font-size: 29px;
  }
  .stat span {
    font-size: 12px;
  }
  dialog {
    padding: 20px;
    max-height: 88dvh;
  }
  .two {
    gap: 12px;
  }
}
/* Keep controls readable without iOS focus zoom, and clear the display cutout. */
.shell {
  padding-top: calc(30px + env(safe-area-inset-top, 0px));
}
@media (max-width: 650px) {
  .shell {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }
  input,
  select,
  .field input,
  .field select,
  .search {
    font-size: 16px;
  }
}

.brand-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  flex: 0 0 40px;
  border-radius: 10px;
}
.login-logo {
  display: block;
  border-radius: 20px;
  margin-bottom: 16px;
}
