/* Beepster — translucent, monochrome; dark by default with a light theme (html[data-theme]). */
:root {
  --fg: 255 255 255;                     /* translucent overlays: white on dark, near-black on light */
  --bg: #07080b;
  --glass: rgb(var(--fg) / .045);
  --glass-2: rgb(var(--fg) / .075);
  --glass-3: rgb(var(--fg) / .11);
  --edge: rgb(var(--fg) / .085);
  --edge-2: rgb(var(--fg) / .16);
  --tile: rgb(var(--fg) / .09);      /* translucent grey behind white icons, never a border */
  --text: #f4f5f7;
  --muted: rgba(244, 245, 247, .52);
  --faint: rgba(244, 245, 247, .3);
  --white: #ffffff;
  --ink: #0a0b0e;
  --bad: #ff8a8a;
  --radius: 22px;
  --blur: blur(22px) saturate(150%);
  --header-bg: rgba(30, 33, 42, .92);
  --float-bg: rgba(22, 24, 30, .76);     /* toast, voice transcript */
  --menu-bg: #15171c;
  --primary-hover: #e9eaee;
  --shadow: rgba(0, 0, 0, .85);
  --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: dark;
}
:root[data-theme=light] {
  --fg: 14 16 20;
  --bg: #eceef2;
  --glass: rgba(255, 255, 255, .62);
  --glass-2: rgba(255, 255, 255, .85);
  --glass-3: #ffffff;
  --edge: rgb(14 16 20 / .09);
  --edge-2: rgb(14 16 20 / .18);
  --tile: rgb(14 16 20 / .06);
  --text: #0f1115;
  --muted: rgba(15, 17, 21, .58);
  --faint: rgba(15, 17, 21, .36);
  --white: #0f1115;                      /* the "high-contrast" fill: white on dark, black on light */
  --ink: #ffffff;
  --bad: #c62f2f;
  --header-bg: rgba(214, 218, 226, .94);
  --float-bg: rgba(255, 255, 255, .9);
  --menu-bg: #ffffff;
  --primary-hover: #2a2d33;
  --shadow: rgba(30, 36, 48, .2);
  --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overflow-x: clip; margin: 0; background: var(--bg); color: var(--text);
  font: 15.5px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(92px + env(safe-area-inset-bottom)); min-height: 100vh; }

/* Soft light behind the glass, so translucency is visible. */
.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 45vmax at 85% -10%, rgb(var(--fg) / .09), transparent 60%),
    radial-gradient(50vmax 40vmax at -10% 35%, rgba(150, 170, 210, .07), transparent 65%),
    radial-gradient(55vmax 40vmax at 60% 110%, rgb(var(--fg) / .05), transparent 60%),
    var(--bg); }

main { max-width: 760px; margin: 0 auto; padding: 0 16px; }
h1, h2 { letter-spacing: -.015em; }
h2 { font-size: .8rem; font-weight: 600; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em;
  display: flex; align-items: center; gap: 8px; }
h2 [data-icon] { display: inline-flex; color: var(--text); opacity: .85; }
a { color: inherit; }
.i { flex: none; display: block; }

/* ---------- controls ---------- */
button, select, input { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select { font-size: 16px; } /* under 16px, iPhone zooms into fields */
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--glass-2); border: 1px solid var(--edge); border-radius: 14px; padding: 10px 15px; cursor: pointer;
  transition: background .2s, border-color .2s, transform .12s, opacity .2s; }
button:hover { background: var(--glass-3); border-color: var(--edge-2); }
button:active { transform: scale(.975); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, select:focus-visible { outline: 2px solid rgb(var(--fg) / .6); outline-offset: 2px; }
input:focus-visible { outline: none; }
button.primary { background: var(--white); color: var(--ink); border-color: transparent; font-weight: 650; }
button.primary:hover { background: var(--primary-hover); }
button.danger { color: var(--text); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--glass-2); }
button.pill { border-radius: 999px; padding: 7px 13px 7px 10px; border-color: var(--edge); }
button.big { flex: 1; font-size: 1.1rem; font-weight: 600; padding: 16px; min-height: 58px; border-radius: 18px; letter-spacing: .01em; }
button.icon-btn { padding: 8px; min-width: 40px; min-height: 40px; border-radius: 12px; color: var(--muted); }
button.icon-btn:hover { color: var(--text); }

input:not([type=checkbox]):not([type=radio]), select {
  background: rgb(var(--fg) / .05); border: 1px solid var(--edge); border-radius: 12px; padding: 10px 12px; min-width: 0;
  transition: border-color .2s, background .2s; }
input:focus, select:focus { border-color: rgb(var(--fg) / .32); background: rgb(var(--fg) / .065); outline: none; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: var(--arrow);
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
select option, select optgroup { background: var(--menu-bg); color: var(--text); }
input::placeholder { color: var(--faint); }
input[type=time]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .6; }
:root[data-theme=light] input[type=time]::-webkit-calendar-picker-indicator { filter: none; }

/* Checkboxes become slim toggles. */
input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 40px; height: 24px; margin: 0;
  border-radius: 999px; background: rgb(var(--fg) / .1); border: 1px solid var(--edge); cursor: pointer; transition: background .2s, border-color .2s; }
