/* jewishlearninginstitution.com
   Warm parchment palette — low-glare, easy on the eyes for daily, long-term use.
   Warm charcoal ink (never pure black) on cream (never pure white), one bronze accent. */

:root {
  /* Light — "Parchment" */
  --bg: #f3ede1;
  --surface: #fbf6ec;
  --surface-2: #ece4d4;
  --surface-3: #e4dbc8;
  --ink: #33302a;
  --ink-2: #5f594e;
  --ink-3: #938a7b;
  --line: #e2d8c6;
  --line-strong: #d5c9b3;
  --accent: #7e6430;
  --accent-ink: #6b5427;
  --accent-soft: #efe6d2;
  --warn: #9c5322;
  --warn-soft: #f2e2d3;
  --shadow: 0 1px 2px rgba(60, 50, 30, 0.05), 0 4px 14px rgba(60, 50, 30, 0.04);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark — "Warm night" (no pure black, no pure white) */
    --bg: #17150f;
    --surface: #211e17;
    --surface-2: #2b271e;
    --surface-3: #35301f;
    --ink: #ece5d6;
    --ink-2: #b1a996;
    --ink-3: #7e7767;
    --line: #332e24;
    --line-strong: #423b2d;
    --accent: #d3b26a;
    --accent-ink: #e0c27e;
    --accent-soft: #2c2618;
    --warn: #e0a06a;
    --warn-soft: #2f2417;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(96px + var(--safe-bottom)); }

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 22px 0;
}
.loc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13.5px; font-weight: 500; padding: 4px 0; cursor: pointer;
}
.loc-btn svg { color: var(--accent); }
.clock { font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.dateblock { padding: 14px 22px 0; }
.brand {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.9px;
  color: var(--accent); text-transform: lowercase; margin-bottom: 10px;
}
.hebdate {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: 30px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.18;
}
.gregdate { color: var(--ink-3); font-size: 14px; margin-top: 3px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 16px 22px 0; }
.chip {
  font-size: 12.5px; font-weight: 500; padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); font-weight: 600; }

/* ---------- Sections ---------- */
main { padding: 0 22px; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: var(--ink-3); }
.section-link { font-size: 13px; color: var(--accent-ink); font-weight: 500; background: none; border: 0; cursor: pointer; font-family: inherit; }

/* ---------- Hero (next zman) ---------- */
.hero {
  margin: 22px 22px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 22px 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.hero-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.hero-name { font-size: 22px; font-weight: 600; margin-top: 6px; letter-spacing: -0.2px; }
.hero-time {
  font-size: 42px; font-weight: 700; letter-spacing: -1.2px; line-height: 1.05;
  color: var(--accent-ink); font-variant-numeric: tabular-nums; margin-top: 2px;
}
.hero-count { font-size: 14px; color: var(--ink-2); margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero-sub { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

/* ---------- Rows ---------- */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.rows.flush { box-shadow: none; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; min-height: 52px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row.tap { cursor: pointer; }
.row.tap:active { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15.5px; font-weight: 500; letter-spacing: -0.1px; }
.row-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.row-heb { font-size: 13.5px; color: var(--ink-3); font-family: "Times New Roman", "FrankRuehl", serif; margin-top: 2px; }
.row-time { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.row-time.past { color: var(--ink-3); font-weight: 500; }
.row-chev { color: var(--ink-3); font-size: 17px; flex: none; }
.row.next { background: var(--accent-soft); }
.row.next .row-title { font-weight: 600; }
.row.next .row-time { color: var(--accent-ink); }

.group-title { font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ink-3); margin: 22px 0 8px; }
.group-title:first-child { margin-top: 6px; }

/* ---------- Prayer list ---------- */
.prayer-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.prayer-row:last-child { border-bottom: 0; }
.prayer-row .val { color: var(--ink-3); font-size: 14px; }
.prayer-row .val.yes { color: var(--accent-ink); font-weight: 600; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ink-3); }
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-num small { font-size: 16px; color: var(--ink-3); font-weight: 500; }
.stat-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.stat-action { font-size: 13.5px; color: var(--accent-ink); font-weight: 600; margin-top: 8px; }

/* ---------- Quick actions ---------- */
.quick { display: flex; flex-wrap: wrap; gap: 9px; }
.quick-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 12px; padding: 11px 15px; font: inherit; font-size: 14.5px; font-weight: 500; cursor: pointer;
}
.quick-btn:active { background: var(--surface-2); }
.quick-btn.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); font-weight: 600; }

