/* ───────────────────────── phones and tablets ─────────────────────────
   Everything that is only for a finger or a small screen lives here, keyed on what
   crates/viewer/src/mobile.rs puts on <html> at boot (and on every resize):
     .touch        a finger (or a pen) is the primary pointer
     .phone / .tablet
     .compact      the thumb layout: a phone, or any narrow window
     .compact-land compact, held sideways
   and the CSS variables --vvh (visual viewport height) and --kb (keyboard inset).
   The compact layout's structure — the bar and its sheets — is built by
   crates/viewer/src/ui/compact.rs, which moves the desktop's own instruments into the
   sheets while it is in force. Same object as the desktop: vellum, ink and brass. */

/* ── the page on a phone: the map owns every touch ── */
html.touch, html.touch body {
  touch-action: manipulation;          /* no double-tap zoom, no 300 ms wait */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;           /* no rubber band, no pull-to-refresh */
}
html.touch body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;         /* no callout on a long press */
}
html.touch input, html.touch textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
html.touch #gl { touch-action: none; cursor: default; }
/* The instruments scroll where they must, but a pinch on them never zooms the page. */
html.touch .ui-chrome > *, html.touch .ui-card, html.touch .photobar, html.touch .tour-note { touch-action: pan-x pan-y; }
.cx-bar, .cx-top { touch-action: none; }
/* The canvas follows the visible viewport (address bar shown or hidden), not 100vh. */
@supports (height: 100dvh) {
  html.touch #gl, html.compact #gl { height: 100dvh; }
}

/* The hand in the clouds: a soft brass ring under a finger that held, then swept. */
.touch-hand {
  position: fixed;
  left: 0;
  top: 0;
  width: 88px;
  height: 88px;
  margin: -44px 0 0 -44px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity .3s ease;
  background: radial-gradient(circle, rgba(240, 231, 207, 0) 50%, rgba(240, 231, 207, 0.5) 57%, rgba(181, 140, 64, 0.38) 62%, rgba(240, 231, 207, 0) 71%);
}
.touch-hand.on { opacity: 1; transition-duration: .12s; }

/* ── a finger on any layout (tablets keep the desktop panels, finger-sized) ── */
html.touch #ui kbd { display: none; }
html.touch #ui .wx-btn { min-width: 44px; min-height: 44px; }
html.touch #ui .tempo button { min-width: 40px; min-height: 40px; }
html.touch #ui .tools .tool { min-height: 40px; }
html.touch #ui .chk { min-height: 36px; align-items: center; }
html.touch #ui .vanebox { width: 44px; height: 44px; }
html.touch #ui .reliefbox input[type=range], html.touch #ui .soundbox input[type=range] { height: 36px; }
html.touch #ui .reliefbox input[type=range]::-webkit-slider-thumb { width: 18px; height: 26px; margin-top: -11.5px; }
html.touch #ui .results li { min-height: 44px; align-items: center; }
html.touch #ui .ui-card .acts button { min-height: 40px; }
html.touch #ui .vs-view, html.touch #ui .pb-view { min-height: 40px; }
/* A tablet keeps the desktop's slips; the instruments' column widens for fingers, the
   weather sits in two rows, and on a short screen the column scrolls (and the dial is
   smaller) rather than running off the bottom. */
html.touch:not(.compact) .instruments {
  width: 13.4em;
  max-height: calc(100dvh - 2 * var(--gutter) - 2.4em);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding-bottom: 0.4em;
}
html.touch:not(.compact) .instruments::-webkit-scrollbar { display: none; }
html.touch:not(.compact) #ui .wxrow { grid-template-columns: repeat(4, 1fr); row-gap: 0.25em; }
html.touch:not(.compact) #ui .wx-btn { min-width: 40px; min-height: 40px; }
html.touch:not(.compact) #ui .tempo { justify-content: center; }
html.touch:not(.compact) #ui .tempo button { min-width: 36px; }
@media (max-height: 860px) {
  html.touch:not(.compact) .dial { width: 7.6em; height: 7.6em; }
}
/* Faded instruments stay findable: there is no hover to bring them back. */
html.touch .ui-chrome.idle > :not(.notice) { opacity: .45; }
/* Inputs at 16 px or more, or iOS zooms the page when they are focused. */
html.touch #ui input:not([type=range]):not([type=checkbox]), html.touch #ui textarea { font-size: max(16px, 1em); }

