* {
  box-sizing: border-box;
}
:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #203b30;
  background: #fafbf7;
  --green: #173e30;
  --muted: #677368;
  --line: #dce4d6;
}
body {
  margin: 0;
}
button,
input,
textarea {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
  color: inherit;
  min-height: 44px;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 10px 16px;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid #648c3b;
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
header {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5vw;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  letter-spacing: -0.8px;
}
.brand b {
  font-weight: 450;
}
.brand img {
  border-radius: 12px;
  margin-right: 5px;
}
nav {
  display: flex;
  background: #edf1e8;
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}
nav .selected {
  background: var(--green);
  color: white;
}
header > span {
  font-size: 11px;
  color: var(--muted);
}
main {
  max-width: 1200px;
  margin: auto;
  padding: 36px 32px 150px;
}
.heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #68795e;
  margin: 0 0 12px;
}
h1,
#title {
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: -1.3px;
  font-weight: 650;
  margin: 0 0 15px;
}
#title {
  border: 0;
  background: transparent;
  max-width: 100%;
  width: 640px;
  color: inherit;
  padding: 0;
  min-width: 0;
}
.heading > div {
  min-width: 0;
}
.secondary {
  border: 1px solid #c7d4be;
  background: #fff;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 12px;
  padding: 10px 16px;
}
.primary {
  background: var(--green);
  color: white;
  border-radius: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  min-height: 48px;
  border: 0;
}
button:hover {
  filter: brightness(0.95);
}
#list-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 30px;
  overflow: auto;
}
#list-tabs button {
  white-space: nowrap;
  font-size: 13px;
  border: 1px solid var(--line);
}
#list-tabs .selected {
  background: #e4edd8;
  border-color: #b8caa6;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 48px;
}
.layout > *,
#add-form,
.row > * {
  min-width: 0;
}
#add-form > label {
  font-size: 19px;
  font-weight: 600;
  display: block;
  margin-bottom: 12px;
}
.entry-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  align-items: center;
  border: 1px solid #a8bd97;
  border-radius: 15px;
  background: white;
  padding: 6px;
  box-shadow: 0 6px 20px #173e3005;
}
.entry-wrap input {
  border: 0;
  background: none;
  padding: 12px;
  min-width: 0;
  width: 100%;
  font-size: 16px;
}
.entry-wrap button {
  font-size: 24px;
  width: 52px;
  padding: 5px;
}
.filters {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 25px;
  border-bottom: 1px solid var(--line);
}
.filters button {
  font-size: 14px;
  border-radius: 0;
  padding: 12px;
}
.filters .selected {
  border-bottom: 2px solid var(--green);
  font-weight: 700;
}
.filters span {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
h2 {
  font-size: 21px;
  letter-spacing: -0.5px;
  margin: 8px 0 12px;
}
.category {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 25px 0 8px;
}
.row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1.4fr) 112px 116px minmax(0, 1fr) 44px;
  grid-template-areas: "toggle name qty price note remove";
  align-items: center;
  gap: 4px 8px;
  padding: 8px 0;
  border-bottom: 1px solid #e5eadf;
}
.toggle {
  grid-area: toggle;
  padding: 0;
  width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
}
.toggle span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid #94a687;
  border-radius: 9px;
  font-size: 17px;
  line-height: 1;
}
.bought .toggle span {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.row input {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  padding: 8px 6px;
  width: 100%;
  min-height: 44px;
  font-size: 15px;
}
.row input:hover,
.row input:focus {
  border-color: #b4c6a5;
  background: white;
}
.row input:invalid {
  border-color: #ac452e;
}
.name-field {
  grid-area: name;
  font-weight: 600;
}
.bought .name-field {
  color: #677368;
  text-decoration: line-through;
}
.note-field {
  grid-area: note;
  color: var(--muted);
}
.quantity {
  grid-area: qty;
  display: flex;
  align-items: center;
}
.quantity input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row .unit {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 6px;
  font-size: 13px;
  color: #3d5a4b;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.price {
  grid-area: price;
  position: relative;
}
.price-hint {
  position: absolute;
  right: 4px;
  top: -9px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}
button.price-hint {
  pointer-events: auto;
  min-height: 24px;
  top: -16px;
  right: 0;
  padding: 4px 8px;
  border-radius: 8px;
  background: #fdf3d8;
  color: #6b4a00;
  font-weight: 600;
  z-index: 1;
}
.row .price-field {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row:has(button.price-hint) .price-field {
  font-style: italic;
  color: var(--muted);
}
.row .remove,
.history-row .remove {
  grid-area: remove;
  padding: 0;
  font-size: 22px;
  color: #6f7d68;
  width: 44px;
}
.category.in-cart {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.empty-filter {
  padding: 30px 4px;
}
.muted {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.suggestions {
  background: #eaf1dd;
  border-radius: 20px;
  padding: 26px;
}
.suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #d3dfc5;
  padding: 12px 0;
  gap: 10px;
}
.suggestion b {
  font-size: 14px;
}
.suggestion small {
  display: block;
  color: #627554;
  font-size: 11px;
  margin-top: 5px;
}
.suggestion button {
  border: 1px solid #b9cca6;
  background: #f9fcf2;
  min-width: 42px;
  padding: 8px;
  font-size: 20px;
}
.budget-card,
.ai-card {
  padding: 24px 4px;
  border-bottom: 1px solid var(--line);
}
.budget-card label {
  font-size: 13px;
  font-weight: 600;
}
.budget-card small {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}
.budget-input {
  display: flex;
  align-items: center;
  gap: 4px;
}
.budget-input input {
  border: 0;
  background: transparent;
  padding: 10px 0;
  width: 100%;
  min-width: 0;
  font-size: 23px;
  color: inherit;
}
.track {
  height: 5px;
  background: #dce6d0;
  border-radius: 4px;
  overflow: hidden;
}
.track > div {
  height: 100%;
  background: #527535;
}
.over {
  color: #a33b22;
}
.over .track > div {
  background: #a33b22;
}
.ai-card h2 {
  font-size: 20px;
}
.ai-card p {
  font-size: 12px;
  line-height: 1.7;
}
#ai-result {
  font-size: 13px;
  white-space: pre-line;
  line-height: 1.8;
}
#checkout {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fafbf7f5;
  border-top: 1px solid #ccd9bf;
  padding: 14px max(24px, calc((100vw - 1136px) / 2));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  backdrop-filter: blur(12px);
  z-index: 3;
}
#checkout small {
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  color: var(--muted);
}
#remaining {
  font-weight: 700;
  color: #2f5a1e;
}
#remaining.over {
  color: #a33b22;
}
#total {
  font-size: 30px;
  letter-spacing: -1px;
}
.empty {
  padding: 45px 10px;
  text-align: center;
  color: #6d7d62;
}
.empty span {
  font-size: 36px;
}
.empty h2 {
  color: #354d2b;
}
.chart {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  height: 210px;
  margin: 25px 0 45px;
  border-bottom: 1px solid var(--line);
}
.bar {
  flex: 1;
  text-align: center;
  font-size: 11px;
  min-width: 0;
}
.bar i {
  display: block;
  width: 100%;
  background: #9dbf77;
  border-radius: 8px 8px 0 0;
  margin: 10px 0;
  min-height: 3px;
}
.bar small {
  display: block;
}
.pattern,
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  gap: 18px;
}
.pattern small,
.history-row small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}
#stats {
  display: flex;
  gap: 40px;
  margin: 30px 0;
}
#stats strong {
  display: block;
  font-size: 28px;
}
#stats small {
  color: var(--muted);
}
.settings-card {
  max-width: 600px;
  margin: 30px 0;
  padding: 24px;
  background: #eff3e8;
  border-radius: 16px;
  line-height: 1.8;
  font-size: 14px;
}
.settings-card label {
  display: block;
  font-size: 12px;
}
.settings-card input {
  width: 100%;
  padding: 13px;
  border: 1px solid #bdcdb0;
  border-radius: 8px;
}
#share-box {
  padding: 20px;
  background: #edf2e4;
  border-radius: 16px;
  margin-top: 20px;
}
textarea {
  width: 100%;
  min-height: 150px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
#toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #173e30;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  z-index: 6;
  max-width: 90vw;
  font-size: 13px;
}
#toast button {
  color: #d5eea7;
}
#error {
  background: #ffecd2;
  padding: 20px;
  margin-bottom: 20px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 900px) {
  header {
    padding: 16px 24px;
    height: auto;
    flex-wrap: wrap;
  }
  header > span {
    display: none;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 25px;
  }
  main {
    padding: 28px 24px 130px;
  }
  .row {
    grid-template-columns: 44px 72px 88px minmax(0, 1fr) 44px;
    grid-template-areas:
      "toggle name name name remove"
      "qty qty price note note";
    row-gap: 20px;
    padding: 6px 0 10px;
  }
}
@media (max-width: 650px) {
  header {
    padding: 14px 18px;
    gap: 12px;
  }
  .brand {
    font-size: 19px;
  }
  nav {
    padding: 2px;
  }
  nav button {
    font-size: 11px;
    padding: 9px;
    min-height: 40px;
  }
  .brand img {
    width: 30px;
    height: 30px;
    margin: 0;
  }
  main {
    padding: 24px 18px 125px;
  }
  .heading {
    align-items: flex-start;
  }
  #title {
    font-size: 28px;
    width: 100%;
    margin: 0;
  }
  .eyebrow {
    margin-bottom: 8px;
  }
  #list-tabs {
    margin: 14px 0 22px;
  }
  .layout {
    display: flex;
    flex-direction: column;
    gap: 25px;
  }
  aside {
    display: grid;
    gap: 16px;
  }
  .suggestions {
    padding: 20px;
  }
  .budget-card,
  .ai-card {
    padding: 16px 4px;
  }
  #add-form > label {
    font-size: 16px;
  }
  .entry-wrap input {
    font-size: 16px;
    padding: 10px;
  }
  #checkout {
    padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  }
  #checkout .primary {
    font-size: 12px;
    padding: 12px 14px;
  }
  #total {
    font-size: 27px;
  }
  .chart {
    gap: 8px;
  }
  .bar {
    font-size: 11px;
  }
  #stats {
    gap: 20px;
  }
  #stats strong {
    font-size: 23px;
  }
  #stats small {
    font-size: 12px;
  }
}
/* Keep editable text readable without triggering mobile focus zoom.
   Do not restrict user scaling in the viewport meta tag. */
