/* Paroikia: hand-written, framework-free styles. Mobile first. */
:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --text: #1d1f1c;
  --muted: #6b6f68;
  --line: #e2ded3;
  --accent: #1f4d3a;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe2;
  --ok: #2f7d4f;
  --ok-soft: #dff1e5;
  --warn: #b26a00;
  --warn-soft: #fbead0;
  --bad: #b8322b;
  --bad-soft: #f8dcd9;
  --never: #5a6473;
  --never-soft: #e6e9ee;
  --radius: 12px;
  --nav-h: 60px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2125;
    --surface-2: #272b30;
    --text: #e9e7e1;
    --muted: #9aa09a;
    --line: #30353b;
    --accent: #5fb389;
    --accent-ink: #0d1f16;
    --accent-soft: #1f3a2d;
    --ok: #6fcf97;
    --ok-soft: #1b3326;
    --warn: #f0b35c;
    --warn-soft: #3a2b12;
    --bad: #ef7f77;
    --bad-soft: #3d1f1c;
    --never: #aab3bf;
    --never-soft: #2b3138;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .35rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 24px; }
main.auth { padding-top: 10vh; }

/* ---------- Navigation ---------- */
.mainnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: space-around; align-items: stretch;
  background: var(--surface); border-top: 1px solid var(--line);
  transition: transform .18s ease-out, opacity .18s ease-out;
}
/* Hidden while scrolling down on phones; app.js toggles the class. */
.mainnav.nav-hidden { transform: translateY(100%); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .mainnav { transition: none; } }
.mainnav .brand { display: none; }
.navlink {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .72rem; text-decoration: none; color: var(--muted); position: relative;
}
.navlink.active { color: var(--accent); }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
@media (min-width: 720px) {
  body { padding-bottom: 24px; padding-top: var(--nav-h); }
  .mainnav {
    top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line);
    justify-content: flex-start; padding: 0 24px; gap: 8px; height: var(--nav-h);
  }
  .mainnav.nav-hidden { transform: none; opacity: 1; pointer-events: auto; }
  .mainnav .brand { display: block; font-weight: 800; font-size: 1.2rem; color: var(--accent); text-decoration: none; margin-right: 24px; letter-spacing: .02em; }
  .navlink { flex: 0 0 auto; flex-direction: row; gap: 8px; font-size: .95rem; padding: 0 12px; border-radius: 8px; }
  .navlink.active { background: var(--accent-soft); }
  .badge { position: static; margin-left: 2px; }
}

/* ---------- Buttons, forms ---------- */
.btn, button.btn, summary.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; min-height: 44px; list-style: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.wide { width: 100%; }
.btn:active { transform: translateY(1px); }
summary.btn::-webkit-details-marker, summary::-webkit-details-marker { display: none; }
summary { cursor: pointer; }
button.link, summary.link, .link {
  background: none; border: 0; padding: 4px 0; color: var(--accent); font: inherit; font-size: .9rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 32px;
}
.link.danger { color: var(--bad); }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; background: var(--surface-2); font-size: 1.3rem; line-height: 1; list-style: none;
}

label { display: block; font-size: .9rem; font-weight: 600; margin: 0 0 10px; }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date],
input[type=number], input[type=time], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
  min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: 20px; height: 20px; margin: 0; }
