/* Jy moet bid — styles (no frameworks). Mobile first; wider layouts in the media queries at the end. */

:root {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #ececf1;
  --hover: rgb(0 0 0 / .05);
  --text: #1c1b22;
  --muted: #64637a;
  --border: #e2e1ea;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --primary-soft: #e0e7ff;
  --accent: #d97706;
  --success: #059669;
  --success-soft: #d1fae5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --row: rgb(255 255 255 / .97);
  --row-hover: #f6f6fa;
  --shadow: 0 1px 2px rgb(0 0 0 / .08), 0 4px 14px rgb(0 0 0 / .06);
  --radius: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111016;
    --surface: #1c1b23;
    --surface-2: #26252f;
    --hover: rgb(255 255 255 / .06);
    --text: #f1f0f6;
    --muted: #a3a2b5;
    --border: #2e2d39;
    --primary: #8b8ff8;
    --primary-ink: #0d0c14;
    --primary-soft: #2a2950;
    --accent: #fbbf24;
    --success: #34d399;
    --success-soft: #12372b;
    --danger: #f87171;
    --danger-soft: #3d1a1e;
    --row: rgb(32 31 40 / .94);
    --row-hover: rgb(44 43 54 / .96);
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 14px rgb(0 0 0 / .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.stack > * + * { margin-top: .85rem; }

svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i-fill { fill: currentColor; stroke: none; }

/* ---------- Form controls ---------- */
label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: .35rem; }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .75rem;
  min-height: 44px;
}
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input[type="color"] { padding: .2rem; width: 48px; flex: none; }
input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { display: block; color: var(--danger); font-size: .82rem; font-weight: 500; margin-top: .25rem; }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; }
label.check input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--primary); }
.form-error { color: var(--danger); font-size: .9rem; font-weight: 500; }
.form-error:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600;
  min-height: 44px; padding: .5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 8px;
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }

/* ---------- Loading & auth ---------- */
.view-loading { min-height: 100dvh; display: grid; place-items: center; background: #07060b; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

.view-auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 16px;
  background: #07060b;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-card form { text-align: left; margin-top: 1.1rem; }
.app-name { font-family: var(--serif); font-size: 1.9rem; margin-top: .6rem; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; margin-top: 1.2rem; }
.tab {
  flex: 1; font: inherit; font-weight: 600; font-size: .92rem; min-height: 38px;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-card .btn { border-radius: 999px; }

.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: #78350f; color: #fff;
  text-align: center; font-size: .85rem; padding: calc(4px + var(--safe-top)) 12px 4px;
}

/* ===========================================================================
   App shell — mobile: one screen at a time (data-screen = lists | list | detail | settings)
   =========================================================================== */
.app { height: 100dvh; overflow: hidden; position: relative; }
.app > * { height: 100%; }
.app[data-screen="lists"] .list-view { display: none; }
.app:not([data-screen="lists"]) .nav { display: none; }

/* ---------- Nav (lists) ---------- */
.nav {
  display: flex; flex-direction: column;
  background: var(--bg);
  padding: calc(10px + var(--safe-top)) 10px calc(10px + var(--safe-bottom));
  overflow-y: auto;
}
.account {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 8px; margin-bottom: 6px;
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.account:hover { background: var(--hover); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
  font-weight: 700; font-size: 1rem; letter-spacing: .02em;
}
.account-text { min-width: 0; display: flex; flex-direction: column; }
.account-text strong, .account-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text small { color: var(--muted); }

.nav-search { position: relative; margin: 4px 0 10px; font-weight: 400; }
.nav-search input { margin: 0; padding-right: 38px; background: var(--surface); min-height: 40px; }
.nav-search-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }
.nav-search input::-webkit-search-cancel-button { display: none; }

.nav-lists { list-style: none; margin: 0; padding: 0; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  min-height: 46px; padding: 0 12px;
  border-radius: 8px;
  color: var(--text); text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--hover); }
.nav-item.is-active { background: var(--surface-2); font-weight: 600; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--primary);
}
.nav-item .i { color: var(--ic, var(--muted)); }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: .8rem; color: var(--muted); min-width: 1.5em; text-align: right; }
.nav-divider { border: 0; border-top: 1px solid var(--border); margin: 8px 6px; }
.new-list {
  display: flex; align-items: center; gap: 14px;
  min-height: 48px; padding: 0 12px; margin-top: auto;
  font: inherit; color: var(--primary); font-weight: 600;
  background: none; border: 0; border-radius: 8px; cursor: pointer; text-align: left;
}
.new-list:hover { background: var(--hover); }

