:root {
  --bg: #fbf6f1;
  --bg-2: #f5ece4;
  --card: #fffdfb;
  --ink: #2c2330;
  --ink-2: #574b5a;
  --line: #ecdfd6;
  --accent: #366a9e;
  --accent-soft: #dfe9f4;
  --warn: #9a5b12;
  --warn-bg: #f9ecd7;
  --shadow: 0 1px 2px rgba(60, 30, 50, .05), 0 8px 24px rgba(60, 30, 50, .07);
  --radius: 18px;
  color-scheme: light;
}
/* Light unless the device is dark or the header button picks dark (data-theme="dark", saved as "theme") */
:root[data-theme="dark"] {
  --bg: #19141c; --bg-2: #211a25; --card: #261f2b; --ink: #f3ecf2; --ink-2: #cdc1ce;
  --line: #3a3040; --accent: #8db8e6; --accent-soft: #1f2c3b; --warn: #e6aa55; --warn-bg: #3a2d1b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 500px at 85% -10%, var(--accent-soft), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.55 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }

/* ── Header */
header.top {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
header.top .wrap { padding-bottom: 0; display: flex; align-items: center; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; text-decoration: none; color: var(--ink); }
.brand svg { width: 34px; height: 34px; }
.brand b { font: 600 24px/1 "Noto Serif", "Fraunces", Georgia, serif; letter-spacing: .2px; }
.brand small { display: block; font-size: 13.5px; color: var(--ink-2); letter-spacing: .3px; margin-top: 2px; }
.theme-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--ink); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.theme-btn:hover { border-color: var(--accent); }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
.home-btn { color: var(--ink-2); text-decoration: none; }
.home-btn svg { width: 17px; height: 17px; }
.home-btn + .theme-btn { margin-left: 6px; }

/* ── Tabs */
.tabbar { display: flex; align-items: center; gap: 4px; margin: 18px 0 6px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar a { flex: 1 0 auto; display: grid; place-items: center; min-height: 44px; padding: 0 9px; white-space: nowrap; border-radius: 999px; font-weight: 600; font-size: 15.5px; color: var(--ink-2); text-decoration: none; }
.tabbar a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.intro { margin: 22px 0 14px; }
.intro h1 { font: 600 28px/1.15 "Noto Serif", "Fraunces", Georgia, serif; margin: 0 0 6px; }
.intro p { margin: 0; color: var(--ink-2); }
.loading { color: var(--ink-2); margin-top: 32px; }
.center { text-align: center; }
.hint { color: var(--warn); font-size: 16px; margin: 8px 2px 0; }
.foot { color: var(--ink-2); font-size: 14px; margin-top: 22px; }
.note { padding: 11px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 16px; margin: 12px 0; }
.note.warn { background: var(--warn-bg); }
.btn {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 16px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--card); width: 100%; padding: 12px; font-size: 16px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 16px; cursor: pointer; }

/* ── Location */
.loc { margin: 16px 0 6px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.loc-now { display: flex; align-items: center; gap: 10px; }
.loc-now svg { width: 26px; height: 26px; color: var(--accent); flex: 0 0 auto; }
.loc-now b { display: block; font-size: 16.5px; }
.loc-now small { color: var(--ink-2); font-size: 14px; }
.loc-find { display: flex; gap: 8px; margin-top: 12px; }
.loc-find[hidden] { display: none; }
.loc-now > div { flex: 1; min-width: 0; }
.loc-change { flex: 0 0 auto; min-height: 44px; }
.swipe { display: none; margin: 14px 2px -6px; color: var(--ink-2); font-size: 14px; }
@media (max-width: 600px) { .swipe { display: block; } }
.search { position: relative; flex: 1; }
.search input, .ap input, .dt input, .settings select {
  width: 100%; padding: 9px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); min-width: 0;
}
.search input:focus, .ap input:focus, .dt input:focus { outline: none; border-color: var(--accent); }
.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); list-style: none; margin: 0; padding: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 320px; overflow: auto;
}
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggest button:hover, .suggest button:focus-visible { background: var(--bg-2); outline: none; }
.suggest small { display: block; color: var(--ink-2); font-size: 14px; }
.suggest .none { padding: 8px 10px; color: var(--ink-2); font-size: 16px; }

