/* Wa'azin Kalma — classic look, phone first.
   No web fonts: system serif/sans keep the first load small on slow data. */

:root {
  --ivory: #FBF8F1;
  --parchment: #F4EEE2;
  --line: #E6DECC;
  --line-strong: #CFC5AE;
  --ink: #1F2430;
  --ink-2: #4A4F5C;
  --muted: #5B5F6B;
  --navy: #1E3A5F;
  --gold: #8A6420;
  --gold-soft: #C9A961;
  --warn-bg: #FDF3E7;
  --warn-line: #E8C9A0;
  --warn-ink: #6B3D0E;
  --ok: #2F5D3A;
  --white: #FFFFFF;
  --serif: Georgia, 'Times New Roman', 'Noto Serif', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  --tabs-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
a { color: var(--navy); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--navy); color: var(--white); padding: 10px 14px; z-index: 20; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--white); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--gold-soft); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 12px; border-radius: 22px;
  border: 1px solid var(--line-strong); background: var(--white); color: var(--navy); font-weight: 600; cursor: pointer;
}
.sync[aria-busy="true"] svg { animation: spin 1s linear infinite; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.lang {
  position: relative; display: inline-flex; align-items: center;
  min-height: 44px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--white); color: var(--navy);
}
.lang svg { position: absolute; left: 10px; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; pointer-events: none; }
.lang select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--navy); font-weight: 600; font-size: 15px;
  min-height: 42px; padding: 0 12px 0 32px; border-radius: 22px; cursor: pointer;
}
@media (max-width: 420px) {
  .sync-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sync { width: 44px; padding: 0; justify-content: center; }
  .lang svg { display: none; }
  .lang select { padding: 0 12px; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sync[aria-busy="true"] svg { animation: none; } }

/* Sync status strip */
.status { font-size: 14px; padding: 6px 16px; background: var(--parchment); color: var(--ink-2); border-bottom: 1px solid var(--line); }
.status:empty { display: none; }
.status.offline { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.status.fresh { color: var(--ok); }

main { outline: none; max-width: 720px; margin: 0 auto; }
.section { padding: 28px 16px 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 4px; }
.section-head h2 { font-size: 26px; }
.section-head a { font-weight: 600; font-size: 15px; }
.eyebrow { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.muted { color: var(--muted); }

/* Home hero */
.hero { background: var(--parchment); border-bottom: 1px solid var(--line); padding: 36px 20px 60px; text-align: center; }
.hero h1 { font-size: 32px; color: var(--navy); margin: 12px 0; }
.hero p { margin: 0 0 20px; color: var(--ink-2); }
.hero .cross { width: 14px; height: 20px; fill: none; stroke: var(--gold); stroke-width: 1.8; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 4px; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--navy); color: var(--white); border: 1px solid var(--navy);
}
.btn + .btn { margin-top: 10px; }
.btn.outline { background: transparent; color: var(--navy); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; display: inline-flex; }
.btn:disabled { opacity: .6; cursor: default; }

.verse { margin: -30px 16px 0; background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 20px; text-align: center; }
.verse blockquote { margin: 0; font-family: var(--serif); font-style: italic; font-size: 19px; line-height: 1.4; }
.verse figcaption { margin-top: 8px; }

.links { list-style: none; margin: 12px 0 0; padding: 0; background: var(--white); border: 1px solid var(--line); border-radius: 6px; }
.links li + li { border-top: 1px solid var(--line); }
.links a { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: var(--ink); min-height: 64px; }
.links .ico { flex: 0 0 44px; height: 44px; border-radius: 50%; background: var(--parchment); color: var(--navy); display: flex; align-items: center; justify-content: center; }
.links .txt { flex: 1; display: flex; flex-direction: column; }
.links .txt b { font-weight: 700; }
.links .txt span { font-size: 15px; color: var(--muted); }
.ico svg, .tabs svg, .chev { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chev { color: var(--gold); }

.card { background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 20px; }
.card.gold { border-color: var(--gold-soft); }
.card h2 { font-size: 24px; margin-bottom: 6px; }

/* Messages */
.filters { position: sticky; top: calc(61px + env(safe-area-inset-top)); z-index: 5; background: var(--ivory); padding: 12px 16px 8px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; background: var(--white); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 12px; }
.search input { flex: 1; border: 0; outline: none; background: transparent; min-height: 44px; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line-strong); background: var(--white); color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--white); }

.day { font-family: var(--serif); font-size: 21px; padding: 20px 16px 6px; border-bottom: 2px solid var(--ink); margin: 0 16px; padding-left: 0; padding-right: 0; }
.msg { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); margin: 0; }
.msg.pinned { background: #FFFDF8; }
.avatar { flex: 0 0 40px; height: 40px; border-radius: 50%; background: var(--parchment); color: var(--navy); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.msg.pinned .avatar { background: var(--navy); color: var(--white); }
.msg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.msg-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 14px; color: var(--muted); }
.msg-meta b { font-size: 16px; color: var(--ink); }
.msg-meta time { margin-left: auto; }
.msg-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.tag-pin { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); font-weight: 700; }