/* ---------- List view ---------- */
.list-view {
  display: flex; flex-direction: column;
  background: var(--list-bg, linear-gradient(180deg, #1b1a3f, #0b0a14));
  color: #fff;
  position: relative;
}
.list-header { padding: calc(8px + var(--safe-top)) 16px 10px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 40px; margin-left: -8px; padding: 0 8px;
  font: inherit; font-weight: 600; color: inherit;
  background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.back-btn:hover { background: rgb(255 255 255 / .08); }
.list-title-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.list-title-row h1 {
  font-size: 1.9rem; font-weight: 700; letter-spacing: -.01em;
  overflow-wrap: anywhere; text-shadow: 0 1px 8px rgb(0 0 0 / .35);
}
.list-title-row .icon-btn:hover { background: rgb(255 255 255 / .1); }
.list-subtitle { margin-top: 2px; font-size: .95rem; opacity: .85; }
.list-subtitle:empty { display: none; }

.list-body { flex: 1; overflow-y: auto; padding: 4px 12px 12px; overscroll-behavior: contain; }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.row {
  display: flex; align-items: center; gap: 4px;
  min-height: 56px; padding: 4px 4px 4px 6px;
  background: var(--row); color: var(--text);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .12);
}
.row:hover { background: var(--row-hover); }
.row.is-selected { background: var(--row-hover); outline: 2px solid var(--primary); outline-offset: -2px; }
.row-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center;
  min-height: 48px; padding: 4px 6px;
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; cursor: pointer;
}
.row-title { overflow-wrap: anywhere; }
.row.is-answered .row-title { color: var(--muted); }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-size: .78rem; color: var(--muted); margin-top: 1px; }
.row-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.row-meta > span + span::before { content: "•"; margin-right: 2px; opacity: .7; }
.row-meta .i { width: 13px; height: 13px; }
.row-meta .is-overdue { color: var(--danger); }
.row-meta .is-today { color: var(--primary); }
.row-meta .star { color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); flex: none; }

/* round "answered" toggle, like To Do's complete circle */
.circle {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: none; border: 0; cursor: pointer; color: var(--muted);
}
.circle::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%;
  border: 1.8px solid currentColor;
  transition: background .15s ease;
}
.circle:hover::before { background: radial-gradient(circle, currentColor 0 4px, transparent 5px); }
.circle.is-done { color: var(--success); }
.circle.is-done::before { background: currentColor; border-color: currentColor; box-shadow: inset 0 0 0 4px var(--row); }

.pray {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 46px; min-height: 46px; flex: none;
  font: inherit; font-size: .7rem; font-weight: 700; color: var(--muted);
  background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.pray:hover { background: var(--hover); }
.pray .emoji { font-size: 1.25rem; line-height: 1.1; filter: grayscale(1); opacity: .65; transition: filter .2s, opacity .2s; }
.pray.is-prayed .emoji { filter: none; opacity: 1; }
.pray.is-prayed { color: var(--accent); }
.pray.pop .emoji { animation: pop .45s ease; }
@keyframes pop { 40% { transform: scale(1.35); } }

.section-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 14px 0 6px; padding: 5px 10px;
  font: inherit; font-size: .88rem; font-weight: 600; color: #fff;
  background: rgb(0 0 0 / .35); border: 0; border-radius: 6px; cursor: pointer;
}
.section-toggle .i { width: 16px; height: 16px; transition: transform .15s; }
.section-toggle[aria-expanded="true"] .i { transform: rotate(90deg); }

.empty-state { text-align: center; padding: 12vh 24px 0; color: #fff; }
.empty-state .big { font-size: 2.6rem; }
.empty-state h2 { font-size: 1.15rem; margin-top: 8px; }
.empty-state p { opacity: .8; margin-top: 4px; max-width: 30ch; margin-inline: auto; }

/* ---------- Quick add (bottom bar) ---------- */
.quick-add {
  display: flex; align-items: center; gap: 4px;
  margin: 0 12px calc(12px + var(--safe-bottom));
  padding: 0 6px 0 4px;
  min-height: 54px;
  background: rgb(20 19 28 / .78);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 8px;
  color: #fff;
}
.quick-add:focus-within { background: var(--row); color: var(--text); }
.quick-add-icon { width: 40px; display: grid; place-items: center; flex: none; }
.quick-add input {
  flex: 1; min-width: 0; margin: 0;
  background: transparent; border: 0; color: inherit; padding: .6rem 0;
}
.quick-add input::placeholder { color: inherit; opacity: .85; }
.quick-add input:focus-visible { outline: none; }
.quick-add-submit {
  font: inherit; font-weight: 600; font-size: .88rem;
  padding: .4rem .8rem; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: inherit; cursor: pointer;
  visibility: hidden;
}
.quick-add:focus-within .quick-add-submit { visibility: visible; }

/* ---------- Panes (detail & settings): full screen on mobile ---------- */
.pane {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--bg);
  animation: slide-in .2s ease;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
.pane-header {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  min-height: 56px;
}
.pane-header h2 { font-size: 1.1rem; flex: 1; }
.pane-close { display: none; }
.pane-body { flex: 1; overflow-y: auto; padding: 4px 12px calc(16px + var(--safe-bottom)); display: grid; gap: 10px; align-content: start; }

.d-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.d-card.flush { padding: 0; overflow: hidden; }
.d-title { display: flex; align-items: flex-start; gap: 2px; padding: 8px 4px; }
.d-title .circle { margin-top: 2px; }
.d-title textarea {
  flex: 1; border: 0; background: transparent; resize: none; overflow: hidden;
  font-size: 1.25rem; font-weight: 650; line-height: 1.3; padding: .55rem .25rem; min-height: 0;
}
.d-title textarea:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--primary); border-radius: 0; }
.d-title.is-answered textarea { color: var(--muted); }
.star-btn { color: var(--muted); margin-top: 4px; }
.star-btn.is-on { color: var(--accent); }
.star-btn.is-on svg { fill: currentColor; }

