/* Examen Conscientiae */
:root {
  --bg: #f6efdf; --bg2: #eee3cb; --card: #fcf9f0; --ink: #2b211c; --muted: #6e6154;
  --gold: #a97f26; --line: rgba(169, 127, 38, .38); --line-soft: rgba(169, 127, 38, .2);
  --accent: #7a1f2b; --accent-ink: #ffffff; --accent-soft: rgba(122, 31, 43, .12);
  --danger: #9b1c1c; --field: #fffdf6;
  --shadow: 0 1px 2px rgba(70, 45, 10, .10), 0 8px 20px rgba(70, 45, 10, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 330px;
  color-scheme: light;
}
:root[data-season="ordinary"] { --accent: #3e6b3a; --accent-soft: rgba(62, 107, 58, .13); }
:root[data-season="advent"], :root[data-season="lent"] { --accent: #5b3a7a; --accent-soft: rgba(91, 58, 122, .13); }
:root[data-season="christmas"], :root[data-season="easter"] { --accent: #8f6a12; --accent-soft: rgba(143, 106, 18, .14); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1714; --bg2: #15110e; --card: #27211c; --ink: #eee4d1; --muted: #aa9e8c;
    --gold: #d8b45f; --line: rgba(216, 180, 95, .42); --line-soft: rgba(216, 180, 95, .2);
    --accent: #d2707c; --accent-ink: #1c1714; --accent-soft: rgba(210, 112, 124, .16);
    --danger: #ef8a8a; --field: #1f1a16;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
  :root[data-season="ordinary"] { --accent: #8dbb86; --accent-soft: rgba(141, 187, 134, .16); }
  :root[data-season="advent"], :root[data-season="lent"] { --accent: #b99ad8; --accent-soft: rgba(185, 154, 216, .17); }
  :root[data-season="christmas"], :root[data-season="easter"] { --accent: #e0bc62; --accent-soft: rgba(224, 188, 98, .17); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.5; color: var(--ink);
  background: linear-gradient(180deg, var(--bg), var(--bg2)); background-attachment: fixed; min-height: 100vh;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; fill: currentColor; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr, .cb { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
[hidden] { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 20px 26px;
  background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-cross { width: 46px; height: 46px; padding: 9px; border-radius: 50%; fill: var(--accent); background: var(--accent-soft); border: 1.5px solid var(--gold); flex: none; }
.brand h1 { font-size: 1.28rem; letter-spacing: .02em; color: var(--ink); }
.brand p { margin: 2px 0 0; font-size: .84rem; font-style: italic; color: var(--muted); }

.prayer { border-left: 3px solid var(--gold); background: var(--accent-soft); border-radius: 0 10px 10px 0; padding: 10px 14px; font-size: .93rem; }
.prayer summary { cursor: pointer; font-weight: 600; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); list-style: none; }
.prayer summary::-webkit-details-marker { display: none; }
.prayer summary::after { content: "  \25BE"; }
.prayer:not([open]) summary::after { content: "  \25B8"; }
.prayer p { margin: 8px 0 0; }
.prayer .sign { font-style: italic; color: var(--muted); }

.modes h2, .eyebrow { font-size: .76rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; font-weight: 700; }
.mode-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left;
  padding: 12px 14px; margin-bottom: 8px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s, background .15s;
}
.mode-btn:hover { border-color: var(--accent); }
.mode-btn[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); padding: 11px 13px; }
.mode-name { display: block; font-weight: 700; font-size: 1.04rem; }
.mode-desc { display: block; font-size: .82rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.badge { min-width: 30px; text-align: center; padding: 2px 9px; border-radius: 999px; font-family: var(--sans); font-size: .8rem; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.badge.zero { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.side-actions { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--field); font-family: var(--sans); font-size: .9rem; font-weight: 600; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.wide { width: 100%; padding: 11px 14px; }
.privacy-link {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; background: none; border: 1px dashed var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: .86rem; color: var(--ink); line-height: 1.35;
}
.privacy-link:hover { border-color: var(--accent); color: var(--accent); }
.privacy-link .icon { margin-top: 2px; color: var(--accent); }
.season { margin: auto 0 0; font-size: .82rem; color: var(--muted); font-style: italic; }
.linklike { background: none; border: 0; padding: 0; text-align: left; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.linklike.small { font-size: .82rem; }

/* Main */
.main { padding: 28px clamp(16px, 4vw, 48px) 60px; outline: none; }
.main-inner { max-width: 820px; margin: 0 auto; }
.main-head { margin-bottom: 18px; }
.title-row { display: flex; align-items: center; gap: 14px; }
.title-row .orn { width: 38px; height: 38px; fill: var(--accent); flex: none; }
.main-head h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); letter-spacing: .01em; }
.tagline { margin: 6px 0 0; font-style: italic; color: var(--muted); }
.orn-rule { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--gold); }
.orn-rule::before, .orn-rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.orn-rule .icon { width: 14px; height: 14px; fill: var(--gold); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: 170px 1fr; gap: 12px; }
.field label { display: block; font-family: var(--sans); font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="date"], input[type="search"], textarea {
  width: 100%; padding: 9px 11px; background: var(--field); border: 1px solid var(--line); border-radius: 9px; font-family: var(--serif); font-size: 1rem; color: var(--ink);
}
textarea { resize: vertical; min-height: 3.2em; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

.reminders summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.reminders .body { margin-top: 10px; font-size: .95rem; }
.reminders p { margin: 0 0 8px; }
.reminders ol { margin: 6px 0 0; padding-left: 1.3em; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 220px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 34px; }
.tool { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--field); font-family: var(--sans); font-size: .84rem; font-weight: 600; }
.tool[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tool:hover { border-color: var(--accent); }
.summary-line { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin: 0 0 10px; }

/* Section cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; background: none; border: 0; text-align: left; }
.card-head:hover { background: var(--accent-soft); }
.medal { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 1.5px solid var(--gold); background: var(--bg); color: var(--accent); font-weight: 700; font-size: 1.02rem; box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px var(--line-soft); }
.medal.long { font-size: .8rem; letter-spacing: -.02em; }
.medal svg { width: 20px; height: 20px; fill: var(--accent); }
.card-title { flex: 1; min-width: 0; }
.t1 { display: block; font-size: 1.14rem; font-weight: 700; }
.latin { font-style: italic; font-weight: 400; color: var(--gold); margin-left: 8px; font-size: .95rem; }
.t2 { display: block; font-size: .88rem; font-style: italic; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.card:not(.open) .t2 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.count { font-family: var(--sans); font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.count.has { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chev { color: var(--gold); transition: transform .18s; }
.card.open .chev { transform: rotate(90deg); }
.card-body { padding: 4px 18px 18px; border-top: 1px solid var(--line-soft); }

.sub { margin: 18px 0 6px; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 700; font-family: var(--sans); }
.sub:first-child { margin-top: 12px; }
.q { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; padding: 10px 0; border-bottom: 1px dotted var(--line-soft); }
.q:last-of-type { border-bottom: 0; }
.q-main { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.box { flex: none; width: 24px; height: 24px; margin-top: 1px; border: 2px solid var(--gold); border-radius: 6px; background: var(--field); display: grid; place-items: center; color: transparent; transition: background .12s, border-color .12s; }
.box .icon { width: 16px; height: 16px; }
.cb:checked + .q-main .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cb:focus-visible + .q-main .box { outline: 3px solid var(--accent); outline-offset: 2px; }
.q-text { flex: 1; }
.rule-tag { display: inline-block; font-family: var(--sans); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin-left: 6px; }
.q-help { grid-column: 1 / -1; margin: 4px 0 0 36px; font-size: .86rem; font-style: italic; color: var(--muted); }
.note { grid-column: 1 / -1; margin: 8px 0 0 36px; width: calc(100% - 36px); }
.q-tools { display: flex; gap: 2px; align-items: flex-start; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; border: 0; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.x:hover { color: var(--danger); }
.icon-btn .icon { width: 16px; height: 16px; }
.q .remove { display: none; }
.customizing .q .remove { display: inline-grid; }
.customizing .q:not(.mine) .q-text { text-decoration: none; }
.mine .q-text::after { content: " · mine"; font-family: var(--sans); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.q.reflect { display: block; border: 0; padding: 12px 0 4px; }
.q.reflect label { display: block; margin-bottom: 6px; }
.q.reflect textarea { min-height: 4.4em; }
.edit-input { width: 100%; }

.add-own { margin-top: 14px; }
.add-own .btn { font-size: .85rem; }
.add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form input { flex: 1 1 220px; }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); font-style: italic; }

.main-foot { margin-top: 26px; text-align: center; font-size: .86rem; color: var(--muted); }
.main-foot .linklike { font-size: .86rem; }

.menu-btn { display: none; }
.backdrop { display: none; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 18px 60px rgba(0, 0, 0, .35); }
dialog.wide { width: min(720px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 12, 8, .55); }
.dlg { padding: 22px 24px 20px; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dlg-head.center { flex-direction: column; align-items: center; text-align: center; }
.dlg-head h2 { font-size: 1.45rem; }
.dlg-cross { width: 48px; height: 48px; padding: 10px; border-radius: 50%; fill: var(--accent); background: var(--accent-soft); border: 1.5px solid var(--gold); }
.dlg h3 { margin: 18px 0 6px; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-family: var(--sans); }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.stack { display: grid; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.prose p, .prose li { font-size: .98rem; }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 1.2em; }
.steps { padding-left: 1.3em; margin: 8px 0 14px; }
.steps li { margin-bottom: 6px; }
.callout { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; font-size: .95rem; }
.callout .icon { color: var(--accent); margin-top: 3px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
legend { padding: 0; font-family: var(--sans); font-size: .76rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.situation { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.situation legend { padding: 0 6px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 10px; margin-bottom: 6px; cursor: pointer; }
.opt:hover { border-color: var(--accent); }
.opt input { margin-top: 5px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.opt small { display: block; color: var(--muted); font-size: .84rem; line-height: 1.3; }
.opt.single { margin-top: 4px; }

/* Cover, toast */
.cover { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: pointer; }
.cover-cross { width: 84px; height: 84px; padding: 18px; border-radius: 50%; fill: var(--accent); background: var(--accent-soft); border: 2px solid var(--gold); }
.cover p { margin: 6px 0 0; font-size: 1.5rem; font-weight: 600; }
.cover small { color: var(--muted); font-style: italic; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; display: flex; gap: 14px; align-items: center; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-family: var(--sans); font-size: .9rem; box-shadow: var(--shadow); max-width: calc(100vw - 24px); }
.toast button { background: none; border: 0; color: var(--bg); text-decoration: underline; font-weight: 700; padding: 0; }

#printout { display: none; }

/* Small screens */
@media (max-width: 900px) {
  .app { display: block; }
  .menu-btn { display: grid; place-items: center; position: fixed; z-index: 30; top: calc(10px + env(safe-area-inset-top, 0px)); left: 10px; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(340px, 88vw); height: 100%; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 8px 0 30px rgba(0, 0, 0, .3); padding-top: calc(22px + env(safe-area-inset-top, 0px)); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(20, 12, 8, .5); }
  .main { padding-top: calc(66px + env(safe-area-inset-top, 0px)); }
  .fields { grid-template-columns: 1fr; }
  .orn-rule { display: none; }
  .title-row .orn { width: 30px; height: 30px; }
  .main-head { margin-bottom: 10px; }
  .card-head { padding: 12px; gap: 10px; }
  .medal { width: 38px; height: 38px; font-size: .9rem; }
  .card-body { padding: 2px 12px 14px; }
}

/* Print: only the generated sheet */
@media print {
  @page { margin: 16mm 15mm 18mm; }
  html, body { background: #fff !important; color: #000 !important; min-height: 0; }
  body { font-size: 11.5pt; line-height: 1.4; }
  .app, .cover, .toast, dialog { display: none !important; }
  #printout { display: block; font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif; }
  .p-head { text-align: center; margin-bottom: 14pt; border-bottom: 1.2pt solid #000; padding-bottom: 10pt; }
  .p-head svg { width: 20pt; height: 20pt; fill: #000; }
  .p-head h1 { font-size: 21pt; margin: 4pt 0 2pt; }
  .p-date { margin: 0; font-style: italic; }
  .p-since { margin: 8pt 0 0; font-size: 11pt; }
  .p-mode { font-size: 15pt; margin: 18pt 0 4pt; padding-bottom: 3pt; border-bottom: .6pt solid #000; break-after: avoid; }
  .p-sec { margin: 12pt 0 0; }
  .p-sec h3 { font-size: 12.5pt; margin: 0 0 2pt; break-after: avoid; }
  .p-sec .p-sub { font-size: 9.5pt; letter-spacing: .08em; text-transform: uppercase; margin: 8pt 0 2pt; break-after: avoid; }
  .p-item { display: flex; gap: 8pt; margin: 0 0 5pt; break-inside: avoid; }
  .p-box { flex: none; width: 9pt; height: 9pt; margin-top: 3.5pt; border: 1pt solid #000; position: relative; }
  .p-box.on::after { content: "\2713"; position: absolute; left: 0; top: -3.2pt; font-size: 11pt; line-height: 1; }
  .p-text { flex: 1; }
  .p-note { display: block; margin-top: 1.5pt; padding-left: 8pt; border-left: .8pt solid #666; font-style: italic; }
  .p-lines { height: 40pt; border-bottom: .6pt solid #888; margin-bottom: 4pt; }
  .p-empty { font-style: italic; }
  .p-contrition { margin-top: 24pt; padding-top: 10pt; border-top: 1.2pt solid #000; break-inside: avoid; text-align: center; }
  .p-contrition h2 { font-size: 13pt; margin: 0 0 6pt; }
  .p-contrition p { font-style: italic; margin: 0 auto; max-width: 150mm; }
  .p-foot { margin-top: 14pt; text-align: center; font-size: 8.5pt; color: #444; }
}
