/* ------------------------------------------------------------------
   Family HQ - built phone-first, widens gracefully on a laptop.
   ------------------------------------------------------------------ */

:root {
  --bg:        #0f1420;
  --bg-2:      #151c2c;
  --card:      #1b2334;
  --card-2:    #222c41;
  --line:      #2c3852;
  --text:      #eef2fa;
  --muted:     #8f9dba;
  --accent:    #5b8def;
  --good:      #3fbf9a;
  --warn:      #f0a13c;
  --bad:       #e5606b;
  --radius:    16px;
  --radius-sm: 11px;
  --tap:       48px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Several rules below set `display`, which would otherwise beat the browser's
   built-in [hidden] rule and leave hidden panels on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

/* `manipulation` drops the double-tap-to-zoom gesture on controls, so fast
   repeated taps (the PIN pad, checking off a list) register as taps instead of
   a zoom. Pinch-to-zoom on the page itself is untouched. */
button, input, textarea, select, label.field, .who, .task, .mini {
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }

/* ============ LOCK SCREEN ============ */

.lock {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px calc(28px + var(--safe-b));
  background: radial-gradient(120% 90% at 50% 0%, #1c2740 0%, var(--bg) 62%);
}

.lock-inner { width: 100%; max-width: 400px; text-align: center; }

.brand { font-size: 2rem; letter-spacing: -0.03em; }

.brand-sub {
  margin: 6px 0 32px;
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.lock-prompt { margin: 0 0 18px; color: var(--muted); font-size: 1rem; }

.who-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.who {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.who:active { transform: scale(0.96); border-color: var(--accent); }

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #0d1220;
}

.who-name { font-weight: 600; font-size: 1.02rem; }
.who-role { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.link-back {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.pin-avatar {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #0d1220;
}

.pin-dots { display: flex; justify-content: center; gap: 15px; margin: 4px 0 2px; }

.pin-dots span {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--line);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pin-dots span.filled { background: var(--accent); border-color: var(--accent); }

.pin-error { min-height: 20px; margin: 10px 0 6px; color: var(--bad); font-size: 0.86rem; }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 300px;
  margin: 0 auto;
}

.pad-key {
  height: 66px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 1.5rem;
  font-weight: 600;
  transition: background 0.1s ease, transform 0.1s ease;
}

.pad-key:active { background: var(--card-2); transform: scale(0.94); }
.pad-del { font-size: 1.2rem; color: var(--muted); }

/* ============ APP SHELL ============ */

#app { padding-bottom: calc(78px + var(--safe-b)); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(15, 20, 32, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px 6px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.94rem;
}

.chip .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; color: #0d1220; font-weight: 700; }

.icon-btn {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 0.86rem;
  padding: 8px 4px;
}

main { padding: 0 16px; max-width: 620px; margin: 0 auto; }

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 4px;
}

.view-head h2 { font-size: 1.25rem; }

.hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 14px; line-height: 1.5; }

.stack { display: flex; flex-direction: column; gap: 10px; }

.bottom-space { height: 24px; }

.empty { color: var(--muted); text-align: center; padding: 34px 16px; font-size: 0.95rem; }

/* ---- date bar ---- */

.datebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 12px;
}

.date-nav {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
}

.date-nav:active { background: var(--card-2); }

.date-label { text-align: center; line-height: 1.3; }
.date-label strong { display: block; font-size: 1.15rem; }
.date-label span { font-size: 0.82rem; color: var(--muted); }

/* ---- progress hero ---- */

.hero-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ring { width: 76px; height: 76px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--good); stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset 0.5s ease; }

.hero-text { display: flex; flex-direction: column; gap: 3px; }
.hero-pct { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; }
.hero-sub { color: var(--muted); font-size: 0.9rem; }

/* ---- task rows ---- */

.task {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  transition: opacity 0.2s ease, background 0.15s ease;
}

