/* Calm, high-contrast mobile UI with large touch targets; light and dark follow the system unless overridden. */
:root {
  --bg: #f6f5f1; --card: #ffffff; --text: #1d2327; --muted: #6a7178; --line: #e4e2db;
  --accent: #2f7d4f; --accent-text: #ffffff; --danger: #b3382c; --chip: #ebe9e2;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14171a; --card: #1e2327; --text: #eceae4; --muted: #99a0a6; --line: #2d3338;
  --accent: #5bbd82; --accent-text: #0e1a13; --danger: #ef7d70; --chip: #2a3035;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a; --card: #1e2327; --text: #eceae4; --muted: #99a0a6; --line: #2d3338;
    --accent: #5bbd82; --accent-text: #0e1a13; --danger: #ef7d70; --chip: #2a3035;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; padding-top: env(safe-area-inset-top); }

.top { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0 12px; }
.top h1 { flex: 1; margin: 0; font-size: 1.25rem; }
.icon-btn { width: 48px; height: 48px; border-radius: 14px; font-size: 1.35rem; display: grid; place-items: center; }
.icon-btn:active { background: var(--chip); }
.status { font-size: .8rem; color: var(--muted); padding: 0 14px; min-height: 1.1em; }
.status.warn { color: var(--danger); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 44px; padding: 0 16px; border-radius: 22px; background: var(--chip); font-weight: 600; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.tab .n { opacity: .7; font-weight: 500; margin-left: 6px; }

.list { flex: 1; overflow-y: auto; padding: 0 12px 16px; overscroll-behavior: contain; }
.cat { margin: 14px 4px 6px; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.item { display: flex; align-items: center; min-height: 58px; background: var(--card); border-radius: 14px; margin-bottom: 6px; border: 1px solid var(--line); }
.item .main { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 6px 4px 6px 12px; text-align: left; min-width: 0; }
.box { flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--muted); display: grid; place-items: center; font-size: 1rem; color: transparent; }
.item.done .box { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.txt { min-width: 0; }
.name { display: block; overflow-wrap: anywhere; }
.note { display: block; font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.qty { flex: none; background: var(--chip); border-radius: 10px; padding: 2px 9px; font-size: .88rem; font-weight: 600; }
.edit { flex: none; width: 48px; height: 58px; color: var(--muted); font-size: 1.2rem; }
.done-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 4px 6px; }
.done-head .cat { margin: 0; }
.clear { min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--chip); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 56px 16px; }

.bar { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.sugs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.sugs:empty { display: none; }
.sug { flex: none; min-height: 40px; padding: 0 14px; border-radius: 20px; background: var(--chip); }
.add { display: flex; gap: 8px; }
.add input { flex: 1; min-width: 0; height: 52px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); padding: 0 16px; }
.add button { width: 56px; height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-text); font-size: 1.6rem; font-weight: 700; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 640px; background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90dvh; overflow-y: auto; }
.sheet h2 { margin: 0 0 12px; font-size: 1.1rem; }
.sheet label { display: block; font-size: .8rem; color: var(--muted); margin: 12px 0 4px; }
.sheet input, .sheet select { width: 100%; height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; }
.row { display: flex; gap: 8px; margin-top: 16px; }
.btn { flex: 1; min-height: 50px; border-radius: 14px; background: var(--chip); font-weight: 600; padding: 0 12px; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.menu-btn { display: block; width: 100%; min-height: 52px; text-align: left; padding: 0 8px; border-bottom: 1px solid var(--line); }
.menu-btn.danger { color: var(--danger); }
.small { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }

.auth { margin: auto; width: 100%; max-width: 380px; padding: 24px 20px; }
.auth h1 { margin: 0 0 6px; }
.auth p { color: var(--muted); margin: 0 0 16px; }
.auth input { width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; margin-bottom: 10px; }
.auth .btn { width: 100%; }
.error { color: var(--danger); min-height: 1.4em; margin: 4px 0; }
@media (prefers-reduced-motion: no-preference) { .item, .tab { transition: background .15s; } }
