/* Westview Church Family Care — theme and layout */
:root {
  --font-head: "Marcellus", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --nav-h: 64px;
  color-scheme: light;
  --bg: #f7f4fa;
  --surface: #ffffff;
  --surface-2: #f1ecf6;
  --text: #2a2231;
  --muted: #6d6377;
  --border: #e4dcec;
  --primary: #5e4483;
  --primary-hover: #4f386f;
  --primary-ink: #ffffff;
  --primary-soft: #eee6f7;
  --gold: #a87e24;
  --gold-soft: #f8f0dc;
  --ok: #2f7451;
  --ok-soft: #e3f2e9;
  --danger: #b13f3a;
  --danger-soft: #fbe9e7;
  --shadow: 0 1px 2px rgba(42, 34, 49, .06), 0 4px 14px rgba(42, 34, 49, .05);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15111a;
  --surface: #1f1926;
  --surface-2: #2a2232;
  --text: #eee8f3;
  --muted: #a99eb5;
  --border: #362d40;
  --primary: #b8a1db;
  --primary-hover: #c9b6e6;
  --primary-ink: #1b1422;
  --primary-soft: #33293f;
  --gold: #dcb862;
  --gold-soft: #3a3120;
  --ok: #7cc79c;
  --ok-soft: #1f3328;
  --danger: #ef8f86;
  --danger-soft: #3d2221;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font-body);
  min-height: 100vh; min-height: 100dvh;
}
a { color: var(--primary); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 400; letter-spacing: .01em; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* Logo swaps with theme */
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
:root[data-theme="dark"] .logo-light { display: none; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: var(--text); text-decoration: none; }
.topbar .brand img { height: 38px; width: auto; }
.topbar .brand-text { min-width: 0; }
.topbar .brand-title { font-family: var(--font-head); font-size: 1.05rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand-sub { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }

/* Main */
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.page-head h1 { font-size: 1.5rem; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
}
.card.accent { border-left: 4px solid var(--gold); }
.card.prayer { border-left: 4px solid var(--primary); }
.card-row { display: flex; gap: 12px; align-items: flex-start; }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 600; }
.card-meta { color: var(--muted); font-size: .85rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.body-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.welcome { background: linear-gradient(135deg, var(--primary-soft), var(--surface)); }
.welcome h2 { margin-bottom: 4px; }

.cat-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.cat-icon svg { width: 22px; height: 22px; }

/* Badges & chips */
.badge {
  font-family: var(--font-body);
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .02em; background: var(--surface-2); color: var(--muted);
}
.badge.open { background: var(--gold-soft); color: var(--gold); }
.badge.filled, .badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.claimed { background: var(--primary-soft); color: var(--primary); }
.badge.leader { background: var(--danger-soft); color: var(--danger); }
.badge.pin { background: var(--gold-soft); color: var(--gold); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 14px; border-radius: 999px; font: inherit; font-size: .9rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

.people { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.people li {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px;
  padding: 3px 10px; font-size: .85rem;
}
.people li.me { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.people button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 1rem; line-height: 1; }

.day-head {
  position: sticky; top: calc(env(safe-area-inset-top) + 61px); z-index: 5;
  font-family: var(--font-head); font-size: 1.05rem; padding: 8px 2px 6px; margin-top: 10px;
  background: var(--bg); display: flex; justify-content: space-between; align-items: baseline;
}
.day-head .today { color: var(--gold); font-family: var(--font-body); font-size: .8rem; font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--primary-ink);
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn.secondary:hover { background: var(--primary-soft); }
.btn.ghost { background: transparent; color: var(--muted); padding: 6px 10px; min-height: 32px; font-weight: 500; }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px; }
.weekdays label { margin: 0; font-weight: 500; }
.weekdays label { position: relative; }
.weekdays input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.weekdays input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.weekdays span {
  display: inline-block; min-width: 46px; text-align: center; padding: 6px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.weekdays input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.error { color: var(--danger); font-size: .9rem; margin-top: 8px; }

/* Login */
.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at top, var(--primary-soft), var(--bg) 65%);
}
.login-box { width: 100%; max-width: 380px; text-align: center; }
.login-box img { width: 230px; max-width: 70%; height: auto; margin: 0 auto 10px; }
.login-box h1 { font-size: 1.45rem; margin-bottom: 4px; }
.login-box form { margin-top: 22px; text-align: left; }
.login-box input { text-align: center; font-size: 1.1rem; letter-spacing: .03em; }

/* Bottom nav */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: flex; width: 100%; max-width: 760px; }
.tabbar a {
  position: relative; flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 34px; height: 3px; margin-left: -17px;
  border-radius: 0 0 3px 3px; background: var(--gold);
}

/* Dialog */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); border: 1px solid var(--border);
  border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(20, 14, 28, .5); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 4px; }
.dlg-body { padding: 4px 18px 18px; overflow-y: auto; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .92rem; z-index: 50;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center;
}
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty svg { width: 38px; height: 38px; color: var(--gold); margin-bottom: 6px; }
.section-title { font-family: var(--font-head); font-size: 1.15rem; margin: 22px 0 10px; }
.list-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.list-table th, .list-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.list-table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); padding: 7px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
footer.site { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 30px; }

@media (min-width: 700px) {
  main { padding-top: 24px; }
  .topbar .brand img { height: 44px; }
}