.media { display: flex; flex-direction: column; gap: 8px; background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.media audio, .media video { width: 100%; max-height: 260px; }
.media-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.saved { color: var(--ok); font-weight: 600; }
.load { padding: 0 16px; }
.load-tip { font-size: 14px; color: var(--muted); }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.more { display: flex; justify-content: center; padding: 20px 16px; }

/* Books */
.book { display: flex; gap: 16px; padding: 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.cover { flex: 0 0 76px; height: 104px; border-radius: 2px 5px 5px 2px; background: var(--navy); color: #E9D49B; box-shadow: inset 5px 0 0 rgba(0,0,0,.18); display: flex; align-items: center; justify-content: center; padding: 8px; text-align: center; font-family: var(--serif); font-size: 13px; line-height: 1.2; }
.book h3 { font-size: 21px; font-weight: 600; }
.reader { padding: 20px 16px 32px; }
.reader h1 { font-size: 30px; color: var(--navy); }
.reader h2 { font-size: 23px; margin: 28px 0 8px; }
.reader p { margin: 0 0 14px; font-family: var(--serif); font-size: 19px; line-height: 1.6; white-space: pre-wrap; }
.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* Ask */
form.ask { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }
.field input, .field select, .field textarea { border: 1px solid var(--line-strong); border-radius: 4px; background: var(--white); padding: 12px; min-height: 48px; }
.field textarea { min-height: 140px; resize: vertical; }
.note { font-size: 15px; padding: 12px 14px; border-radius: 4px; background: var(--parchment); }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pending { list-style: none; padding: 0; margin: 8px 0 0; }
.pending li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }

.admin-link { text-align: center; font-size: 14px; margin: 8px 0 24px; }
.admin-link a { color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; }

/* Bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--white); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabs-h); text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.tabs svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--navy); }
.tabs a[aria-current="page"] svg { stroke-width: 2.2; }

@media (min-width: 760px) {
  .hero h1 { font-size: 44px; }
  .hero .btns { max-width: 420px; margin: 0 auto; }
}

/* Teaching schedule (home screen) */
.schedule { list-style: none; margin: 12px 0 0; padding: 0; background: var(--white); border: 1px solid var(--line); border-radius: 6px; }
.schedule li { display: flex; gap: 14px; padding: 12px 16px; align-items: baseline; }
.schedule li + li { border-top: 1px solid var(--line); }
.schedule li.today { background: #FBF6EA; box-shadow: inset 3px 0 0 var(--gold); }
.schedule .when { flex: 0 0 104px; display: flex; flex-direction: column; }
.schedule .when span, .schedule .what span { font-size: 15px; color: var(--muted); }
.schedule .what { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
