@font-face {
  font-family: 'Golos Text';
  src: url('/fonts/GolosText.ttf') format('truetype');
  font-weight: 400 900;
  font-display: swap;
}
:root, [data-theme='linen'] {
  --canvas: #ecede7; --surface: #fcfcf9; --raised: #ffffff;
  --text: #27372d; --muted: #65705f; --completed: #6a7564;
  --line: #dde2d7; --control: #81917a;
  --accent: #326342; --accent-hover: #264e32; --soft: #e8eee1; --on-accent: #ffffff;
  --focus: #2367bd; --danger: #a63632; --danger-soft: #fcebe8;
  --overlay: rgba(20,30,22,.38); --shadow: rgba(20,30,22,.16);
  color-scheme: light;
}
[data-theme='ocean'] {
  --canvas: #e9eff5; --surface: #f8fbff; --raised: #ffffff;
  --text: #24364c; --muted: #5d6e83; --completed: #657486;
  --line: #d9e3ee; --control: #7c8fa8;
  --accent: #245f99; --accent-hover: #1b4a79; --soft: #e5eff9; --on-accent: #ffffff;
  --focus: #9b4e1a; --danger: #a43137; --danger-soft: #fcedef;
  --overlay: rgba(20,35,55,.4); --shadow: rgba(20,35,55,.16);
  color-scheme: light;
}
[data-theme='plum'] {
  --canvas: #f0ebf0; --surface: #fffaff; --raised: #ffffff;
  --text: #403043; --muted: #786579; --completed: #7c6b7f;
  --line: #e7dce8; --control: #9b7b9e;
  --accent: #7b3d79; --accent-hover: #622c60; --soft: #f2e5f2; --on-accent: #ffffff;
  --focus: #216b83; --danger: #a03042; --danger-soft: #fce9ef;
  --overlay: rgba(48,32,51,.4); --shadow: rgba(48,32,51,.16);
  color-scheme: light;
}
[data-theme='graphite'] {
  --canvas: #131918; --surface: #1d2524; --raised: #26312f;
  --text: #e8eeea; --muted: #b1bfb7; --completed: #a0b0a6;
  --line: #3b4943; --control: #819a8b;
  --accent: #a6d8ba; --accent-hover: #bfe8ce; --soft: #30493b; --on-accent: #15291d;
  --focus: #88bff4; --danger: #ffb4ab; --danger-soft: #4b2b2b;
  --overlay: rgba(0,0,0,.6); --shadow: rgba(0,0,0,.3);
  color-scheme: dark;
}
:root {
  font-family: 'Golos Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-synthesis: none; color: var(--text); background: var(--canvas);
  --radius-control: 12px; --radius-dialog: 20px;
  --visible-height: 100dvh; --viewport-top: 0px; --keyboard-gap: 0px;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 16px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .65; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 600; letter-spacing: -.4px; }