input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: rgb(var(--fg) / .55); transition: transform .22s cubic-bezier(.3, .7, .4, 1), background .2s; }
input[type=checkbox]:checked { background: var(--white); border-color: transparent; }
input[type=checkbox]:checked::after { transform: translateX(16px); background: var(--ink); }
input[type=checkbox]:disabled { opacity: .4; cursor: default; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--header-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid rgb(var(--fg) / .12); }
.brand { display: flex; gap: 9px; align-items: center; font-weight: 650; letter-spacing: -.01em; font-size: 1.05rem; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; display: block; }
.brand .mark .i { width: 16px; height: 16px; }
.top-right { display: flex; align-items: center; gap: 6px; }
#themeBtn { padding: 7px; border-radius: 999px; color: var(--muted); }
#themeBtn:hover { color: var(--text); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; padding: 5px 11px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--edge); color: var(--muted); letter-spacing: .01em; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.chip.on { color: var(--text); border-color: var(--edge-2); }
.chip.on::before { background: var(--white); box-shadow: 0 0 8px rgb(var(--fg) / .8); }
.chip.warn { color: var(--text); }
.chip.warn::before { background: transparent; border: 1.5px solid rgb(var(--fg) / .75); width: 5px; height: 5px; animation: blink 1.6s infinite; }
.chip.off { color: var(--bad); }
.chip.off::before { background: var(--bad); }
.chip.na { opacity: .5; border-style: dashed; }
.chip.na::before { background: transparent; border: 1px dashed var(--faint); }
#status.on::before { animation: blink 1.6s infinite; }
button.chip { cursor: pointer; }
button.chip:hover { background: var(--glass-2); border-color: var(--edge-2); }
.chip.chip-trail { color: var(--text); border-color: var(--edge-2); }
.chip.chip-trail::before { background: #f43f5e; box-shadow: 0 0 8px rgb(244 63 94 / .7); animation: blink 1.6s infinite; }
button.chip { cursor: pointer; padding: 6px 12px; }
.chip .i { width: 14px; height: 14px; margin: 0 -2px 0 -1px; opacity: .9; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- cards ---------- */
.card { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 12px 0; margin: 0;
  border-top: 1px solid rgb(var(--fg) / .08); -webkit-backdrop-filter: none; backdrop-filter: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.head-actions { display: flex; gap: 8px; align-items: center; }
#btnStartAll { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.note { background: var(--glass); border: 1px solid var(--edge); color: var(--muted); border-radius: 16px; padding: 12px 14px; font-size: .88rem; margin: 6px 0; }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.wrap { flex-wrap: wrap; }
.switch { display: flex; gap: 12px; align-items: center; margin: 12px 0; cursor: pointer; }
.inline { display: inline-flex; gap: 10px; align-items: center; white-space: nowrap; }
.controls { display: flex; gap: 10px; margin: 14px 0 10px; }

/* ---------- live tiles ---------- */
/* Six columns: elapsed time spans the row, distance and pace share the next, everything else is three across. */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tile { display: block; grid-column: span 2; min-width: 0; background: rgb(var(--fg) / .035); border: 1px solid var(--edge); border-radius: 14px; padding: 9px 10px 8px; text-align: left; }
.tile .k { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v { font-size: 1.25rem; font-weight: 400; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.tile .v .u { font-size: .6em; font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: .25em; }
.tile.hero { grid-column: span 3; background: none; border: 0; padding: 4px 4px 6px; }
.tile.hero[data-k=elapsed] { grid-column: span 6; }
.tile.hero .k { font-size: .7rem; }
.tile.hero .v { font-size: clamp(2rem, 11vw, 3.2rem); font-weight: 250; line-height: 1.1; margin-top: 0; }
.tile.hero[data-k=elapsed] .v { font-size: clamp(3rem, 18vw, 5.2rem); font-weight: 200; }
.tile.hero .v .u { font-size: .4em; }
.hero-card { padding: 10px 0 2px; }
.hero-card .tiles { gap: 4px 8px; }
body:not([data-session=idle]) .controls { margin-top: 6px; }
.tile.hit { border-color: rgb(var(--fg) / .7); box-shadow: 0 0 0 1px rgb(var(--fg) / .45), 0 0 28px rgb(var(--fg) / .18); }
.tile.hero.hit { box-shadow: none; border: 0; text-shadow: 0 0 24px rgb(var(--fg) / .5); }

/* ---------- your notifications ---------- */
.rules { list-style: none; padding: 0; margin: 0; }
.rules li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgb(var(--fg) / .12); }
.rules li:last-child { border-bottom: 0; }
.rules .desc { flex: 1; min-width: 0; }
.rules .desc small { display: block; color: var(--muted); }
.rules .go { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 40px; border-radius: 999px; font-weight: 600; flex: none; }
.rules .go * { pointer-events: none; }
body:not([data-session=idle]) .rules .go { display: none; }
body:not([data-session=idle]) .rules li:not(.watching) .desc { opacity: .4; }
.rules li.watching .desc { color: var(--tint-text, var(--tint, #e4531a)); font-weight: 600; }
.rules .empty { color: var(--muted); display: block; padding: 6px 0; }
.rules .edit, .rules .del { padding: 8px; min-width: 40px; min-height: 40px; border-radius: 12px; color: var(--muted); }
.rules .edit:hover, .rules .del:hover { color: var(--text); }
.rules .edit *, .rules .del * { pointer-events: none; }

.rule-form { display: grid; gap: 12px; background: rgb(var(--fg) / .035); border: 1px solid var(--edge); border-radius: 18px; padding: 14px; margin-top: 12px; }
.rule-form .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rule-form label { display: grid; gap: 6px; font-size: .82rem; color: var(--muted); }
.rule-form label.switch { display: flex; color: var(--text); align-self: end; }
.rule-form .actions { display: flex; gap: 8px; justify-content: flex-end; }

details summary { cursor: pointer; color: var(--text); margin-top: 12px; opacity: .8; list-style: none; display: flex; align-items: center; gap: 6px; }
details summary::-webkit-details-marker { display: none; }
details:not(.settings) > summary::before { content: ''; width: 16px; height: 16px; background: currentColor; transition: transform .2s;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat; }
details[open]:not(.settings) > summary::before { transform: rotate(90deg); }
.help-list { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.help-list li { margin: 4px 0; }

/* ---------- log ---------- */
.log { list-style: none; padding: 0; margin: 0; max-height: 320px; overflow: auto; }
.log li { padding: 10px 0; border-bottom: 1px solid rgb(var(--fg) / .06); color: var(--muted); font-size: .9rem; }
.log li:last-child { border-bottom: 0; }
.log li b { display: flex; align-items: center; gap: 7px; color: var(--text); font-weight: 600; }
.log li b .i { width: 15px; height: 15px; }
.log time { color: var(--faint); font-size: .78rem; margin-right: 8px; font-variant-numeric: tabular-nums; }

/* ---------- mic ---------- */
.mic { --teal: 45 212 191; position: relative; width: 58px; height: 58px; margin-top: -26px; justify-self: center; align-self: start;
  border-radius: 50%; padding: 0; background: rgb(var(--teal)); color: #053b34; border: 0;
  box-shadow: 0 0 0 5px var(--bg), 0 12px 28px -10px var(--shadow); }
.mic:hover { background: #5eead4; }
.mic .i { width: 22px; height: 22px; }
.mic.listening { background: #5eead4; color: #053b34; border-color: transparent; animation: pulse 1.3s infinite; }
.mic.handsfree:not(.listening) { box-shadow: 0 0 0 5px var(--bg), 0 0 0 8px rgb(var(--teal) / .4), 0 12px 28px -10px var(--shadow); } /* always listening: soft teal ring */
@keyframes pulse { 0% { box-shadow: 0 0 0 5px var(--bg), 0 0 0 5px rgb(var(--teal) / .55); } 100% { box-shadow: 0 0 0 5px var(--bg), 0 0 0 24px rgb(var(--teal) / 0); } }
.transcript { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 9; text-align: center;
  background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--edge); border-radius: 16px; padding: 11px 15px; font-size: .95rem; }
.transcript.final { border-color: var(--edge-2); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: calc(58px + env(safe-area-inset-top)); transform: translateX(-50%); width: min(92vw, 520px); z-index: 20;
  background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--edge-2); color: var(--text); padding: 13px 17px; border-radius: 18px; font-weight: 600;
  box-shadow: 0 20px 44px -16px var(--shadow); animation: drop .28s cubic-bezier(.3, .7, .4, 1); }
.toast small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- Android download ---------- */
.apk { display: flex; align-items: center; gap: 14px; text-decoration: none; transition: background .2s, border-color .2s; }
.apk:hover { background: var(--glass-2); border-color: var(--edge-2); }
.apk-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--tile); flex: none; }
.apk-text b { display: block; font-weight: 600; }
.apk-text small { color: var(--muted); }

footer { text-align: center; margin: 22px 0 6px; line-height: 1.55; }
/* Notification tiles: thin line icons — white on dark, black on light — on a flat tile that is
   80% transparent, with a touch of category colour. No gradient, shadow or highlight. */
.vz { --cat: 148 163 184; --tint: 30%; display: grid; place-items: center; flex: none; width: var(--vz, 44px); height: var(--vz, 44px);
  border-radius: calc(var(--vz, 44px) * .3); color: var(--white);
  background: rgb(var(--fg) / .2);
  background: color-mix(in srgb, rgb(var(--cat) / .2) var(--tint), rgb(var(--fg) / .2)); }
:root[data-theme=light] .vz { --tint: 45%; }
.vz svg { width: 60%; height: 60%; display: block; }
.vz.cat-distance  { --cat: 20 184 166; }  /* teal   */
.vz.cat-time      { --cat: 99 102 241; }  /* indigo */
.vz.cat-body      { --cat: 244 63 94; }   /* rose   */
.vz.cat-elevation { --cat: 34 197 94; }   /* green  */
.vz.cat-weather   { --cat: 245 158 11; }  /* amber  */
.vz.cat-safety    { --cat: 249 115 22; }  /* orange */
.vz.cat-device    { --cat: 139 92 246; }  /* violet */
.vz.cat-other     { --cat: 148 163 184; } /* slate  */

footer .credits { margin-top: 12px; }
footer .credits summary { justify-content: center; margin: 0; font-size: .82rem; color: var(--faint); }
footer .credits p { margin: 8px 0 0; font-size: .78rem; color: var(--faint); }
footer .credits a { color: var(--muted); text-decoration: none; }
footer .credits a:hover { color: var(--text); }
footer .ver { display: block; margin-top: 10px; color: var(--faint); letter-spacing: .04em; }
footer button.link { padding: 0; background: none; border: 0; color: var(--muted); font: inherit; letter-spacing: inherit; text-decoration: underline; text-underline-offset: 2px; }
footer button.link:hover { background: none; color: var(--text); }
footer .kodowl { display: block; margin-top: 8px; font-size: .72rem; color: var(--faint); }
footer .kodowl a { color: var(--muted); text-decoration: none; }
footer .kodowl a:hover { color: var(--text); }
footer .kodowl img { height: 11px; width: auto; vertical-align: -1px; margin-right: 3px; }
:root[data-theme=light] footer .kodowl img { filter: invert(1); }

/* ---------- layout: one tab at a time, each with its own sub-pages ---------- */
[hidden] { display: none !important; }
main { display: flex; flex-direction: column; }
main > *, .col > * { order: 10; }
.col { display: contents; } /* phones: one column, ordered by the rules below */
body[data-tab=home] main [data-page]:not([data-page~=home]),
body[data-tab=alerts] main [data-page]:not([data-page~=alerts]),
body[data-tab=trail] main [data-page]:not([data-page~=trail]),
body[data-tab=trips] main [data-page]:not([data-page~=trips]),
body[data-tab=system] main [data-page]:not([data-page~=system]) { display: none !important; }
/* My alerts: on Home, and as the "My alerts" tab of Alerts */
body:not([data-tab=home]) #targetsCard { display: none; }
body[data-tab=alerts][data-sub=custom] #wizard { display: none !important; }
body:not([data-sub=custom]) #customCard { display: none !important; }
body:not([data-sub=tools]) #trailTools,
body:not([data-sub=share]) #shareCard,
body[data-tab=trips][data-sub=tools] #tripsCard, body[data-tab=trips][data-sub=share] #tripsCard { display: none !important; }
/* Trips: Saved trips | Tools | Sharing on top */
body[data-tab=trips] #tripsTabNav { order: 1; margin-top: 12px; }
/* Trail: the map, then Tools | Sharing below it. Saved trips have their own Trips tab. */
body[data-tab=trail] #traceCard { order: 0; }
body[data-tab=trail] #tripsNav { order: 1; margin-top: 2px; }
body[data-tab=alerts] #logCard { order: 30; margin-top: 18px; }
.sub-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #f43f5e; margin-inline-start: 5px; vertical-align: 2px; }
body[data-tab=system][data-sub] #settingsMenu { display: none !important; }
body[data-tab=system]:not([data-sub]) #settingsCard { display: none !important; }
body:not([data-sub=account]) #setAccount, body:not([data-sub=voice]) #setVoice, body:not([data-sub=sensors]) #setSensors,
body:not([data-sub=alerts]) #setAlerts, body:not([data-sub=cats]) #setCats, body:not([data-sub=look]) #setLook, body:not([data-sub=app]) #setApp { display: none !important; }
/* Home */
#welcome { order: 0; padding: 14px 0 4px; }
#welcome h1 { margin: 0; font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; }
#welcome p { margin: 4px 0 0; }
body:not([data-session=idle]) #welcome { display: none; }
body[data-tab=home] #targetsCard { order: 6; }
body[data-tab=home] #homeTrails { order: 7; }
body[data-tab=home][data-session=idle] #targetsCard { order: 1; }
body[data-tab=home][data-session=idle] #homeTrails { order: 2; }
#homeTrails { border-top: 0; }
body[data-tab=alerts] #targetsCard { order: 2; }
body[data-tab=alerts] #btnAdd { display: none; }
/* Live: Start first when idle; the big numbers first while running */
body[data-session=idle] :is(#liveCard, #readingsCard) { display: none; }
body[data-session=idle] .controls { order: 1; }
body[data-session=idle] #activeNow { order: 3; }
body[data-session=idle] #btnSensorsQuick { order: 4; }
body[data-session=idle] #homeHint { order: 5; }
body:not([data-session=idle]) #liveCard { order: 1; }
body:not([data-session=idle]) .controls { order: 2; }
body:not([data-session=idle]) #activeNow { order: 3; }
body:not([data-session=idle]) #awakeNote { order: 4; }
body:not([data-session=idle]) #readingsCard { order: 5; }
body:not([data-session=idle]) :is(#btnSensorsQuick, #homeHint) { display: none; }
/* Other tabs: the segmented control first, then the page */
.subnav, #settingsMenu { order: 1; }
#targetsCard, #wizard, #customCard, #logCard, #traceCard, #trailTools, #tripsCard, #shareCard, #settingsCard { order: 2; }
.subnav { margin: 10px 0 4px; }
.subnav [role=tab] { flex: 1; border: 0; border-radius: 11px; background: none; color: var(--muted); padding: 9px 6px; font-weight: 500; white-space: nowrap; }
.subnav [role=tab].on { background: var(--white); color: var(--ink); font-weight: 650; }
#targetsCard, #wizard, #customCard, #logCard, #traceCard, #trailTools, #tripsCard, #shareCard { border-top: 0; }

#tripsCard, #trailTools, #shareCard, #traceCard { scroll-margin-top: 64px; }
.home-hint { display: grid; justify-items: center; gap: 12px; padding: 26px 0 10px; text-align: center; }
.home-hint p { margin: 0; }
/* Settings: a menu of rows, each opens a page */
.menu { display: grid; gap: 2px; padding: 8px 0 12px; min-width: 0; }
.menu-row { display: flex; min-width: 0; width: 100%; align-items: center; gap: 12px; text-align: left; padding: 11px 10px 11px 8px; border-radius: 14px; background: none; border: 0; }
.menu-row:hover, .menu-row.on { background: var(--glass-2); }
.menu-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tile); flex: none; }
.menu-ico .i { width: 18px; height: 18px; }
.menu-text { display: block; flex: 1; min-width: 0; }
.menu-text b { display: block; font-weight: 600; }
.menu-text small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-chev { color: var(--faint); display: inline-flex; }
.menu-chev .i { width: 18px; height: 18px; transform: rotate(-90deg); }
.sub-bar { display: flex; align-items: center; gap: 4px; margin: 6px 0 2px; }
.sub-bar .sub-back { padding: 7px 10px 7px 6px; color: var(--muted); }
.sub-bar h2 { margin: 0; font-size: 1.05rem; color: var(--text); text-transform: none; letter-spacing: -.01em; }
.settings > .card { border-top: 0; padding-top: 8px; }
.settings .switch { margin: 6px 0 14px; }
.settings p.small + .switch { margin-top: 2px; }
#iosCard { margin: 10px 0; }
#iosCard .card-head { margin-bottom: 4px; }
#iosCard p { margin: 0; font-size: .92rem; }
#setApp .apk { padding: 12px; border: 1px solid var(--edge); border-radius: 16px; background: var(--glass); margin: 4px 0 12px; }
#setApp .ver { letter-spacing: .04em; }
#setApp .kodowl img { height: 11px; width: auto; vertical-align: -1px; margin-right: 3px; }
:root[data-theme=light] #setApp .kodowl img { filter: invert(1); }
#setApp .credits summary { margin: 0; font-size: .82rem; color: var(--faint); }
#setApp .credits p { margin: 8px 0 0; font-size: .78rem; color: var(--faint); }
#setApp button.link { padding: 0; background: none; border: 0; color: var(--muted); font: inherit; letter-spacing: inherit; text-decoration: underline; text-underline-offset: 2px; }
.switch .why { color: var(--faint); font-size: .8rem; }

/* ---------- wizard ---------- */
.wizard { margin-top: 0; scroll-margin-top: 64px; padding: 4px 0 14px; border-top: 0; }
.wizard h1 { font-size: 1.35rem; font-weight: 600; line-height: 1.2; margin: 2px 0 14px; }
.wiz-tip { display: flex; align-items: center; gap: 7px; margin: 12px 0 0; }
.wiz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 8px; }
.wiz-type { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; text-align: left;
  padding: 12px; border-radius: 16px; background: rgb(var(--fg) / .035); }
.wiz-tabs { margin: 0 0 12px; overflow-x: auto; }
.wiz-tab { flex: 1; padding: 9px 6px; border: 0; border-radius: 11px; background: none; color: var(--muted); white-space: nowrap; }
.wiz-tab.on { background: var(--white); color: var(--ink); font-weight: 650; }
.wiz-custom { display: grid; gap: 12px; }
.wiz-custom p { margin: 0; }
.wiz-custom-btn { width: 100%; }
.wiz-type b { font-size: .94rem; font-weight: 600; line-height: 1.25; }
.wiz-type small { color: var(--muted); font-size: .76rem; line-height: 1.3; }
.wiz-type .vz { --vz: 38px !important; margin-bottom: 6px; }
.wiz-type:hover, .wiz-type:focus-visible { border-color: var(--edge-2); background: rgb(var(--fg) / .07); }
.wiz-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.wiz-form h1 { margin: 0; display: flex; align-items: center; gap: 12px; }
.wiz-back { justify-self: start; padding: 7px 12px 7px 8px; color: var(--muted); }
.wiz-form .ask { margin: -6px 0 0; color: var(--muted); font-size: 1.02rem; }
.value-row { display: flex; gap: 10px; align-items: center; }
.value-row input { flex: 1 1 0; width: 0; min-width: 0; font-size: 2.1rem; font-weight: 300; letter-spacing: -.02em; padding: 10px 16px; border-radius: 16px;
  font-variant-numeric: tabular-nums; }
.value-row select { font-size: 1.05rem; padding: 13px 36px 13px 12px; }
.value-row .unit, .value-row .dash { color: var(--muted); font-size: 1.05rem; white-space: nowrap; }
.picks { display: flex; flex-wrap: wrap; gap: 7px; }
.picks button { border-radius: 999px; padding: 8px 16px; font-variant-numeric: tabular-nums; }
.picks button.sel { background: var(--white); color: var(--ink); border-color: transparent; font-weight: 650; }
.seg { display: flex; gap: 8px; padding: 4px; background: rgb(var(--fg) / .04); border: 1px solid var(--edge); border-radius: 15px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 9px; border-radius: 11px; cursor: pointer; color: var(--muted); transition: background .2s, color .2s; }
.seg input:checked + span { background: var(--white); color: var(--ink); font-weight: 650; }
/* Alert sound picker: the segmented look, wrapped into a grid. */
.seg.sound-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; margin-bottom: 6px; }
.seg.sound-pick span { padding: 9px 4px; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg.sound-pick.off { opacity: .55; }
.wiz-form .msg { display: grid; gap: 6px; color: var(--muted); font-size: .84rem; }
.wiz-form button.big { flex: none; }

/* Live sensor preview: the Live card shows while idle only once sensors are on */
.sensors-quick { align-self: center; color: var(--muted); font-size: .88rem; margin: 0 0 6px; }
.sensors-quick:hover { color: var(--text); }
body[data-session=idle][data-sensors=live] #readingsCard { display: block; order: 4; }

@media (max-width: 420px) {
  main { padding: 0 12px; }
  .card { padding: 12px 0; }
  .wiz-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- trace map ---------- */
.trace-wrap { position: relative; width: 100vw; margin: 4px calc(50% - 50vw) 14px; }
.trace-map { height: clamp(300px, 48vh, 640px); border-radius: 0; overflow: hidden; background: rgb(var(--fg) / .05); border: 0; border-block: 1px solid var(--edge); }
.trace-recenter { position: absolute; right: 10px; top: 10px; z-index: 2; padding: 8px; border-radius: 12px; background: var(--float-bg);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.trace-controls { display: grid; gap: 12px; }
.trace-controls .row { margin: 0; }
.trace-controls .big { flex: 1; }
.trace-live { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .92rem; }
.trace-live .rec { width: 8px; height: 8px; border-radius: 50%; background: #f43f5e; flex: none; animation: blink 1.6s infinite; }
.trace-nomap { padding: 18px; margin: 0; color: var(--muted); font-size: .9rem; }
/* tap-on-the-line popup, in the app's colours */
.trace-pop .maplibregl-popup-content { background: var(--float-bg); color: var(--text); border-radius: 12px; padding: 8px 12px;
  box-shadow: 0 10px 26px -10px var(--shadow); font: inherit; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.trace-pop b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.trace-pop span { color: var(--muted); font-size: .8rem; }
.trace-pop.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--float-bg); }
.trace-pop.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--float-bg); }
.trace-pop.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--float-bg); }
.trace-pop.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--float-bg); }

/* ---------- saved trips ---------- */
.trips { list-style: none; padding: 0; margin: 0; }
.trips > li { border-bottom: 1px solid rgb(var(--fg) / .12); }
.trips > li:last-child { border-bottom: 0; }
.trips .empty { color: var(--muted); padding: 6px 0; }
.trip-head { display: flex; align-items: center; gap: 4px; }
.trip-main { flex: 1; min-width: 0; display: block; text-align: left; padding: 11px 4px; border-radius: 12px; }
.trip-main b { display: block; font-weight: 600; }
.trip-main small { display: block; color: var(--muted); }
.trip-head .icon-btn { color: var(--muted); }
.trip-head .icon-btn:hover { color: var(--text); }
.trip-head * { pointer-events: auto; }
.trip-head .icon-btn * , .trip-main * { pointer-events: none; }
.trip-detail { padding: 0 4px 14px; display: grid; gap: 10px; }
.trip-detail p { margin: 0; }
.trip-detail .row { margin: 0; }
.trip-alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .9rem; }
.trip-alerts time { color: var(--faint); margin-right: 8px; font-variant-numeric: tabular-nums; }
.trace-viewing { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; font-size: .88rem; color: var(--muted); }
#btnClearLog { padding: 5px 10px; font-size: .82rem; color: var(--muted); }
.trace-controls .seg span { padding: 9px 4px; font-size: .9rem; white-space: nowrap; }
/* Map controls follow the MAP's light/dark mode (separate from the app theme). */
.trace-map .maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(255, 255, 255, .9); color: #5b606b; }
.trace-map .maplibregl-ctrl-attrib a { color: #5b606b; }
.map-dark .trace-map .maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(22, 24, 30, .85); color: #a4a9b3; }
.map-dark .trace-map .maplibregl-ctrl-attrib a { color: #a4a9b3; }
.map-dark .trace-map .maplibregl-ctrl-attrib-button { filter: invert(1); background-color: transparent; }
.trace-maptheme, .trace-recenter { position: absolute; top: 10px; z-index: 2; padding: 8px; border-radius: 12px;
  background: rgba(255, 255, 255, .92); color: #0f1115; border: 1px solid rgba(0, 0, 0, .08); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.trace-maptheme { left: 10px; }
.trace-maptheme:hover, .trace-recenter:hover { background: #ffffff; }
.map-dark .trace-maptheme, .map-dark .trace-recenter { background: rgba(22, 24, 30, .85); color: #f4f5f7; border-color: rgba(255, 255, 255, .12); }
.map-dark .trace-maptheme:hover, .map-dark .trace-recenter:hover { background: rgba(32, 35, 42, .95); }
/* Map credits stay closed (ⓘ only) until tapped — no flash while the map loads */
.trace-map:not(.credits-touched) .maplibregl-ctrl-attrib-inner { display: none; }
.trace-map:not(.credits-touched) .maplibregl-ctrl-attrib.maplibregl-compact { padding: 2px 24px 2px 0; }
.trace-map .maplibregl-ctrl button:focus:not(:focus-visible) { box-shadow: none; outline: none; }

/* ---------- bottom bar: Alerts | Trail | (mic) | Trips | Settings ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: stretch;
  max-width: 760px; margin: 0 auto; padding: 4px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--header-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-top: 1px solid rgb(var(--fg) / .12); }
.tabbar [role=tab] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; position: relative;
  background: transparent; border: 0; border-radius: 12px; padding: 4px 2px; color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .01em; }
.tabbar [role=tab] .i { width: 24px; height: 24px; }
@media (hover: hover) and (pointer: fine) { .tabbar [role=tab]:hover { background: var(--glass); } } /* no stuck highlight box after a tap on phones */
.tabbar [role=tab][aria-selected=true] { color: var(--text); }
.tabbar [role=tab][aria-selected=true] .i { stroke-width: 2; }
.tabbar .tab-dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: #f43f5e; box-shadow: 0 0 0 2px var(--bg); animation: blink 1.6s infinite; }
#traceCard { padding-top: 8px; }

/* ---------- active now: status chips under the Start/Pause buttons ---------- */
.active-now { margin: 0 0 10px; }
.active-list { display: flex; flex-wrap: wrap; gap: 6px; }
.active-item { font-size: .82rem; padding: 6px 12px 6px 9px; border-radius: 999px; gap: 7px; color: var(--muted); }
.active-item .i { width: 15px; height: 15px; }
.active-item.live { color: var(--text); border-color: var(--edge-2); }
.active-item .dot { width: 7px; height: 7px; border-radius: 50%; background: #f43f5e; flex: none; animation: blink 1.6s infinite; }

/* ---------- account ---------- */
.acct-row { display: flex; align-items: center; gap: 12px; margin: 2px 0 10px; }
.acct-row b { display: block; font-weight: 600; }
.acct-row small { color: var(--muted); }
.acct-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tile); flex: none; }
#accountBody p { margin: 0 0 10px; }
#accountBody input[name=acctName] { flex: 1 1 160px; }

/* ---------- trail extras ---------- */
.trail-banners { display: grid; gap: 8px; }
.trail-banners:empty { display: none; }
.trail-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 14px;
  background: rgb(var(--fg) / .05); border: 1px solid var(--edge); font-size: .88rem; margin-bottom: 10px; }
.trail-banner b { font-weight: 650; }
.trail-banner .pill { flex: none; }
.trail-legend { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin: -6px 0 12px; }
.trail-legend .ramp { flex: 1; height: 6px; border-radius: 3px; }
.trail-profile { margin: -4px 0 14px; cursor: pointer; }
.trail-profile .profile-head { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.trail-profile svg { display: block; width: 100%; height: 64px; }
.trail-profile .parea { fill: rgb(45 212 191 / .18); }
.trail-profile .pline { fill: none; stroke: #2dd4bf; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.trail-profile .pmark { stroke: var(--text); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 3; }
.trace-pop span { display: block; }

/* ---------- trail tools ---------- */
#trailTools .wiz-type.on { border-color: rgb(45 212 191 / .55); box-shadow: inset 0 0 0 1px rgb(45 212 191 / .25); }
#trailTools .wiz-type.on small { color: #2dd4bf; }
.tool-panel { display: grid; gap: 14px; }
.tool-panel h1 { margin: 0; display: flex; align-items: center; gap: 12px; }
.tool-panel .ask { margin: 0; color: var(--muted); }
.tool-panel p { margin: 0; }
.tool-panel .big { flex: none; }
.tool-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tool-list .pill { font-size: .86rem; }
.tool-rows { list-style: none; margin: 0; padding: 0; }
.tool-rows li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid rgb(var(--fg) / .06); padding: 4px 0; }
.tool-rows li:last-child { border-bottom: 0; }
.tool-rows li > span { flex: 1; }
.tool-rows b { display: block; font-weight: 600; }
.tool-rows small { color: var(--muted); }
.picks .pill.sel { background: var(--white); color: var(--ink); border-color: transparent; font-weight: 650; }
.file-pill { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-self: start; padding: 7px 13px 7px 10px; border-radius: 999px; border: 1px solid var(--edge); background: var(--glass-2); }
.art-preview { width: 100%; max-width: 420px; border-radius: 16px; border: 1px solid var(--edge); }
.trail-banner .warn { color: #f97316; font-weight: 600; }
/* Trail tools: three compact tiles across */
#trailTools .wiz-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#trailTools .wiz-type { align-items: center; text-align: center; padding: 10px 6px; gap: 1px; }
#trailTools .wiz-type .vz { --vz: 34px !important; margin-bottom: 5px; }
#trailTools .wiz-type b { font-size: .8rem; }
#trailTools .wiz-type small { font-size: .68rem; }

/* ---------- full-screen sheet (the "Add alert" picker) ---------- */
.as-win { position: fixed; inset: 0; z-index: 15; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; padding: 0; margin: 0; }
.win-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--header-bg);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 1px solid rgb(var(--fg) / .12); }
.win-bar h2 { margin: 0; font-size: 1.05rem; color: var(--text); text-transform: none; letter-spacing: -.01em; }
.win-body { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(40px + env(safe-area-inset-bottom)); }
.win-body > .ask { margin: 0 0 12px; color: var(--muted); font-size: 1.02rem; }
body.win-open { overflow: hidden; }
#accountBody .row { margin-bottom: 0; }

/* ================= landscape iPad and desktop (900px+ wide; phones in landscape keep the phone layout) =================
   A navigation rail on the left with the mic on top, and two columns:
   Alerts = live numbers + controls | your alerts + log;  Trail = big map | trail tools. */
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  :root { --rail: calc(92px + env(safe-area-inset-left)); }
  body { padding-left: var(--rail); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .top { padding-left: 24px; padding-right: calc(24px + env(safe-area-inset-right)); }

  /* rail */
  .tabbar { top: 0; bottom: 0; left: 0; right: auto; width: var(--rail); max-width: none; margin: 0;
    display: flex; flex-direction: column; align-items: stretch; gap: 6px;
    padding: calc(14px + env(safe-area-inset-top)) 10px calc(14px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
    border-top: 0; border-right: 1px solid rgb(var(--fg) / .07); }
  .tabbar [role=tab] { flex: none; min-height: 66px; font-size: .72rem; gap: 4px; border-radius: 16px; }
  .tabbar [role=tab][aria-selected=true] { background: var(--glass-2); }
  .transcript { left: calc(var(--rail) + 24px); right: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

  /* two columns: the page on the left, its companion on the right */
  main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); column-gap: 36px; align-items: start;
    max-width: 1320px; padding: 0 calc(28px + env(safe-area-inset-right)) 0 28px; }
  .col { display: flex; flex-direction: column; min-width: 0; }
  .col-side { padding-top: 6px; }
  /* Home: live | my alerts.  Alerts: categories | my alerts.  Trail: map | tools.  Trips: one column.  System: menu | page */
  body[data-tab=home] #targetsCard { display: block !important; }
  body[data-tab=alerts] main { grid-template-columns: minmax(0, 1fr); }
  body[data-tab=alerts] .col-side { display: none; }
  body[data-tab=trail] #traceCard { display: block !important; }
  body[data-tab=trips] main { grid-template-columns: minmax(0, 1fr); }
  body[data-tab=trips] .col-main { display: none; }
  body[data-tab=trips] #tripsCard, body[data-tab=trips] #trailTools, body[data-tab=trips] #shareCard, body[data-tab=trips] #tripsTabNav { max-width: 860px; width: 100%; }
  body[data-tab=system][data-sub] #settingsMenu { display: grid !important; }
  body[data-tab=system]:not([data-sub]) #settingsCard { display: block !important; }
  #trailNav [data-sub=map], .sub-bar .sub-back { display: none !important; }
  body[data-tab=trail] main { grid-template-columns: minmax(0, 1fr); }
  body[data-tab=trail] .col-side { display: none; }
  body[data-tab=system] main { grid-template-columns: 320px minmax(0, 1fr); column-gap: 28px; }
  body[data-tab=system] .col-main { display: contents; }
  body[data-tab=system] #settingsMenu { grid-column: 1; position: sticky; top: 70px; }
  body[data-tab=system] #settingsCard { grid-column: 2; max-width: 640px; }
  .subnav { margin-top: 0; }
  .menu-row.on { background: var(--glass-3); }
  .menu-chev { display: none; }
  .sub-bar { margin: 8px 0 6px; }
  .sub-bar h2 { font-size: 1.3rem; }

  /* Alerts: bigger numbers, four readings across */
  .tile.hero .v { font-size: clamp(2.6rem, 4.6vw, 4.2rem); }
  .tile.hero[data-k=elapsed] .v { font-size: clamp(4.4rem, 8.5vw, 7.5rem); }
  #tilesMore { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #tilesMore .tile { grid-column: auto; }
  .controls { margin-top: 18px; }
  .wiz-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

  /* Trail: the map fills the height of the screen */
  .trace-wrap { width: auto; margin: 4px 0 14px; }
  .trace-map { height: clamp(360px, calc(100vh - 300px), 980px); height: clamp(360px, calc(100dvh - 300px), 980px);
    border-radius: 20px; border: 1px solid var(--edge); }
  #trailTools { padding-top: 14px; }

}


/* ---------- Bright colors (html[data-bright]): Apple-style, minimal. Flat iOS system colors, no gradients. ---------- */
:root[data-bright] {
  --red: #ff3b30; --orange: #ff9500; --yellow: #ffcc00; --green: #34c759; --teal: #30b0c7; --blue: #0a84ff; --indigo: #5e5ce6; --purple: #bf5af2; --pink: #ff2d55;
  --brand: #ff6a2b; --tint: var(--brand); --tint-text: #ff7a3d;
}
:root[data-bright][data-theme=light] { --blue: #007aff; --indigo: #5856d6; --purple: #af52de; --teal: #30b0c7; --green: #34c759; --brand: #e4531a; --tint: var(--brand); --tint-text: #d9480f; }
/* Icons: solid rounded squares like iOS Settings */
:root[data-bright] .vz { background: rgb(var(--cat)); color: #fff; }
:root[data-bright] .vz.cat-distance  { --cat: 48 176 199; }
:root[data-bright] .vz.cat-time      { --cat: 94 92 230; }
:root[data-bright] .vz.cat-body      { --cat: 255 45 85; }
:root[data-bright] .vz.cat-elevation { --cat: 52 199 89; }
:root[data-bright] .vz.cat-weather   { --cat: 255 149 0; }
:root[data-bright] .vz.cat-safety    { --cat: 255 59 48; }
:root[data-bright] .vz.cat-device    { --cat: 175 82 222; }
:root[data-bright] .vz.cat-other     { --cat: 142 142 147; }
/* One accent colour for actions */
:root[data-bright] button.primary { background: var(--tint); color: var(--on-tint, #fff); }
:root[data-bright] button.primary:hover { background: var(--tint); filter: brightness(1.08); }
:root[data-bright] .tabbar [role=tab][aria-selected=true] { color: var(--tint-text, var(--tint)); }
:root[data-bright] .tabbar .mic { background: var(--tint); color: var(--on-tint, #fff); border-color: transparent; }
:root[data-bright] .chip.on::before { background: var(--green); box-shadow: none; }
:root[data-bright] input[type=checkbox], :root[data-bright] input[type=radio] { accent-color: var(--tint); }
:root[data-bright] input[type=checkbox]:checked { background: var(--tint); border-color: transparent; }
:root[data-bright] input[type=checkbox]:checked::after { background: var(--on-tint, #fff); }
:root[data-bright] .wiz-type:hover, :root[data-bright] .wiz-type:focus-visible { border-color: var(--tint); }
/* Readings: just a small coloured label, numbers stay neutral */
:root[data-bright] .tile .k { color: var(--tc, var(--muted)); }
:root[data-bright] .tile:nth-child(6n+1) { --tc: var(--blue); }
:root[data-bright] .tile:nth-child(6n+2) { --tc: var(--green); }
:root[data-bright] .tile:nth-child(6n+3) { --tc: var(--orange); }
:root[data-bright] .tile:nth-child(6n+4) { --tc: var(--pink); }
:root[data-bright] .tile:nth-child(6n+5) { --tc: var(--indigo); }
:root[data-bright] .tile:nth-child(6n+6) { --tc: var(--teal); }
:root[data-bright] .tile.hero .k { color: var(--muted); }
:root[data-bright] .subnav [role=tab].on, :root[data-bright] .wiz-tab.on { background: #fff; color: #000; font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / .12), 0 0 0 .5px rgb(0 0 0 / .04); }
:root[data-bright][data-theme=dark] .subnav [role=tab].on, :root[data-bright][data-theme=dark] .wiz-tab.on { background: #636366; color: #fff; }
:root[data-bright] .seg input:checked + span { background: #fff; color: #000; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
:root[data-bright][data-theme=dark] .seg input:checked + span { background: #636366; color: #fff; }
.setting-block { margin-top: 8px; }
.setting-block p { margin: 0; width: 100%; }

/* Satellite toggle: under the light/dark map button */
.trace-sat { top: 56px; }
.trace-sat[aria-pressed=true] { background: var(--tint, #e4531a); color: var(--on-tint, #fff); border-color: transparent; }
.map-sat .trace-maptheme:not(.trace-sat) { display: none; }
.map-sat .trace-sat { top: 10px; }

/* ---------- bottom bar: Home | Alerts | Trail | Trips | System; mic in the header ---------- */
.tabbar { grid-template-columns: repeat(5, 1fr); }
.top .mic { width: 40px; height: 40px; margin: 0 0 0 4px; box-shadow: none; align-self: center; }
.top .mic .i { width: 20px; height: 20px; }
.top .mic.handsfree:not(.listening) { box-shadow: 0 0 0 3px rgb(var(--teal) / .35); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(var(--teal) / .55); } 100% { box-shadow: 0 0 0 14px rgb(var(--teal) / 0); } }
:root[data-bright] .top .mic { background: var(--tint); color: var(--on-tint, #fff); }
:root[data-bright] .top .mic.listening { background: var(--red); }
.transcript { top: calc(64px + env(safe-area-inset-top)); bottom: auto; }

/* ---------- Alerts: activity chips + a banner per category ---------- */
.subnav.cats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px 6px; margin: 10px -16px 6px;
  background: none; border: 0; border-radius: 0; scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
.subnav.cats::-webkit-scrollbar { display: none; }
.subnav.cats [role=tab] { flex: none; display: inline-flex; gap: 6px; align-items: center; padding: 9px 14px; border-radius: 999px;
  background: var(--glass-2); border: 1px solid var(--edge); color: var(--text); font-weight: 600; scroll-snap-align: start; }
.subnav.cats [role=tab].on { background: var(--white); color: var(--ink); border-color: transparent; }
:root[data-bright] .subnav.cats [role=tab].on { background: var(--tint); color: var(--on-tint, #fff); box-shadow: none; }
.subnav.cats .emo { font-size: 1.1em; line-height: 1; }
.cat-banner { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; margin: 4px 0 12px;
  background: linear-gradient(135deg, rgb(var(--cc) / .22), rgb(var(--cc) / .08)); border: 1px solid rgb(var(--cc) / .25); }
.cat-banner .cat-emo { font-size: 2.4rem; line-height: 1; }
.cat-banner b { display: block; font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.cat-banner small { display: block; color: var(--muted); font-size: .9rem; }
.cat-fitness { --cc: 255 45 85; } .cat-trekking { --cc: 52 199 89; } .cat-cycling { --cc: 255 149 0; }
.cat-driving { --cc: 10 132 255; } .cat-everyday { --cc: 255 204 0; }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  .subnav.cats { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; }
}

/* ---------- second mic: floating at the bottom right, in thumb reach ---------- */
.mic-fab { position: fixed; z-index: 11; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; margin: 0;
  border-radius: 50%; box-shadow: 0 10px 24px -8px rgb(0 0 0 / .55); }
.mic-fab .i { width: 24px; height: 24px; }
.mic-fab.handsfree:not(.listening) { box-shadow: 0 0 0 4px rgb(var(--teal) / .35), 0 10px 24px -8px rgb(0 0 0 / .55); }
:root[data-bright] .mic-fab { background: var(--tint); color: var(--on-tint, #fff); }
:root[data-bright] .mic-fab.listening { background: var(--red); }
body { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  .mic-fab { right: auto; left: calc((var(--rail) - 56px) / 2); bottom: calc(18px + env(safe-area-inset-bottom)); box-shadow: none; }
  body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* Sensors tab: the "turn on sensors" link sits above the menu */
#btnSensorsQuick { order: 0; }
body[data-tab=system] #btnSensorsQuick { align-self: stretch; justify-content: flex-start; margin: 10px 0 0; padding: 12px; border-radius: 14px;
  background: var(--glass-2); border: 1px solid var(--edge); color: var(--text); font-weight: 600; text-align: left; }
body[data-tab=system][data-sub] #btnSensorsQuick { display: none; }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  body[data-tab=system] #btnSensorsQuick { grid-column: 1; }
  body[data-tab=system][data-sub] #btnSensorsQuick { display: inline-flex; }
  body[data-tab=system] #btnSensorsQuick[hidden] { display: none !important; }
}

/* ---------- trail controls on the map: stop mode across the top, Start at the top right ---------- */
.trace-controls.on-map { position: absolute; z-index: 3; top: 10px; left: 10px; right: 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px; align-items: start; pointer-events: none; }
.trace-controls.on-map > * { pointer-events: auto; }
.trace-controls.on-map .seg { grid-column: 1 / -1; padding: 3px; gap: 3px; border-radius: 14px;
  background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-color: var(--edge-2);
  box-shadow: 0 6px 18px -8px rgb(0 0 0 / .45); }
.trace-controls.on-map .seg span { padding: 7px 4px; font-size: .86rem; }
.trace-controls.on-map .value-row { grid-column: 1; justify-self: start; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 14px;
  background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--edge-2); }
.trace-controls.on-map .value-row input { flex: none; width: 76px; font-size: 1.1rem; padding: 6px 10px; border-radius: 10px; }
.trace-controls.on-map > .row { grid-column: 2; margin: 0; flex-wrap: nowrap; gap: 6px; justify-content: flex-end; }
.trace-controls.on-map .big { flex: none; min-height: 42px; padding: 9px 16px; font-size: .98rem; border-radius: 14px; box-shadow: 0 8px 20px -8px rgb(0 0 0 / .55); }
.trace-controls.on-map .ghost { padding: 9px; min-width: 42px; min-height: 42px; border-radius: 14px; font-size: 0;
  background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--edge-2); }
.trace-controls.on-map .ghost .i { width: 18px; height: 18px; }
/* while recording: status pill on the left, End trail at the top right */
.trace-controls.on-map .trace-live { grid-column: 1; justify-self: start; align-self: center; padding: 8px 12px; border-radius: 999px; font-size: .84rem;
  color: var(--text); background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--edge-2); }
.trace-controls.on-map > .big { grid-column: 2; }
/* map buttons move below the controls; Follow-me goes to the bottom right */
.trace-maptheme { top: 118px; }
.trace-sat { top: 164px; }
.map-sat .trace-sat { top: 118px; }
.trace-recenter { top: auto; bottom: 34px; right: 10px; }
.trace-wrap { margin-bottom: 8px; }

.trace-controls.on-map .big.danger { background: #ff3b30; color: #fff; border-color: transparent; }
.trace-controls.on-map .big.danger:hover { background: #ff453a; }
/* phones: the controls live on the map now, so the map gets the room */
.trace-map { height: clamp(320px, calc(100vh - 300px), 900px); height: clamp(320px, calc(100dvh - 300px), 900px); }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  #trailNav { display: none !important; }
  .trace-map { height: clamp(360px, calc(100dvh - 150px), 980px); }
}

/* ---------- Home: My alerts (first 5, then scroll), Readings as a drop-down below ---------- */
.drop-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 0; background: none; border: 0; border-radius: 10px; color: inherit; }
.drop-head:hover { background: none; }
.drop-head h2 { margin: 0; }
.drop-chev { display: inline-flex; color: var(--muted); transition: transform .2s; }
.drop-chev .i { width: 18px; height: 18px; }
#readingsCard.open .drop-chev { transform: rotate(180deg); }
#readingsCard:not(.open) #tilesMore { display: none; }
#readingsCard:not(.open) .card-head { margin-bottom: 0; }
.rules { max-height: calc(5 * 62px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.rules li { min-height: 62px; }
h2 .count:not(:empty) { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--glass-3); color: var(--text); font-size: .72rem; letter-spacing: 0; }

/* Readings: an accordion on the Sensors tab, under the "turn on sensors" link */
body[data-tab=system] #btnSensorsQuick { order: 2 !important; }
body[data-tab=system] #readingsCard { order: 3 !important; display: block; border-top: 0; }
body[data-tab=system][data-sub] #readingsCard { display: none; }
#readingsCard .card-head { padding: 4px 12px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--edge); }
#readingsCard.open .card-head { margin-bottom: 10px; }
#readingsCard .drop-head { flex: 1; }
#readingsCard:not(.open) #tilesMore { display: none; }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  body[data-tab=system] #readingsCard, body[data-tab=system][data-sub] #readingsCard { display: block; grid-column: 1; }
  body[data-tab=system] #readingsCard #tilesMore { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
#readingsCard .drop-head { justify-content: flex-start; white-space: nowrap; min-width: 0; }
#readingsCard .card-head > #clockMode { white-space: nowrap; }

/* Accent colour picker (Settings → Appearance) */
.accent-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 4px 0 6px; position: relative; }
.accent-row label { position: relative; cursor: pointer; }
.accent-row input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.accent-row span { display: block; width: 38px; height: 38px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .15); transition: transform .15s; }
.accent-row .custom span { background: conic-gradient(#ff3b30, #ffcc00, #34c759, #30b0c7, #0a84ff, #bf5af2, #ff2d55, #ff3b30); }
.accent-row .custom span.set { background: var(--sw); }
.accent-row .custom span::after { content: '+'; display: grid; place-items: center; height: 100%; color: #fff; font-weight: 700; font-size: 1.2rem; text-shadow: 0 1px 2px rgb(0 0 0 / .5); }
.accent-row input:checked + span { outline: 3px solid var(--tint-text, var(--tint, #ff6a2b)); outline-offset: 3px; transform: scale(1.05); }
.accent-row input:focus-visible + span { outline: 3px solid var(--ink, #fff); outline-offset: 3px; }
#accentColor { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; right: 0; bottom: 0; border: 0; padding: 0; }
.accent-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }

/* Right-to-left languages (Arabic, Hebrew): html[dir=rtl] */
[dir=rtl] select { padding-right: 12px; padding-left: 34px; background-position: left 10px center; }
[dir=rtl] .tile, [dir=rtl] .menu-row, [dir=rtl] .wiz-type, [dir=rtl] .trip-main,
[dir=rtl] body[data-tab=system] #btnSensorsQuick { text-align: right; }
[dir=rtl] .tile .v .u { margin-left: 0; margin-right: .25em; }
[dir=rtl] .help-list { padding-left: 0; padding-right: 20px; }
[dir=rtl] .log time, [dir=rtl] .trip-alerts time { margin-right: 0; margin-left: 8px; }
[dir=rtl] .menu-chev .i { transform: rotate(90deg); }
[dir=rtl] .sub-bar .sub-back .i { transform: scaleX(-1); }
[dir=rtl] .sub-bar .sub-back { padding: 7px 6px 7px 10px; }
[dir=rtl] .mic-fab { right: auto; left: 16px; }
[dir=rtl] .tabbar .tab-dot { left: auto; right: calc(50% + 8px); }
[dir=rtl] input[type=checkbox] { direction: ltr; } /* switches keep their on-to-the-right look */
/* numbers, times and units read left-to-right inside RTL text */
[dir=rtl] .tile .v { direction: ltr; text-align: right; }
[dir=rtl] time { unicode-bidi: isolate; direction: ltr; display: inline-block; }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  [dir=rtl] body { padding-left: 0; padding-right: var(--rail); }
  [dir=rtl] .tabbar { left: auto; right: 0; border-right: 0; border-left: 1px solid rgb(var(--fg) / .07); }
  [dir=rtl] .mic-fab { left: auto; right: calc((var(--rail) - 56px) / 2); }
  [dir=rtl] .transcript { left: 24px; right: calc(var(--rail) + 24px); }
}
.lang-pick select { min-width: 200px; }
/* Language row in the Settings menu: the whole row is a native picker (transparent select on top). */
.menu-lang { position: relative; cursor: pointer; }
.menu-lang select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; z-index: 1; border: 0; }
.menu-lang:focus-within { background: var(--glass-2); }
.lang-hint { font-size: 11px; font-weight: 400; color: var(--muted); margin-inline-start: 6px; }

.sound-own { align-items: center; gap: 8px; margin-bottom: 8px; }
.sound-own .hidden { display: none; }
#soundOwnName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.sound-vol { align-items: center; gap: 10px; margin-bottom: 8px; }
.sound-vol input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent, currentColor); }
.sound-vol.off { opacity: .55; }
#soundVolVal { min-width: 3.2em; text-align: right; }

.lang-hint { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }
.lang-hint .i { width: 13px; height: 13px; }

/* ---------- sign-in screen (account required) ---------- */
html.gated body > *:not(#gate):not(script):not(.toast):not(#toast) { visibility: hidden; }
html.gated, html.gated body { overflow: hidden; }
.gate { position: fixed; inset: 0; z-index: 9999; overflow-y: auto; background: var(--bg); display: flex; justify-content: center; align-items: flex-start;
  padding: max(28px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom)); }
.gate[hidden] { display: none; }
.gate-card { width: 100%; max-width: 400px; margin: auto 0; display: flex; flex-direction: column; gap: 12px; }
.gate-brand { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 700; margin-bottom: 10px; }
.gate-brand img { width: 40px; height: 40px; border-radius: 11px; }
.gate h1 { font-size: 1.6rem; margin: 6px 0 0; font-weight: 700; }
.gate p { margin: 0; }
.gate form { display: flex; flex-direction: column; gap: 12px; }
.gate-field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--muted); }
.gate-field input, .gate-field select { width: 100%; box-sizing: border-box; color: var(--text); }
.gate button.wide { width: 100%; justify-content: center; padding: 13px 16px; border-radius: 14px; font-size: 1rem; }
.gate button.primary { background: var(--tint, #ff6a2b); color: var(--on-tint, #fff); border-color: transparent; }
.gate button.primary:hover { filter: brightness(1.08); }
.gate button.primary:disabled { opacity: .6; }
.gate button.link { align-self: center; padding: 6px; background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; font: inherit; font-size: .92rem; }
.gate button.link:hover { color: var(--text); background: none; }
.gate-alt { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 14px; padding-top: 18px; border-top: 1px solid var(--edge); }
.gate-msg { color: var(--bad); font-size: .9rem; }
.gate-msg.ok { color: var(--text); background: var(--glass-2); padding: 10px 12px; border-radius: 12px; }
#setAccount .acct-lang { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
#setAccount .acct-lang select { width: 100%; }
html.gated #toast { z-index: 10000; }

/* My alerts: Start all and Add under the list */
.rules-foot { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.rules-foot #btnStartAll { flex: 1; justify-content: center; }

/* ---------- Trail: map only (no Map/Tools bar); map buttons on the left of the Start trail row ---------- */
/* Saved trips | Tools | Sharing sit under the map (phones) or beside it (wide screens). Phones: leave room so the bar shows. */
@media not ((min-width: 900px) and (min-height: 600px)) {
  body[data-tab=trail] .trace-map { height: clamp(300px, calc(100dvh - 330px), 900px); }
}
.trace-controls.on-map .seg { order: 0; }
.trace-controls.on-map > .row { order: 1; grid-column: 1 / -1; justify-content: flex-end; }
.trace-controls.on-map .value-row, .trace-controls.on-map .trace-live { order: 2; grid-column: 1 / -1; }
.trace-controls.on-map .map-btns { display: flex; gap: 6px; margin-right: auto; }
.trace-controls.on-map .map-btns .trace-maptheme { position: static; top: auto; left: auto; display: inline-grid; place-items: center;
  min-width: 42px; min-height: 42px; padding: 9px; border-radius: 14px; }


/* Settings > Update & about (Android app): text full width, button on its own row below */
.update-card { padding: 12px; border: 1px solid var(--edge); border-radius: 16px; background: var(--glass); margin: 4px 0 12px; }
.update-card p { margin: 0 0 10px; }
.update-card .row { margin: 0; }

/* ---------- My alerts (light orange) and My trails (light green): two clearly separate cards ---------- */
#targetsCard, #homeTrails { --box-bg: rgb(249 115 22 / .10); --box-edge: rgb(249 115 22 / .32); --box-ink: #fdba74; --box-btn: #ea580c;
  background: var(--box-bg); border: 1px solid var(--box-edge) !important; border-radius: 18px; padding: 14px 16px; margin: 10px 0; }
#homeTrails { --box-bg: rgb(34 197 94 / .10); --box-edge: rgb(34 197 94 / .32); --box-ink: #86efac; --box-btn: #16a34a; }
:root[data-theme=light] #targetsCard { --box-bg: #fff1e6; --box-edge: #fdc9a0; --box-ink: #c2410c; }
:root[data-theme=light] #homeTrails { --box-bg: #eafaf0; --box-edge: #a7e8bf; --box-ink: #15803d; }
:is(#targetsCard, #homeTrails) h2 { color: var(--box-ink); display: inline-flex; align-items: center; gap: 8px; }
:is(#targetsCard, #homeTrails) h2 [data-icon] { color: var(--box-ink); opacity: 1; }
:is(#targetsCard, #homeTrails) .rules li { border-bottom-color: var(--box-edge); }
:is(#targetsCard, #homeTrails) .rules-foot .pill { border-color: var(--box-edge); color: var(--box-ink); background: transparent; }
#homeTrails .rules .go { background: var(--box-btn); color: #fff; border-color: transparent; }

/* ---------- in-app confirm dialog (src/dialog.js) ---------- */
.dlg-back { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px;
  background: rgba(0, 0, 0, .5); opacity: 0; transition: opacity .15s ease; }
.dlg-back.in { opacity: 1; }
.dlg { width: min(100%, 380px); background: var(--menu-bg); color: var(--text); border: 1px solid var(--edge-2);
  border-radius: var(--radius); padding: 22px 20px 16px; box-shadow: 0 18px 50px var(--shadow);
  transform: scale(.96); transition: transform .15s ease; }
:root[data-theme=light] .dlg { background: #fff; }
.dlg-back.in .dlg { transform: none; }
.dlg-title { margin: 0 0 6px; font-size: 1.1rem; text-transform: none; letter-spacing: -.01em; color: var(--text); }
.dlg-msg { margin: 0 0 20px; font-size: 1.05rem; line-height: 1.4; white-space: pre-line; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dlg-btns button { min-width: 96px; }
.dlg-btns .dlg-ok { background: var(--tint, #ff6a2b); color: var(--on-tint, #fff); border-color: transparent; }
.dlg-btns .dlg-ok.danger { background: #d93c3c; color: #fff; }
.dlg-btns .dlg-ok:hover { filter: brightness(1.08); }

/* ---------- Trail > Sharing (src/sharing.js) ---------- */
#shareBody .card-head h2 { display: flex; align-items: center; gap: 8px; }
.share-sec { padding: 12px 0 14px; border-top: 1px solid var(--edge); display: grid; gap: 10px; }
.share-sec:first-of-type { border-top: 0; padding-top: 4px; }
.share-sec h3 { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.share-sec .ask { margin: 0; color: var(--muted); }
.share-sec p.small { margin: 0; }
.share-form { display: flex; gap: 8px; align-items: stretch; }
.share-form input, .share-pick { flex: 1; min-width: 0; width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--edge-2); background: var(--glass); color: var(--text); font: inherit; }
.share-form button { flex: none; white-space: nowrap; }
.share-sec > .ghost.small { justify-self: start; }
.live-tag { color: #f43f5e; font-weight: 700; }
.share-people { display: flex; flex-wrap: wrap; gap: 5px; }
.share-person { font-size: .76rem; padding: 3px 9px; border-radius: 999px; background: var(--glass-2); color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.share-list li { display: flex; align-items: center; gap: 4px; padding: 4px 0; border-bottom: 1px solid var(--edge); }
.share-list li:last-child { border-bottom: 0; }
.share-list .share-main { flex: 1; min-width: 0; display: grid; gap: 3px; justify-items: start; justify-content: stretch; text-align: start; background: none; border: 0; padding: 8px 4px; color: var(--text); font: inherit; cursor: pointer; }
.share-list .share-main b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-list .share-main small { color: var(--muted); }
.share-list li.unseen .share-main b::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #f43f5e; margin-inline-start: 6px; vertical-align: 2px; }
.share-list .icon-btn { flex: none; padding: 9px; border-radius: 12px; }
.danger-text { color: var(--bad); }

/* Settings > Update & about (Android app): run in the background */
.bg-switches { display: grid; gap: 8px; margin: 0 0 12px; }
#bgCard .small { margin: 0 0 10px; }

/* ---------- Trail: live info under the map ---------- */
.trail-info { margin-top: 8px; }
.trail-info .ti-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border-radius: 12px; border: 0;
  background: rgb(var(--fg) / .05); color: var(--text); font-size: .95rem; font-weight: 600; text-align: start; font-variant-numeric: tabular-nums; }
.trail-info .ti-sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trail-info .ti-head .i { flex: none; transition: transform .2s; }
.trail-info .ti-head[aria-expanded=true] .i { transform: rotate(180deg); }
.trail-info .ti-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.trail-info .ti { background: rgb(var(--fg) / .05); border-radius: 12px; padding: 7px 9px; min-width: 0; }
.trail-info .ti small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.25; }
.trail-info .ti b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.trail-info .ti-wide { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; }
.trail-info .ti-wide b { font-weight: 600; }
/* Share button just before Start / End trail */
.trace-controls.on-map .share-btn { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 42px; padding: 9px 12px; border-radius: 14px;
  font-size: .9rem; color: var(--text); background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--edge-2); }
.trace-controls.on-map .share-btn[aria-pressed=true] { border-color: #2dd4bf; color: #2dd4bf; }
.trace-controls.on-map .share-btn.live { border-color: #f43f5e; color: #f43f5e; }

/* Start / End trail popup: the choices sit loose (no box around them), 2 per row; an odd last one spans the row */
.trail-end .end-seg { flex-wrap: wrap; margin: 8px 0 14px; padding: 0; background: none; border: 0; border-radius: 0; }
.trail-end .end-seg label { flex: 1 1 40%; }
.trail-end .end-seg span { padding: 10px 4px; font-size: .9rem; border: 1px solid var(--edge-2); border-radius: 12px; }
.trail-end .end-seg input:checked + span { border-color: transparent; }
.trail-end .end-seg input:focus-visible + span { outline: 2px solid var(--white); outline-offset: 2px; }
.trail-end .end-value { margin: 0 0 18px; }
.trail-end .end-value input { width: 90px; flex: none; }
.trail-end .dlg-ok.danger { background: #ff3b30; }

/* ---------- Settings behind the ☰ button (top right); mic centered, half over the bottom bar ---------- */
.tabbar { grid-template-columns: 1fr 1fr 84px 1fr 1fr; } /* the middle column stays free for the mic */
#tabTrail { grid-column: 4; }
#tabTrips { grid-column: 5; }
.mic-fab, [dir=rtl] .mic-fab { right: auto; left: 50%; margin-left: -28px; bottom: calc(35px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  .mic-fab { margin-left: 0; left: calc((var(--rail) - 56px) / 2); bottom: calc(18px + env(safe-area-inset-bottom)); }
  [dir=rtl] .mic-fab { margin-left: 0; left: auto; right: calc((var(--rail) - 56px) / 2); }
}

/* ---------- Trail: map only; (i) on the map opens the info in a bottom sheet ---------- */
.trace-infobtn { position: absolute; z-index: 2; left: 10px; bottom: 34px; padding: 8px; border-radius: 12px; background: var(--float-bg);
  color: var(--text); border: 1px solid var(--edge-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); display: grid; place-items: center; }
.trace-infobtn:hover { background: #ffffff; }
.map-dark .trace-infobtn { background: rgba(22, 24, 30, .85); color: #f4f5f7; border-color: rgba(255, 255, 255, .12); }
[dir=rtl] .trace-infobtn { left: auto; right: 10px; }
[dir=rtl] .trace-recenter { right: auto; left: 10px; }
.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s ease; }
.sheet-back.in { opacity: 1; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 760px; margin: 0 auto; max-height: 80dvh; overflow-y: auto;
  background: var(--menu-bg); color: var(--text); border-radius: 28px 28px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px var(--shadow); transform: translateY(100%); transition: transform .22s ease; touch-action: pan-y; }
:root[data-theme=light] .sheet { background: #fff; }
.sheet-back.in .sheet { transform: none; }
.sheet-grab { width: 44px; height: 5px; border-radius: 3px; background: rgb(var(--fg) / .25); margin: 4px auto 14px; cursor: grab; }
.sheet-title { margin: 0 0 14px; font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; text-transform: none; color: var(--text); cursor: grab; touch-action: none; }
.sheet-body > p { margin: 0 0 8px; }
.sheet .trail-info { margin: 0 0 14px; }
.sheet .trail-info .ti-grid { margin-top: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sheet .trail-info .ti { padding: 10px 12px; }
.sheet .trail-info .ti b { font-size: 18px; }
.sheet .trail-legend, .sheet .trail-profile { margin: 0 0 14px; }
@media (min-width: 900px) and (min-height: 600px), (min-width: 900px) and (pointer: fine) {
  .sheet { left: var(--rail); }
  [dir=rtl] .sheet { left: 0; right: var(--rail); }
}
/* alert forms inside the bottom sheet */
.sheet .rule-form { background: none; border: 0; padding: 0; margin: 0; }
.sheet .wiz-form .ask { margin: 0; display: flex; align-items: center; gap: 12px; color: var(--text); font-size: 1.05rem; }
.sheet .wiz-form .ask svg { flex: none; }
.sheet .wiz-form button.big { width: 100%; }
.rule-form input, .rule-form select { color: var(--text); }
/* Google Maps / Street View links in the map popups */
.trace-pop .pop-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.trace-pop .pop-links a { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  color: var(--text); background: rgb(var(--fg) / .08); text-decoration: none; white-space: nowrap; }
.trace-pop .pop-links a:hover { background: rgb(var(--fg) / .14); }
.trace-pop .pop-links .i { width: 15px; height: 15px; }
/* Home: My alerts | My trails tabs (one list at a time) */
#homeNav [role=tab] { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#homeNav [role=tab] .i { width: 18px; height: 18px; }
/* icon and count inside the tab are not .seg choice pills: no padding, same colour as the tab (white when selected) */
#homeNav [role=tab] span { display: inline-flex; padding: 0; border-radius: 0; color: inherit; background: none; }
#homeNav .count:empty { display: none; }
body[data-tab=home] #homeNav { order: 6; }
body[data-tab=home][data-session=idle] #homeNav { order: 1; }
body[data-tab=home][data-home=trails] #targetsCard, body[data-tab=home][data-home=alerts] #homeTrails { display: none !important; }
.dlg-count { font-variant-numeric: tabular-nums; opacity: .7; }
/* Alerts: the category's one-line subtitle, centred, no card */
.cat-sub { margin: 6px 0 14px; text-align: center; color: var(--muted); font-size: .98rem; }
/* Settings: alert categories (drag to sort, tap to edit) */
.cat-order, .card-pick { list-style: none; margin: 6px 0 4px; padding: 0; display: grid; gap: 6px; }
.cat-order li, .card-pick li { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 2px; border-radius: 12px; background: rgb(var(--fg) / .05); }
.cat-order li.dragging, .card-pick li.dragging { background: var(--glass-3, rgb(var(--fg) / .12)); box-shadow: 0 8px 20px -8px var(--shadow); position: relative; z-index: 1; }
.drag { flex: none; display: grid; place-items: center; width: 34px; height: 40px; color: var(--muted); cursor: grab; touch-action: none; }
.cat-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; background: none; color: var(--text); text-align: start; border-radius: 10px; }
.cat-row:disabled { opacity: 1; cursor: default; }
.cat-row .emo { font-size: 1.3rem; }
.cat-row .nm, .pick-card .nm { flex: 1; min-width: 0; font-weight: 600; }
.cat-row small, .pick-card small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.cat-row .i { color: var(--muted); }
.cat-edit { display: grid; gap: 12px; }
.cat-edit label { display: grid; gap: 6px; font-size: .82rem; color: var(--muted); }
.cat-edit input[type=text], .cat-edit input:not([type]) { color: var(--text); }
.cat-edit-top { display: grid; grid-template-columns: 76px 1fr; gap: 10px; }
.cat-edit .emo-in input { text-align: center; font-size: 1.4rem; padding-block: 6px; }
.cat-edit .card-pick { max-height: 44dvh; overflow-y: auto; }
.pick-card { flex: 1; min-width: 0; display: flex !important; align-items: center; gap: 10px; padding: 4px 4px; color: var(--text) !important; font-size: .95rem !important; cursor: pointer; }
.pick-card input { flex: none; margin: 0 4px 0 0; }
.src-tag { display: inline-block; margin-inline-start: 6px; padding: 0 6px; border-radius: 6px; font-style: normal; font-weight: 600; font-size: .68rem; line-height: 1.5; vertical-align: 1px; background: rgb(var(--fg) / .08); color: var(--muted); }
.card-pick-head { display: flex; align-items: center; gap: 7px; margin: 14px 0 0; }
.card-pick-head .i { flex: none; }
.cat-edit .card-pick.off { max-height: 30dvh; }
.card-pick li.off { opacity: .5; }
.card-pick li.off .drag { visibility: hidden; }
.card-pick li.off .pick-card { cursor: not-allowed; }
/* Wear OS cards in the web app (no watch bridge): shown, switched off */
.wiz-type.off { opacity: .5; cursor: not-allowed; }
.wiz-type.off:hover, .wiz-type.off:focus-visible { transform: none; }
.wiz-type .src-tag { display: table; margin: 3px 0 1px; }
.wiz-note { display: flex; align-items: center; gap: 7px; margin: 10px 0 0; }
.wiz-note .i { flex: none; }
.cat-edit .actions { display: flex; gap: 8px; align-items: center; }
.cat-edit .actions .sp { flex: 1; }
.danger-text { color: var(--red, #ef4444); }

/* ---------- No box around groups of tabs or choices (Home / Trips tabs, Settings pickers, alert forms, trail popups):
   each tab or choice is its own outlined button; the selected one is filled. ---------- */
.seg, .subnav.seg, .trace-controls.on-map .seg { padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none; }
.seg > label > span, .subnav.seg [role=tab] { border: 1px solid var(--edge-2); border-radius: 12px; }
.seg input:checked + span, .subnav.seg [role=tab].on { border-color: transparent; }
.subnav.seg { gap: 8px; margin-top: 12px; }
.subnav.seg [role=tab] { padding: 9px 4px; overflow: hidden; text-overflow: ellipsis; }
.trace-controls.on-map .seg > label > span { background: var(--float-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }

/* Password fields: eye button to show / hide (src/pw-eye.js) */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > input { width: 100%; box-sizing: border-box; padding-inline-end: 48px; }
.pw-eye { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; margin: 0; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; box-shadow: none; }
.pw-eye:hover, .pw-eye[aria-pressed=true] { color: var(--text); background: rgb(var(--fg) / .06); }

/* Trip map: full-screen map for a saved trip (src/trip-map.js), separate from the Trail map */
.tripmap { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; background: var(--bg); }
.tripmap[hidden] { display: none; }
html.tripmap-open, html.tripmap-open body { overflow: hidden; }
.tripmap-head { display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px 6px; background: var(--header-bg); color: var(--text); border-bottom: 1px solid var(--edge); }
.tripmap-head .icon-btn { padding: 8px; color: var(--text); }
.tripmap-title { display: flex; flex-direction: column; min-width: 0; }
.tripmap-title b { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tripmap-title small { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tripmap-wrap { position: relative; flex: 1; min-height: 0; }
.tripmap-map { position: absolute !important; inset: 0; } /* maplibre-gl.css sets .maplibregl-map to relative */
.tripmap-modes { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 2; display: flex; gap: 2px; padding: 3px;
  border-radius: 999px; background: rgba(255, 255, 255, .94); box-shadow: 0 2px 10px rgba(0, 0, 0, .22); }
.tripmap-modes button { border: 0; margin: 0; min-height: 0; padding: 8px 14px; border-radius: 999px; background: transparent; color: #1f2329; font-size: .88rem; font-weight: 600; cursor: pointer; }
.tripmap-modes button.on { background: #1f2329; color: #ffffff; }
.tripmap.map-dark .tripmap-modes { background: rgba(22, 24, 30, .9); }
.tripmap.map-dark .tripmap-modes button { color: #e8eaef; }
.tripmap.map-dark .tripmap-modes button.on { background: #ffffff; color: #15171c; }
.tripmap-fit { position: absolute; right: 10px; top: 10px; z-index: 2; padding: 9px; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .08);
  background: rgba(255, 255, 255, .94); color: #1f2329; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); cursor: pointer; line-height: 0; }
.tripmap.map-dark .tripmap-fit { background: rgba(22, 24, 30, .9); color: #f4f5f7; border-color: rgba(255, 255, 255, .12); }
.tripmap .maplibregl-ctrl-bottom-right { bottom: calc(64px + env(safe-area-inset-bottom)); }