/* ───────────────────────── the compact layout ───────────────────────── */

.cx { display: none; }
html.compact .cx {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* The layout's measures, on the root: the notice, the card, slips and sheets all use them. */
html.compact {
  --cx-gap: 8px;
  --cx-bar: 60px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  /* The fan-content notice sits just above the bar (public copy only). */
  --cx-notice: 0px;
  /* Where the bar (and the notice) end: sheets, cards and slips stand above this. */
  --cx-stack: calc(max(var(--safe-b), 6px) + var(--cx-bar) + var(--cx-notice) + var(--cx-gap));
}
html.compact:has(#notice) { --cx-notice: 44px; }
html.compact #ui.photo .cx { display: none; }
html.compact .cx > * { pointer-events: auto; }

/* The desktop's slips of vellum make way: their controls are in the sheets now. */
html.compact .ui-chrome > .instruments,
html.compact .ui-chrome > .tools,
html.compact .ui-chrome > .marginalia,
html.compact .ui-chrome > .views-slip,
html.compact .ui-chrome > .ledger,
html.compact .reveal { display: none !important; }

/* The cartouche shrinks to a title in the corner. */
html.compact .ui-chrome > .cartouche {
  top: calc(var(--safe-t) + 8px);
  left: calc(var(--safe-l) + 8px);
  width: auto;
  max-width: calc(100vw - 90px);
  padding: 5px 13px 5px;
  pointer-events: none;
}
html.compact .cartouche::after { inset: 0.32em; }
html.compact .cartouche-title { font-size: 21px; }
html.compact .cartouche-sub { font-size: 11px; margin: 1px 0 0; min-height: 0; }
html.compact .cartouche .about-link, html.compact .cartouche .search { display: none; }

/* The compass, top right: a finger's width, there to put north back up. */
html.compact .cx-top {
  position: absolute;
  top: calc(var(--safe-t) + 8px);
  right: calc(var(--safe-r) + 8px);
}
html.compact .cx-top .compass { width: 46px; height: 46px; display: block; }

/* ── the bar ── */
html.compact .cx-bar {
  position: absolute;
  left: calc(var(--safe-l) + var(--cx-gap));
  right: calc(var(--safe-r) + var(--cx-gap));
  bottom: max(var(--safe-b), 6px);
  height: var(--cx-bar);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding: 0 4px;
}
.cx-b {
  flex: 1 1 0;
  min-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
  color: var(--ui-ink-soft);
  touch-action: manipulation;
}
.cx-ico { display: block; width: 26px; height: 26px; }
.cx-ico svg { width: 100%; height: 100%; display: block; }
.cx-svg, .cx-ico svg.wx {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cx-svg .fill, .cx-ico svg.wx .fill { fill: rgba(var(--ui-vellum), 0.9); }
.cx-lbl {
  font-size: 11.5px;
  font-style: italic;
  line-height: 1.1;
  white-space: nowrap;
  font-variant-numeric: lining-nums tabular-nums;
}
.cx-b[data-sheet=time] .cx-lbl { font-style: normal; font-size: 12.5px; letter-spacing: 0.02em; }
.cx-b.on { color: var(--ui-rubric); }
/* The open sheet's button is underlined in red ink, as a tab on a ledger. */
.cx-b.on::after {
  content: "";
  position: absolute;
  left: 30%;
  right: 30%;
  bottom: 5px;
  border-bottom: 1.5px solid var(--ui-rubric);
  transform: rotate(-1.5deg);
}
.cx-b:active { color: var(--ui-rubric); }

/* ── the fan-content notice: small, legible, just above the bar ── */
html.compact #notice {
  left: calc(var(--safe-l) + var(--cx-gap));
  right: calc(var(--safe-r) + var(--cx-gap));
  bottom: calc(max(var(--safe-b), 6px) + var(--cx-bar) + 4px);
  transform: none;
  width: auto;
  max-width: none;
  max-height: 40px;
  overflow: hidden;
  padding: 2px 8px 3px;
  font-size: 8.5px;
  line-height: 1.28;
  color: #3e2f22;
  background: rgba(237, 226, 196, 0.8);
  z-index: 1;
}
html.compact #ui.photo ~ #notice { bottom: max(var(--safe-b), 6px); }

/* ── sheets ── */
html.compact .cx-sheet {
  position: absolute;
  left: calc(var(--safe-l) + var(--cx-gap));
  right: calc(var(--safe-r) + var(--cx-gap));
  bottom: var(--cx-stack);
  max-height: min(60dvh, calc(var(--vvh, 100dvh) - var(--cx-stack) - var(--safe-t) - 16px));
  display: flex;
  flex-direction: column;
  visibility: hidden;
  transform: translateY(calc(100% + var(--cx-stack) + 20px));
  transition: transform .3s cubic-bezier(.22, .8, .24, 1), visibility 0s .3s;
  overflow: hidden;
}
html.compact .cx-sheet.on {
  visibility: visible;
  transform: none;
  transition: transform .3s cubic-bezier(.22, .8, .24, 1);
}
html.compact .cx-sheet.dragging { transition: none; }
/* The find sheet hangs from the top, clear of the keyboard. */
html.compact .cx-sheet.top {
  top: calc(var(--safe-t) + 8px);
  bottom: auto;
  max-height: calc(var(--vvh, 100dvh) - var(--safe-t) - 24px);
  transform: translateY(calc(-100% - var(--safe-t) - 20px));
}
html.compact .cx-sheet.top.on { transform: none; }
html.compact .cx-sheet.top .cx-grab { display: none; }

.cx-head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 6px 2px 0 16px;
  touch-action: none;                  /* the handle is swiped, not scrolled */
}
.cx-grab {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 38px;
  margin-left: -19px;
  border-top: 1.5px solid rgba(42, 29, 20, 0.28);
  border-radius: 1px;
}
.cx-title {
  margin: 0;
  font-family: var(--hand-italic);
  font-style: italic;
  font-synthesis: none;
  font-weight: normal;
  font-size: 20px;
}
.cx-title::first-letter { color: var(--ui-rubric); }
.cx-x {
  margin-left: auto;
  width: 46px;
  height: 46px;
  font-size: 26px !important;
  line-height: 1;
  color: var(--ui-sepia) !important;
}
.cx-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 16px 16px;
  touch-action: pan-y;
}
/* The desktop's panels, moved into a sheet, lose their own slip of vellum. */
.cx-body .panel {
  position: static;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  margin: 0;
  width: auto;
  max-height: none;
  transform: none;
  opacity: 1;
}
.cx-body .panel::before, .cx-body .panel::after { display: none; }