/* ---------- Segmented ---------- */
.segmented { display: flex; gap: 4px; background: var(--surface-2); border-radius: 13px; padding: 4px; }
.seg {
  flex: 1; border: 0; background: transparent; padding: 10px 4px; border-radius: 10px;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink-2); cursor: pointer;
}
.seg.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(60,50,30,0.1); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 13px; padding: 12px 18px; font: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
}
.btn.wide { display: block; width: 100%; margin-top: 12px; }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--warn); }
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.4; }

/* ---------- Fields ---------- */
.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 15.5px;
}
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; font-size: 15.5px; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- Ring ---------- */
.ring {
  width: 58px; height: 58px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--line) 0);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.ring span { background: var(--surface); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }

/* ---------- Chapter grid ---------- */
.book { margin-top: 20px; }
.book-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 9px; }
.book-title span { color: var(--ink-3); font-weight: 400; }
.chapter-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.chapter {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 11px; padding: 11px 0; font: inherit; font-size: 14.5px; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chapter.done { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); font-weight: 700; }
.chapter:active { background: var(--surface-2); }

/* ---------- Week table ---------- */
.week { display: flex; flex-direction: column; }
.week-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.week-row:last-child { border-bottom: 0; }
.week-day { width: 62px; flex: none; font-size: 13.5px; font-weight: 600; }
.week-day .tiny { display: block; font-weight: 400; }
.week-times { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.week-head { padding-bottom: 8px; }
.week-head .week-times { color: var(--ink-3); font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.week-row.is-today .week-day, .week-row.is-today .week-times { color: var(--accent-ink); font-weight: 600; }

/* ---------- Kovea ---------- */
.check {
  width: 34px; height: 34px; border-radius: 50%; border: 1.8px solid var(--line-strong);
  background: transparent; color: #fff; font-size: 16px; cursor: pointer; flex: none;
  display: grid; place-items: center;
}
.check.on { background: var(--accent); border-color: var(--accent); }

/* ---------- Misc ---------- */
.muted { color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }
.tiny { font-size: 12px; color: var(--ink-3); }
.sub { color: var(--ink-2); font-size: 14.5px; }
.note { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; line-height: 1.55; }
.banner { margin: 16px 22px 0; padding: 12px 16px; border-radius: 13px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13.5px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: center;
  padding: 6px 0 calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
  max-width: 560px; margin: 0 auto;
}
.tab {
  border: 0; background: transparent; color: var(--ink-3); font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; padding: 6px 12px; font-size: 10.5px; font-weight: 500;
}
.tab.on { color: var(--accent-ink); }

/* ---------- Sheet ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(40, 33, 20, 0.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 93vh;
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.2px; }
.close {
  border: 0; background: var(--surface-2); color: var(--ink-2); width: 32px; height: 32px;
  border-radius: 50%; font-size: 14px; cursor: pointer; display: grid; place-items: center;
}
.sheet-body { padding: 18px 20px calc(26px + var(--safe-bottom)); overflow-y: auto; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 18px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--ink-3); }
.kv span:last-child { text-align: right; }

/* ---------- Hebrew & reader ---------- */
.hebrew { font-family: "Times New Roman", "FrankRuehl", "David CLM", serif; }
.rtl { direction: rtl; text-align: right; }
.big-hebrew { font-size: 26px; line-height: 1.8; }
.reader { display: flex; flex-direction: column; gap: 4px; }
.verse { padding: 16px 0; border-bottom: 1px solid var(--line); }
.verse:last-child { border-bottom: 0; }
.verse .hebrew { font-size: 27px; line-height: 1.95; letter-spacing: 0.2px; }
.verse .eng { color: var(--ink-2); font-size: 15px; margin-top: 9px; line-height: 1.6; }
.verse .tiny { margin-top: 7px; }
.reader-progress { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.reader-progress span { display: block; height: 100%; background: var(--accent); }

/* ---------- City search ---------- */
.city-results { max-height: 210px; overflow-y: auto; margin-top: 8px; }
.city {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 12px 2px; font: inherit; font-size: 15px; border-bottom: 1px solid var(--line);
  cursor: pointer; color: var(--ink);
}
.city .tiny { display: block; }
