/* journal — a prayer journal. 2026.
   Part of Quid Divinum (quiddivinum.com): the app uses the lvm-family ergonomic
   shell (cards, tabs, dialogs) wearing qd's rose mark ("rosa mystica, the
   divine in the ordinary") on a warm sepia/brown palette — leather-and-
   parchment, contemplative — with Fraunces for the display headings. Light &
   dark. */

/* `hidden` must win over component `display` rules (e.g. flex containers). */
[hidden] { display: none !important; }

:root {
  color-scheme: light dark;

  --bg: #f6f1ea;
  --bg-grad: radial-gradient(ellipse 90% 65% at 50% 30%, #f6f1ea 0%, #efe5d6 55%, #e0cdb3 100%);
  --surface: #fffdfa;
  --surface-2: #f3ebdf;
  --ink: #2e2418;
  --ink-soft: #6f5e4a;
  --ink-faint: #9a8a73;
  --line: #ece2d3;
  --line-strong: #ddc9b0;

  --brand: #8a5a2b;
  --brand-strong: #6f4621;
  --brand-tint: #f1e6d4;
  --on-brand: #ffffff;
  --ring: rgba(138, 90, 43, 0.30);

  --danger: #c4413f;

  --ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(46, 34, 24, 0.05);
  --shadow-sm: 0 1px 3px rgba(46, 34, 24, 0.06), 0 1px 2px rgba(46, 34, 24, 0.04);
  --shadow-md: 0 10px 30px -8px rgba(46, 34, 24, 0.18);
  --shadow-lg: 0 30px 70px -20px rgba(46, 34, 24, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a140d;
    --bg-grad: radial-gradient(ellipse 90% 65% at 50% 26%, rgba(190, 140, 80, 0.15) 0%, rgba(26, 20, 13, 0) 55%);
    --surface: #241b12;
    --surface-2: #2d2217;
    --ink: #f1e9dc;
    --ink-soft: #bcab93;
    --ink-faint: #8a7a62;
    --line: #382b1d;
    --line-strong: #4a3826;

    --brand: #d9b483;
    --brand-strong: #e6c89c;
    --brand-tint: rgba(190, 140, 80, 0.18);
    --on-brand: #241a0f;
    --ring: rgba(200, 150, 90, 0.35);

    --danger: #f0686d;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 12px 34px -10px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--ui);
  color: var(--ink);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
}

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

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.55; }
.empty-hint { padding: 2.5rem 0.5rem; line-height: 1.6; max-width: 48ch; }

/* ── header ── */
.chrome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.95rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.mark { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--brand); }
.rose-mark { width: 1.25rem; height: auto; display: block; }
.mark-word { font-family: var(--display); font-size: 1.18rem; font-weight: 600; letter-spacing: 0; color: var(--ink); }
.chrome-nav { display: flex; align-items: center; gap: 1.25rem; font-size: 0.85rem; }
.who { color: var(--ink-faint); font-size: 0.78rem; font-weight: 450; }

/* ── tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 1.4rem auto 0;
  max-width: 280px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tab {
  flex: 1;
  font-family: var(--ui);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.tab.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-xs); }

main { max-width: 760px; margin: 0 auto; padding: clamp(1.25rem, 3.5vw, 2.5rem); }

/* ── buttons (shared with meal / track) ── */
.btn {
  font-family: var(--ui);
  font-size: 0.875rem;
  font-weight: 550;
  padding: 0.58rem 1.05rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, box-shadow 0.14s, transform 0.08s;
}
.btn:hover { border-color: var(--brand); box-shadow: var(--shadow-xs); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 4px 14px -4px var(--ring); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { font-size: 0.8rem; padding: 0.36rem 0.7rem; }
.btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
/* The destructive confirm (remove an entry). */
.btn-danger {
  background: var(--danger); border-color: var(--danger); color: #fff;
  font-weight: 650; white-space: nowrap;
}
.btn-danger:hover { filter: brightness(1.05); border-color: var(--danger); }
.icon-btn {
  font-family: var(--ui);
  background: none; border: none; cursor: pointer;
  color: var(--ink-faint); font-size: 0.85rem; line-height: 1;
  padding: 0.3rem 0.4rem; border-radius: var(--r-sm); transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ── day banner ── */
.day-banner { margin-bottom: 1.4rem; }
.day-title { font-family: var(--display); font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em; }
.day-meta { display: block; font-size: 0.82rem; color: var(--ink-faint); font-weight: 500; margin-top: 0.2rem; }

/* ── cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.card-hint { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.5; margin-bottom: 0.8rem; }

/* ── quick-add ── */
.add-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-start; }
.add-row input,
.add-row textarea {
  flex: 1; min-width: 9rem; font-family: var(--ui); font-size: 0.95rem; line-height: 1.5;
  padding: 0.6rem 0.7rem; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
}
.add-row textarea { resize: vertical; min-height: 2.9rem; }
.add-row input:focus,
.add-row textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.j-add .btn { align-self: stretch; }
/* Flashed on a field when its save fails, so an error isn't silent. */
.input-error, .input-error:focus {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 26%, transparent) !important;
}

