/* Family App Portal — mobile-first.
 *
 * Shares the visual language of Nicole Home deliberately: same palette, same
 * radii, same 48px-minimum tap targets. These sit next to each other on the
 * same phone home screen and should read as one household system.
 */

:root {
  --bg: #0d0f16;
  --surface: #171a24;
  --surface-2: #1f2330;
  --line: #2b3040;
  --text: #eef1f8;
  --muted: #9aa3b8;
  --accent: #5b9dff;      /* cool blue — distinguishes this from Nicole Home's warm lamp */
  --accent-ink: #04122b;
  --ok: #4ade80;
  --danger: #ff6b6b;
  --radius: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --line: #dcdfea;
    --text: #171a24;
    --muted: #5c6478;
    --accent: #1f6fe0;
    --accent-ink: #ffffff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: contain;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { font-size: 14px; color: var(--muted); }
.linkbtn {
  background: none; border: 0; padding: 8px;
  color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
  text-decoration: none;
}

/* ---------- family photo welcome ---------- */

.photohero {
  position: relative;
  max-width: 880px;
  min-height: 250px;
  margin: 18px auto 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
}
.photohero[hidden] { display: none; }
.collage {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  background: var(--line);
}
.collage img { width: 100%; height: 100%; object-fit: cover; min-width: 0; min-height: 0; }
.collage img:first-child { grid-row: 1 / 3; }
.collage::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(8,10,16,.72), rgba(8,10,16,.12) 65%, rgba(8,10,16,.25));
}
.hero-copy { position: relative; z-index: 1; padding: 34px; max-width: 400px; color: #fff; }
.hero-copy h2 { margin: 4px 0 0; font-size: clamp(25px, 5vw, 42px); line-height: 1.05; }
.eyebrow { margin: 0; color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }

/* ---------- list ---------- */

.home-intro {
  max-width: 640px; margin: 28px auto 0; padding: 0 16px;
}
.home-intro h2 { margin: 4px 0 2px; font-size: 28px; letter-spacing: -.025em; }
.home-intro > p:last-child { margin: 0; color: var(--muted); }
.list { padding: 16px 16px 40px; max-width: 640px; margin: 0 auto; }
.loading, .empty { color: var(--muted); text-align: center; padding: 40px 16px; }

.footer {
  max-width: 640px;
  margin: -20px auto 32px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.footer a { color: var(--accent); }

.card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 14px; }

.appicon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--surface-2);
  object-fit: cover;
  display: grid; place-items: center;
  font-weight: 700; font-size: 22px; color: var(--muted);
}

.card-body { min-width: 0; }

