:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #252f26;
  background: #f3f1e8;
  color-scheme: light;
  --ink: #252f26;
  --muted: #565e50;
  --paper: #fffdf6;
  --line: #e2ded0;
  --accent: #a6362b;
  --accent-hover: #8c2d24;
  --sage: #e6ebdd;
  --green: #3f5a3b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.shell { width: min(100% - 64px, 960px); margin-inline: auto; }
.symbols { position: absolute; width: 0; height: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
}
.brand {
  display: inline-flex;
  align-items: center;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -.06em;
}
.brand-dot, h1 span { color: var(--accent); }
.brand-icon, .empty-icon {
  display: grid;
  place-items: center;
  border-radius: 10px;
}
.brand-icon {
  width: 32px;
  height: 32px;
  margin-right: 9px;
  background: var(--accent);
  color: var(--paper);
}
.brand-icon svg, button svg, .empty-icon svg, .complete svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.masthead-label { color: var(--muted); font-size: 13px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.9fr);
  align-items: start;
  gap: clamp(22px, 5vw, 66px);
  padding-block: 49px 64px;
}
.intro { min-width: 0; padding-top: 20px; }
.eyebrow {
  color: var(--muted);
  font: 700 11px/1.4 ui-monospace, "Consolas", monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
}
h1 {
  margin-top: 7px;
  font: 700 clamp(53px, 7.7vw, 91px)/.98 Georgia, serif;
  letter-spacing: -.082em;
}
.produce-print {
  display: block;
  width: min(100%, 252px);
  height: auto;
  margin-top: 22px;
}

.shopping-list { min-width: 0; }
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.list-header h2 { font-size: clamp(20px, 3.4vw, 26px); line-height: 1.2; letter-spacing: -.045em; }
.count {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--sage);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
progress {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 3px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  appearance: none;
  background: var(--sage);
  color: var(--green);
}
progress::-webkit-progress-bar { background: var(--sage); }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }

.store-picker { margin-top: 18px; }
.store-picker-header, .store-picker-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.store-picker-header { justify-content: space-between; }
.store-picker select { flex: 1; min-width: 0; }
.store-picker button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
select, .add-form input, .dialog-form input {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #b9b9a9;
  border-radius: 10px;
  background: #fffefa;
  color: var(--ink);
  font-size: 16px;
}