/* ── entry list + date groups ── */
.entry-list { display: flex; flex-direction: column; gap: 1.4rem; }
.date-group { display: flex; flex-direction: column; gap: 0.6rem; }
.date-group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
  padding: 0 0.2rem;
}
.date-group-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); font-weight: 700; }
.date-group-ago { font-size: 0.72rem; color: var(--ink-faint); font-weight: 500; }

/* ── entry card ── */
.entry {
  display: flex; align-items: flex-start; gap: 0.7rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 0.85rem 0.95rem;
}
.entry.prayed { background: linear-gradient(180deg, var(--brand-tint), var(--surface)); }

/* the ✓ toggle */
.pray-toggle {
  flex: 0 0 auto; margin-top: 0.05rem;
  width: 1.65rem; height: 1.65rem; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  color: transparent; font-size: 0.9rem; line-height: 1; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.14s, border-color 0.14s, color 0.14s, transform 0.08s;
}
.pray-toggle:hover { border-color: var(--brand); }
.pray-toggle:active { transform: scale(0.92); }
.pray-toggle[aria-pressed="true"] {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
  box-shadow: 0 3px 10px -3px var(--ring);
}

.entry-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.entry-obs {
  font-size: 0.98rem; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; cursor: text; border-radius: var(--r-sm);
}
.entry.prayed .entry-obs { color: var(--ink-soft); }

/* the answer / resolution */
.entry-res {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.55rem 0.65rem; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2);
}
.entry-res-label {
  flex: 0 0 auto; margin-top: 0.1rem;
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 700;
  color: var(--brand-strong);
}
.entry-res-text {
  flex: 1; min-width: 0; font-size: 0.92rem; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; cursor: text;
}
.entry-res-clear { flex: 0 0 auto; margin: -0.15rem -0.1rem 0 0; }
.add-res-btn { align-self: flex-start; color: var(--brand); padding-left: 0; padding-right: 0; }
.add-res-btn:hover { background: transparent; border-color: transparent; text-decoration: underline; }

.entry-foot { display: flex; align-items: center; justify-content: flex-end; }
.entry-del { font-size: 0.78rem; }

/* inline editor (observation / answer) */
.inline-edit { display: flex; flex-direction: column; gap: 0.5rem; }
.inline-edit-input {
  width: 100%; font-family: var(--ui); font-size: 0.95rem; line-height: 1.5;
  padding: 0.55rem 0.65rem; border: 1px solid var(--brand); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); resize: vertical; min-height: 3rem;
}
.inline-edit-input:focus { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.inline-edit-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── dialogs (shared with meal / track) ── */
.dialog {
  border: none; border-radius: var(--r-xl); padding: 0; margin: auto;
  width: min(440px, 94vw); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
  animation: dialog-in 0.18s cubic-bezier(0.2, 0.7, 0.3, 1);
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog::backdrop { background: rgba(20, 13, 5, 0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dialog form { padding: 1.6rem; display: flex; flex-direction: column; gap: 1.05rem; max-height: 88vh; overflow-y: auto; }
.dialog h2 { font-family: var(--display); font-weight: 600; font-size: 1.4rem; letter-spacing: -0.01em; }

.form-error { color: var(--danger); font-size: 0.8rem; min-height: 1em; font-weight: 500; }
.dialog-actions { display: flex; gap: 0.6rem; align-items: center; list-style: none; padding: 0; margin: 0; }
.dialog-actions .spacer { flex: 1; }
