/* Marrakech Guide: one stylesheet. Phone first (390 px), large text, large tap targets,
   high contrast for strong sunlight, light and dark themes. */

:root {
  --bg: #fbf6ee;
  --surface: #ffffff;
  --surface2: #f3e9da;
  --ink: #17110d;
  --muted: #54473c;
  --line: #d9c8b1;
  --accent: #9e341c;
  --accent-ink: #ffffff;
  --accent-soft: #f7e0d4;
  --ok: #165c34;
  --ok-bg: #dcefe2;
  --warn: #7c4100;
  --warn-bg: #faeacd;
  --bad: #9b1717;
  --bad-bg: #f9dddd;
  --gem: #4f2f80;
  --gem-bg: #ebe2f6;
  --chip: #efe3d1;
  --top-bg: #9e341c;
  --top-ink: #ffffff;
  --shadow: 0 1px 2px rgba(60, 35, 15, .08), 0 2px 10px rgba(60, 35, 15, .06);
  --radius: 14px;
  --fs: 19px;
  --top: 58px;
  --bottom: 68px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Noto Naskh Arabic", "Noto Sans Arabic", "Geeza Pro", "Arabic Typesetting", "DejaVu Sans", Arial, sans-serif;
  color-scheme: light;
}
:root[data-size="larger"] { --fs: 21px; }
:root[data-size="largest"] { --fs: 23.5px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110f0d; --surface: #1c1815; --surface2: #27211c; --ink: #f8f2ea; --muted: #d3c6b7; --line: #40362d;
    --accent: #f2906a; --accent-ink: #1a0d07; --accent-soft: #3b2219; --ok: #8fdcae; --ok-bg: #15301f;
    --warn: #f5be6e; --warn-bg: #382810; --bad: #ffa4a4; --bad-bg: #3a1616; --gem: #d3bbf5; --gem-bg: #2b2140;
    --chip: #2a241e; --shadow: none; color-scheme: dark; --top-bg: #3b1a10; --top-ink: #fbe9df;
  }
}
:root[data-theme="dark"] {
  --bg: #110f0d; --surface: #1c1815; --surface2: #27211c; --ink: #f8f2ea; --muted: #d3c6b7; --line: #40362d;
  --accent: #f2906a; --accent-ink: #1a0d07; --accent-soft: #3b2219; --ok: #8fdcae; --ok-bg: #15301f;
  --warn: #f5be6e; --warn-bg: #382810; --bad: #ffa4a4; --bad-bg: #3a1616; --gem: #d3bbf5; --gem-bg: #2b2140;
  --chip: #2a241e; --shadow: none; color-scheme: dark; --top-bg: #3b1a10; --top-ink: #fbe9df;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.55;
  padding-bottom: calc(var(--bottom) + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
}
body.has-sheet { overflow: hidden; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1em; }
h4 { font-size: 1rem; margin: 1em 0 .3em; }
p { margin: 0 0 .8em; }
ul, ol { padding-left: 1.3em; margin: 0 0 .8em; }
li { margin-bottom: .35em; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }

.small { font-size: .85rem; }
.btn, .chip, .subtab, .seg button, .badge, .tier, .score, .langtog button, .netbadge, .switch, .stars, .bottombar a, .sort { overflow-wrap: normal; }
.chip .n { white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.dot { color: var(--muted); padding: 0 .1em; }
.warn-txt { color: var(--warn); font-weight: 600; }
.bad-txt { color: var(--bad); }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 12px; padding-top: env(safe-area-inset-top, 0px);
  background: var(--top-bg); color: var(--top-ink);
}
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 800; font-size: 1.12rem; min-height: 48px; }
.brand-ico { width: 28px; height: 28px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.netbadge { font-size: .72rem; font-weight: 700; padding: 4px 9px; border-radius: 999px; border: 2px solid currentColor; white-space: nowrap; }
.netbadge.off { background: #ffd27a; color: #2b1800; border-color: #ffd27a; }
.netbadge.ready, .netbadge.on { opacity: .95; }
.langtog { display: flex; border: 2px solid var(--top-ink); border-radius: 12px; overflow: hidden; }
.langtog button { min-width: 48px; min-height: 42px; border: 0; background: transparent; color: var(--top-ink); font-weight: 800; cursor: pointer; }
.langtog button.on { background: var(--top-ink); color: var(--top-bg); }

main { display: block; outline: none; }
.page { max-width: 760px; margin: 0 auto; padding: 14px 16px 28px; overflow-wrap: anywhere; }
.page-title { margin-top: 6px; }
.intro, .lead { font-size: 1.02rem; }
.lead { font-weight: 700; }
.loading { display: flex; justify-content: center; padding: 30vh 0; }
.spinner { width: 42px; height: 42px; border: 5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottombar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--bottom); color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 700;
  border-top: 4px solid transparent;
}
.bottombar a svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottombar a.on { color: var(--accent); border-top-color: var(--accent); }

/* ---------- buttons, chips, badges ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-weight: 700; text-decoration: none; cursor: pointer;
  text-align: center; line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.btn.toggle.on .ico { color: var(--accent); }
.btn.toggle.on[data-key="want"] .ico { fill: currentColor; }
.btn.disabled { opacity: .55; cursor: default; }
.btn.wide { width: 100%; }
.btn.small-btn { min-height: 46px; margin: 6px 0; }
.btn.on { border-color: var(--accent); }
.ico { width: 24px; height: 24px; flex: none; }
.ico-sm { width: 18px; height: 18px; }
.link-btn { background: none; border: 0; padding: 10px 0; min-height: 44px; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.file-btn { position: relative; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 6px; }
.actions > p { grid-column: 1 / -1; margin: 0; }
.actions .wide { grid-column: 1 / -1; }
.actions.compact { margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 6px 14px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; font-size: .92rem; text-align: left;
}
.chip .n { font-weight: 500; color: var(--muted); font-size: .8rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on .n { color: inherit; opacity: .85; }
.chip.extra { display: none; }
.fgroup.show-extra .chip.extra { display: inline-flex; }

.badge {
  display: inline-block; font-size: .78rem; font-weight: 700; line-height: 1.3; padding: 4px 10px;
  border-radius: 999px; background: var(--chip); color: var(--ink); margin: 0 6px 6px 0;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.gem { background: var(--gem-bg); color: var(--gem); }
.badge.muted { background: var(--chip); color: var(--muted); }
.badge.top { background: var(--ok); color: #fff; }
.badge.tier-b { background: var(--accent-soft); color: var(--ink); }
.badge.want { background: var(--accent-soft); color: var(--accent); }
.badge.visited { background: var(--ok-bg); color: var(--ok); }
[data-theme="dark"] .badge.top { color: #0d1f14; }

.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; flex-wrap: nowrap; max-width: 100%; }
.seg button { min-height: 48px; padding: 6px 14px; border: 0; background: var(--surface); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg.mode { display: flex; width: 100%; }
.seg.mode button { flex: 1; justify-content: center; padding: 6px 4px; font-size: .95rem; }

.switch { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 6px 4px; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 600; text-align: left; }
.switch-knob { width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch-knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on .switch-knob { background: var(--accent); }
.switch.on .switch-knob::after { left: 23px; }

/* ---------- explore ---------- */
.subtabs {
  position: sticky; top: var(--top); z-index: 20; display: flex; gap: 6px; overflow-x: auto;
  margin: -14px -16px 10px; padding: 10px 16px; background: var(--bg); border-bottom: 2px solid var(--line);
  scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtab { flex: none; display: inline-flex; align-items: center; min-height: 46px; padding: 6px 15px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap; font-size: .95rem; }
.subtab.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toolbar { margin-bottom: 6px; }
.searchbox { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); }
.searchbox:focus-within { border-color: var(--accent); }
.searchbox input { flex: 1; border: 0; outline: none; background: transparent; min-height: 52px; font-size: 1.05rem; min-width: 0; }
.tool-row { display: flex; gap: 10px; margin-top: 10px; align-items: stretch; }
.filter-btn { flex: 1; }
.active-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.chip.removable { padding-right: 10px; }
.count-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.count { font-weight: 700; margin: 6px 0; }
.sort { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); }
.sort select { min-height: 46px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); padding: 4px 8px; font-weight: 600; color: var(--ink); }
.also-found { font-size: .9rem; background: var(--surface2); padding: 8px 12px; border-radius: 10px; }
.empty { padding: 24px 4px; color: var(--muted); font-size: 1.05rem; }
.sentinel { min-height: 4px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block; padding: 13px 15px 9px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.card:active { background: var(--surface2); }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-name { font-weight: 800; font-size: 1.1rem; line-height: 1.3; }
.card-ar { display: block; font-family: var(--font-ar); font-size: 1.05rem; color: var(--muted); margin-top: 2px; text-align: right; }
.card-meta { color: var(--muted); font-size: .88rem; margin-top: 3px; }
.card-sub { font-size: .9rem; margin-top: 6px; }
.card-badges { margin-top: 8px; }
.tier, .score {
  flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 1.9em; height: 1.9em; padding: 0 .4em;
  border-radius: 8px; font-weight: 800; font-size: .85rem; margin-top: 1px;
}
.tier-a { background: var(--accent); color: var(--accent-ink); }
.tier-b { background: var(--accent-soft); color: var(--accent); border: 2px solid var(--accent); }
.tier-c { background: var(--chip); color: var(--muted); border: 2px solid var(--line); }
.tier-top { background: var(--ok); color: #fff; font-size: .72rem; padding: 0 .55em; }
.score { background: var(--chip); color: var(--ink); border: 2px solid var(--line); }

.mapbox { height: 420px; min-height: 300px; border-radius: var(--radius); overflow: hidden; border: 2px solid var(--line); }
#map { width: 100%; height: 100%; background: var(--surface2); }
.map-pop { font-weight: 700; font-size: 1rem; display: inline-block; padding: 6px 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: .85rem; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.leaflet-container { font: inherit; }
.leaflet-container a.leaflet-popup-close-button { width: 32px; height: 32px; font-size: 24px; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-back { position: absolute; inset: 0; background: rgba(15, 8, 4, .55); }
.sheet {
  position: relative; overflow-wrap: anywhere; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); max-width: 760px; width: 100%; margin: 0 auto;
}
.sheet-wrap.full .sheet { max-height: 100vh; height: 100%; border-radius: 0; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
.sheet h2 { padding-right: 56px; }
.sheet-x { position: absolute; top: 10px; right: 10px; width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; }
.sheet-wrap.full .sheet-x { top: calc(10px + env(safe-area-inset-top, 0px)); }
.sheet-foot { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; padding: 12px 0; background: var(--bg); border-top: 2px solid var(--line); margin-top: 16px; }
.sheet-foot .btn { flex: 1; }
.fgroup { border: 0; padding: 0; margin: 0 0 18px; }
.fgroup legend { font-weight: 800; font-size: 1.02rem; margin-bottom: 8px; padding: 0; }
.fpanel .switch:first-of-type { border-top: 1px solid var(--line); }
#toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 60; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: 90vw; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- detail pages ---------- */
.backbar { margin: -4px 0 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 12px 0 4px; border: 0; background: none; color: var(--accent); font-weight: 800; cursor: pointer; }
.back svg { width: 26px; height: 26px; }
.dhead { margin-bottom: 4px; }
.dhead-kind { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 4px; }
.dhead h1 { font-size: 1.7rem; margin-bottom: 6px; }
.h1-source { font-size: 1.15rem !important; font-weight: 700; }
.dhead-ar { font-family: var(--font-ar); font-size: 1.6rem; line-height: 1.6; direction: rtl; text-align: right; margin-bottom: 4px; }
.small-ar { font-size: 1.3rem; }
.dhead-names { color: var(--muted); margin-bottom: 4px; }
.dhead-meta { color: var(--muted); font-size: .92rem; margin-bottom: 8px; }
.dhead-badges { margin-top: 6px; }
.sec { margin: 20px 0 0; padding-top: 16px; border-top: 2px solid var(--line); }
.sec > h2 { color: var(--ink); }
.sec.practical { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; }
.sec.mine { background: var(--surface2); border-radius: var(--radius); padding: 16px; border-top: 0; }
.sec.warn-sec h2 { color: var(--warn); }
.sec.reco { background: var(--accent-soft); border-radius: var(--radius); padding: 16px; border-top: 0; }
.facts { margin: 0; }
.facts dt { font-weight: 800; font-size: .86rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 10px; }
.facts dd { margin: 2px 0 0; }
.checked { margin-top: 14px; font-weight: 600; font-size: .92rem; }
.week { border-collapse: collapse; margin-top: 12px; width: 100%; font-size: .95rem; }
.week th { text-align: left; padding: 6px 10px 6px 0; width: 7.5em; vertical-align: top; }
.week td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.week tr:first-child td { border-top: 1px solid var(--line); }
.fallback { font-size: .85rem; font-style: italic; color: var(--warn); background: var(--warn-bg); padding: 6px 10px; border-radius: 8px; display: inline-block; }
.fallback-inline { font-size: .78rem; font-style: italic; color: var(--warn); }
.pending { font-style: italic; color: var(--muted); }
.pending-box { margin: 12px 0; padding: 14px; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); font-weight: 600; }
.clamp { max-height: 15em; overflow: hidden; position: relative; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.clamp.open { max-height: none; -webkit-mask-image: none; mask-image: none; }
.cite {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.75em; height: 1.55em; padding: 0 .35em; margin: 0 1px;
  border: 1.5px solid var(--accent); border-radius: 6px; background: var(--accent-soft); color: var(--accent);
  font-size: .72rem; font-weight: 800; vertical-align: .25em; cursor: pointer; position: relative; line-height: 1;
}
.cite::after { content: ""; position: absolute; inset: -9px -4px; }
.srclist { padding-left: 2em; font-size: .9rem; }
.srclist li { margin-bottom: .55em; }
.srclist a { color: var(--ink); }
.lookfor li, .people li, .recs li, .warnings li { margin-bottom: .6em; }
.warnings li::marker { color: var(--warn); }
.timeline { list-style: none; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.tl-date { display: block; font-weight: 800; color: var(--accent); font-size: .92rem; }
@media (min-width: 600px) { .timeline li { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 12px; } }
.label-legend { font-weight: 800; color: var(--gem); }
.legend-item { border-left: 4px solid var(--gem); padding-left: 12px; margin-bottom: 14px; }
.theme { margin-bottom: 12px; }
.inscr, .also, .variation, .transport { margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.links li { margin-bottom: .5em; }
.photo img { width: 100%; border-radius: var(--radius); }
.photo figcaption { font-size: .8rem; color: var(--muted); }
.lbl { font-weight: 800; margin: 12px 0 6px; }
.note { width: 100%; min-height: 96px; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); resize: vertical; }
.note:focus { border-color: var(--accent); outline: none; }
.stars { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.star { width: 50px; height: 50px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; cursor: pointer; }
.star.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.foot { margin-top: 24px; }
details.more { margin: 8px 0; border: 2px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--surface); }
details.more > summary { min-height: 50px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
details.more[open] { padding-bottom: 10px; }
.stop { padding: 12px 0 16px; border-bottom: 2px solid var(--line); }
.stop h3 { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.stop-n { display: inline-flex; align-items: center; justify-content: center; width: 1.8em; height: 1.8em; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .85rem; flex: none; }
.screenings { list-style: none; padding: 0; }
.screenings li { display: grid; grid-template-columns: 3.6em minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.dates { padding-left: 1.1em; }

/* readings */
.readings { padding-left: 0; list-style: none; counter-reset: r; }
.readings.plain { margin: 0; }
.reading { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.reading.is-read .reading-cite { color: var(--muted); }
.readbox { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; font-weight: 700; color: var(--muted); min-width: 50px; cursor: pointer; }
.readbox input { width: 30px; height: 30px; accent-color: var(--accent); margin: 4px 0 0; }
.reading-body { flex: 1; min-width: 0; }
.reading-cite { color: var(--ink); font-weight: 600; text-decoration: none; display: block; overflow-wrap: anywhere; }
.reading-meta { margin-top: 6px; }
.summary { margin-top: 8px; padding: 10px 12px; background: var(--surface2); border-radius: 10px; font-size: .92rem; }
.progress { height: 14px; border-radius: 999px; background: var(--chip); overflow: hidden; border: 1px solid var(--line); }
.progress .bar { height: 100%; background: var(--ok); transition: width .2s; }
.progress-txt { font-weight: 700; margin-top: 6px; }

/* show to a local */
.local-card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.local-ar { font-family: var(--font-ar); font-size: 2.4rem; line-height: 1.55; font-weight: 700; direction: rtl; text-align: right; overflow-wrap: anywhere; }
.local-ar.huge { font-size: 3.1rem; }
.local-fr { font-size: 1.5rem; font-weight: 800; margin-top: 10px; line-height: 1.3; }
.local-latin { font-size: 1.05rem; color: var(--muted); margin-top: 6px; }
.local-addr { font-size: 1.1rem; margin-top: 8px; }
.local-missing { font-size: 1.1rem; font-weight: 700; color: var(--warn); }

/* today and plan */
.today-date { font-size: 1.1rem; font-weight: 700; color: var(--muted); }
.day { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; scroll-margin-top: calc(var(--top) + 12px); }
.day.today { border-color: var(--accent); border-width: 3px; }
.day-head h2 { margin-bottom: 2px; }
.day-n { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.partial { font-weight: 700; color: var(--warn); margin: 4px 0 0; }
.daylight { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 10px 0; font-size: .95rem; }
.daychips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.daychips .chip { flex: none; }
.home-card { background: var(--surface2); border-radius: var(--radius); padding: 16px; border-top: 0; }
.home-dir { margin: 10px 0; font-weight: 700; }
.dir-row { display: flex; gap: 14px; align-items: center; }
.dir-arrow { width: 56px; height: 56px; color: var(--accent); flex: none; transition: transform .3s; }
.dir-main { font-size: 1.15rem; }

/* more */
.menu { list-style: none; padding: 0; margin: 0; }
.menu li { margin: 0; }
.menu a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 8px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700; }
.menu .badge { margin: 0; }
.plain-list { list-style: none; padding: 0; }
.leftout, .bibrow { padding: 12px 0; border-bottom: 1px solid var(--line); }
.bibrow a { color: var(--ink); overflow-wrap: anywhere; }
.badges-row { margin-top: 6px; }

/* desktop */
@media (min-width: 900px) {
  .topbar { padding: 0 24px; }
  .bottombar { left: 50%; transform: translateX(-50%); max-width: 760px; border: 2px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
  .list { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 370px) {
  .actions { grid-template-columns: 1fr; }
  .netbadge { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .topbar, .bottombar, .actions, .sec.mine, .backbar { display: none; }
  body { padding: 0; }
}

/* ---------- itinerary (Phase 5) ---------- */
.update-banner { background: var(--accent-soft); border: 2px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0 14px; }
.update-banner p { margin: 0 0 10px; font-weight: 600; }
.suggest { background: var(--warn-bg); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.suggest p { margin: 0 0 8px; font-weight: 600; color: var(--warn); }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-btns input { flex: 1 1 8em; min-height: 48px; font-size: 1rem; padding: 6px 10px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.day.past { opacity: .82; }
.day-sum { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 8px; font-weight: 600; }
.routes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0 12px; }
.routes .lbl { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.routes .lbl .ico { width: 20px; height: 20px; }
.route-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.route-chips .btn { min-width: 52px; justify-content: center; font-weight: 800; }
ol.stops { list-style: none; margin: 6px 0 4px; padding: 0; }
.stop { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.stop .when { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stop .when span { color: var(--muted); font-size: .85rem; }
.stop .nm { font-weight: 700; overflow-wrap: anywhere; }
.stop .nm a { color: inherit; }
.stop .badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.stop.meal .nm { font-weight: 600; }
.stop.done .nm, .stop.done .when strong { text-decoration: line-through; color: var(--muted); }
.role { display: inline-block; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--accent); }
.stop .ops { display: flex; gap: 6px; }
.tick, .more-btn { width: 48px; height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.tick.on { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.leg { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; padding: 2px 0 2px 1.2em; }
.leg .ico { width: 18px; height: 18px; flex: none; }
.leg.taxi { color: var(--warn); font-weight: 600; }
.leg.back { padding-left: 0; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 2px; }
li.gap { list-style: none; color: var(--muted); font-style: italic; font-size: .9rem; padding: 6px 0 6px 1.2em; border-top: 1px dashed var(--line); }
.badge.lock { background: var(--gem-bg); color: var(--gem); }
ul.warns { margin: 10px 0; padding: 10px 12px 10px 28px; background: var(--warn-bg); color: var(--warn); border-radius: 10px; font-weight: 600; }
details.infos, details.day-more { margin: 8px 0; }
details.infos summary, details.day-more summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
details.infos ul { margin: 4px 0; padding-left: 22px; color: var(--muted); font-size: .92rem; }
.evening, .rain, .daytrip-box { border-top: 2px solid var(--line); margin-top: 12px; padding-top: 10px; }
.evening p, .rain p { margin: 4px 0 8px; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.tools .btn { justify-content: flex-start; font-size: .95rem; }
.btn.alt { text-align: left; justify-content: flex-start; height: auto; padding-top: 10px; padding-bottom: 10px; margin: 6px 0; }
.btn.alt span { display: block; }
.sheet .btn.wide { margin: 6px 0; }
.sheet input[type="text"], .sheet input[type="number"] { width: 100%; min-height: 50px; font-size: 1rem; padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); margin-bottom: 6px; }
ol.dnf { padding-left: 1.4em; }
ol.dnf li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
ol.dnf li > div { min-width: 0; }
.next-card .next-name { font-size: 1.25rem; font-weight: 800; margin: 0 0 4px; }
.local-list .ar { font-family: var(--font-ar); font-size: 1.3rem; }
@media (max-width: 370px) { .tools { grid-template-columns: 1fr; } .stop { grid-template-columns: 4.2em minmax(0, 1fr) auto; } }
@media print {
  .noprint, .tools, .ops, .routes, .update-banner, .suggest, .seg, details.day-more { display: none !important; }
  .day { border: 0; padding: 0; }
  .stop { break-inside: avoid; }
}

fieldset.modeset { border: 2px solid var(--line); border-radius: 12px; margin: 8px 0; padding: 8px 12px 12px; }
fieldset.modeset legend { font-weight: 800; padding: 0 6px; }
fieldset.modeset label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0; font-weight: 600; }
fieldset.modeset input { width: 7.5em; min-height: 48px; font-size: 1rem; padding: 6px 8px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }

figure.photo img { width: 100%; height: auto; border-radius: 10px; display: block; background: var(--surface2); }
figure.photo.detail { margin: 8px 0 4px; }
figure.photo.detail img { max-height: 260px; object-fit: cover; }
figure.photo figcaption { font-size: .82rem; color: var(--muted); margin-top: 4px; }
figure.photo figcaption .photo-cap { color: var(--ink); }
figure.photo .noimg-note { display: none; }
figure.photo.noimg img { display: none; }
figure.photo.noimg .noimg-note { display: inline; }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Places screen (start screen): map on top, folding category groups ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.search-row { display: flex; gap: 10px; align-items: stretch; }
.search-row .searchbox { flex: 1; min-width: 0; }
.search-row .filter-btn { flex: none; }
.mapwrap { margin-top: 10px; scroll-margin-top: calc(var(--top) + 76px); }
.map-note { margin: 4px 0 0; }
.places .legend { margin-top: 8px; gap: 4px 14px; }
.places .mapbox { height: 40vh; min-height: 240px; max-height: 460px; }
.cg-hint { margin: 2px 0 8px; }
.cgroups { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.cgroup { border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); scroll-margin-top: calc(var(--top) + 76px); }
.cgroup.open { border-color: var(--accent); background: var(--surface2); }
.cg-head { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 16px; background: none; border: 0; border-radius: var(--radius); color: var(--ink); font: inherit; font-weight: 800; font-size: 1.04rem; text-align: left; cursor: pointer; }
.cg-name { flex: 1; min-width: 0; }
.cg-n { flex: none; min-width: 38px; padding: 3px 10px; border-radius: 999px; background: var(--chip); color: var(--ink); font-weight: 700; font-size: .9rem; text-align: center; }
.cgroup.open .cg-n { background: var(--accent); color: var(--accent-ink); }
.cg-chev { flex: none; width: 11px; height: 11px; margin: -5px 4px 0 2px; border-right: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: rotate(45deg); }
.cgroup.open .cg-chev { transform: rotate(-135deg); margin-top: 5px; }
.cg-body { padding: 0 12px 12px; }
.cg-body > .btn { margin-top: 10px; }
.cg-tomap { display: inline-flex; align-items: center; gap: 8px; }
.cg-tomap .ico { width: 20px; height: 20px; }

/* ---------- Itinerary screen: one day at a time, Today on top during the trip ---------- */
.daystrip { position: sticky; top: var(--top); z-index: 20; display: flex; gap: 6px; overflow-x: auto; margin: 8px -16px 10px; padding: 10px 16px; background: var(--bg); border-bottom: 2px solid var(--line); scrollbar-width: none; }
.daystrip::-webkit-scrollbar { display: none; }
.daystrip .chip { flex: none; }
.daystrip .chip.is-today:not(.on) { border-color: var(--accent); color: var(--accent); }
.itin-top .home-btn { margin: 6px 0 4px; }
.itinerary .day { scroll-margin-top: calc(var(--top) + 76px); }
.day-nav { display: flex; justify-content: space-between; gap: 10px; margin: 6px 0 18px; }
.day-nav .btn { flex: 0 1 auto; }
@media print { .daystrip, .itin-top, .day-nav { display: none; } }

/* ---------- data saver and reduced motion ---------- */
.mapbox.off { height: auto; min-height: 0; max-height: none; }
.map-off { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; background: var(--surface2); }
.map-off p { margin: 0; }
.photo-load { display: none; }
.photo.saver .photo-load { display: inline-flex; margin: 8px 0; }
.photo.saver img { display: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---- the Agafay night (decision 43) ---- */
.overnight-box { border-top: 2px solid var(--line); margin-top: 12px; padding: 12px; background: var(--gem-bg); border-radius: var(--radius); }
.overnight-box .seg { margin: 4px 0 6px; }
.overnight-box .btn { margin-top: 8px; }
.overnight-note { margin: 8px 0 12px; padding: 10px 14px; background: var(--gem-bg); color: var(--ink); border-radius: 12px; font-weight: 600; }
.overnight-note .btn { margin-top: 6px; }
.fit-group { margin: 14px 0 6px; }
.fit-group h3 { margin-bottom: 2px; }
details.camp { margin: 8px 0; border: 2px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--surface); }
details.camp > summary { min-height: 56px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 8px 0; cursor: pointer; }
details.camp[open] { padding-bottom: 12px; }
.fit-skyview details.camp { border-color: var(--ok); }
.fit-busy details.camp > summary .strong, .fit-other details.camp > summary .strong { color: var(--muted); }
.ask { background: var(--accent-soft); padding: 8px 12px; border-radius: 10px; }
.warn-box { background: var(--warn-bg); color: var(--ink); padding: 10px 14px; border-radius: 10px; margin: 8px 0; }
table.sky tr.on th, table.sky tr.on td { background: var(--gem-bg); font-weight: 700; }

/* ---- Build A (Claude artifact) ---- */
.no-tiles.leaflet-container { background: var(--surface2); }
figure.photo.artifact a { display: inline-flex; }
.photo-link { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; }
.photo-link svg { width: 20px; height: 20px; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; width: 100%; }

/* ---------- guides (views/guides.js) and trip journal (views/journal.js) ---------- */
.guide details.fold { margin: 14px 0 0; border-top: 2px solid var(--line); padding-top: 6px; }
.guide details.fold > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; cursor: pointer; list-style: none; }
.guide details.fold > summary::-webkit-details-marker { display: none; }
.guide details.fold > summary h2 { margin: 0; font-size: 1.15rem; }
.phrases li.phrase { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ph-mean { font-weight: 700; }
.ph-dar { font-size: 1.15rem; margin-top: 4px; }
.ph-ar { font-size: 1.45rem; margin-top: 4px; text-align: right; }
.ph-fr { margin-top: 2px; }
.ph-lang { display: inline-block; min-width: 3.6em; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ph-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.price-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.pr-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pr-val { font-weight: 800; white-space: nowrap; color: var(--accent); }
ul.tips { padding-left: 1.2em; }
ul.tips li { margin: 8px 0; }
.fx { display: grid; gap: 10px; margin: 14px 0 6px; }
.fx-row { display: flex; align-items: center; gap: 10px; font-weight: 800; flex-wrap: wrap; }
.fx-row > span { min-width: 3.2em; }
.fx-row input { flex: 1 1 0; width: 0; min-width: 0; box-sizing: border-box; min-height: 56px; padding: 0 14px; font-size: 1.3rem; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); }
.fx-row input:focus { border-color: var(--accent); outline: none; }
.fx-rate { font-size: 1.1rem; font-weight: 800; margin: 10px 0 2px; }
.fx-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.fx-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.fx-table td + td { text-align: right; font-weight: 700; }
.em-num { margin: 10px 0; }
.em-call { justify-content: flex-start; }
.em-n { font-size: 1.3rem; font-weight: 800; margin-right: 6px; }
.em-place { padding: 12px 0; border-bottom: 1px solid var(--line); }
.gloss-ar { font-size: 1.4rem; text-align: right; margin: 0 0 6px; }
.journal .jday.today { border-top-color: var(--accent); }
.journal .jvisited { margin-top: 4px; }