.suffix { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.suffix input { width: 6em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 140px; }
.row > button { margin-bottom: 10px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.form { padding: 16px; }
.form h2 { margin-top: 12px; }
.form h2:first-child { margin-top: 0; }
.family-row label { flex: 1 1 100%; }
@media (min-width: 540px) { .family-row label { flex: 1 1 30%; } }

.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented label { margin: 0; flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
  display: block; text-align: center; padding: 9px 10px; border-radius: 999px; border: 1px solid var(--line);
  font-weight: 500; font-size: .9rem; background: var(--surface);
}
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

.flash { background: var(--accent-soft); color: var(--text); padding: 10px 14px; border-radius: 10px; font-weight: 500; }
.error { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 10px; font-weight: 500; }

/* ---------- Cards and lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.card.pinned { border-color: var(--accent); }
.card.pinned h2 { color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list.archived { opacity: .7; }
.note-body, .slot-body { margin: 0 0 4px; white-space: normal; overflow-wrap: anywhere; }
.note-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.note-meta form { display: inline; }
.links { margin-top: 20px; font-size: .95rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 8px -6px; text-decoration: none; font-weight: 600; }

/* People list */
.search { margin-bottom: 10px; }
.search input { margin: 0; border-radius: 999px; padding-left: 16px; }
.chips { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 500;
}
.chip b { font-weight: 700; color: var(--muted); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.active b { color: inherit; }
.chip.schedule.active { background: var(--warn); border-color: var(--warn); color: #fff; }
.chip.overdue.active { background: var(--bad); border-color: var(--bad); color: #fff; }

.people { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.people li + li { border-top: 1px solid var(--line); }
.people .empty { padding: 24px 16px; color: var(--muted); text-align: center; }
.slat { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; }
.slat:active { background: var(--surface-2); }
.slat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.slat .name { font-weight: 600; }
.slat .sub { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slat-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: .8rem; }
.pill { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.pill svg { width: 14px; height: 14px; }

.avatar {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; background: var(--never-soft); color: var(--never);
}
.avatar.big { width: 56px; height: 56px; font-size: 1.2rem; }
.avatar.ok { background: var(--ok-soft); color: var(--ok); }
.avatar.schedule { background: var(--warn-soft); color: var(--warn); }
.avatar.overdue { background: var(--bad-soft); color: var(--bad); }
.status { font-weight: 600; white-space: nowrap; }
.status.ok { color: var(--ok); }
.status.schedule { color: var(--warn); }
.status.overdue { color: var(--bad); }
.status.never { color: var(--never); }

/* Person page */
.person-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.person-title { flex: 1; min-width: 0; }
.person-title h1 { margin: 0; }
.status-line { margin: 0; font-size: .9rem; }
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: 46px; z-index: 5; width: min(320px, 85vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.menu-panel form + form { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }

.actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.action > summary { width: 100%; }
.action[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.action .panel {
  background: var(--surface); border: 1px solid var(--line); border-top: 0; padding: 14px;
  border-radius: 0 0 10px 10px;
}
.action.wide { margin: 8px 0 0; }
@media (min-width: 540px) {
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions .action { flex: 1 1 30%; }
  .actions .action[open] { flex-basis: 100%; }
}

details.inline > summary { display: inline-flex; }
details.inline > form { margin-top: 8px; padding: 12px; background: var(--surface-2); border-radius: 10px; }
details.inline.right { margin-left: auto; }
details.inline.add { margin-top: 6px; }

.family { list-style: none; padding: 0; margin: 0 0 4px; }
.family > li { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.family > li:first-child { border-top: 0; padding-top: 0; }
.family-main { flex: 1 1 200px; }
.family-note { margin: 0; font-size: .92rem; color: var(--muted); }
.family .name { font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { padding: 10px 0 10px 16px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline > li::before { content: ""; position: absolute; left: -7px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.meeting-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline .list { margin-top: 6px; }

/* Prayer page */
.slots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.slot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.slot.prayed { opacity: .6; }
.slot.prayed .slot-body { text-decoration: none; }
.slot-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.slot-head .name { font-weight: 700; text-decoration: none; }
.slot-head .muted { font-size: .8rem; }
.slot-body { font-size: 1.05rem; }
.slot-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.slot-actions form { display: inline; }
.done { color: var(--ok); font-weight: 700; padding: 10px 4px; }

/* Auth */
.authbox { max-width: 400px; margin: 0 auto; }
.brand-title { color: var(--accent); font-size: 2rem; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.15rem; letter-spacing: .04em;
  background: var(--surface); border: 2px dashed var(--accent); border-radius: 10px; padding: 14px; text-align: center; user-select: all;
}

/* htmx request indicator: dim the element being replaced */
.htmx-request { opacity: .6; transition: opacity .15s; }