.task.done { opacity: 0.5; }
.task.done .task-title { text-decoration: line-through; }

.check {
  flex: none;
  width: 27px;
  height: 27px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
  display: grid;
  place-items: center;
  font-size: 0.86rem;
  color: transparent;
  transition: all 0.15s ease;
}

.check.on { background: var(--good); border-color: var(--good); color: #08130f; }
.check:active { transform: scale(0.88); }
.check[disabled] { opacity: 0.45; cursor: default; }

.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 1rem; line-height: 1.35; word-break: break-word; }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; font-size: 0.76rem; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card-2);
  font-size: 0.72rem;
}

.task-note { margin-top: 6px; font-size: 0.85rem; color: var(--muted); line-height: 1.45; white-space: pre-wrap; }

/* Small glyph, thumb-sized hit area. */
.row-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -8px -10px -8px 0;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
}

.row-btn:active { color: var(--text); }

/* ---- family cards ---- */

.person-card {
  padding: 15px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.person-top { display: flex; align-items: center; gap: 12px; }
.person-name { flex: 1; font-weight: 600; font-size: 1.03rem; }
.person-count { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.bar { height: 7px; border-radius: 999px; background: var(--line); margin-top: 12px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width 0.45s ease; }

.person-tasks { margin-top: 13px; display: flex; flex-direction: column; gap: 8px; }

.mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--bg-2);
  border-radius: 9px;
  font-size: 0.9rem;
}

.mini.done { opacity: 0.45; }
.mini.done .mini-title { text-decoration: line-through; }
.mini-title { flex: 1; min-width: 0; word-break: break-word; }

/* ---- routine rows ---- */

.routine {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}

.routine.off { opacity: 0.45; }
.routine-main { flex: 1; min-width: 0; }
.routine-title { font-size: 0.99rem; }
.routine-meta { margin-top: 5px; font-size: 0.77rem; color: var(--muted); }

/* ---- buttons ---- */

.btn-small {
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.87rem;
  font-weight: 600;
}

.btn-small:active { background: rgba(91, 141, 239, 0.14); }

.btn {
  width: 100%;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}

.btn:active { filter: brightness(0.9); }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn[disabled] { opacity: 0.55; }

/* ---- FAB + tabs ---- */

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(84px + var(--safe-b));
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 1.9rem;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.fab:active { transform: scale(0.93); }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  padding-bottom: var(--safe-b);
  background: rgba(15, 20, 32, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 12px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

.tab-ico { font-size: 1.05rem; line-height: 1; }
.tab.is-active { color: var(--accent); }

/* ---- sheet ---- */

.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 13, 0.66); }

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 10px 18px calc(26px + var(--safe-b));
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  animation: rise 0.22s ease;
}

@keyframes rise { from { transform: translateY(22px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.sheet-grip { width: 42px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { font-size: 1.15rem; margin-bottom: 16px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

input[type="text"], input[type="date"], input[type="tel"], textarea, select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
}

textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

/* Tap-to-fill suggestions under a text field. */
.quick { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }

.quick-chip {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.87rem;
  white-space: nowrap;
}

.quick-chip:active { transform: scale(0.94); }
.quick-chip.on { border-color: var(--accent); background: rgba(91, 141, 239, 0.16); color: var(--text); font-weight: 600; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }

.seg button, .seg .opt {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.seg button.on, .seg .opt.on { border-color: var(--accent); background: rgba(91, 141, 239, 0.16); color: var(--text); font-weight: 600; }

.dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow button { min-height: 42px; padding: 0; font-size: 0.78rem; }

.sheet-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }

/* ---- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 80;
  max-width: 88vw;
  padding: 11px 18px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: rise 0.18s ease;
}

.toast.bad { border-color: var(--bad); color: #ffd9dc; }

/* ---- wider screens ---- */

@media (min-width: 760px) {
  main { max-width: 720px; padding: 0 24px; }
  .who-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
