:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", sans-serif;
  color: #243a32; background: #f4f6f3; font-synthesis: none;
  --green: #23654e; --ink: #243a32; --muted: #65756c; --line: #e1e8e2;
  --soft: #edf4ee; --surface: #fff; --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; border: 0; touch-action: manipulation; min-height: 44px; }
button:disabled { cursor: wait; opacity: .6; }
input { min-height: 48px; width: 100%; min-width: 0; padding: 12px 14px; border: 1px solid #d5dfd7; border-radius: 12px; background: #f9fbf8; color: var(--ink); font-size: 16px; }
input:focus { border-color: var(--green); background: white; }
button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #bc954b; outline-offset: 3px; }
[hidden] { display: none !important; }
.app { width: 100%; max-width: 640px; margin: auto; padding: max(24px, env(safe-area-inset-top)) 20px 120px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 750; letter-spacing: .025em; }
.brand-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--green); color: white; font-size: 23px; }
.icon-button { display: grid; place-items: center; width: 44px; flex-shrink: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 26px; }
#settings { font-size: 0; background: #eaf0e9 url('/settings.svg') center / 20px no-repeat; }
.intro { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 28px 0 20px; }
h1 { font-size: 25px; letter-spacing: -.02em; margin: 0; font-weight: 750; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; }
p { font-size: 14px; line-height: 1.85; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
#status-dot { width: 6px; height: 6px; border-radius: 50%; background: #5b8a6d; flex-shrink: 0; }
.list-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: #e8eee7; flex: 1; max-width: 330px; }
.tab { flex: 1; background: transparent; color: #5c7062; border-radius: 10px; font-size: 14px; padding: 8px 10px; min-height: 44px; white-space: nowrap; }
.tab.active { background: white; color: var(--green); font-weight: 700; box-shadow: 0 2px 5px #263b3210; }
.tab span { display: inline-block; min-width: 21px; margin-left: 4px; padding: 2px 5px; border-radius: 6px; font-size: 11px; background: #edf1eb; }
.tab.active span { background: #e8f2e9; }
.text-button { background: transparent; color: var(--muted); font-size: 13px; padding: 8px 10px; border-radius: 9px; }
.store-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.store-heading .text-button { color: var(--green); }
.store-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.store-filter { min-height: 44px; max-width: 100%; overflow-wrap: anywhere; padding: 9px 14px; border: 1px solid #dce5dc; border-radius: 22px; background: #fff; color: #556a5e; font-size: 13px; }
.store-filter.active { border-color: var(--green); background: var(--green); color: white; font-weight: 650; }
.items:not(:empty) { background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 3px 12px #233d3303; }
.item { display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px; background: white; }
.item + .item { border-top: 1px solid #e8ede7; }
.check { min-width: 44px; width: 44px; padding: 0; background: transparent; color: white; border-radius: 10px; display: grid; place-items: center; }
.check span { width: 25px; height: 25px; border: 1.5px solid #aebeb0; border-radius: 8px; display: grid; place-items: center; font-size: 16px; }
.item.done .check span { background: var(--green); border-color: var(--green); }
.item-content { min-width: 0; flex: 1; padding: 2px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; row-gap: 2px; }
.item-name { grid-column: 1 / -1; grid-row: 1; }
.item-name { display: block; font-size: 17px; font-weight: 650; line-height: 1.45; overflow-wrap: anywhere; }
.item.done .item-name { text-decoration: line-through; text-decoration-color: #8f9b92; color: #617168; }
.item-meta { grid-column: 1 / -1; grid-row: 2; font-size: 13px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.quantity { color: #435f4e; margin-right: 8px; }
.item-links { grid-column: 1; grid-row: 3; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.store-tag { font-size: 11px; border-radius: 5px; background: var(--soft); color: #496651; padding: 2px 6px; overflow-wrap: anywhere; max-width: 100%; }
.product-link { color: var(--green); font-size: 13px; text-underline-offset: 3px; min-height: 32px; display: inline-flex; align-items: center; }
.item-dates { grid-column: 1 / -1; grid-row: 4; font-size: 11px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.item-actions { grid-column: 2; grid-row: 3; display: flex; margin-left: 4px; }
.item-action { background: transparent; color: var(--green); font-size: 12px; font-weight: 600; padding: 7px 4px; border-radius: 7px; white-space: nowrap; }
.item-controls { display: flex; flex-direction: column; align-self: flex-start; gap: 0; flex-shrink: 0; }
.item-controls button { width: 44px; min-height: 44px; border-radius: 12px; padding: 0; }
.delete { color: #738378; font-size: 22px; background: transparent; }
.edit-icon { font-size: 0; background: #f1f5ef url('/edit.svg') center / 19px no-repeat; }
.delete:hover { color: #a04e40; background: #fbf0ec; }
.edit-icon:hover { background-color: #e4eee3; }
.empty { padding: 60px 12px; text-align: center; }
.empty-icon { display: grid; place-items: center; margin: auto auto 18px; width: 52px; height: 52px; border-radius: 17px; background: #e9f1e7; color: #597c60; font-size: 25px; }
.empty h2 { font-size: 16px; color: var(--muted); font-weight: 500; }
.clear-button { display: block; margin: 15px auto 0; color: #8a5e51; font-size: 12px; }
.add-dock { position: fixed; bottom: 0; left: 0; right: 0; z-index: 3; display: flex; justify-content: center; background: #f4f6f3ee; backdrop-filter: blur(12px); border-top: 1px solid #e1e8e2; padding: 12px 20px max(14px,env(safe-area-inset-bottom)); }
.primary, .secondary { min-height: 48px; padding: 12px 16px; border-radius: 12px; font-weight: 650; }
.primary { background: var(--green); color: white; }
.primary:hover { background: #1b513e; }
.secondary { background: #edf3e9; color: var(--green); }
.add-dock .primary { width: 100%; max-width: 600px; min-height: 52px; box-shadow: 0 4px 12px #1c5a3e16; }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
#setup .primary, #setup .secondary { width: 100%; margin-top: 12px; }
.divider { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0; }
#join-form label, #invite-result label { display: block; font-size: 13px; margin-bottom: 8px; }
dialog { width: calc(100% - 32px); max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid #e2e8df; border-radius: 24px; color: var(--ink); background: white; box-shadow: 0 18px 70px #132b2b35; }
dialog::backdrop { background: #18332c66; backdrop-filter: blur(3px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dialog-header h2 { margin: 0; }
#add-dialog { max-width: 520px; }
.add-panel label, .store-field legend { font-size: 13px; color: #52675a; font-weight: 600; }
.add-panel > label { display: block; }
.add-panel > input { margin-top: 8px; }
.quantity-field { display: block; margin-top: 18px; }
.quantity-field input { display: block; width: 126px; margin-top: 8px; }
.store-field { padding: 0; border: 0; margin: 20px 0 0; min-width: 0; }
.store-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.store-button { max-width: 100%; overflow-wrap: anywhere; min-height: 44px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; color: #556a5e; background: #f8faf6; font-size: 13px; }
.store-button.selected { background: var(--soft); border-color: #708e76; color: #21583f; font-weight: 700; }
.add-store { border-style: dashed; color: var(--green); background: white; }
.new-store-row { padding: 14px; margin-bottom: 16px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.new-store-row label { display: block; font-size: 13px; color: var(--muted); }
.new-store-row input { margin-top: 8px; }
.store-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.extra-fields { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 8px; }
.extra-fields summary { cursor: pointer; padding: 12px 0; min-height: 44px; color: #52675a; font-size: 13px; }
.url-field { display: block; margin-top: 12px; }
.url-field input { margin-top: 8px; }
.form-actions { position: sticky; bottom: -24px; display: flex; gap: 10px; margin-top: 24px; padding: 14px 0 max(14px,env(safe-area-inset-bottom)); background: white; border-top: 1px solid var(--line); }
.form-actions button { flex: 1; min-width: 0; font-size: 14px; }
.small { font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
#invite-result { margin-top: 18px; }
#invite-result .secondary { margin-top: 10px; }
.danger { display: block; margin-top: 12px; color: #a04e40; }
#toast { position: fixed; bottom: calc(94px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 10; width: max-content; max-width: calc(100% - 32px); padding: 14px 18px; background: #263e32; color: white; border-radius: 12px; font-size: 13px; box-shadow: 0 8px 25px #17372720; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 480px) {
  #add-dialog { margin: auto 0 0; width: 100%; max-width: none; max-height: calc(100dvh - 16px); border-radius: 24px 24px 0 0; padding: 20px; }
  #add-dialog::before { content: ''; display: block; width: 34px; height: 4px; border-radius: 4px; background: #dce4db; margin: -10px auto 15px; }
  .form-actions { bottom: -20px; }
}
@media (max-width: 350px) { .app { padding-left: 14px; padding-right: 14px; } .intro { gap: 8px; } .intro h1 { font-size: 23px; } .item { padding-left: 6px; padding-right: 6px; gap: 4px; } .item-name { font-size: 16px; } .item-dates { font-size: 11px; } .form-actions button { font-size: 13px; padding: 12px 9px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
