:root {
  color-scheme: light;
  --pine: #173a31;
  --dark: #172a24;
  --muted: #53645c;
  --paper: #f3f3eb;
  --line: #dce2d7;
  --white: #fff;
  --lime: #e1f079;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--dark);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #558462; outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap {
  width: min(100%, 64rem);
  margin-inline: auto;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.masthead {
  background: var(--pine);
  color: var(--white);
  padding-top: max(1.15rem, env(safe-area-inset-top));
  padding-bottom: 1.25rem;
}
.header-line, .brand, .summary-line, .list-heading, .list-actions, .group-heading {
  display: flex;
  align-items: center;
}
.header-line, .summary-line, .list-heading, .group-heading {
  justify-content: space-between;
  gap: .65rem;
}
.brand { gap: .55rem; font-weight: 750; }
.brand img { border-radius: 8px; }
.offline-status { color: #e0ecc7; font-size: .875rem; text-align: right; }
.offline-status[data-ready]::before {
  content: "";
  display: inline-block;
  width: .5rem;
  height: .5rem;
  margin-right: .38rem;
  border-radius: 50%;
  background: var(--lime);
  vertical-align: .08em;
}
h1 { font-size: clamp(2.45rem, 7vw, 4.45rem); line-height: 1.04; letter-spacing: -.055em; margin: 1.45rem 0 1.2rem; }
h2, h3, p { margin: 0; }
.list-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .25rem;
  width: min(100%, 22rem);
  padding: .25rem;
  border-radius: .8rem;
  background: #102b24;
}
.list-switch button {
  min-height: 44px;
  border: 0;
  border-radius: .6rem;
  color: var(--white);
  background: transparent;
  font-weight: 700;
}
.list-switch button[aria-pressed="true"] { color: var(--dark); background: var(--lime); }

main { padding-top: 1.25rem; padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
.summary, .group { background: var(--white); border: 1px solid var(--line); border-radius: .95rem; }
.summary { padding: 1rem; }
.summary h2 { font-size: clamp(1.25rem, 4vw, 1.7rem); letter-spacing: -.035em; }
.summary p { margin-top: .2rem; color: var(--muted); font-size: .9rem; }
.summary button { flex-shrink: 0; }
progress { display: block; width: 100%; height: .55rem; margin-top: .9rem; appearance: none; border: 0; border-radius: 1rem; background: #e7ece4; color: #387354; overflow: hidden; }
progress::-webkit-progress-bar { background: #e7ece4; }
progress::-webkit-progress-value { background: #387354; border-radius: 1rem; }
progress::-moz-progress-bar { background: #387354; border-radius: 1rem; }
.list-heading { flex-wrap: wrap; margin: 1.4rem 0 .7rem; }
.list-heading h2 { font-size: 1.4rem; letter-spacing: -.035em; }
.list-actions { gap: .3rem; flex-wrap: wrap; }
.primary, .subtle, .reset, .danger {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: .62rem;
  padding: .43rem .72rem;
  color: var(--pine);
  background: transparent;
  font-size: .875rem;
  font-weight: 750;
}
.primary { color: var(--white); background: var(--pine); }
.reset { border-color: #a7b8ab; }
.reset:disabled { color: var(--muted); border-color: var(--line); }
.danger, .storage-error { color: #8d2924; }
.storage-error { margin-bottom: .8rem; }
.subtle:hover, .reset:not(:disabled):hover { background: #e9eee5; }
.primary:hover { background: #245342; }

.checklist { display: grid; gap: .8rem; }
.group { min-width: 0; }
.group-heading {
  padding: .7rem .9rem;
  color: var(--pine);
  background: #e8ede3;
  border-radius: .88rem .88rem 0 0;
}
.group-heading h3 { font-size: 1rem; }
.group-count { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.group ul { list-style: none; margin: 0; padding: 0; }
.group li { display: flex; align-items: stretch; min-width: 0; }
.group li + li { border-top: 1px solid var(--line); }
.check-row {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  min-height: 53px;
  gap: .7rem;
  padding: .6rem .9rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.check-row:hover { background: #f6f8f3; }
.group li:last-child .check-row { border-radius: 0 0 .9rem .9rem; }
.check-row input { flex: 0 0 auto; width: 1.35rem; height: 1.35rem; margin: 0; accent-color: #31734f; cursor: pointer; }
#checklist .check-row input:checked + span { color: var(--muted); text-decoration: line-through; }
.edit-item { align-self: center; margin-right: .35rem; }
.empty { padding: .9rem; color: var(--muted); }

#info-title { font-size: 1.4rem; letter-spacing: -.035em; margin-bottom: .7rem; }
.group-heading label { font-weight: 700; }
.info-fields { padding: .9rem; }
.info-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .25rem; margin-top: .65rem; }
.info-status { color: var(--muted); font-size: .875rem; margin-right: auto; }
.danger:hover { background: #f8ece8; }

dialog { width: min(calc(100% - 2rem), 27rem); padding: 1.2rem; border: 1px solid var(--line); border-radius: 1rem; color: var(--dark); }
dialog::backdrop { background: #10241fc0; }
dialog h2 { margin-bottom: 1rem; }
#item-form label { display: block; margin-top: .7rem; font-weight: 650; }
#item-text, #item-category, .info-fields input { width: 100%; min-height: 44px; padding: .4rem .6rem; border: 1px solid #97a99d; border-radius: .5rem; background-color: var(--white); color: var(--dark); }
.info-fields input {
  min-height: 56px;
  font-size: clamp(1.625rem, 5vw, 2.25rem);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
#item-text, #item-category { margin-top: .3rem; }
dialog select {
  appearance: none;
  padding-right: 2rem;
  background: linear-gradient(45deg, transparent 50%, var(--pine) 50%) right 1rem center / .35rem .35rem no-repeat,
              linear-gradient(135deg, var(--pine) 50%, transparent 50%) right .65rem center / .35rem .35rem no-repeat;
}
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem; margin-top: 1rem; }
.dialog-actions .danger { margin-right: auto; }

#catalog-dialog { padding: 0; }
.catalog-header { position: sticky; top: 0; z-index: 1; padding: .85rem 1rem; background: var(--white); border-bottom: 1px solid var(--line); }
.catalog-heading { display: flex; justify-content: space-between; align-items: center; gap: .65rem; }
.catalog-heading h2 { margin: 0; }
.catalog-header p { margin: .35rem 0 0; }
.catalog-header .list-actions { margin-top: .5rem; }
#catalog { display: grid; gap: .7rem; padding: .85rem 1rem; }

@media (min-width: 46rem) {
  .wrap { padding-inline: 2rem; }
  .masthead { padding-bottom: 1.6rem; }
  .checklist { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
