:root {
  --navy: #0f3d5e; --red: #ba0c2f; --bg: #f4f6f9; --card: #fff; --text: #17212b; --muted: #6b7785;
  --line: #e1e6ec; --accent: #0f5f9c; --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; overscroll-behavior: none; }
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--bg); position: relative; }
.splash { margin: auto; color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; /* 16px stops iOS zoom */ width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
textarea { resize: vertical; }
h1, h2, h3 { margin: 0; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .center { text-align: center; } .pad { padding: 12px 4px; } .grow { flex: 1; min-width: 0; } .bold { font-weight: 700; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 12px 8px; background: var(--navy); color: #fff; flex: none; }
.group-btn { background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 999px; padding: 7px 14px; display: flex; align-items: center; gap: 6px; max-width: 70%; font-weight: 600; }
.group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-btn { margin-left: auto; background: none; border: 0; padding: 0; }
.conn { font-size: .75rem; color: #ffd; } .conn.bad { background: #b45309; padding: 2px 8px; border-radius: 99px; }
.demo-strip { background: #fff3cd; color: #7a5b00; font-size: .8rem; text-align: center; padding: 3px; flex: none; }
main#view { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
main#view.chat-mode { overflow: hidden; display: flex; flex-direction: column; }
.view { padding: 12px 12px 90px; }
.view.chat-view { padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* tabs */
.tabs { display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); flex: none; }
.tabs.hidden { display: none; }
.tab { flex: 1; background: none; border: 0; padding: 7px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--muted); position: relative; min-width: 0; }
.tab .ico { font-size: 1.25rem; line-height: 1.2; } .tab .lbl { font-size: .66rem; }
.tab.on { color: var(--accent); font-weight: 600; }
.badge { background: var(--red); color: #fff; border-radius: 99px; font-size: .72rem; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; }
.tab-badge { position: absolute; top: 2px; left: 55%; }

/* generic */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); border: 0; text-align: left; width: 100%; }
button.card { cursor: pointer; }
.row-card { display: flex; align-items: center; gap: 10px; }
.card.current { outline: 2px solid var(--accent); }
.title { font-weight: 600; }
.btn { border: 1px solid var(--line); background: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: #b91c1c; border-color: #f3c4c4; }
.btn.small { padding: 6px 10px; font-size: .85rem; } .btn.big { padding: 14px; font-size: 1.05rem; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 6px; align-self: center; }
.icon-btn { background: none; border: 0; font-size: 1.2rem; padding: 6px 10px; border-radius: 10px; line-height: 1; } .icon-btn.big { font-size: 1.5rem; } .icon-btn.light { color: #fff; }
.plain { background: none; border: 0; padding: 0; text-align: left; }
.dot { display: inline-block; border-radius: 50%; vertical-align: middle; flex: none; }
.avatar { overflow: hidden; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; }
.tag { background: #eef2f6; color: var(--muted); border-radius: 99px; padding: 2px 8px; font-size: .72rem; }
.banner { background: #e8f1fb; border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 6px 0 10px; }
.banner.warn { background: #fff4e0; color: #7a4b00; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; } .empty .big { font-size: 2.5rem; }
.field { display: flex; flex-direction: column; gap: 4px; } .label { font-size: .82rem; font-weight: 600; color: var(--muted); } .hint { color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; } .check input { width: 20px; height: 20px; }
.seg { display: inline-flex; background: #e6ebf1; border-radius: 10px; padding: 3px; } .seg.wide { display: flex; margin: 8px 0; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); flex: 1; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; font-size: .88rem; display: inline-flex; align-items: center; gap: 4px; } .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; } .swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; } .swatch.on { border-color: #111; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.fab { position: fixed; right: max(16px, calc((100vw - 720px) / 2 + 16px)); bottom: calc(72px + var(--safe-b)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 2rem; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.3); z-index: 5; }
.checkbox { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #aab4c0; background: #fff; flex: none; color: #fff; font-weight: 800; padding: 0; } .checkbox.on { background: #16a34a; border-color: #16a34a; }
.request, .grocery-item { display: flex; align-items: center; gap: 10px; }
.done .title, .grocery-item.done .grow { text-decoration: line-through; color: var(--muted); }
.overdue { color: #b91c1c; font-weight: 600; }

/* auth */
.auth { padding: calc(24px + var(--safe-t)) 20px 24px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; height: 100%; }
.auth h1 { text-align: center; color: var(--navy); } .auth-logo { width: 84px; height: 84px; border-radius: 20px; align-self: center; }

/* sheets */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: #fff; width: 100%; max-width: 720px; border-radius: 20px 20px 0 0; max-height: 92dvh; display: flex; flex-direction: column; padding-bottom: var(--safe-b); animation: up .18s ease-out; }
.sheet.tall { height: 88dvh; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet-body { padding: 8px 16px 20px; overflow-y: auto; }
.sheet-body section { margin-bottom: 16px; } .sheet-body h3 { margin-bottom: 8px; }
.invite { background: #eef6ff; border-radius: 12px; padding: 14px; text-align: center; } .invite code { font-size: 1.7rem; letter-spacing: .15em; font-weight: 700; color: var(--navy); user-select: all; }
#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #1f2933; color: #fff; padding: 10px 16px; border-radius: 99px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: 90vw; text-align: center; font-size: .9rem; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.install-banner { display: flex; align-items: center; gap: 8px; background: #fff; border-top: 1px solid var(--line); padding: 8px 12px; font-size: .9rem; position: absolute; left: 0; right: 0; bottom: calc(58px + var(--safe-b)); z-index: 4; box-shadow: 0 -2px 8px rgba(0,0,0,.1); }

/* calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; background: #fff; border-radius: var(--radius); padding: 6px; }
.dow { text-align: center; font-size: .72rem; color: var(--muted); padding: 4px 0; }
.cell { position: relative; aspect-ratio: 1 / 1; border: 0; background: none; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 0; gap: 2px; }
.cell.empty { pointer-events: none; } .cell .num { font-size: .92rem; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.cell.today .num { background: var(--red); color: #fff; font-weight: 700; } .cell.sel { background: #e8f1fb; outline: 2px solid var(--accent); }
.dots { display: flex; gap: 2px; min-height: 8px; }
.day-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
.event { display: flex; border-left: 6px solid #999; } .agenda-day { margin: 14px 0 2px; color: var(--navy); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: .82rem; color: var(--muted); } .legend-item { display: inline-flex; gap: 4px; align-items: center; }

/* notes */
.note .tag { margin-top: 6px; display: inline-block; }

/* photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.photo-cell { aspect-ratio: 1/1; border: 0; padding: 0; background: #dde3ea; overflow: hidden; border-radius: 4px; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewer { position: fixed; inset: 0; background: #000; z-index: 80; display: flex; flex-direction: column; color: #fff; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; padding: calc(10px + var(--safe-t)) 12px 6px; }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; } .viewer-img.loading { opacity: .7; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.18); border: 0; color: #fff; font-size: 2rem; width: 44px; height: 64px; border-radius: 12px; z-index: 2; } .viewer-nav.left { left: 6px; } .viewer-nav.right { right: 6px; }
.viewer-bottom { padding: 10px 14px calc(14px + var(--safe-b)); display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; } .viewer-bottom .muted { color: #b8c2cc; } .cap-text { font-weight: 600; }
.viewer a.btn { background: #fff; color: #111; text-decoration: none; }

/* chat */
.channel-icon { width: 42px; height: 42px; border-radius: 50%; background: #e8f1fb; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); flex: none; }
.right-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: #fff; border-bottom: 1px solid var(--line); flex: none; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 10px 4px; display: flex; flex-direction: column; gap: 3px; -webkit-overflow-scrolling: touch; }
.day-sep { text-align: center; margin: 10px 0 4px; font-size: .74rem; color: var(--muted); } .day-sep span { background: #e6ebf1; padding: 2px 10px; border-radius: 99px; }
.msg { display: flex; flex-direction: column; max-width: 82%; } .msg.mine { align-self: flex-end; align-items: flex-end; } .msg.theirs { align-self: flex-start; }
.sender { font-size: .75rem; font-weight: 700; margin: 6px 4px 1px; }
.bubble { background: #fff; padding: 7px 11px 5px; border-radius: 16px; box-shadow: 0 1px 1px rgba(0,0,0,.08); cursor: pointer; min-width: 64px; word-break: break-word; }
.msg.mine .bubble { background: #d6eafc; }
.bubble .text { white-space: pre-wrap; } .bubble .meta { font-size: .66rem; color: var(--muted); text-align: right; margin-top: 1px; }
.quote { border-left: 3px solid var(--accent); background: rgba(0,0,0,.05); padding: 3px 8px; border-radius: 6px; margin-bottom: 4px; font-size: .82rem; max-width: 240px; }
.chat-photo { display: block; border: 0; padding: 0; background: #dde3ea; border-radius: 10px; overflow: hidden; margin-bottom: 4px; min-width: 120px; min-height: 80px; }
.chat-photo img { display: block; width: 100%; max-width: 240px; height: auto; }
.reactions { display: flex; gap: 4px; margin-top: -4px; z-index: 1; flex-wrap: wrap; }
.react-chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 1px 7px; font-size: .8rem; } .react-chip.on { background: #d6eafc; border-color: var(--accent); }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #eef2f6; font-size: .85rem; border-top: 1px solid var(--line); flex: none; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px; background: #fff; border-top: 1px solid var(--line); flex: none; }
.composer textarea { resize: none; border-radius: 20px; max-height: 120px; }
.send-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; flex: none; font-size: 1.1rem; }
.emoji-row { display: flex; justify-content: space-around; } .emoji-btn { font-size: 1.8rem; background: none; border: 0; padding: 6px; border-radius: 12px; }
@media (hover: hover) { .btn:hover, .chip:hover { filter: brightness(.96); } }

/* ---- profiles, People tab, birthdays ---- */
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tab .lbl { white-space: nowrap; }
.cell .cake { position: absolute; top: 0; right: 2px; font-size: .62rem; line-height: 1; }
.cell.has-bday .num { box-shadow: inset 0 0 0 2px #f5b301; }
.cell.today.has-bday .num { box-shadow: none; }
.event.birthday { align-items: center; gap: 10px; background: #fff9e6; }
.person-card .title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.person-card .chev { color: var(--muted); font-size: 1.4rem; }
.allergy-line { color: #8a3b00; font-size: .82rem; margin-top: 2px; }
.tag.hot { background: #fde68a; color: #7a4b00; font-weight: 700; }
.nudge { display: flex; align-items: center; gap: 12px; background: #e8f1fb; }
.nudge p { margin: 2px 0 0; font-size: .9rem; }
.bday-strip { margin-bottom: 8px; } .bday-strip h3 { margin: 6px 0 8px; }
.member-open { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.profile { gap: 14px; }
.pf-head { display: flex; align-items: center; gap: 14px; }
.pf-name { font-size: 1.5rem; }
.pf-line { margin-top: 4px; }
.pf-sec { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0 !important; }
.pf-sec h3 { margin: 0 0 8px !important; }
.alert-card { background: #fff4e0; border-color: #f2c77a; color: #5c3600; }
.fav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fav-item { display: flex; align-items: center; gap: 8px; min-width: 0; } .fav-ico { font-size: 1.4rem; }
.fav-val { font-weight: 600; overflow-wrap: anywhere; }
.chip.static { cursor: default; }
.pf-list { margin: 0; padding-left: 20px; } .pf-list li { margin: 2px 0; overflow-wrap: anywhere; }
.pf-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.small-print { font-size: .78rem; margin: 4px 0 0; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stack.tight { gap: 8px; align-items: flex-start; }
.self-end { align-self: end; padding-bottom: 10px; }
.avatar-box { flex: none; }
#pf-form h3 { margin-top: 6px; }
@media (max-width: 380px) { .fav-grid, .grid3 { grid-template-columns: 1fr 1fr; } .tab .lbl { font-size: .6rem; } }
.pf-prompt { background: none; border: 1px dashed #b8c4d0; color: var(--accent); border-radius: 10px; padding: 8px 12px; text-align: left; width: 100%; font-size: .92rem; }
.pf-prompt.inline { border: 0; padding: 0; width: auto; font-size: .88rem; text-decoration: underline; }
.chip.pf-prompt-chip { border-style: dashed; color: var(--accent); }
.fav-item.blank .fav-ico { opacity: .45; }

/* Show/Hide password toggle */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { padding-right: 76px; }
.pw-toggle { position: absolute; right: 0; top: 50%; transform: translateY(-50%); min-width: 64px; min-height: 44px; padding: 0 12px; background: transparent; border: 0; color: var(--accent); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; border-radius: 10px; }

/* notifications */
.notif-status { margin: 4px 0; font-weight: 600; } .notif-status.ok { color: #15803d; } .notif-status.warn { color: #7a4b00; }
.notif-toggles { gap: 6px; } .notif-toggle { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: .95rem; } .notif-toggle input { width: 22px; height: 22px; flex: none; }
.small { font-size: .85rem; }
.notify-banner { display: flex; align-items: center; gap: 8px; background: #fff; border-top: 1px solid var(--line); padding: 8px 12px; font-size: .9rem; position: absolute; left: 0; right: 0; bottom: calc(58px + var(--safe-b)); z-index: 4; box-shadow: 0 -2px 8px rgba(0,0,0,.1); }

.swatch-custom { width: 34px; height: 34px; padding: 0; border: 3px solid #d1d5db; border-radius: 50%; background: none; overflow: hidden; cursor: pointer; }
.swatch-custom::-webkit-color-swatch-wrapper { padding: 0; } .swatch-custom::-webkit-color-swatch { border: none; border-radius: 50%; }

/* profile photo crop */
.crop-box { align-items: center; }
.crop-frame { position: relative; width: min(100%, 300px); aspect-ratio: 1; overflow: hidden; background: #111; border-radius: 12px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.crop-frame.drag { cursor: grabbing; }
.crop-img { position: absolute; max-width: none; pointer-events: none; -webkit-user-drag: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.55), inset 0 0 0 2px rgba(255,255,255,.9); pointer-events: none; }
.crop-zoom { display: flex; align-items: center; gap: 10px; width: min(100%, 300px); font-size: 1.3rem; color: var(--muted); }
.crop-zoom input { padding: 0; border: 0; background: none; }
.crop-actions { width: min(100%, 300px); justify-content: space-between; } .crop-actions .btn { flex: 1; }