/* ── the hour: a tape of the sky ── */
.cx-tape {
  position: relative;
  height: 62px;
  margin: 4px -16px 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.cx-tape:focus-visible { outline: 1px dotted var(--ui-rubric); outline-offset: -3px; }
.cx-bandwrap { position: absolute; left: 0; top: 2px; will-change: transform; }
.cx-band { display: block; overflow: visible; }
.cx-band .cx-rule { stroke: rgba(42, 29, 20, 0.5); stroke-width: 0.8; fill: none; }
.cx-band .cx-tick { stroke: rgba(42, 29, 20, 0.6); stroke-width: 1; }
.cx-band .cx-tick.q { stroke-opacity: 0.45; }
.cx-band .cx-hr {
  font-family: var(--ui-serif);
  font-style: italic;
  font-size: 12px;
  fill: var(--ui-ink-soft);
  text-anchor: middle;
  font-variant-numeric: oldstyle-nums;
}
.cx-band .cx-hr.word { font-family: var(--hand-italic); font-size: 13.5px; fill: var(--ui-ink); }
/* The brass needle the sky slides under. */
.cx-needle {
  position: absolute;
  left: 50%;
  top: 1px;
  height: 42px;
  width: 3px;
  margin-left: -1.5px;
  background: linear-gradient(90deg, var(--ui-brass-lo), var(--ui-brass-hi) 45%, var(--ui-brass) 70%, var(--ui-brass-lo));
  box-shadow: 0 0 0 0.5px #3b2a10, 1px 2px 3px rgba(10, 5, 2, 0.45);
  pointer-events: none;
}
.cx-needle::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--ui-brass-hi), var(--ui-brass) 55%, var(--ui-brass-lo));
  box-shadow: 0 0 0 0.5px #3b2a10, 1px 2px 3px rgba(10, 5, 2, 0.45);
}
.cx-chips { display: flex; gap: 6px; margin: 8px 0 2px; }
.cx-chip {
  flex: 1 1 0;
  min-height: 40px;
  font-style: italic !important;
  font-size: 14px !important;
  border: 0.5px solid rgba(42, 29, 20, 0.35) !important;
  border-radius: 2px;
}
.cx-chip:active { color: var(--ui-rubric); border-color: var(--ui-rubric) !important; }
.cx-tempo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.cx-tempo .clock { margin: 0; justify-content: flex-start; }
.cx-tempo .clock .hour { font-size: 24px; }
.cx-tempo .clock .period { font-size: 15px; }
.cx-tempo .tempo { margin: 0; gap: 2px; }
.cx-tempo .tempo button { min-width: 44px; min-height: 44px; font-size: 15px; }
.cx-tempo .tempo .play svg { width: 18px; height: 18px; }