.d-pray {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 14px;
  font: inherit; color: inherit; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.d-pray:hover { background: var(--row-hover); }
.d-pray .emoji { font-size: 1.6rem; }
.d-pray strong { display: block; color: var(--primary); }
.d-pray small { color: var(--muted); }
.d-pray.pop .emoji { animation: pop .45s ease; }

.d-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 400;
}
.d-row:last-child { border-bottom: 0; }
.d-row > .i { flex: none; }
.d-row input, .d-row select {
  flex: 1; margin: 0; border: 0; background: transparent; padding: .5rem 0; min-height: 50px; color: var(--text);
}
.d-row input::placeholder { color: var(--muted); }
.d-row select:invalid, .d-row select.is-empty { color: var(--muted); }
.d-row input:focus-visible, .d-row select:focus-visible { outline: none; }
.d-row:focus-within { color: var(--primary); }
.d-row.has-value > .i { color: var(--primary); }
.d-row.is-overdue > .i, .d-row.is-overdue input { color: var(--danger); }
.d-date { position: relative; cursor: pointer; }
.d-date-text { flex: 1; }
.d-date.has-value .d-date-text { color: var(--primary); }
.d-date.is-overdue .d-date-text { color: var(--danger); }
.d-row .d-date-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; }
.d-clear { position: relative; z-index: 1; width: 36px; height: 36px; color: var(--muted); }
.d-clear .i { width: 16px; height: 16px; }

.d-notes { border: 0; background: transparent; padding: 0; min-height: 90px; resize: none; }
.d-notes:focus-visible { outline: none; }
.d-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.d-answer { background: var(--success-soft); border-color: transparent; }
.d-answer .d-label { color: var(--success); }

.journal-form { display: flex; gap: 8px; align-items: flex-end; }
.journal-form textarea { min-height: 44px; resize: none; }
.timeline { list-style: none; margin: 12px 0 0 6px; padding: 0 0 0 16px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 12px 10px; }
.timeline li::before {
  content: ""; position: absolute; left: -23px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--primary);
}
.timeline li.kind-prayed::before { border-color: var(--accent); }
.timeline li.kind-status::before { border-color: var(--success); background: var(--success); }
.timeline time { font-size: .75rem; color: var(--muted); }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.timeline .del { float: right; font-size: .78rem; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 2px 6px; }

.d-footer {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--muted);
}
.d-footer span { flex: 1; text-align: center; }
.d-footer .icon-btn { color: var(--muted); }
.d-footer .icon-btn.danger:hover { color: var(--danger); }

/* ---------- Dialogs ---------- */
.dialog {
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 18px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / .4);
}
.dialog-sm { width: min(400px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(7 6 11 / .6); }
.dialog h2 { font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dialog-actions .btn-left { margin-right: auto; }
.inline-form { display: flex; gap: 8px; }
.inline-form input[type="text"] { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: calc(100vw - 24px);
  background: #f1f0f6; color: #111016;
  padding: .55rem .6rem .55rem 1rem; border-radius: 8px;
  font-size: .92rem; font-weight: 500;
  box-shadow: 0 8px 24px rgb(0 0 0 / .35);
  z-index: 70;
  animation: toast-in .2s ease;
}
.toast button { font: inherit; font-weight: 700; color: #4f46e5; background: none; border: 0; padding: .25rem .5rem; cursor: pointer; border-radius: 6px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ===========================================================================
   Wider screens: nav | list | pane side by side (like To Do on desktop)
   =========================================================================== */
@media (min-width: 760px) {
  .app { display: grid; grid-template-columns: 290px minmax(0, 1fr) auto; }
  .app[data-screen] .nav, .app[data-screen] .list-view { display: flex; }
  .nav { border-right: 1px solid var(--border); }
  .new-list { border-top: 1px solid var(--border); border-radius: 0; margin-inline: -10px; padding-inline: 22px; }
  .back-btn { display: none; }
  .list-header { padding: 28px 32px 14px; }
  .list-title-row h1 { font-size: 1.75rem; }
  .list-body { padding: 4px 32px 12px; }
  .quick-add { margin: 0 32px 24px; }
  .pane {
    position: static; width: 360px;
    border-left: 1px solid var(--border);
    animation: none;
  }
  .pane .back-btn { display: none; }
  .pane-close { display: inline-grid; }
  .toast { bottom: 96px; }
}
@media (min-width: 760px) and (max-width: 1099px) {
  /* Pane overlays the list instead of squeezing it */
  .pane { position: absolute; inset: 0 0 0 auto; box-shadow: -10px 0 30px rgb(0 0 0 / .3); }
}

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