@media (max-width: 900px), (pointer: coarse) {
  input,
  textarea,
  .row input,
  .row label input,
  .name-field,
  .settings-card input {
    font-size: max(16px, 1rem);
  }
}
.heading-actions {
  display: flex;
  gap: 8px;
  flex: none;
}
.secondary.icon {
  padding: 10px;
  min-width: 44px;
  color: #6f4a3c;
}
#completions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
#completions:empty {
  display: none;
}
#completions button {
  font-size: 14px;
  padding: 8px 14px;
  border: 1px solid #b9cca6;
  background: #f1f6e8;
  border-radius: 22px;
}
.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.spend {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 96px;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  font-size: 14px;
}
.spend .track {
  height: 10px;
}
.spend b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#categories,
#price-changes {
  margin-bottom: 36px;
}
.pattern .up {
  color: #a33b22;
  font-weight: 700;
}
.pattern .down {
  color: #2f5a1e;
  font-weight: 700;
}
.history-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.aisle {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid #d9e2cf;
  padding: 4px 0;
}
.aisle span {
  flex: 1;
}
.aisle button {
  border: 1px solid #bdcdb0;
  background: white;
  min-width: 44px;
  padding: 6px;
}
.settings-card .check {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  min-height: 44px;
  cursor: pointer;
}
.settings-card .check input {
  width: 22px;
  height: 22px;
  flex: none;
  accent-color: var(--green);
}
.settings-card .secondary {
  margin: 0 8px 8px 0;
}
@media (max-width: 650px) {
  .spend {
    grid-template-columns: 104px minmax(0, 1fr) 84px;
    gap: 8px;
    font-size: 13px;
  }
  #checkout .primary {
    flex: none;
  }
}
@media (max-width: 650px) {
  .heading {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}
#toast {
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
}
#toast button {
  flex: none;
  font-weight: 700;
}