/* ── weather ── */
.cx-wx .wxrow { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cx-wx .wx-btn {
  aspect-ratio: auto;
  min-height: 58px;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.cx-wx .wx-btn svg.wx { width: 28px; height: 28px; }
.cx-wx .wx-btn.on { box-shadow: inset 0 0 0 1px rgba(154, 36, 20, 0.7); }
.cx-cap { display: none; }
.cx-wx .cx-cap { display: block; font-size: 12.5px; font-style: italic; color: var(--ui-ink-soft); }
.cx-wx .wx-btn.on .cx-cap { color: var(--ui-rubric); }
.cx-wx .wxname { display: none; }
.cx-wx .windrow { margin-top: 12px; gap: 12px; }
.cx-wx .vanebox { width: 52px; height: 52px; }
.cx-wx .windtxt { font-size: 15px; }

/* ── views ── */
.cx-viewlist { display: grid; }
.cx-view {
  text-align: left;
  min-height: 46px;
  padding: 6px 2px !important;
  font-family: var(--hand-italic) !important;
  font-style: italic !important;
  font-synthesis: none;
  font-size: 18px !important;
  border-bottom: 0.5px solid rgba(42, 29, 20, 0.16) !important;
}
@media (max-height: 760px) {
  .cx-view { min-height: 40px; font-size: 16.5px !important; padding: 4px 2px !important; }
}
.cx-view::before { content: "\2767"; margin-right: 0.6em; color: var(--ui-sepia); font-size: 0.75em; font-family: var(--ui-serif); }
.cx-view:active { color: var(--ui-rubric); }
.cx-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cx-act {
  min-height: 44px;
  padding: 0 14px !important;
  font-style: italic !important;
  font-size: 15px !important;
  border: 0.5px solid rgba(42, 29, 20, 0.4) !important;
  border-radius: 2px;
}
.cx-act.primary, .cx-act.act-picture { color: var(--ui-rubric); border-color: rgba(154, 36, 20, 0.55) !important; }
.cx-act:active { color: var(--ui-rubric); border-color: var(--ui-rubric) !important; }
.cx-pic { display: none; margin-top: 14px; padding-top: 12px; border-top: 0.5px solid rgba(42, 29, 20, 0.25); }
.cx-pic.on { display: block; }
.cx-pic-img {
  display: block;
  max-width: 100%;
  max-height: 32dvh;
  margin: 0 auto;
  box-shadow: 0 0 0 0.5px rgba(60, 40, 20, 0.5), 0.2em 0.35em 0.9em -0.25em rgba(10, 5, 2, 0.6);
  -webkit-touch-callout: default;      /* hold it to save it to Photos */
  -webkit-user-select: auto;
  user-select: auto;
  pointer-events: auto;
}
.cx-pic-hint { margin: 8px 0 0; text-align: center; font-size: 13px; font-style: italic; color: var(--ui-sepia); }
.cx-pic .cx-acts { justify-content: center; margin-top: 6px; }

/* ── find ── */
.cx-findbox .search input {
  height: 46px;
  font-size: 18px !important;
  padding: 0 0.2em;
}
.cx-findbox .search .search-key { display: none; }
.cx-findbox .results {
  position: static;
  margin: 6px -16px 0;
  max-height: calc(var(--vvh, 100dvh) - var(--safe-t) - 150px);
  overflow: auto;
  overscroll-behavior: contain;
  background: none;
  box-shadow: none;
}
.cx-findbox .results li { min-height: 46px; padding: 0 16px; font-size: 16px; }

/* ── more ── */
.cx-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 10px; }
.cx-quick .cx-act { flex: 1 1 auto; }
.cx-inst > * { margin: 10px 0 0 !important; }
.cx-inst .reliefbox { gap: 12px; padding: 0 !important; }
.cx-inst .reliefbox .lbl-relief { font-size: 16px; }
.cx-inst .reliefbox input[type=range] { height: 44px; }
.cx-inst .reliefbox input[type=range]::-webkit-slider-thumb { width: 20px; height: 30px; margin-top: -13.5px; }
.cx-inst .toggles .chk, .cx-inst .soundbox .chk { min-height: 44px; font-size: 16px; }
.cx-inst .toggles { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.cx-inst .soundbox .snd-row { display: grid; grid-template-columns: 6em 1fr; align-items: center; min-height: 44px; }
.cx-inst .soundbox input[type=range] { width: 100%; height: 40px; }
.cx-ledger { margin-top: 14px; }
.cx-ledger .ledger { overflow: visible; }
.cx-ledger .sect > summary { min-height: 44px; font-size: 17px; }
.cx-ledger .chk { min-height: 40px; font-size: 15px; }
.cx-ledger .paces button { min-height: 40px; }
.cx-gestures, .touch-controls { margin-top: 16px; }
.cx-gestures h3, .touch-controls h3 {
  margin: 0 0 6px;
  font-weight: normal;
  font-style: italic;
  font-size: 16px;
  border-bottom: 0.5px solid rgba(42, 29, 20, 0.4);
}
.cx-gestures h3::first-letter, .touch-controls h3::first-letter { color: var(--ui-rubric); }
.cx-gestures dl, .touch-controls dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 14px; }
.cx-gestures dt, .touch-controls dt { white-space: nowrap; }
.cx-gestures dd, .touch-controls dd { margin: 0; font-style: italic; color: var(--ui-ink-soft); }
.touch-controls { margin: 0 0 1.2em; }
html:not(.touch) .touch-controls { display: none; }

/* ── what else stands above the bar: the place card, slips, notices ── */
html.compact .ui-card {
  left: calc(var(--safe-l) + var(--cx-gap)) !important;
  right: calc(var(--safe-r) + var(--cx-gap));
  top: auto !important;
  bottom: var(--cx-stack);
  width: auto;
  max-height: 46dvh;
  overflow: auto;
  overscroll-behavior: contain;
  transform: none !important;
  padding: 14px 16px 12px;
  touch-action: pan-y;
}
html.compact .ui-card h2 { font-size: 20px; padding-right: 1em; }
html.compact .ui-card .acts { gap: 6px 10px; }
html.compact .ui-card .acts button { min-height: 44px; font-size: 15px; }
html.compact .ui-chrome > .slip {
  left: calc(var(--safe-l) + var(--cx-gap));
  right: calc(var(--safe-r) + var(--cx-gap));
  bottom: var(--cx-stack);
  width: auto;
  max-width: none;
  transform: translateY(0.6em);
}
html.compact .ui-chrome > .slip.on { transform: none; }
html.compact .slip-acts button, html.compact .slip .x { min-height: 44px; min-width: 44px; }
html.compact .ui-chrome > .editslip { display: none; }
html.compact .ui-chrome > .notice {
  bottom: calc(var(--cx-stack) + 12px);
  max-width: calc(100vw - 32px);
  font-size: 15px;
}
html.compact #ui.cx-open .ui-chrome > .notice { bottom: calc(var(--cx-stack) + 50dvh); }

/* Photo mode on a phone: only the views, to swipe through, and Done. */
html.compact .photobar {
  left: calc(var(--safe-l) + var(--cx-gap));
  right: calc(var(--safe-r) + var(--cx-gap));
  bottom: max(var(--safe-b), 6px);
  transform: none;
  width: auto;
  max-width: none;
  padding: 6px 8px;
}
html.compact .pb-views { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; max-width: 100%; touch-action: pan-x; scrollbar-width: none; }
html.compact .pb-view { white-space: nowrap; min-height: 40px; font-size: 15px; }
html.compact .pb-row > :not(.pb-acts), html.compact .pb-acts > :not(.pb-done) { display: none; }
html.compact .pb-done { min-height: 40px; padding: 0 18px !important; font-size: 16px; }
html.compact .photobar.idle { opacity: 0.35; }

/* The walkthrough's notes, phone-sized. */
html.compact .tour-note { max-width: calc(100vw - 32px); font-size: 15px; }
html.compact .tour-foot button { min-height: 40px; padding: 0 10px; }

/* The help and About sheet: a reading sheet from the bottom, nearly the whole height. */
html.compact .help { place-items: end center; }
html.compact .help-sheet {
  width: calc(100vw - 2 * var(--cx-gap) - var(--safe-l) - var(--safe-r));
  max-height: calc(var(--vvh, 100dvh) - var(--safe-t) - 24px);
  margin-bottom: max(var(--safe-b), 8px);
  padding: 1.1em 1.15em 1em;
  overscroll-behavior: contain;
}
html.compact .help-sheet .cols { grid-template-columns: 1fr; gap: 1em; }
html.compact .help-sheet .x { width: 46px; height: 46px; top: 4px; right: 4px; }
html.compact .help-tab { min-height: 44px; }
html.compact .help-pane.controls section:not(.touch-controls) { display: none; }

/* The map's lettering on a small screen: fewer names, larger (the layout culls whatever
   collides, so a larger hand is also a sparser one). */
html.compact .lbl { font-size: calc(1.14em * var(--base, 1)); }

/* While it loads, the status line stands clear of where the bar will be. */
html.compact #status { bottom: calc(max(env(safe-area-inset-bottom, 0px), 6px) + 130px); font-size: 16px; }

/* ── held sideways: the bar becomes a rail down the right-hand side ── */
html.compact.compact-land, html.compact.compact-land:has(#notice) { --cx-bar: 64px; --cx-notice: 0px; --cx-foot: 0px; }
/* Sideways, the notice runs along the bottom under the map: sheets and cards end above it. */
html.compact.compact-land:has(#notice) { --cx-foot: 32px; }
html.compact-land .cx-bar {
  left: auto;
  top: 50%;
  bottom: auto;
  right: calc(var(--safe-r) + var(--cx-gap));
  width: var(--cx-bar);
  height: min(320px, calc(100dvh - 16px));
  transform: translateY(-50%);
  flex-direction: column;
  padding: 4px 0;
}
html.compact-land .cx-b.on::after { left: auto; right: 4px; top: 30%; bottom: 30%; border-bottom: 0; border-right: 1.5px solid var(--ui-rubric); transform: rotate(1.5deg); }
html.compact-land .cx-top { right: calc(var(--safe-r) + var(--cx-gap) * 2 + var(--cx-bar)); }
html.compact-land .cx-sheet, html.compact-land .cx-sheet.top {
  left: auto;
  right: calc(var(--safe-r) + var(--cx-gap) * 2 + var(--cx-bar));
  top: calc(var(--safe-t) + var(--cx-gap));
  bottom: calc(max(var(--safe-b), 4px) + var(--cx-foot) + var(--cx-gap));
  width: min(360px, 52vw);
  max-height: none;
  transform: translateX(calc(100% + var(--cx-bar) + 40px));
}
html.compact-land .cx-sheet.on { transform: none; }
html.compact-land .cx-sheet .cx-grab {
  display: block;
  top: 50%;
  left: 6px;
  width: 0;
  height: 38px;
  margin: -19px 0 0;
  border-top: 0;
  border-left: 1.5px solid rgba(42, 29, 20, 0.28);
}
html.compact-land .cx-head { touch-action: none; }
html.compact-land #notice {
  left: calc(var(--safe-l) + var(--cx-gap));
  right: calc(var(--safe-r) + var(--cx-gap) * 2 + var(--cx-bar));
  bottom: max(var(--safe-b), 4px);
  max-height: 30px;
}
html.compact-land .ui-card, html.compact-land .ui-chrome > .slip {
  left: auto !important;
  right: calc(var(--safe-r) + var(--cx-gap) * 2 + var(--cx-bar));
  width: min(360px, 52vw);
  bottom: calc(max(var(--safe-b), 4px) + var(--cx-foot) + var(--cx-gap));
  max-height: calc(100dvh - var(--safe-t) - var(--cx-foot) - 60px);
}
html.compact-land .ui-chrome > .notice { bottom: 46px; }
html.compact-land .photobar { right: calc(var(--safe-r) + var(--cx-gap)); }
html.compact-land .help-sheet { width: min(640px, calc(100vw - 32px)); }

@media (prefers-reduced-motion: reduce) {
  html.compact .cx-sheet, html.compact .cx-sheet.on { transition: none; }
}