.card h2 {
  margin: 0 0 2px;
  font-size: 17px; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.meta {
  margin: 0 0 8px;
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta .pkg {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  opacity: 0.75;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.desc { margin: 0 0 14px; font-size: 14px; color: var(--muted); }

.notes {
  margin: -8px 0 14px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
}

.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.btn {
  min-height: 48px;
  padding: 0 22px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:active { filter: brightness(0.92); }

/* An update is the action worth noticing, so it is the one that gets colour;
   a fresh install and an already-current app are both quieter. */
.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.badge {
  font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 20%, transparent);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent);
}
.badge.update {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Deliberately the quietest state on the card. A placeholder should read as
   information, not as something that failed to load or is waiting to be tapped. */
.badge.soon {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

/* A placeholder card has no version line and no button, so it sits shorter than
   an installable one. Slightly dimming it keeps the real apps dominant. */
.card.soon .appicon { opacity: 0.7; }

.unavailable { font-size: 14px; color: var(--muted); font-style: italic; }

.signer {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: 0.6;
  overflow-wrap: anywhere;
}

/* ---------- note + toast ---------- */

.note {
  margin: 0 16px 20px;
  max-width: 640px;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.note[hidden] { display: none; }
@media (min-width: 672px) { .note { margin-left: auto; margin-right: auto; } }

.toast {
  position: fixed; left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
  font-size: 14px; z-index: 50;
}
.toast[hidden] { display: none; }

/* ---------- login ---------- */

.login-page { display: grid; place-items: center; min-height: 100svh; padding: 24px; }

.fun-login {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 22%, color-mix(in srgb, #ffd166 18%, transparent), transparent 28%),
    radial-gradient(circle at 82% 78%, color-mix(in srgb, #ff6b6b 14%, transparent), transparent 30%),
    linear-gradient(145deg, var(--bg), color-mix(in srgb, var(--bg) 82%, #5b9dff));
}
.paper-shapes { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.shape { position: absolute; display: block; opacity: .78; filter: saturate(.9); }
.shape-one {
  width: 170px; height: 170px; left: -55px; top: 9%;
  border-radius: 48% 52% 62% 38%; background: #5b9dff; transform: rotate(22deg);
}
.shape-two {
  width: 115px; height: 115px; right: 6%; top: 8%;
  border: 24px solid #ffd166; border-radius: 50%; transform: rotate(-12deg);
}
.shape-three {
  width: 210px; height: 68px; right: -62px; bottom: 12%;
  border-radius: 999px; background: #ff7d73; transform: rotate(-24deg);
}
.shape-four {
  width: 78px; height: 78px; left: 8%; bottom: 12%;
  background: #65d6ad; transform: rotate(18deg); border-radius: 18px;
}
.shape-five {
  width: 24px; height: 110px; right: 19%; top: 39%;
  border-radius: 999px; background: #b794f6; transform: rotate(42deg);
}

.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
}
.family-login-card {
  max-width: 400px;
  padding: 34px 30px 26px;
  border-color: color-mix(in srgb, var(--line) 70%, #5b9dff);
  box-shadow: 0 26px 80px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.04);
}
.family-mark {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 82px; margin: 0 auto 15px;
  transform: rotate(-2deg);
}
.mark-m, .mark-n {
  display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 19px;
  color: #fff; font-size: 34px; font-weight: 900; line-height: 1;
  box-shadow: 0 9px 20px rgba(0,0,0,.22);
}
.mark-blue { background: #397ee8; transform: rotate(-7deg); }
.mark-coral { background: #ef6c63; transform: rotate(6deg); }
.mark-n {
  z-index: 2; margin: 0 -3px;
  color: #342400; background: #ffd166;
  transform: translateY(-5px) rotate(1deg);
}
.mark-98 {
  align-self: flex-end; margin: 0 0 -4px -9px; z-index: 3;
  padding: 5px 8px; border-radius: 9px;
  color: #fff; background: #7357bd;
  font-size: 15px; font-weight: 900; transform: rotate(-5deg);
  box-shadow: 0 5px 12px rgba(0,0,0,.2);
}
.login-kicker {
  margin: 0 0 5px; color: var(--accent);
  font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
}
.login-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.02em; }
.login-welcome { min-height: 42px; margin: 0 auto 22px; max-width: 310px; color: var(--muted); font-size: 14px; }
.login-card form { text-align: left; }
.login-card label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.login-card input {
  width: 100%;
  /* 16px minimum or mobile Safari zooms the page on focus. */
  font-size: 16px;
  padding: 13px 14px; margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.primary {
  width: 100%; min-height: 50px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 650; cursor: pointer;
  touch-action: manipulation;
}
.primary:disabled { opacity: 0.6; cursor: default; }
.login-footnote { margin: 18px 0 0; color: var(--muted); font-size: 12px; }

/* ---------- account + administration ---------- */

.settings-page { max-width: 560px; margin: 28px auto 48px; padding: 0 16px; }
.settings-page.wide { max-width: 760px; }
.settings-card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.settings-card + .settings-card { margin-top: 18px; }
.settings-card h2 { margin: 6px 0 10px; }
.settings-intro, .field-help { color: var(--muted); }
.field-help { margin: -8px 0 16px; font-size: 13px; }
.settings-card label, .reset-dialog label {
  display: block; margin: 14px 0 6px;
  color: var(--muted); font-size: 13px; font-weight: 650;
}
.settings-card input, .reset-dialog input {
  width: 100%; padding: 13px 14px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px;
}
.settings-card .primary { margin-top: 6px; }
.callout {
  padding: 12px 14px; border-radius: 12px;
  color: var(--text); background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
}
.callout[hidden] { display: none; }
.user-list { margin-top: 18px; border-top: 1px solid var(--line); }
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 15px 0; border-bottom: 1px solid var(--line);
}
.user-row strong, .user-row span { display: block; }
.user-row > div > span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.user-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.btn.compact { min-height: 40px; padding: 0 15px; font-size: 14px; }
.reset-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 24px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
}
.reset-dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.reset-dialog h2 { margin: 0 0 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.access-matrix { margin-top: 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.permission-table { width: 100%; min-width: 680px; border-collapse: collapse; background: var(--bg); }
.permission-table th, .permission-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.permission-table thead th {
  position: sticky; top: 0; z-index: 1;
  color: var(--muted); background: var(--surface-2);
  font-size: 12px; font-weight: 700;
}
.permission-table th:first-child { text-align: left; min-width: 180px; }
.permission-table tbody tr:last-child th, .permission-table tbody tr:last-child td { border-bottom: 0; }
.permission-table tbody th strong, .permission-table tbody th span { display: block; }
.permission-table tbody th span { margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 400; text-transform: capitalize; }
.permission-table input[type='checkbox'] {
  width: 22px; height: 22px; margin: 0;
  accent-color: var(--accent); cursor: pointer;
}
.permission-table input[type='checkbox']:disabled { cursor: wait; opacity: .55; }

@media (max-width: 620px) {
  .who { display: none; }
  .topbar-right { gap: 3px; }
  .linkbtn { padding: 8px 6px; }
  .photohero { margin: 12px 12px 0; min-height: 220px; border-radius: 19px; }
  .collage { grid-template-columns: 1.4fr 1fr; }
  .collage img:nth-child(n+4) { display: none; }
  .hero-copy { padding: 26px; }
  .user-row { align-items: flex-start; }
}

.error {
  margin: 0 0 14px; padding: 11px 13px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger); font-size: 14px;
}
.error[hidden] { display: none; }

@media (max-width: 480px) {
  .family-login-card { padding: 29px 22px 23px; }
  .shape-two { right: -38px; }
  .shape-four { left: -24px; }
}

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

/* Mike's private launcher. */
.dashboard-page { max-width: 1240px; padding: 38px 28px 70px; margin: auto; }
.dashboard-intro h2 { font-size: clamp(30px, 4vw, 46px); letter-spacing: -.04em; margin: 8px 0 12px; line-height: 1.1; }
.dashboard-intro > p:last-child { color: var(--muted); max-width: 630px; }
.dashboard-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 28px 0 18px; }
.dashboard-search { display: block; width: min(100%, 540px); font-size: 14px; }
.dashboard-search input { width: 100%; margin-top: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font: inherit; }
.dashboard-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.dashboard-filter { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 24px; font: inherit; font-size: 14px; padding: 10px 16px; cursor: pointer; }
.dashboard-filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dashboard-section { margin-bottom: 30px; }
.dashboard-section > h2 { font-size: 18px; margin-bottom: 14px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.dashboard-card { display: flex; flex-direction: column; padding: 22px; border: 1px solid var(--line); background: var(--surface); border-radius: 18px; }
.dashboard-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--accent); background: var(--surface-2); font-size: 23px; font-weight: 700; }
.dashboard-icon-image { object-fit: contain; padding: 6px; }
.dashboard-card h3 { margin: 15px 0 8px; font-size: 18px; }
.dashboard-card .desc { font-size: 14px; flex: 1; margin-top: 0; }
.dashboard-card .actions { margin-top: 14px; flex-wrap: wrap; }
.dashboard-card .btn { min-height: 44px; }
.dashboard-card .badge { white-space: normal; }
@media(max-width: 1000px) { .dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media(max-width: 740px) { .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dashboard-page { padding: 26px 18px 50px; } .dashboard-toolbar { align-items: start; flex-direction: column; gap: 0; } .topbar { flex-wrap: wrap; } .topbar-right { flex-wrap: wrap; gap: 6px; } }
@media(max-width: 430px) { .dashboard-grid { grid-template-columns: 1fr; } }

.service-launch { display: block; color: inherit; text-decoration: none; }
.service-launch:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