/* ── Day */
.daybar { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.daymid { flex: 1; text-align: center; }
.daymid b { display: block; font: 600 20px/1.2 "Noto Serif", "Fraunces", Georgia, serif; }
.daymid small { color: var(--ink-2); font-size: 15px; }
.nav { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 22px; line-height: 1; cursor: pointer; }

.next {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 0 0; padding: 12px 16px; border-radius: 14px;
  background: var(--accent); color: var(--card);
}
.next small { opacity: .85; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; font-size: 13.5px; }
.next b { font: 600 20px "Noto Serif", "Fraunces", Georgia, serif; }
.next span { margin-left: auto; font-weight: 600; }

.times { list-style: none; margin: 12px 0 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.times li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.times li:first-child { border-top: 0; }
.times li.is-next { background: var(--accent-soft); }
.times .ti { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-2); color: var(--accent); }
.times .ico { width: 20px; height: 20px; }
.times .tn { flex: 1; min-width: 0; }
.times .tn b { display: block; font-size: 16px; }
.times .tn small { display: block; color: var(--ink-2); font-size: 14px; line-height: 1.35; }
.times .tt { font: 600 19px "Noto Serif", "Fraunces", Georgia, serif; white-space: nowrap; font-variant-numeric: tabular-nums; }
.times li.imsak .tt, .times li.sunrise .tt, .times li.sunset .tt, .times li.midnight .tt { color: var(--ink-2); font-size: 17px; }
sup { color: var(--warn); }

.fast { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.fast > div { padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.fast small { display: block; color: var(--ink-2); font-size: 14px; }
.fast b { display: block; font: 600 24px/1.2 "Noto Serif", "Fraunces", Georgia, serif; margin: 2px 0; }

.qibla { display: flex; align-items: center; gap: 16px; margin-top: 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.qibla svg { width: 96px; height: 96px; flex: 0 0 auto; }
.qibla b { display: block; font: 600 20px "Noto Serif", "Fraunces", Georgia, serif; }
.qibla small { display: block; color: var(--ink-2); font-size: 15px; }
.qibla .btn.small { margin-top: 10px; padding: 7px 12px; font-size: 16px; }
.qibla .top { display: none; }
.qibla.live .top { display: block; }
.qibla.facing { border-color: var(--accent); background: var(--accent-soft); }
.qhelp { margin-top: 8px; font-size: 16px; }
.calib-link { display: block; margin: 10px auto 0; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.calib { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(20, 12, 24, .55); }
.calib-card { width: min(400px, 100%); max-height: calc(100vh / var(--z, 1) - 32px); overflow-y: auto; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.calib-card h2 { margin: 0 0 6px; font: 600 21px/1.2 "Noto Serif", "Fraunces", Georgia, serif; }
.calib-card svg { display: block; width: 100%; height: auto; margin: 4px 0 8px; }
.calib-card ol { margin: 0 0 16px; padding-left: 20px; font-size: 16px; }
.calib-card li { margin: 0 0 6px; }
.qlink { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; padding: 13px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; font-size: 16px; }
.qlink b { font: 600 18px "Noto Serif", "Fraunces", Georgia, serif; }
.qlink span:last-child { color: var(--accent); font-weight: 600; }
.qlink:hover { border-color: var(--accent); }
.qibla.live { flex-direction: column; text-align: center; }
.qibla.live svg { width: min(240px, 70vw); height: min(240px, 70vw); }
.qhelp summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* ── Month */
.table-wrap { margin-top: 14px; overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.month { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.month th, .month td { padding: 7px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.month th:first-child, .month td:first-child { text-align: left; }
.month th { font-size: 14px; color: var(--ink-2); font-weight: 600; position: sticky; top: 0; background: var(--card); }
.month tr.today td { background: var(--accent-soft); font-weight: 700; }
.month td:nth-child(3), .month td:nth-child(6) { font-weight: 600; }

/* ── Flight */
.flight { display: grid; gap: 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.flight label { display: block; font-size: 15px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.ap { position: relative; }
/* Date and time side by side, each allowed to shrink: phones (iOS above all) give date and time inputs a wide built-in
   minimum, which otherwise pushes them out of the box */
.flight { grid-template-columns: minmax(0, 1fr); }
.dt > div { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; }
.dt input { display: block; max-width: 100%; box-sizing: border-box; -webkit-appearance: none; appearance: none; min-height: 42px; text-align: left; }
.dt input::-webkit-date-and-time-value { text-align: left; }
@media (max-width: 360px) { .dt > div { grid-template-columns: minmax(0, 1fr); } }
.fsum { margin: 20px 0 6px; text-align: center; }
.route { display: flex; align-items: center; gap: 10px; }
.route b { font: 600 26px "Noto Serif", "Fraunces", Georgia, serif; }
.route span { flex: 1; color: var(--ink-2); font-size: 15px; border-bottom: 2px dashed var(--line); padding-bottom: 2px; }
.fsum small { color: var(--ink-2); font-size: 15px; }
h2.sub { margin: 22px 0 8px; font: 600 19px/1.25 "Noto Serif", "Fraunces", Georgia, serif; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 2px; background: var(--line); }
.timeline li { position: relative; display: flex; gap: 12px; padding: 8px 0; }
.tl-ic { position: relative; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--line); display: grid; place-items: center; color: var(--accent); }
.tl-ic .ico { width: 19px; height: 19px; }
.tl-edge .tl-ic { background: var(--accent); color: var(--card); border-color: var(--accent); }
.timeline li.back .tl-ic { color: var(--warn); }
.timeline b { display: block; font-size: 16px; }
.timeline .t2 { display: block; font-size: 16px; }
.qnose { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 12px 8px 8px; background: var(--accent-soft); border-radius: 12px; }
.qnose svg { width: 54px; height: 54px; flex: 0 0 auto; }
.qnose b { display: block; font-size: 16px; color: var(--ink); }
.qnose small { display: block; color: var(--ink-2); font-size: 15px; }
.timeline .t2 b { display: inline; font-size: 16px; }
.timeline small { display: block; color: var(--ink-2); font-size: 15px; margin-top: 2px; }

.good { margin: 0; padding: 14px 16px 14px 34px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: 16px; }
.good li { margin: 0 0 8px; }
.good li:last-child { margin: 0; }
.rulings { margin: 10px 0 0; display: grid; gap: 8px; }
.ruling { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; }
.ruling summary { cursor: pointer; padding: 11px 0; font-weight: 600; font-size: 16px; }
.ruling p { margin: 0 0 10px; font-size: 16px; }
.ruling .src { font-size: 14px; color: var(--ink-2); }

.settings { display: grid; gap: 12px; margin-top: 16px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.settings label { display: grid; gap: 4px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.settings label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.settings input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

@media (max-width: 520px) {
  .intro h1 { font-size: 24px; }
  .loc-find { flex-direction: column; }
  .times .tt { font-size: 17px; }
}
.print-only { display: none; }
.note.assume summary { cursor: pointer; }
.note.assume[open] summary { margin-bottom: 6px; }
.note.assume ul { margin: 8px 0 0; padding-left: 20px; }
.note.assume li { margin: 0 0 5px; }
@media print {
  /* always print in the light colours, even when the page is dark */
  :root, :root[data-theme="dark"] {
    --bg: #fff; --bg-2: #f5f2ee; --card: #fff; --ink: #1d1820; --ink-2: #555; --line: #d8cfc6;
    --accent: #2c5d8f; --accent-soft: #e6eef7; --warn: #8a5210; --warn-bg: #f7ead6; --shadow: none; color-scheme: light;
  }
  header.top, .tabbar, .no-print { display: none !important; }
  .print-only { display: block; font: 600 18pt "Noto Serif", "Fraunces", Georgia, serif; margin: 10mm 0 4mm; }
  .timeline li, .qnose { break-inside: avoid; }
  .qnose { background: #eef4fb; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  details.ruling { display: none; }
  .print-only.print-brand { margin: 0 0 1mm; padding-bottom: 2mm; border-bottom: 0.6pt solid #2c5d8f; font: 600 8.5pt "DM Sans", Helvetica, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: #2c5d8f; }
  .print-only.print-brand b { text-transform: none; letter-spacing: 0; font-size: 10pt; }
  .print-only.print-brand + h1.print-only { margin-top: 3mm; }
  .print-only.print-made { margin: 8mm 0 0; padding-top: 3mm; border-top: 0.6pt solid #d8cfc6; font: 400 9pt "DM Sans", Helvetica, sans-serif; color: #555; }
  .refs details.ruling { display: block; break-inside: avoid; border: 0; padding: 0; margin: 0 0 3mm; }
  .refs details.ruling summary { list-style: none; font-weight: 700; }
  .refs details.ruling p { margin: 1mm 0; font-size: 9.5pt; }
  .fplan li.urgent, .estimate { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .fplan li, .estimate .sky li { break-inside: avoid; }
  body { background: #fff; color: #000; }
  .wrap { max-width: none; padding: 0; }
  .table-wrap { border: 0; overflow: visible; }
  .month th, .month td { padding: 3px 6px; }
}

/* No zoom on a double tap (pinch to zoom still works) */
html, body { touch-action: manipulation; }
.fbtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.fbtns .btn { width: auto; flex: 1 1 150px; max-width: 240px; }
/* The flight's estimates, and how to check them from the window */
.estimate { margin: 14px 0; padding: 14px 16px; border-radius: var(--radius, 16px); border: 1.5px solid var(--accent); background: var(--card); }
.estimate h2.sub { margin-top: 0; }
.estimate p { margin: 0 0 10px; }
.estimate .sky { margin: 0 0 10px; padding-left: 20px; }
.estimate .sky li { margin: 6px 0; }
.timeline small.window { display: block; margin-top: 4px; color: var(--accent); font-weight: 600; }
/* The flight's Download PDF and Print, side by side with an icon each */
.fbtns { display: flex; gap: 10px; justify-content: center; margin: 14px 0 18px; }
.fbtn { flex: 1 1 0; max-width: 260px; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.fbtn:hover { border-color: var(--accent); }
.fbtn svg { width: 26px; height: 26px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.fbtn b { display: block; font-size: 16px; }
.fbtn small { display: block; color: var(--ink-2); font-size: 14px; }
.fbtn.dl { background: var(--accent); border-color: var(--accent); color: var(--card); }
.fbtn.dl small { color: color-mix(in srgb, var(--card) 80%, transparent); }
/* Your prayers on this flight: one plain line per prayer, those to pray in the air marked */
.fplan { margin: 14px 0; }
.fplan ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fplan li { padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.fplan li.urgent { border-color: var(--warn, #b26a12); background: var(--warn-bg, var(--card)); }
.fplan li b { display: block; font-size: 17px; margin-bottom: 2px; }
.fplan li span { display: block; font-size: 16px; line-height: 1.45; }
.fplan .small { margin: 8px 2px 0; color: var(--ink-2); font-size: 15px; }
.dt label small { font-weight: 400; color: var(--ink-2); }
.refs { margin-top: 22px; }
.refs > p { color: var(--ink-2); font-size: 15px; }
.fplan ul { display: flex; flex-wrap: wrap; gap: 8px; }
.fplan li { padding: 8px 14px; border-radius: 999px; }
.fplan li b { margin: 0; font-size: 16px; }
.fplan .key { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 50%; vertical-align: -1px; border: 1px solid var(--warn, #b26a12); background: var(--warn-bg, #f7ead6); }
