:root {
  --bg: #0F1115; --surface: #181B22; --surface-2: #20242E; --line: #2C313C;
  --text: #ECEFF4; --muted: #9AA4B2; --accent: #5B8DEF;
  --c-david: #4285F4; --c-pamela: #16A765; --c-ava: #F4B5C0; --c-chris: #FF7537; --c-family: #7B1FA2;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  overscroll-behavior: none;
}
.hidden { display: none !important; }

/* App shell */
.ph-app { position: fixed; inset: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom)); display: flex; flex-direction: column; }
.ph-view { display: none; flex-direction: column; height: 100%; min-height: 0; }
.ph-view:not(.hidden) { display: flex; }

.ph-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.ph-head-title { font-size: 20px; font-weight: 800; text-align: center; flex: 1; }
.ph-nav {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: 24px; cursor: pointer;
}
.ph-subhead { padding: 10px 16px; display: flex; gap: 8px; align-items: center; overflow-x: auto; }
.ph-section-title { font-size: 15px; color: var(--muted); margin: 18px 4px 8px; }
.ph-chip { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 14px; }

.ph-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 24px; }

/* Buttons / inputs */
.ph-btn { padding: 12px 18px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700; }
.ph-btn-primary { display: inline-block; text-decoration: none; }
.ph-add { display: flex; gap: 8px; padding: 12px 16px calc(12px); background: var(--surface); border-top: 1px solid var(--line); }
.ph-add input, .ph-search input {
  flex: 1; padding: 14px; font-size: 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}

/* Calendar agenda */
.ph-event { display: flex; gap: 12px; padding: 14px; margin-bottom: 10px; background: var(--surface); border-radius: 14px; border-left: 5px solid var(--c, var(--accent)); }
.ph-event-time { font-size: 14px; color: var(--muted); min-width: 64px; font-weight: 600; }
.ph-event-body { flex: 1; }
.ph-event-title { font-size: 17px; font-weight: 700; }
.ph-event-person { font-size: 13px; color: var(--muted); }
.ph-empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* Tasks */
.ph-tabs .ph-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ph-list { list-style: none; margin: 0; padding: 0; }
.ph-item { display: flex; align-items: center; gap: 12px; padding: 14px 6px; border-bottom: 1px solid var(--line); }
.ph-item.done .ph-item-text { text-decoration: line-through; color: var(--muted); }
.ph-check { width: 28px; height: 28px; flex: none; border: 2px solid var(--line); border-radius: 50%; background: transparent; }
.ph-item.done .ph-check { background: var(--accent); border-color: var(--accent); }
.ph-item-text { flex: 1; font-size: 17px; }
.ph-item-sub { font-size: 13px; color: var(--muted); }
.ph-del { width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 24px; }

/* Groceries */
.gro-card { display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 8px; background: var(--surface); border-radius: 12px; }
.gro-card img { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 8px; flex: none; }
.gro-card-body { flex: 1; min-width: 0; }
.gro-card-name { font-size: 15px; font-weight: 600; }
.gro-card-price { font-size: 14px; color: var(--muted); }
.gro-card-add { padding: 10px 14px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
.ph-hint { color: var(--muted); padding: 8px 2px; }

/* Money */
.pm-card { background: var(--surface); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.pm-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.pm-card-name { font-size: 19px; font-weight: 800; }
.pm-card-total { font-size: 22px; font-weight: 800; color: var(--accent); }
.pm-card-sub { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.pm-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.pm-row-day { color: var(--muted); font-size: 13px; }
.pm-row-amt { font-weight: 700; }

/* Tab bar */
.ph-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); z-index: 50;
}
.ph-tab { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; }
.ph-tab.active { color: var(--accent); }
.ph-tab-ico { font-size: 22px; line-height: 1; }

/* Connect screen */
.ph-connect { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.ph-connect-card { text-align: center; }
.ph-connect-card h1 { font-size: 26px; }
.ph-btn-primary { background: var(--accent); padding: 14px 24px; border-radius: 12px; color: #fff; font-weight: 700; }

/* Login */
.ph-login { display: flex; flex-direction: column; gap: 14px; width: min(360px, 86vw); }
.ph-login input { padding: 14px 16px; font-size: 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.ph-login .ph-btn-primary { margin-top: 4px; border: 0; }
.ph-login-error { color: #ff8a80; font-size: 14px; }
.ph-signout {
  position: fixed; top: calc(var(--safe-top) + 10px); right: 12px; z-index: 60;
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--surface-2); color: var(--muted); font-size: 18px;
}

/* Toast */
.ph-toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  background: var(--surface-2); color: var(--text); padding: 12px 20px; border-radius: 999px;
  font-size: 15px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.ph-toast.ok { background: #1f7a3d; color: #fff; }
.ph-toast.error { background: #b3261e; color: #fff; }