h2 { font-size: 20px; line-height: 1.3; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.app-shell { max-width: 640px; min-height: 100dvh; margin: auto; background: var(--surface); padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.list-header { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 16px 20px; min-height: 84px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; background: var(--surface); }
.list-titles { min-width: 0; }
.list-titles h1 { overflow-wrap: anywhere; }
.list-titles p { font-size: 14px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.list-count { flex-shrink: 0; font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.5px; }
.list-content { padding: 0 16px; }
.list-row { display: grid; grid-template-columns: minmax(0,4fr) minmax(44px,1fr); min-height: 56px; border-bottom: 1px solid var(--line); }
.item-toggle { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 4px; text-align: left; min-width: 0; }
.item-check, .add-symbol { width: 24px; height: 24px; border: 1.5px solid var(--control); border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; }
.item-check svg { width: 17px; height: 17px; stroke-width: 2.3; visibility: hidden; }
.item-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-name { font-size: 18px; line-height: 1.35; font-weight: 400; overflow-wrap: anywhere; }
.item-note { font-size: 13px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.item-edit { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 8px 4px 8px 0; color: var(--muted); border-radius: 8px; }
.item-edit svg { width: 16px; height: 16px; }
.item-amount { font-size: 13px; text-align: right; overflow-wrap: anywhere; min-width: 0; line-height: 1.4; }
.list-row.completed .item-check { background: var(--soft); color: var(--accent); border-color: var(--accent); }
.list-row.completed .item-check svg { visibility: visible; }
.list-row.completed .item-name, .list-row.completed .item-amount { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--completed); }
.list-row.completed .item-note { color: var(--completed); }
.add-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 4px; color: var(--accent); text-align: left; font-weight: 500; }
.add-symbol { border-color: var(--accent); font-size: 23px; line-height: 1; font-weight: 400; }
.archive-notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); padding: 8px 0; }
.bottom-nav { position: fixed; z-index: 3; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 640px; display: grid; grid-template-columns: repeat(3,1fr); padding: 8px 12px max(12px,env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.nav-button { min-height: 52px; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; border-radius: var(--radius-control); color: var(--muted); font-size: 12px; font-weight: 500; }
.nav-button svg { width: 22px; height: 22px; }
.nav-button.selected { color: var(--accent); background: var(--soft); }
.section-header { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 20px; min-height: 76px; background: var(--surface); }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 4px; color: var(--accent); font-size: 16px; font-weight: 500; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; flex-shrink: 0; color: var(--muted); font-size: 28px; font-weight: 400; border-radius: var(--radius-control); }
.button { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; border-radius: var(--radius-control); padding: 12px 16px; font-size: 16px; font-weight: 500; }
.button + .button, #list-actions { margin-top: 8px; }
.primary { color: var(--on-accent); background: var(--accent); }
.primary:hover { background: var(--accent-hover); }
.secondary { border: 1px solid var(--control); color: var(--accent); background: var(--raised); }
.danger { color: var(--danger); }
.danger:hover { background: var(--danger-soft); }
.empty-message { color: var(--muted); font-size: 14px; text-align: center; padding: 24px 12px; }
.search-field { display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 4px 0 12px; background: var(--raised); border: 1px solid var(--control); border-radius: var(--radius-control); }
.search-field > svg { width: 20px; height: 20px; color: var(--muted); }
.search-field input { flex: 1; min-width: 0; border: 0; border-radius: 8px; outline: none; padding: 12px 8px; background: none; font-size: 16px; }
.search-field:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.search-field input:focus-visible { outline: none; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
#add-search::-webkit-search-cancel-button { display: none; }
.search-field .icon-button { width: 36px; min-width: 36px; }
.submit-add { width: 40px; height: 40px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-size: 25px; flex-shrink: 0; }
.select-wrap { display: inline-flex; align-items: center; position: relative; max-width: 100%; min-width: 0; }
.select-wrap select { appearance: none; background: transparent; border: 0; padding: 8px 28px 8px 0; min-height: 44px; font-size: 16px; color: var(--accent); font-weight: 500; width: 100%; cursor: pointer; text-overflow: ellipsis; }
.select-wrap > span { position: absolute; right: 8px; top: 8px; color: var(--accent); pointer-events: none; }
select option { background: var(--raised); color: var(--text); }
.catalog-tools { position: sticky; top: 0; padding: 0 20px 8px; background: var(--surface); z-index: 2; }
.catalog-filters { display: flex; gap: 12px; justify-content: space-between; align-items: center; margin-top: 8px; }
.catalog-filters .select-wrap { flex: 1; }
.check-label { display: flex !important; align-items: center; gap: 8px; min-height: 44px; font-size: 14px !important; color: var(--muted); white-space: nowrap; }
.check-label input { width: 18px !important; height: 18px; min-height: 0 !important; margin: 0 !important; accent-color: var(--accent); flex-shrink: 0; }
.directory-items { padding: 0 16px; }
.directory-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; text-align: left; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.directory-row > span:first-child { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
.directory-row strong { font-size: 16px; font-weight: 400; overflow-wrap: anywhere; }
.directory-row small { font-size: 13px; color: var(--muted); }
.directory-row > svg { color: var(--muted); width: 18px; }
.directory-row.is-hidden strong { color: var(--muted); }
.settings-content { padding: 0 20px; }
.settings-section { margin-bottom: 28px; }
.settings-section h2 { font-size: 14px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; }
.setting-row strong { font-size: 16px; font-weight: 400; overflow-wrap: anywhere; }
.setting-row small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.setting-row > span:last-child { font-size: 24px; color: var(--muted); }
.theme-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.theme-option { text-align: left; padding: 0; border-radius: var(--radius-control); border: 2px solid var(--line); overflow: hidden; }
.theme-option[aria-pressed='true'] { border-color: var(--accent); }
.theme-preview { background: var(--surface); color: var(--text); display: flex; gap: 8px; padding: 16px 12px; height: 78px; align-items: center; border-bottom: 1px solid var(--line); }
.theme-preview .preview-check { width: 20px; height: 20px; background: var(--soft); color: var(--accent); border: 1px solid var(--accent); border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: 13px; }
.preview-lines { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.preview-lines span { display: block; height: 5px; width: 78%; border-radius: 4px; background: var(--text); }
.preview-lines span + span { width: 55%; background: var(--muted); height: 4px; }
.theme-name { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-size: 14px; font-weight: 500; color: var(--text); background: var(--raised); }
.theme-selected { width: 18px; height: 18px; color: var(--accent); }
.theme-selected svg { width: 18px; height: 18px; }
dialog { color: var(--text); border: 1px solid var(--line); background: var(--surface); padding: 0; box-shadow: 0 12px 60px var(--shadow); }
dialog::backdrop { background: var(--overlay); }
body:has(dialog[open]) { overflow: hidden; }
.modal { position: fixed; top: calc(var(--viewport-top) + var(--visible-height) / 2); left: 50%; bottom: auto; right: auto; transform: translate(-50%,-50%); margin: 0; width: calc(100% - 32px); max-width: 520px; max-height: calc(var(--visible-height) - 32px); border-radius: var(--radius-dialog); overflow-y: auto; overscroll-behavior: contain; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; padding: 12px 16px 8px 24px; position: sticky; top: 0; z-index: 2; background: var(--surface); }
.form-body { padding: 4px 24px 24px; }
.form-body > label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 16px; }
.form-body input, .form-body textarea, .form-body select { display: block; width: 100%; min-height: 48px; margin-top: 6px; border-radius: var(--radius-control); border: 1px solid var(--control); padding: 10px 12px; font-size: 16px; font-weight: 400; background: var(--raised); }
.form-body textarea { resize: vertical; line-height: 1.45; }
.form-body input:disabled, .form-body select:disabled { color: var(--muted); opacity: 1; background: var(--surface); }
.form-error { margin-bottom: 16px; color: var(--danger); font-size: 14px; }
.supporting-text { margin-top: 16px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.info-body p { margin-bottom: 16px; font-size: 16px; }
.info-body p:last-child { margin-bottom: 0; }
.add-sheet { position: fixed; inset: auto 0 var(--keyboard-gap); margin: 0 auto; width: 100%; max-width: 640px; height: min(800px,calc(var(--visible-height) - 40px)); max-height: calc(var(--visible-height) - 16px); border-radius: 20px 20px 0 0; }
.add-sheet[open] { display: flex; flex-direction: column; }
.add-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 20px; min-height: 64px; flex-shrink: 0; }
.add-header .select-wrap { flex: 1; max-width: calc(100% - 88px); }
.add-header .text-button { flex-shrink: 0; }
.add-sheet .search-field { margin: 0 20px 12px; flex-shrink: 0; }
.add-scroll { overflow: auto; overscroll-behavior: contain; flex: 1; min-height: 0; padding: 0 12px max(24px,env(safe-area-inset-bottom)); scrollbar-width: thin; }
.choice-row { display: grid; grid-template-columns: minmax(0,1fr) 56px; min-height: 56px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.choice-row.is-selected { background: var(--soft); }
.choice-body { text-align: left; padding: 12px; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.choice-mark { display: grid; place-items: center; color: var(--accent); min-height: 56px; }
.choice-mark > span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--control); }
.choice-mark svg { width: 18px; height: 18px; }
.is-selected .choice-mark > span { border-color: var(--accent); color: var(--on-accent); background: var(--accent); }
.custom-choice { color: var(--accent); }
.add-feedback { position: absolute; bottom: max(20px,env(safe-area-inset-bottom)); left: 20px; right: 20px; margin: auto; width: max-content; max-width: calc(100% - 40px); background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: var(--radius-control); box-shadow: 0 6px 24px var(--shadow); font-size: 14px; pointer-events: none; }
.picker-body { padding: 0 20px 20px; }
.segmented { display: flex; padding: 4px; border-radius: var(--radius-control); background: var(--canvas); gap: 4px; margin-bottom: 20px; }
.segmented button { flex: 1; min-height: 44px; padding: 8px; font-size: 14px; border-radius: 8px; color: var(--muted); }
.segmented button[aria-pressed='true'] { color: var(--accent); background: var(--raised); font-weight: 500; }
.list-group h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 20px 4px 4px; }
.list-option { display: grid; grid-template-columns: minmax(0,4fr) minmax(44px,1fr); min-height: 60px; border-bottom: 1px solid var(--line); }
.list-option.active { background: var(--soft); border-radius: 8px; }
.list-open { text-align: left; display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 8px; min-width: 0; }
.list-open strong { font-size: 16px; font-weight: 400; overflow-wrap: anywhere; }
.list-open small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.list-options-button { display: grid; place-items: center; color: var(--muted); }
.list-options-button svg { width: 20px; height: 20px; }
.notice { padding: 12px 16px; font-size: 14px; }
.error { background: var(--danger-soft); color: var(--danger); }
.toast { position: fixed; z-index: 10; bottom: calc(88px + var(--keyboard-gap)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); width: max-content; display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: var(--radius-control); background: var(--text); color: var(--surface); box-shadow: 0 6px 24px var(--shadow); font-size: 14px; }
.toast button { min-height: 32px; font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.toast span { overflow-wrap: anywhere; }
@media (hover: hover) {
  .item-edit:hover, .icon-button:hover, .directory-row:hover, .setting-row:hover { background: var(--soft); }
  .text-button:hover, .add-row:hover { color: var(--accent-hover); }
}
@media (min-width: 700px) {
  .app-shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .add-sheet { bottom: max(24px,var(--keyboard-gap)); border-radius: 20px; max-width: 580px; height: min(760px,calc(var(--visible-height) - 64px)); }
  .list-content, .directory-items { padding-left: 24px; padding-right: 24px; }
  .list-header, .section-header { padding-left: 28px; padding-right: 28px; }
}
@media (max-width: 359px) {
  .list-header { padding-left: 16px; padding-right: 16px; gap: 8px; }
  .list-count { font-size: 24px; }
  .section-header { padding-left: 16px; padding-right: 16px; }
  .section-header .text-button { font-size: 14px; }
  .form-body { padding-left: 20px; padding-right: 20px; }
  .modal-header { padding-left: 20px; }
  .theme-options { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

.item-toggle:disabled { opacity: 1; }
.primary:active { background: var(--accent-hover); }
.secondary:active, .text-button:active, .icon-button:active, .item-edit:active, .choice-body:active, .choice-mark:active { background: var(--soft); }
.add-symbol svg { width: 16px; height: 16px; }
.text-button > svg { width: 18px; height: 18px; }
.submit-add svg { width: 20px; height: 20px; }
.choice-add { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0,1fr) 56px; padding: 0; }
.choice-label { padding: 12px; align-self: center; }

.auth-screen { min-height:100dvh; display:grid; place-items:center; padding:24px; }
.auth-card { width:min(100%,360px); }
.auth-card h1 { font-size:28px; margin:0 0 24px; }
.auth-card form,.auth-card label,#join-form,#password-form { display:grid; gap:14px; }
.auth-card label { gap:6px; }
.auth-card input,#join-form input,#password-form input,#invite-link { width:100%; min-height:48px; border:1px solid var(--control); border-radius:12px; background:var(--raised); color:var(--text); padding:10px 12px; font:inherit; }
.sync-status { position:fixed; top:0; left:50%; transform:translateX(-50%); max-width:100%; z-index:30; background:var(--text); color:var(--surface); font-size:13px; padding:6px 14px; border-radius:0 0 12px 12px; text-align:center; }
.member-row { display:flex; align-items:center; flex-wrap:wrap; gap:8px; padding:10px 0; border-bottom:1px solid var(--line); }
.member-row>span { flex:1; min-width:100px; }
.member-row small { display:block; color:var(--muted); font-size:13px; }
#group-management { display:grid; gap:10px; }
#invite-link { font-size:14px; }
[hidden] { display:none !important; }