select {
  appearance: none;
  min-width: 0;
  padding-inline-end: 38px;
  background: #fffefa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%233f5a3b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 12px center / 16px no-repeat;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}
select:enabled:hover { border-color: #87967b; }
select:disabled { opacity: .65; cursor: default; }

@supports (appearance: base-select) and selector(::picker(select)) {
  select, select::picker(select) { appearance: base-select; }
  select {
    align-items: center;
    gap: 8px;
    padding-inline-end: 12px;
    background-image: none;
  }
  select:open { border-color: #87967b; box-shadow: 0 0 0 3px var(--sage); }
  select::picker-icon {
    flex: none;
    color: var(--green);
    font-size: 13px;
  }
  select:open::picker-icon { rotate: 180deg; }
  select::picker(select) {
    min-inline-size: min(230px, calc(100vw - 32px));
    max-inline-size: calc(100vw - 32px);
    max-block-size: min(340px, 65dvh);
    margin-block: 6px;
    padding: 6px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 12px 30px #252f2626, 0 2px 5px #252f260d;
  }
  select option {
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    overflow-wrap: anywhere;
    cursor: pointer;
  }
  select option:checked {
    background: var(--sage);
    color: var(--green);
    font-weight: 700;
  }
  select option:not(:checked):hover { background: #f1efe4; }
  select option:focus-visible { outline-offset: -2px; }
  select option::checkmark {
    order: 1;
    flex: none;
    margin-inline-start: auto;
    color: var(--green);
  }
  select optgroup {
    margin-block-start: 4px;
    padding-block-start: 6px;
    border-block-start: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }
  select optgroup option { color: var(--ink); }
  select optgroup option::before {
    content: "";
    flex: 0 0 24px;
    height: 24px;
    border-radius: 7px;
    background: #f0f1e6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 7v6h10V7M2 7l1-4h10l1 4H2Zm4 6V9h4v4' fill='none' stroke='%233f5a3b' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat;
  }
  #store option[value="new"] {
    margin-block-start: 4px;
    border-block-start: 1px solid var(--line);
    color: var(--accent-hover);
    font-weight: 700;
  }
  #store option[value="new"]::before { content: "+"; width: 24px; text-align: center; font-size: 20px; }
}

@media (forced-colors: active) {
  select { appearance: auto; padding-inline-end: 10px; background-image: none; }
}

.composer {
  position: sticky;
  z-index: 1;
  top: max(6px, env(safe-area-inset-top));
  margin-top: 14px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 6px;
}
.composer-header h3 { font-size: 16px; }
.add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(88px, 23vw, 112px);
  align-items: end;
  gap: 10px;
}
.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.field label { color: var(--muted); font-size: 13px; font-weight: 700; }
.add-form input, .add-form select { width: 100%; min-width: 0; }
.add-form input::placeholder { color: var(--muted); opacity: 1; }
.add-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding-inline: 8px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fffefa;
  font-weight: 700;
}
.add-form button:active:not(:disabled) { box-shadow: inset 0 2px 5px #3c170866; }
.error { margin-top: 9px; color: var(--accent-hover); font-size: 14px; }
.loading { margin: 16px 0 0; color: var(--muted); font-size: 14px; }

.secondary-action, .finish-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}
.secondary-action svg { width: 17px; height: 17px; }
.secondary-action:hover, .store-picker button:hover, .finish-button:hover { background: var(--sage); }
.finish-button { margin-top: 14px; border-color: #87967b; background: var(--paper); }
.action-notice { margin-top: 12px; color: var(--green); font-size: 14px; }

.item-group { margin-top: 15px; }
.item-group + .item-group { margin-top: 22px; }
.item-group h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font: 700 12px/1.4 ui-monospace, "Consolas", monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.item-group h3::after { flex: 1; height: 1px; background: var(--line); content: ""; }
#aisles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr));
  align-items: start;
  gap: 12px;
  margin-top: 12px;
}
.aisle { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.aisle h4 { padding-inline: 6px; color: var(--green); font-size: 14px; font-weight: 750; }
.aisle .items { margin-top: 0; }
.aisle .item:last-child { border-bottom: 0; }
.items { padding: 0; margin: 5px 0 0; list-style: none; }
.item {
  display: flex;
  align-items: stretch;
  min-height: 54px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 225px;
}
.item button { border: 0; border-radius: 8px; background: transparent; color: var(--ink); }
.item-toggle { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 10px 6px; text-align: left; }
.item-copy { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 9px; min-width: 0; }
.item-name, .item-quantity, .item-store { overflow-wrap: anywhere; }
.item-name { font-weight: 600; }
.item-quantity { color: var(--muted); font-size: 13px; }
.item-store { padding: 2px 6px; border-radius: 4px; background: var(--sage); color: var(--green); font-size: 12px; }
.checkmark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 1.5px solid #757e68;
  border-radius: 6px;
}
.checkmark svg { width: 17px; height: 17px; visibility: hidden; }
.item-toggle[aria-pressed="true"] .checkmark { border-color: var(--green); background: var(--sage); color: var(--green); }
.item-toggle[aria-pressed="true"] .checkmark svg { visibility: visible; }
.item-toggle[aria-pressed="true"] .item-name { color: var(--muted); text-decoration: line-through; }
.item .item-edit, .item .item-remove { display: grid; place-items: center; flex: 0 0 44px; color: var(--muted); }
.item-edit svg, .item-remove svg { width: 18px; height: 18px; }
@media (hover: hover) {
  .add-form button:hover:not(:disabled) { background: var(--accent-hover); }
  .item button:hover { background: #f1efe4; }
  .item .item-remove:hover { background: #faebe3; color: var(--accent-hover); }
}

.empty {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 16px;
  border: 1px dashed #c9c6b5;
  border-radius: 13px;
  background: #f8f6ec;
  color: var(--muted);
  font-size: 14px;
}
#empty-title { margin-bottom: 3px; color: var(--ink); font: 700 20px/1.2 Georgia, serif; }
.empty-icon { width: 36px; height: 36px; flex: none; background: var(--sage); color: var(--green); }
.complete {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 17px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--sage);
  color: var(--green);
  font-size: 14px;
  font-weight: 650;
}

dialog {
  width: min(100% - 28px, 430px);
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 15px 40px #252f2630;
}
dialog::backdrop { background: #252f2666; }
.dialog-form { display: grid; gap: 9px; }
.dialog-form h2 { font-size: 22px; letter-spacing: -.035em; }
.dialog-form p { color: var(--muted); overflow-wrap: anywhere; }
.dialog-form .error { color: var(--accent-hover); }
.dialog-form label { font-size: 14px; font-weight: 700; }
.dialog-form button {
  min-width: 44px;
  min-height: 44px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
}
.dialog-form button:disabled { cursor: default; opacity: .45; }
.dialog-form .primary { border-color: var(--accent); background: var(--accent); color: #fffefa; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.ingredient-picker { min-width: 0; margin: 5px 0 0; padding: 0; border: 0; }
.ingredient-picker legend { padding: 0; font-size: 14px; font-weight: 700; }
.ingredient-picker p { margin: 3px 0; font-size: 13px; }
#ingredients label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
#ingredients input { width: 18px; min-height: 0; height: 18px; padding: 0; accent-color: var(--green); }
#ingredients span { color: var(--muted); font-size: 13px; font-weight: 500; }
#history-entries details { padding: 10px 0; border-bottom: 1px solid var(--line); }
#history-entries summary { min-height: 26px; cursor: pointer; font-weight: 700; }
#history-entries ul { margin: 7px 0; padding-left: 24px; overflow-wrap: anywhere; }
#history-status:empty { display: none; }
#store-order { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
#store-order li { display: flex; align-items: center; gap: 5px; border-bottom: 1px solid var(--line); }
#store-order span { flex: 1; padding: 8px 0; font-size: 14px; }

@media (max-width: 710px) {
  .shell { width: min(100% - 24px, 620px); }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 15px; padding-block: 14px 32px; }
  .intro { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 3px; }
  h1 { font-size: clamp(49px, 11vw, 64px); }
  .produce-print { width: 104px; margin: 0; }
  .masthead-inner { min-height: 56px; }
}
