@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Newsreader:ital,opsz,wght@0,6..72,500;1,6..72,400&family=Noto+Naskh+Arabic:wght@600&display=swap');

:root {
  --ink: #2a241b;
  --ink-soft: #6c6253;
  --paper: #faf9f6;
  --white: #fffefb;
  --gold: #b8914f;
  --gold-deep: #765a2c;
  --gold-pale: #e7dabb;
  --silver: #a9a7a1;
  --sage: #7d8876;
  --line: #ded8ca;
  --shadow: 0 24px 60px rgba(90, 70, 37, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "IBM Plex Sans", sans-serif; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(183,104,63,.35); outline-offset: 3px; }

.shell { width: min(100%, 760px); min-height: 100vh; margin: auto; background: var(--paper); padding-bottom: 92px; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.brand-mark { display: block; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px rgba(90,70,37,.14); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .03em; }
.brand small { color: var(--ink-soft); font-size: 11px; margin-top: 2px; }
.icon-button { border: 1px solid var(--line); background: transparent; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; }

.view { display: none; padding: 0 24px 44px; }
.view.active { display: block; animation: settle .45s ease both; }
@keyframes settle { from { opacity: 0; transform: translateY(8px); } }
.day-intro, .page-heading { position: relative; padding: 52px 0 44px; }
.eyebrow { margin: 0 0 12px; color: var(--gold-deep); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 600; }
h1, h2 { font-family: "Newsreader", Georgia, serif; font-weight: 500; }
h1 { margin: 0; max-width: 520px; font-size: clamp(42px, 9vw, 68px); line-height: .96; letter-spacing: -.035em; }
h1 em { color: var(--gold-deep); font-weight: 400; }
.rhythm { position: absolute; right: 4px; top: 37px; width: 106px; height: 106px; display: grid; place-items: center; }
.rhythm svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.rhythm circle { fill: none; stroke: var(--line); stroke-width: 1; }
.rhythm .progress-ring { stroke: var(--gold); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 245 327; }
.rhythm-number { font: 500 22px "Newsreader", serif; }

.remembrance-card { position: relative; overflow: hidden; background: linear-gradient(145deg, #352c20, #171511); color: var(--white); padding: 32px; border-radius: 4px 28px 4px 4px; box-shadow: var(--shadow); }
.remembrance-card::after { content: ""; position: absolute; width: 230px; height: 230px; right: -108px; top: -115px; border: 1px solid rgba(231,218,187,.22); border-radius: 50%; box-shadow: 0 0 0 18px rgba(231,218,187,.035), 0 0 0 36px rgba(231,218,187,.025); pointer-events: none; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.occasion { color: #c5ccdb; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.listen-button { border: 1px solid rgba(255,255,255,.25); color: var(--white); background: transparent; border-radius: 999px; padding: 7px 13px; cursor: pointer; }
.arabic { margin: 30px 0 6px; font-family: "Noto Naskh Arabic", "Scheherazade New", "Amiri", serif; font-size: clamp(26px, 5.6vw, 38px); line-height: 2.05; color: var(--white); }
.arabic:empty { display: none; }
/* The line as printed, shown until the entry has been transcribed. Inverted so the
   black-on-white scan sits on the dark card. */
.arabic-scan { display: block; width: 100%; max-width: 470px; height: auto; margin: 26px 0 16px;
  /* invert turns the black-on-white scan white-on-black, then screen drops the black
     so the letters sit on the card rather than in a box. */
  filter: invert(1) contrast(1.08); mix-blend-mode: screen; opacity: .96; }
.arabic-scan[hidden] { display: none; }
.dialog-arabic { font-family: "Noto Naskh Arabic", "Scheherazade New", "Amiri", serif; font-size: 26px; line-height: 2; margin: 4px 0 10px; }
.dialog-arabic:empty { display: none; }
.category-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.category-filter button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 13px; font-size: 12px; color: var(--ink-soft); cursor: pointer; }
.category-filter button[aria-pressed="true"] { border-color: var(--gold-deep); color: var(--gold-deep); background: rgba(231,218,187,.3); font-weight: 600; }
.library-item .library-category { display: block; margin-top: 4px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-deep); }
/* The romanisation reads at the same size as the English and is set in italic,
   the usual convention for transliterated text. Only its spacing changes with
   the Arabic above it — app.js sets .has-arabic on the card. */
.transliteration { margin: 26px 0 14px; font: italic 400 18px/1.6 "Newsreader", serif; color: #eef1f6; }
.remembrance-card.has-arabic .transliteration { margin: 14px 0 14px; }
.translation { color: #dce0e9; font: 400 18px/1.55 "Newsreader", serif; }
.unchecked { margin: 18px 0 0; padding-left: 11px; border-left: 2px solid rgba(231,218,187,.4); color: #b9c0cf; font-size: 11px; letter-spacing: .02em; }
.source-line { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; border-top: 1px solid rgba(255,255,255,.15); margin-top: 30px; padding-top: 18px; color: #aeb7ca; font-size: 11px; }
.chapter-title { display: block; margin-bottom: 5px; color: #c9d0de; }
.chapter-title[hidden] { display: none; }
.source-line button { border: 0; border-bottom: 1px solid currentColor; padding: 0 0 2px; color: var(--gold-pale); background: transparent; cursor: pointer; white-space: nowrap; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.context-block { margin-top: 18px; padding: 30px 30px 26px; border-left: 2px solid var(--gold-pale); background: var(--white); }
.context-block .eyebrow { margin-bottom: 10px; }
.context-block #contextText { margin: 0; color: var(--ink); font: 400 18px/1.7 "Newsreader", Georgia, serif; }
.context-reference { margin: 14px 0 0; color: var(--ink-soft); font-size: 12px; }
.context-reference:empty { display: none; }
.story-block { display: grid; grid-template-columns: 64px 1fr; gap: 22px; margin-top: 18px; padding: 34px 30px; border: 1px solid var(--gold-pale); background: linear-gradient(120deg, rgba(231,218,187,.22), rgba(255,254,251,.76)); }
.story-marker { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--gold-pale); background: var(--white); }
.story-marker img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; opacity: .86; }
.story-block h2 { margin: 0 0 14px; font-size: clamp(25px, 5vw, 34px); line-height: 1.08; }
.story-block #backgroundStory { margin: 0; color: var(--ink-soft); font: 400 17px/1.65 "Newsreader", serif; }
.story-attribution { margin: 18px 0 0; color: var(--gold-deep); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

.reflection-block { padding: 48px 0 12px; }
.reflection-block h2 { max-width: 620px; margin: 0 0 32px; font-size: clamp(30px, 6vw, 44px); line-height: 1.08; }
.reflection-block label, .settings-card label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 9px; }
textarea { width: 100%; resize: vertical; padding: 18px; border: 1px solid var(--line); border-radius: 3px 18px 3px 3px; background: var(--white); color: var(--ink); line-height: 1.55; }
.journal-hint { margin: -4px 0 12px; color: var(--ink-soft); font-size: 13px; }
.starters { display: grid; gap: 14px; margin: 0 0 16px; }
.starters:empty { display: none; }
.starter-group { display: grid; gap: 7px; }
.starter-label { margin: 0; color: var(--gold-deep); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.starter-label span { margin-left: 8px; color: var(--silver); font-weight: 400; letter-spacing: .02em; text-transform: none; }
.starter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.starter-row button { border: 1px solid var(--line); background: var(--white); color: var(--ink-soft); border-radius: 999px; padding: 7px 13px; font-size: 12.5px; cursor: pointer; text-align: left; }
.starter-row button:hover { border-color: var(--gold-deep); color: var(--gold-deep); }
.journal-actions { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; }
#saveStatus { color: var(--sage); font-size: 12px; }
.primary-button { border: 0; background: var(--gold-deep); color: white; border-radius: 3px 14px 3px 3px; padding: 13px 18px; font-weight: 600; cursor: pointer; }
.primary-button.completed { background: var(--sage); }

.page-heading { padding-top: 58px; }
.journal-summary { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); background: var(--white); margin-bottom: 28px; }
.journal-summary div { padding: 22px; }
.journal-summary div + div { border-left: 1px solid var(--line); }
.journal-summary strong, .journal-summary span { display: block; }
.journal-summary strong { font: 500 38px "Newsreader", serif; }
.journal-summary span { color: var(--ink-soft); font-size: 12px; }
.entries { display: grid; gap: 12px; }
.entry { padding: 22px; background: var(--white); border-left: 3px solid var(--sage); }
.entry time { color: var(--ink-soft); font-size: 11px; }
.entry h3 { margin: 6px 0 10px; font: 500 24px "Newsreader", serif; }
.entry p { margin: 0; color: var(--ink-soft); line-height: 1.55; white-space: pre-wrap; }
.empty { padding: 34px; border: 1px dashed var(--line); color: var(--ink-soft); text-align: center; }
.text-button { margin-top: 24px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--ink); background: transparent; cursor: pointer; }
.plain-link { display: block; width: fit-content; margin-top: 18px; color: var(--gold-deep); font-size: 12px; }

.search-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 9px; }
.library-search { width: 100%; padding: 15px 17px; border: 1px solid var(--line); border-radius: 3px 15px 3px 3px; background: var(--white); color: var(--ink); }
.library-status { display: flex; justify-content: space-between; gap: 12px; padding: 14px 0 24px; color: var(--ink-soft); font-size: 10px; }
.library-grid { display: grid; gap: 12px; }
.library-item { width: 100%; display: grid; grid-template-columns: 48px 1fr auto; gap: 16px; align-items: center; padding: 17px; border: 1px solid var(--line); background: var(--white); text-align: left; cursor: pointer; }
.library-number { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--gold-pale); color: var(--gold-deep); font: 500 17px "Newsreader", serif; }
.library-item strong, .library-item small { display: block; }
.library-item strong { font: 500 20px "Newsreader", serif; }
.library-item small { margin-top: 3px; color: var(--ink-soft); }
.library-arrow { color: var(--gold); }
.install-card details { margin-top: 18px; color: var(--ink-soft); font-size: 12px; }
.install-card summary { color: var(--gold-deep); cursor: pointer; }

.settings-card { padding: 26px; background: var(--white); border: 1px solid var(--line); margin-bottom: 16px; }
.settings-card h2 { margin-top: 0; font-size: 28px; }
.settings-card input { width: 100%; padding: 13px; margin: 0 0 14px; border: 1px solid var(--line); background: var(--paper); font-size: 18px; }
.settings-card p { line-height: 1.6; }
.help-text { color: var(--ink-soft); font-size: 12px; }

.bottom-nav { position: fixed; z-index: 5; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 760px); height: 74px; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(248,246,240,.94); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.bottom-nav button { border: 0; background: transparent; color: var(--ink-soft); font-size: 11px; cursor: pointer; }
.bottom-nav button span { display: block; margin-bottom: 4px; font-size: 17px; }
.bottom-nav button.active { color: var(--gold-deep); font-weight: 600; }

.institute-signature { display: flex; align-items: center; gap: 14px; padding: 18px 4px; }
.institute-signature img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; }
.institute-signature strong, .institute-signature span { display: block; }
.institute-signature strong { font: 500 20px "Newsreader", serif; }
.institute-signature span { color: var(--ink-soft); margin-top: 3px; font-size: 11px; }

dialog { width: min(calc(100% - 36px), 520px); padding: 34px; border: 0; border-radius: 3px 24px 3px 3px; color: var(--ink); background: var(--white); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(23,35,63,.72); backdrop-filter: blur(4px); }
dialog h2 { font-size: 32px; margin: 0 0 15px; }
dialog p { line-height: 1.6; }
.dialog-close { float: right; border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 88px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: white; padding: 11px 16px; border-radius: 999px; font-size: 12px; transition: .25s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .rhythm { position: relative; inset: auto; margin: 30px 0 -12px; }
  .day-intro { padding-bottom: 34px; }
  .remembrance-card { margin-inline: -8px; padding: 28px 24px; }
  .story-block { grid-template-columns: 1fr; padding: 26px 22px; }
  .story-marker { width: 46px; height: 46px; }
  .story-marker img { width: 36px; height: 36px; }
  .journal-actions { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
