:root {
  --paper: #f7f3ec;
  --surface: #fffdf9;
  --surface-soft: #f2eee7;
  --ink: #181c19;
  --muted: #70766f;
  --line: rgba(27, 33, 29, .10);
  --accent: #ff6f4e;
  --green: #237a61;
  --yellow: #f3d98b;
  --danger: #a83b2a;
  --shadow: 0 16px 38px rgba(43, 48, 42, .10);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 16% -8%, rgba(35,122,97,.14), transparent 34%),
    radial-gradient(circle at 98% 0%, rgba(255,111,78,.12), transparent 30%),
    linear-gradient(180deg, #fbf7ef, var(--paper));
}

button, input, select, textarea { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .7; cursor: wait; }
.hidden { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 7vw, 38px); line-height: 1.03; letter-spacing: -.025em; }
h2 { margin-bottom: 0; font-size: 24px; line-height: 1.12; letter-spacing: -.015em; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.5; }
.inline-icon { width: 15px; height: 15px; }

.auth-shell {
  min-height: calc(100vh - env(safe-area-inset-top));
  display: grid;
  place-items: end center;
  padding: 20vh 0 0;
  background: linear-gradient(rgba(18,28,23,.16), rgba(18,28,23,.42)), url('/images/login-home.webp') center/cover no-repeat;
}
.auth-orb, .liquid-bg, .hero-aurora { display: none; }
.auth-card {
  width: min(100%, 520px);
  max-height: 84vh;
  overflow-y: auto;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
  border-radius: 30px 30px 0 0;
  background: rgba(255,253,249,.96);
  box-shadow: 0 -16px 46px rgba(0,0,0,.18);
}
.brand-mark { display: flex; width: 58px; height: 36px; margin-bottom: 22px; }
.brand-mark span { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); }
.brand-mark span:last-child { margin-left: -10px; background: var(--green); mix-blend-mode: multiply; }
.auth-intro { max-width: 360px; margin: 12px 0 26px; color: var(--muted); line-height: 1.5; }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #4d544e; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
  box-shadow: inset 0 1px rgba(255,255,255,.8);
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: rgba(35,122,97,.46); box-shadow: 0 0 0 4px rgba(35,122,97,.10); }
.person-setup { position: relative; display: grid; gap: 12px; padding: 18px 16px 16px; border-left: 4px solid var(--accent); border-radius: 18px; background: #fff4ec; }
.person-setup.person-b { border-color: var(--green); background: #edf7f1; }
.person-number { position: absolute; top: 8px; right: 12px; color: rgba(0,0,0,.18); font-size: 26px; font-weight: 900; }
.primary-btn, .secondary-btn, .danger-btn {
  min-height: 52px;
  border: 0;
  border-radius: 17px;
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
}
.primary-btn { background: var(--green); color: white; box-shadow: 0 10px 24px rgba(35,122,97,.20); }
.secondary-btn { border: 1px solid var(--line); background: #fff; }
.danger-btn { display: flex; align-items: center; justify-content: center; gap: 8px; background: #fdebe6; color: var(--danger); }
.form-error { min-height: 20px; margin: 14px 0 0; color: var(--danger); font-size: 13px; }
.member-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.member-choice { min-height: 80px; border: 1px solid var(--line); border-radius: 18px; background: #fff; cursor: pointer; font-weight: 800; }
.member-choice.active { border-color: var(--member-color); box-shadow: inset 0 0 0 2px var(--member-color); background: color-mix(in srgb, var(--member-color) 8%, white); }

.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 14px 16px 126px;
  overflow-x: clip;
  touch-action: pan-y;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 4px 2px;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.sync-state { display: none; color: var(--green); font-size: 12px; font-weight: 800; }
.sync-state.offline { color: #a06722; }
.avatar {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--member-color, var(--green));
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--member-color, var(--green)) 26%, transparent);
}
.view { display: none; animation: appear .18s ease; }
.view.active { display: block; }
@keyframes appear { from { opacity: .35; transform: translateY(3px); } }

.hero-panel {
  position: relative;
  min-height: 188px;
  padding: 22px 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    radial-gradient(circle at 95% 5%, rgba(255,111,78,.18), transparent 34%),
    radial-gradient(circle at 5% 0%, rgba(35,122,97,.13), transparent 34%),
    linear-gradient(145deg, #fffdfa, #f6eddd);
  box-shadow: var(--shadow);
}
.hero-panel::after {
  content: "";
  position: absolute;
  right: -76px;
  bottom: -108px;
  width: 228px;
  height: 228px;
  border: 1px solid rgba(35,122,97,.14);
  border-radius: 50%;
  box-shadow: 0 0 0 28px rgba(35,122,97,.05), 0 0 0 58px rgba(35,122,97,.03);
}
.hero-panel > * { position: relative; z-index: 1; }
.hero-panel p { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--green); font-size: 14px; font-weight: 700; }
.hero-panel h2 { max-width: 340px; font-size: clamp(32px, 9vw, 44px); line-height: 1; letter-spacing: -.035em; }
.home-pulse { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.home-pulse span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid rgba(35,122,97,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: #46524a;
  font-size: 11px;
  font-weight: 800;
}

.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.quick-grid button {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(38,45,39,.07);
}
.quick-grid svg { color: var(--accent); }

.section-block {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.section-block.compact { margin-top: 0; }
.section-heading, .page-heading, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading { margin-bottom: 16px; }
.text-btn { border: 0; background: none; color: var(--green); font-size: 14px; font-weight: 900; cursor: pointer; }
.split-section { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 14px; }
.count-badge { display: grid; place-items: center; min-width: 34px; height: 34px; border-radius: 50%; background: #f2dda0; font-weight: 900; }
.item-list { display: grid; gap: 1px; overflow: hidden; border-radius: 20px; background: rgba(24,30,26,.07); }
.item-list.roomy { margin-top: 18px; }
.task-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  min-height: 72px;
  padding: 12px 11px;
  background: #fff;
}
.task-row.done .item-title, .shop-row.done .item-title { color: var(--muted); text-decoration: line-through; }
.task-check, .shop-check { display: grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid #b1b8b0; border-radius: 50%; background: transparent; cursor: pointer; }
.task-check svg, .shop-check svg { width: 17px; opacity: 0; }
.done .task-check, .done .shop-check { border-color: var(--green); background: var(--green); color: white; }
.done .task-check svg, .done .shop-check svg { opacity: 1; }
.item-title { margin: 0 0 4px; font-size: 15px; font-weight: 850; }
.item-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 11px; }
.item-meta .overdue { color: #b4422e; font-weight: 850; }
.member-dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--member-color); }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; }
.mini-list { display: grid; gap: 10px; }
.mini-row { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.mini-row:last-child { border: 0; padding-bottom: 0; }
.activity-list { display: grid; gap: 12px; }
.activity-item { display: grid; grid-template-columns: auto 1fr; gap: 9px; font-size: 13px; line-height: 1.35; }
.activity-avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--member-color); color: white; font-size: 10px; font-weight: 900; }
.activity-item time { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.empty { padding: 28px 12px; border-radius: 18px; background: var(--surface-soft); color: var(--muted); text-align: center; font-size: 14px; }

.page-heading { margin: 6px 0 18px; }
.page-heading h2 { font-size: 34px; }
.round-add { display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--accent); color: white; cursor: pointer; box-shadow: 0 10px 24px rgba(255,111,78,.22); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 16px; background: #e8e4dd; }
.segmented button { min-height: 40px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 850; cursor: pointer; }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.quick-input { display: grid; grid-template-columns: 1fr 52px; gap: 8px; margin: 16px 0; }
.quick-input button { display: grid; place-items: center; border: 0; border-radius: 16px; background: var(--accent); color: white; cursor: pointer; }
.shopping-groups { display: grid; gap: 14px; }
.shopping-group h3 { margin: 0 0 8px; color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.shop-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.quantity { min-width: 35px; color: var(--muted); font-size: 12px; text-align: right; }
.notes-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
.note-card { position: relative; min-height: 156px; padding: 20px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.note-card.pinned { border-top: 4px solid var(--yellow); }
.note-card p { margin: 0 0 30px; line-height: 1.55; white-space: pre-wrap; }
.note-card footer { position: absolute; right: 16px; bottom: 13px; left: 20px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.note-card footer button { border: 0; background: none; color: var(--muted); cursor: pointer; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: min(calc(100% - 26px), 488px);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255,253,249,.98);
  box-shadow: 0 -8px 30px rgba(34,39,35,.14);
  transform: translateX(-50%);
  touch-action: pan-y;
}
.bottom-nav button { display: grid; place-items: center; gap: 3px; min-height: 58px; border: 0; border-radius: 22px; background: transparent; color: #777e77; font-size: 10px; font-weight: 850; cursor: pointer; }
.bottom-nav button.active { background: var(--green); color: white; }
.bottom-nav svg { width: 21px; height: 21px; }

.sheet-dialog { width: min(92vw, 520px); max-height: 92vh; margin: auto; border: 1px solid var(--line); border-radius: 30px; padding: 0; background: var(--surface); box-shadow: var(--shadow); }
.sheet-dialog::backdrop { background: rgba(20,24,20,.42); backdrop-filter: blur(2px); }
.dialog-body { display: grid; gap: 16px; padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
.close-btn { width: 42px; height: 42px; border: 0; background: transparent; color: var(--muted); font-size: 30px; cursor: pointer; }
.two-columns { display: grid; grid-template-columns: 1fr; gap: 12px; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 18px; height: 18px; }
.small-dialog { width: min(92vw, 410px); }
.notification-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-soft); }
.notification-card strong { font-size: 14px; }
.notification-card p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.inline-action { margin: 7px 0 0; border: 0; padding: 0; background: transparent; color: var(--green); font-size: 11px; font-weight: 800; cursor: pointer; }
.notification-icon { position: relative; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(145deg, #ff7b5e, #ed5637); }
.notification-icon span { position: absolute; top: 11px; left: 11px; width: 16px; height: 14px; border: 2px solid white; border-radius: 8px 8px 5px 5px; }
.notification-icon span:last-child { top: 27px; left: 17px; width: 4px; height: 2px; border: 0; border-radius: 2px; background: white; }
.ios-switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; border: 0; border-radius: 16px; padding: 2px; background: #d1d1d6; cursor: pointer; transition: background .18s; }
.ios-switch span { display: block; width: 27px; height: 27px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: transform .18s cubic-bezier(.2,.8,.2,1); }
.ios-switch.active { background: #34c759; }
.ios-switch.active span { transform: translateX(20px); }
.toast { position: fixed; z-index: 50; top: calc(104px + env(safe-area-inset-top)); right: 50%; width: max-content; max-width: min(340px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 18px; background: rgba(24,28,25,.92); color: white; opacity: 0; transform: translate(50%, -8px); pointer-events: none; transition: .18s; font-size: 13px; box-shadow: 0 14px 34px rgba(0,0,0,.18); }
.toast.show { opacity: 1; transform: translate(50%, 0); }
.portrait-only { display: none; }

@media (min-width: 480px) {
  .app-shell { padding-inline: 20px; }
  .two-columns { grid-template-columns: 1fr 1fr; }
  .hero-panel { min-height: 230px; }
}

@media (max-width: 430px) {
  .topbar h1 { font-size: 25px; }
  .hero-panel { min-height: 184px; padding: 20px 18px; }
  .hero-panel h2 { font-size: 34px; max-width: 292px; }
  .home-pulse span { font-size: 10px; }
  .quick-grid { gap: 8px; }
  .quick-grid button { min-height: 68px; }
  .section-block { padding: 18px 14px; }
  .section-heading h2 { font-size: 30px; }
  .section-heading .text-btn { flex: 0 0 auto; }
  .app-shell { padding-bottom: 142px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  body > :not(.portrait-only) { display: none !important; }
  .portrait-only { position: fixed; z-index: 999; inset: 0; display: grid; place-content: center; justify-items: center; padding: 24px; background: var(--paper); text-align: center; }
  .portrait-only strong { margin-top: 22px; font-size: 22px; }
  .portrait-only p { max-width: 310px; margin: 8px 0 0; color: var(--muted); line-height: 1.45; }
  .rotate-phone { position: relative; width: 72px; height: 46px; border: 4px solid var(--green); border-radius: 12px; transform: rotate(-8deg); }
  .rotate-phone span { position: absolute; top: 50%; right: -26px; width: 18px; height: 18px; margin-top: -9px; border-top: 3px solid var(--accent); border-right: 3px solid var(--accent); transform: rotate(45deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
