/* examen — daily examination of conscience. 2026.
   Part of Quid Divinum (quiddivinum.com): the app uses the lvm-family ergonomic
   shell (cards, tabs, dialogs) wearing qd's brand — the amethyst rose ("rosa
   mystica, the divine in the ordinary") on a veil palette, 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: #f4f0f8;
  --bg-grad: radial-gradient(ellipse 90% 65% at 50% 30%, #f4f0f8 0%, #ece4f2 55%, #d8c9e4 100%);
  --surface: #fffdff;
  --surface-2: #f1ecf6;
  --ink: #2a2335;
  --ink-soft: #6a5c78;
  --ink-faint: #918aa0;
  --line: #e7e0f0;
  --line-strong: #d8c9e4;

  --brand: #6e4e86;
  --brand-strong: #573c6c;
  --brand-tint: #ece4f2;
  --on-brand: #ffffff;
  --ring: rgba(110, 78, 134, 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(26, 18, 38, 0.05);
  --shadow-sm: 0 1px 3px rgba(26, 18, 38, 0.06), 0 1px 2px rgba(26, 18, 38, 0.04);
  --shadow-md: 0 10px 30px -8px rgba(26, 18, 38, 0.18);
  --shadow-lg: 0 30px 70px -20px rgba(26, 18, 38, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171320;
    --bg-grad: radial-gradient(ellipse 90% 65% at 50% 26%, rgba(138, 107, 163, 0.16) 0%, rgba(23, 19, 32, 0) 55%);
    --surface: #201a2c;
    --surface-2: #281f38;
    --ink: #ece8f3;
    --ink-soft: #ada3bd;
    --ink-faint: #7a7090;
    --line: #2e2642;
    --line-strong: #3f3458;

    --brand: #c4b1dc;
    --brand-strong: #d6c8e8;
    --brand-tint: rgba(138, 107, 163, 0.18);
    --on-brand: #1c1326;
    --ring: rgba(160, 123, 176, 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; }
.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); }

/* The "I went to confession" reset — deliberate, weighty, brand-coloured. */
.btn-confession {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
  font-weight: 650; box-shadow: 0 4px 14px -4px var(--ring); white-space: nowrap;
}
.btn-confession:hover { background: var(--brand-strong); border-color: var(--brand-strong); }

/* ── 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-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; }
.card-head h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); font-weight: 700; }
.card-hint { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.5; margin-bottom: 0.8rem; }

/* ── examination questions ── */
.q-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; counter-reset: q; }
.q-list:empty { display: none; }
.q-item {
  display: flex; align-items: flex-start; gap: 0.65rem;
  font-size: 0.98rem; line-height: 1.5; color: var(--ink);
}
.q-item::before {
  counter-increment: q; content: counter(q);
  flex: 0 0 auto; width: 1.5rem; height: 1.5rem; margin-top: 0.05rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  background: var(--brand-tint); color: var(--brand-strong); border-radius: 999px;
}
.q-text { flex: 1; min-width: 0; }
/* edit mode: editable rows */
.q-item.editing { align-items: center; gap: 0.45rem; }
.q-item.editing::before { content: ""; }
.q-edit-input {
  flex: 1; min-width: 0; font-family: var(--ui); font-size: 0.95rem; padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink);
}
.q-edit-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.q-empty { font-size: 0.9rem; color: var(--ink-soft); padding: 0.3rem 0; }
.q-add { margin-top: 0.8rem; }

/* ── reflection ── */
#reflection {
  width: 100%; font-family: var(--ui); font-size: 1rem; line-height: 1.6;
  padding: 0.8rem 0.9rem; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); resize: vertical; min-height: 9rem;
}
#reflection:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.save-state { font-size: 0.74rem; color: var(--ink-faint); font-weight: 550; min-height: 1em; }
.save-state.saved { color: var(--brand-strong); }

/* ── add rows (resolutions, questions) ── */
.add-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.add-row input {
  flex: 1; min-width: 9rem; font-family: var(--ui); font-size: 0.95rem;
  padding: 0.6rem 0.7rem; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
}
.add-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
/* Flashed on an input when its submit fails, so a save 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;
}

/* ── resolutions ── */
.res-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.8rem; }
.res-list:empty { display: none; }
.res-item {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2);
}
.res-mark { flex: 0 0 auto; color: var(--brand); font-size: 0.95rem; line-height: 1.5; }
.res-text { flex: 1; min-width: 0; font-size: 0.95rem; line-height: 1.5; color: var(--ink); }
.res-rm { flex: 0 0 auto; margin-top: -0.1rem; }

/* ── confession banner ── */
.confession-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: linear-gradient(180deg, var(--brand-tint), var(--surface));
  border-color: var(--line-strong);
}
.conf-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.conf-text strong { font-size: 1.02rem; letter-spacing: -0.01em; }

/* ── history ── */
.history-list { display: flex; flex-direction: column; gap: 0.9rem; }
.hist-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 1rem 1.15rem;
}
.hist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; }
.hist-date { font-size: 1rem; font-weight: 700; letter-spacing: -0.015em; }
.hist-ago { font-size: 0.74rem; color: var(--ink-faint); font-weight: 500; }
.hist-reflection { font-size: 0.95rem; line-height: 1.6; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.hist-res { margin-top: 0.7rem; display: flex; flex-direction: column; gap: 0.3rem; }
.hist-res-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); font-weight: 700; }
.hist-res-item { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.92rem; line-height: 1.5; color: var(--ink); }
.hist-res-item .res-mark { font-size: 0.9rem; }

/* ── 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(12, 8, 20, 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; }
