/* NomadMate offline layer styles (top bar, connection pill, Emergency screen, accessibility fixes).
 * Loaded after the inline styles in index.html, so rules here win. */

:root {
  --focus: #fbbf24;
  --red: #b91c1c;
  --red-dark: #7f1d1d;
}

/* ---------------------------------------------------------- base / a11y */
html { scroll-behavior: smooth; }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.2em; }
.icon-sm { width: 1em; height: 1em; margin-left: 4px; vertical-align: -0.12em; }
.badge .icon { margin-right: 2px; color: #fbbf24; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
main:focus, h1:focus { outline: none; }
main:focus-visible, h1:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 1000;
  background: #fbbf24; color: #0b1220; font-weight: bold; padding: 12px 16px; border-radius: 10px;
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

textarea::placeholder { color: #94a3b8; opacity: 1; }

/* Primary buttons: dark text on amber for contrast (white on amber was too low) */
.btn-primary { color: #0b1220; background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.btn-secondary { color: var(--text); }
button, .btn-primary, .btn-secondary { min-height: 44px; }
button .icon { margin-right: 8px; }
.mode-pill { min-height: 44px; }
.copy-plan-btn, a[href*="/pdf"]:not([hidden]) { min-height: 44px; display: inline-flex !important; align-items: center; padding: 10px 14px !important; font-size: 14px !important; }
#tripHistory a, .history a { text-decoration: underline; }
.history-time, .history-a { overflow-wrap: anywhere; }

a { color: #fbbf24; }
a:hover { color: #fde68a; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  button:hover { transform: none !important; }
}

/* ------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(11, 18, 32, 0.96); border-bottom: 1px solid #334155;
  backdrop-filter: blur(8px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-height: 44px; border-radius: 10px; }
.brand-icon { border-radius: 9px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 18px; }
.brand-sub { font-size: 12px; color: #cbd5e1; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.conn-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px;
  border-radius: 999px; font-size: 13px; font-weight: bold; border: 1px solid transparent;
}
.conn-pill.is-online { background: #064e3b; color: #d1fae5; border-color: #10b981; }
.conn-pill.is-offline { background: #78350f; color: #fef3c7; border-color: #f59e0b; }
.conn-pill.is-degraded { background: #78350f; color: #fef3c7; border-color: #f59e0b; }
.conn-pill.is-checking { background: #1f2937; color: #e2e8f0; border-color: #475569; }

.emergency-top {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  background: var(--red); color: #fff; font-weight: bold; text-decoration: none; border-radius: 12px;
  border: 2px solid #fecaca;
}
.emergency-top:hover { color: #fff; background: #991b1b; }
.emergency-top[aria-current="page"] { background: #fff; color: var(--red); border-color: var(--red); }

/* ----------------------------------------------------------- update bar */
.update-bar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 200; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: 14px; background: #1e3a8a; color: #fff; border: 2px solid #93c5fd;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.update-bar[hidden] { display: none; }
.update-bar span { flex: 1 1 200px; font-weight: bold; }
.update-bar .btn-secondary { background: #0b1220; }

/* ------------------------------------------------------- needs signal */
.needs-signal {
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; padding: 12px 14px;
  border-radius: 12px; background: #78350f; color: #fef3c7; border: 1px solid #f59e0b; line-height: 1.5;
}
.needs-signal[hidden] { display: none; }
.needs-signal a { color: #fff; font-weight: bold; }
.is-needs-signal textarea, .is-needs-signal button:disabled { opacity: 0.55; }

/* --------------------------------------------------------- install/footer */
.install-area { margin-top: 22px; }
.install-area[hidden], [hidden] { display: none !important; }
.site-footer { margin-top: 30px; padding: 20px 0 40px; border-top: 1px solid #1f2937; color: #cbd5e1; font-size: 14px; }
.site-footer p { margin: 0 0 6px; }

/* -------------------------------------------------------- Emergency view */
.emergency-view .wrap { padding-top: 20px; }
.emergency-view h1 { font-size: 36px; margin: 6px 0 14px; letter-spacing: -0.02em; }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: bold; text-decoration: none; }
.back-link .icon { margin-right: 4px; }
.em-section { background: rgba(17,24,39,0.92); border: 1px solid #334155; border-radius: 18px; padding: 20px; margin: 0 0 18px; }
.em-section h2 { margin: 0 0 8px; font-size: 22px; }
.em-section h3 { margin: 16px 0 8px; font-size: 17px; }
.em-intro { margin: 0 0 12px; color: #cbd5e1; line-height: 1.6; }
.em-lead { margin: 0 0 12px; font-size: 20px; font-weight: bold; }
.loading-note { color: #cbd5e1; }

.callout { display: flex; gap: 12px; align-items: flex-start; border-radius: 14px; padding: 14px 16px; margin: 0 0 18px; line-height: 1.55; }
.callout > .icon { width: 1.6em; height: 1.6em; margin-top: 2px; }
.callout p { margin: 0 0 6px; }
.callout-title { font-weight: bold; font-size: 16px; }
.callout-warn { background: #451a03; border: 1px solid #f59e0b; color: #fef3c7; }
.callout-warn a { color: #fff; }
.callout-draft { background: #1e1b4b; border: 2px dashed #a5b4fc; color: #e0e7ff; }
.callout-inline { background: #451a03; border: 1px solid #f59e0b; color: #fef3c7; padding: 10px 12px; border-radius: 10px; margin: 10px 0 0; }

.call-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.call-btn {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 14px 18px; border-radius: 16px;
  background: #1f2937; color: #fff; text-decoration: none; border: 2px solid #64748b; font-weight: bold;
}
.call-btn .icon { width: 1.8em; height: 1.8em; }
.call-btn:hover { color: #fff; border-color: #fff; }
.call-text { display: flex; flex-direction: column; line-height: 1.2; }
.call-num { font-size: 22px; }
.call-label { font-size: 14px; font-weight: normal; color: #e2e8f0; }
.call-primary { background: var(--red); border-color: #fecaca; min-height: 84px; }
.call-primary .call-num { font-size: 34px; }
.call-primary .call-label { color: #fff; font-size: 16px; }
.call-primary:hover { background: #991b1b; }
.call-when { margin: 8px 0 0; color: #cbd5e1; line-height: 1.5; font-size: 14px; }
.call-others { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 16px 0; }
.call-other .call-btn { min-height: 56px; }

.gps-panel { background: #0b1220; border: 1px solid #334155; border-radius: 14px; padding: 16px; }
.gps-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.gps-status { margin: 12px 0 0; color: #fde68a; line-height: 1.55; }
.gps-status.is-error { color: #fecaca; }
.gps-sat { margin: 8px 0 0; color: #cbd5e1; font-size: 14px; }
.gps-result { margin: 14px 0 0; display: grid; gap: 4px; }
.gps-result dt { font-size: 13px; color: #cbd5e1; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 10px; }
.gps-result dd { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.gps-big { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 28px !important; font-weight: bold; color: #fff; }
.gps-say { background: #1f2937; border-left: 4px solid #fbbf24; padding: 10px 12px; border-radius: 8px; font-size: 20px !important; line-height: 1.5; }

.steps { margin: 10px 0; padding-left: 24px; line-height: 1.65; }
.steps li { margin: 6px 0; }

.aid-card { border: 1px solid #475569; border-radius: 14px; margin: 0 0 12px; background: #0b1220; }
.aid-card.sev-critical { border-color: #ef4444; }
.aid-card summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; min-height: 56px; border-radius: 14px; }
.aid-card summary::-webkit-details-marker { display: none; }
.aid-card .aid-icon { color: #f87171; width: 1.6em; height: 1.6em; }
.sum-text { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sum-title { font-weight: bold; font-size: 18px; }
.sum-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chev { transition: transform 0.15s ease; }
.aid-card[open] .chev { transform: rotate(180deg); }
.aid-body { padding: 4px 18px 18px; border-top: 1px solid #334155; line-height: 1.6; }
.aid-when { color: #e2e8f0; font-style: italic; }
.call-first { display: flex; align-items: center; gap: 8px; background: var(--red); color: #fff; padding: 10px 14px; border-radius: 10px; margin: 12px 0 8px; }
.donot { list-style: none; margin: 10px 0; padding: 0; }
.donot li { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; color: #fecaca; }
.donot .icon-sm { margin-top: 5px; flex: none; }
.aid-caveat { font-size: 13px; color: #cbd5e1; border-top: 1px dashed #475569; padding-top: 10px; margin-top: 12px; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: bold; border: 1px solid transparent; }
.tag-sev { background: #1f2937; color: #f1f5f9; border-color: #64748b; }
.tag-draft { background: #1e1b4b; color: #e0e7ff; border: 1px dashed #a5b4fc; }
.tag-overdue { background: #7f1d1d; color: #fee2e2; border-color: #f87171; margin-left: 6px; }

.src { margin-top: 12px; font-size: 14px; color: #cbd5e1; }
.src-line { margin: 4px 0; overflow-wrap: anywhere; }
.src-k { color: #e2e8f0; font-weight: bold; }
.src-note { font-size: 13px; color: #94a3b8; }
.url { color: #cbd5e1; font-size: 13px; }

.sel-label { display: block; font-weight: bold; margin: 6px 0; }
#stateSelect { min-height: 44px; font-size: 16px; padding: 8px 12px; border-radius: 10px; background: #0b1220; color: #f8fafc; border: 1px solid #64748b; max-width: 100%; }
.links { padding-left: 20px; line-height: 1.7; }
.links li { margin: 8px 0; overflow-wrap: anywhere; }
.levels { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.lvl { padding: 10px 12px; border-radius: 10px; border-left: 8px solid; background: #0b1220; line-height: 1.5; }
.lvl-yellow { border-color: #facc15; }
.lvl-orange { border-color: #fb923c; }
.lvl-red { border-color: #ef4444; }
.em-foot { font-size: 14px; color: #cbd5e1; }

@media (min-width: 700px) {
  .call-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .emergency-view h1 { font-size: 30px; }
  .gps-big { font-size: 22px !important; }
  .topbar { padding-left: 12px; padding-right: 12px; }
}
@media (forced-colors: active) {
  .call-btn, .emergency-top, .tag, .callout { border: 2px solid CanvasText; }
}

/* ---------------------------------------------- additions after first test */
.brand:hover { color: var(--text); }
.offline-wrap { padding-bottom: 0; padding-top: 16px; }
.offline-banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: #78350f; border: 1px solid #f59e0b; color: #fef3c7; line-height: 1.5; }
.offline-banner > .icon { width: 1.6em; height: 1.6em; margin-top: 2px; }
.offline-banner p { margin: 0 0 10px; }
.offline-cta { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border-radius: 12px; background: var(--red); color: #fff; font-weight: bold; text-decoration: none; border: 2px solid #fecaca; }
.offline-cta:hover { color: #fff; background: #991b1b; }
.call-first span { flex: 1; }
@media (max-width: 480px) {
  .brand-text { display: none; }
}

/* per-state advice list (bushfire card) */
.state-variants { margin: 14px 0; padding-top: 10px; border-top: 1px solid #334155; }
.sv-title { font-size: 17px; margin: 0 0 6px; }
.sv-intro { margin: 6px 0 10px; color: #e2e8f0; }
.sv-list { list-style: none; margin: 0; padding: 0; }
.sv-item { border: 1px solid #475569; border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; background: #0f172a; }
.sv-item p { margin: 4px 0; }
.sv-state { display: inline-block; min-width: 2.6em; padding: 1px 8px; border-radius: 6px; background: #1e293b; border: 1px solid #64748b; font-weight: 700; text-align: center; }
.sv-engine { font-size: 1.02em; }
.sv-other { color: #cbd5e1; font-size: 14px; }
.sv-src { font-size: 13px; overflow-wrap: anywhere; }
.sv-caveats { border-left: 4px solid #f59e0b; background: #1c1917; padding: 8px 12px; border-radius: 6px; margin: 10px 0; }
.sv-cav-title { margin: 0 0 4px; font-weight: 700; }
.sv-caveats ul { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.55; }

/* ===================================================== Stage 2: Guides screen */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.guides-top {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px;
  background: #1e293b; color: var(--text); font-weight: bold; text-decoration: none; border-radius: 12px;
  border: 2px solid #64748b;
}
.guides-top:hover { color: var(--text); background: #334155; }
.guides-top[aria-current="page"] { background: #fff; color: #0b1220; border-color: #fbbf24; }
.guides-top .icon { margin: 0; }
.offline-cta-alt { background: #1e293b; border-color: #94a3b8; margin-left: 8px; }
.offline-cta-alt:hover { background: #334155; }
.guides-cta { display: inline-flex; align-items: center; text-decoration: none; }

.guides-view .wrap { padding-top: 20px; padding-bottom: 36px; }
.guides-view h1 { margin: 6px 0 14px; }
.guides-view h2 { font-size: 24px; margin: 8px 0 10px; line-height: 1.25; }
.guides-view h3 { font-size: 17px; margin: 18px 0 8px; }
.guide-lead { color: #cbd5e1; margin: 0 0 14px; }

.guide-search { margin: 0 0 16px; }
.guide-search-label { display: block; font-weight: bold; margin: 0 0 6px; }
.guide-search-row {
  display: flex; align-items: center; gap: 10px; background: #0b1220; border: 2px solid #64748b;
  border-radius: 14px; padding: 4px 12px; min-height: 52px;
}
.guide-search-row:focus-within { border-color: var(--focus); }
.guide-search-row input {
  flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font-size: 17px;
  min-height: 44px; padding: 6px 0;
}
.guide-search-row input:focus-visible { outline: none; }
.guide-search-row input::placeholder { color: #94a3b8; opacity: 1; }
.guide-search-row:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.cat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cat-card {
  display: flex; flex-direction: column; gap: 4px; height: 100%; box-sizing: border-box; padding: 14px 16px;
  background: rgba(17,24,39,0.92); border: 1px solid #475569; border-radius: 14px; color: var(--text);
  text-decoration: none; min-height: 88px;
}
.cat-card:hover { border-color: #fbbf24; color: var(--text); }
.cat-title { font-weight: bold; font-size: 18px; }
.cat-blurb { color: #cbd5e1; font-size: 14px; line-height: 1.45; }
.cat-count { color: #fbbf24; font-size: 13px; font-weight: bold; margin-top: auto; }

.guide-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.guide-li { background: rgba(17,24,39,0.92); border: 1px solid #475569; border-radius: 14px; padding: 12px 16px; }
.guide-link { display: inline-block; min-height: 44px; padding: 8px 0 2px; font-weight: bold; font-size: 18px; text-decoration: none; line-height: 1.3; }
.guide-link:hover .guide-title { text-decoration: underline; }
.guide-cat { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: #94a3b8; margin: 0 0 4px; }
.guide-snippet { margin: 4px 0 8px; color: #e2e8f0; line-height: 1.5; }
.guide-src { margin: 6px 0 0; font-size: 13px; color: #cbd5e1; overflow-wrap: anywhere; }
.guide-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tag-region { background: #0c4a6e; color: #e0f2fe; border-color: #38bdf8; }
.guide-empty { background: #1f2937; border: 1px solid #475569; border-radius: 12px; padding: 14px 16px; }

.guide-body { line-height: 1.65; font-size: 17px; max-width: 70ch; }
.guide-body p { margin: 0 0 12px; }
.guide-body ul, .guide-body ol { margin: 0 0 14px; padding-left: 22px; }
.guide-body li { margin: 0 0 8px; }
.guide-source { margin-top: 22px; padding: 14px 16px; background: #0b1220; border: 1px solid #334155; border-radius: 14px; overflow-wrap: anywhere; }
.guide-source h3 { margin-top: 0; }
.guide-source ul { margin: 6px 0; padding-left: 20px; }
.guide-also { margin: 10px 0 4px; font-weight: bold; }
.guide-reviewed { font-weight: bold; margin: 10px 0 6px; }
.guide-open-card { display: inline-flex; align-items: center; margin: 4px 0 8px; }
.guide-back { margin-bottom: 6px; }

/* Offline Ask fallback */
.ask-offline-note { margin: 0 0 12px; }
.ask-matches { display: flex; flex-direction: column; gap: 10px; }
.ask-match { border: 1px solid #475569; border-radius: 12px; padding: 10px 14px; background: #0b1220; }
.ask-match-title { font-weight: bold; font-size: 17px; display: inline-block; min-height: 44px; padding-top: 10px; }
.ask-match .guide-snippet { margin: 0 0 6px; }

@media (max-width: 480px) {
  .guides-top span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .guides-top { padding: 8px 12px; }
  .offline-cta-alt { margin-left: 0; margin-top: 8px; }
  .offline-banner a.offline-cta { display: flex; justify-content: center; }
  .guide-body { font-size: 16px; }
}

@media (forced-colors: active) {
  .guides-top, .cat-card, .guide-li, .ask-match, .guide-search-row { border: 2px solid CanvasText; }
}
@media (prefers-reduced-motion: reduce) {
  .cat-card, .guide-li, .guides-top { transition: none !important; }
}

/* ===================================================== Stage 3: saved data, checklists, settings, print */
.saved-note { margin: 0 0 10px; color: #cbd5e1; }
.history-item + .history-item { margin-top: 12px; }
.plan-item { margin-bottom: 15px; }
.plan-body { margin-top: 6px; line-height: 1.6; overflow-wrap: anywhere; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.plan-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px;
  border-radius: 10px; background: #0b1220; border: 1px solid #475569; color: #fbbf24; font-weight: 700;
  font-size: 14px; text-decoration: none; cursor: pointer;
}
.plan-btn[hidden] { display: none; }
.plan-time { font-size: 13px; color: #94a3b8; margin-top: 8px; }

.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 10px; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 44px; font-weight: bold; }
.checklists-sub { margin: 26px 0 10px; }

/* tick lists */
.tick-wrap { max-width: 70ch; }
.tick-progress { font-weight: bold; color: #fbbf24; margin: 4px 0 8px; }
.tick-section { margin: 0 0 18px; }
.tick-section h3 { margin: 16px 0 8px; font-size: 18px; }
.tick-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tick-item { background: rgba(17,24,39,0.92); border: 1px solid #475569; border-radius: 12px; padding: 4px 12px 8px; }
.tick-item.is-done { border-color: #15803d; }
.tick-item.is-done .tick-text { text-decoration: line-through; text-decoration-thickness: 2px; color: #cbd5e1; }
.tick-label { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 0 4px; cursor: pointer; line-height: 1.5; font-size: 17px; }
.tick-label input[type="checkbox"] { flex: none; width: 28px; height: 28px; margin: 2px 0 0; accent-color: #f59e0b; cursor: pointer; }
.tick-text { overflow-wrap: anywhere; }
.tick-guides { display: block; font-size: 14px; margin: 0 0 2px 40px; color: #cbd5e1; }
.tick-guides a { display: inline-block; min-height: 24px; padding: 6px 0; }
.tick-actions { margin: 10px 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.btn-danger { border-color: #f87171; color: #fecaca; }
.checklist-plain { white-space: pre-wrap; line-height: 1.6; }
.ai-checklist { margin-top: 10px; }

/* settings */
.set-section { margin: 0 0 24px; padding: 14px 16px; background: rgba(17,24,39,0.92); border: 1px solid #475569; border-radius: 14px; }
.set-section h2 { margin: 0 0 8px; font-size: 20px; }
.set-lead { margin: 0 0 10px; line-height: 1.55; }
.set-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0; }
.set-facts dt { color: #cbd5e1; font-weight: bold; }
.set-facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .set-facts { grid-template-columns: 1fr; gap: 0; } .set-facts dd { margin-bottom: 8px; } }

/* print: only the #printArea is printed (see js/print.js) */
.print-area { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; color: #000; background: #fff; font: 12pt/1.5 Arial, Helvetica, sans-serif; padding: 0; }
  #printArea h1 { font-size: 20pt; margin: 0 0 6pt; }
  #printArea h2 { font-size: 14pt; margin: 14pt 0 4pt; }
  #printArea .print-meta { color: #333; margin: 0 0 4pt; }
  #printArea .print-list { list-style: none; padding: 0; margin: 0; }
  #printArea .print-list li { margin: 0 0 4pt; page-break-inside: avoid; }
  #printArea .print-foot { margin-top: 14pt; font-size: 10pt; color: #333; border-top: 1px solid #999; padding-top: 6pt; }
  html, body { background: #fff !important; }
}
@media (forced-colors: active) {
  .tick-item, .set-section, .plan-btn { border: 2px solid CanvasText; }
}
@media (prefers-reduced-motion: reduce) {
  .tick-item, .plan-btn, .tick-label { transition: none !important; }
}
.guide-li > a.guide-title { display: inline-flex; align-items: center; min-height: 44px; font-weight: bold; font-size: 18px; text-decoration: none; padding: 6px 0; }

/* ===================================================== UX quick-fix: compact answers, answer tools */
.output-head { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.02); padding-right: 10px; }
.output-head .output-header { flex: 1 1 auto; min-width: 0; }
.output-tools { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.output-tools[hidden] { display: none; }
.tool-btn {
  min-height: 44px; padding: 8px 14px; border-radius: 10px; background: #0b1220; border: 1px solid #475569;
  color: #fbbf24; font-weight: 700; font-size: 14px; cursor: pointer;
}
.output.emergency .tool-btn { border-color: #f87171; color: #fecaca; }

/* Long text is cut with a fade, never scrolled inside its own box. The button expands it in place. */
.is-clamped { --clamp-bg: #0b1220; max-height: 15em; overflow: hidden; position: relative; box-sizing: border-box; }
.output-body.is-clamped { max-height: 17em; }
.is-clamped::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4em; pointer-events: none;
  background: linear-gradient(to bottom, rgba(11,18,32,0), var(--clamp-bg));
}
.collapse-toggle {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; margin: 6px 0 0; padding: 10px 14px;
  border-radius: 10px; background: #0b1220; border: 1px solid #fbbf24; color: #fbbf24; font-weight: 700; font-size: 15px; cursor: pointer;
}
.collapse-toggle[hidden] { display: none; }
.collapse-toggle[aria-expanded="true"] { border-color: #475569; color: #e2e8f0; }
.output .collapse-toggle { margin: 0; border-radius: 0; border-width: 1px 0 0; border-color: var(--border); }
.output .collapse-toggle[aria-expanded="false"] { border-color: #fbbf24; }
@media (forced-colors: active) {
  .collapse-toggle, .tool-btn { border: 2px solid CanvasText; }
  .is-clamped::after { display: none; }
}

/* ================================================================ D1: home tiles + phone bottom nav */
.home-tiles { margin: 16px 0 26px; scroll-margin-top: 80px; }
.home-tiles-title { margin: 0 0 12px; font-size: 20px; letter-spacing: -0.01em; }
.tile-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile-item { margin: 0; display: flex; }
.tile {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-height: 132px; padding: 14px;
  border-radius: 18px; background: #111827; border: 1px solid #334155; color: #f8fafc; text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.tile:hover { color: #f8fafc; border-color: #f59e0b; background: #162033; transform: translateY(-1px); }
.tile:active { transform: scale(0.98); }
.tile-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 14px; background: #1f2937; color: #fbbf24; }
.tile-icon .icon { width: 26px; height: 26px; margin: 0; }
.tile-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile-title { font-size: 18px; font-weight: bold; line-height: 1.2; }
.tile-hint { font-size: 14px; color: #cbd5e1; line-height: 1.3; }
.tile-avail { font-size: 12px; color: #cbd5e1; line-height: 1.3; margin-top: 2px; }
.tile-avail::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #10b981; vertical-align: 0; }
.tile-avail-online::before { background: #f59e0b; }
.tile-avail-mixed::before { background: #38bdf8; }
.tile-emergency { background: #7f1d1d; border: 2px solid #fecaca; }
.tile-emergency:hover { background: #991b1b; border-color: #fff; }
.tile-emergency .tile-icon { background: #b91c1c; color: #fff; }
.tile-emergency .tile-hint, .tile-emergency .tile-avail { color: #fee2e2; }
html.is-offline .tile-avail-online { color: #fde68a; }

@media (min-width: 700px) {
  .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .tile { min-height: 150px; padding: 18px; }
}
@media (max-width: 699px) {
  .brand-badges { display: none; }   /* the tiles replace the badge row on phones */
  .hero { margin-bottom: 4px; }
  .hero-left h1 { font-size: 30px; margin-bottom: 6px; }
  .hero-left p { font-size: 16px; margin-bottom: 0; }
  .wrap { padding-top: 18px; }
}

/* Bottom navigation: phones only */
.bottom-nav { display: none; }
@media (max-width: 699px) {
  html.has-bottom-nav .bottom-nav {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    background: rgba(11, 18, 32, 0.98); border-top: 1px solid #334155;
    padding-bottom: env(safe-area-inset-bottom);
  }
  html.has-bottom-nav.is-typing .bottom-nav { display: none; }
  html.has-bottom-nav body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  html.has-bottom-nav { scroll-padding-bottom: 80px; }
  html.has-bottom-nav .update-bar { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
.bn-list { list-style: none; margin: 0; padding: 0; display: flex; }
.bn-item { flex: 1 1 0; min-width: 0; margin: 0; }
.bn-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 62px; padding: 6px 2px; color: #cbd5e1; text-decoration: none; font-size: 12px; font-weight: bold; line-height: 1.2;
  border-top: 3px solid transparent;
}
.bn-link .icon { width: 24px; height: 24px; margin: 0; }
.bn-label { max-width: 100%; overflow-wrap: anywhere; text-align: center; }
.bn-link:hover { color: #fde68a; }
.bn-link[aria-current="page"] { color: #fbbf24; border-top-color: #fbbf24; background: #111827; }
.bn-link:focus-visible { outline-offset: -4px; }

/* Anchors on the home screen sit below the sticky top bar */
#askCard, #planCard { scroll-margin-top: 84px; }

@media (forced-colors: active) {
  .tile, .tile-icon { border: 2px solid CanvasText; }
  .bn-link[aria-current="page"] { border-top: 4px solid Highlight; }
  .bottom-nav { border-top: 2px solid CanvasText; }
}
@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile:hover, .tile:active { transform: none; }
}

/* "by OutbackMind" line under the NomadMate heading (the top bar hides the brand text on small phones) */
.hero-left p.hero-by { margin: -2px 0 8px; font-size: 14px; color: #cbd5e1; letter-spacing: 0.02em; }
@media (min-width: 481px) { .hero-left p.hero-by { display: none; } }
@media (max-width: 699px) { html.has-bottom-nav #guidesBtn { display: none; } }   /* Guides is in the bottom bar */

/* ================================================================ D2: separate screens */
.ask-view .grid, .plans-view .wrap > .card { margin-top: 6px; }
.screen-gap { height: 22px; }
.plans-view .card, .ask-view .card { max-width: 100%; }
.plans-view #planBtn { min-height: 44px; }
#history .history-item[hidden], #tripHistory .plan-item[hidden] { display: none !important; }
.list-toggle { margin-top: 12px; border-radius: 12px; border: 1px solid #f59e0b; }

/* Saved screen: one row per saved list, each with a way to open it */
.hub-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
.hub-item { margin: 0; padding: 14px 16px; border-radius: 16px; background: #111827; border: 1px solid #334155; }
.hub-item p { margin: 0 0 4px; }
.hub-title { font-weight: bold; font-size: 18px; }
.hub-count { color: #f8fafc; }
.hub-latest { overflow-wrap: anywhere; }
.hub-open { display: inline-flex; align-items: center; margin-top: 8px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid #475569; background: #0b1220; color: var(--text); font-weight: bold; text-decoration: none; }
@media (min-width: 700px) { .hub-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (forced-colors: active) { .hub-item { border: 2px solid CanvasText; } }
#outputCard { scroll-margin-top: 84px; }
.home-fallback { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.home-fallback a { display: inline-flex; align-items: center; min-height: 48px; padding: 10px 18px; border-radius: 14px; text-decoration: none; font-weight: bold; border: 1px solid #334155; }
.home-fallback .btn-primary { border-color: #f59e0b; }

/* ================================================================ D3: design tokens and polish
 * Visual only. No behaviour, data or markup changes. The app is dark by design (glare-friendly outdoors and at night);
 * it declares color-scheme: dark so form controls and scrollbars match. High contrast and forced-colours are handled below. */
:root {
  color-scheme: dark;
  /* type scale */
  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;   /* kept from the tested layout; the tiles and bottom bar were sized for it */
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 30px; --fs-3xl: 38px;
  --lh-tight: 1.2; --lh-body: 1.6;
  /* spacing scale (4px base) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  /* shape */
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-pill: 999px;
  --shadow-1: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 10px 28px rgba(0, 0, 0, 0.35);
  /* surfaces and lines */
  --surface-0: #0b1220; --surface-1: #111827; --surface-2: #1f2937;
  --line: #334155; --line-strong: #64748b;
  --amber: #fbbf24;
  --radius: var(--r-lg);
}
body { font-family: var(--font); line-height: 1.5; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
h1, h2, h3 { line-height: var(--lh-tight); }
.hero-left h1 { font-size: var(--fs-3xl); }
.home-tiles-title, .em-section h2, .set-section h2 { font-size: var(--fs-xl); }
.side-card-title, .tile-title, .hub-title { font-size: var(--fs-lg); }
.label, .output-header { font-size: var(--fs-xs); letter-spacing: 0.09em; }
@media (max-width: 699px) { .hero-left h1 { font-size: var(--fs-2xl); } }

/* cards, tiles and inner panels share a radius and a shadow */
.card, .em-section, .set-section { border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.history-item, .plan-item, .output, .checklist-output, .hub-item, .aid-card, .gps-panel, .tick-item { border-radius: var(--r-md); }
.tile { border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-height: 132px; }
.tile-icon { border-radius: var(--r-md); }
.tile:hover { box-shadow: var(--shadow-2); }
.tile-emergency { box-shadow: 0 6px 22px rgba(185, 28, 28, 0.38); }

/* one button language: 44px minimum, same radius, clear hover / pressed / disabled states */
button, .btn-primary, .btn-secondary { border-radius: var(--r-md); font-family: inherit; letter-spacing: 0.005em; }
.btn-primary { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary:hover, .tool-btn:hover, .hub-open:hover { border-color: var(--amber); }
button:active:not(:disabled), .btn-primary:active, .btn-secondary:active { transform: translateY(1px) scale(0.99); }
.mode-pill, .badge, .conn-pill, .tag, .emergency-badge, .normal-badge { border-radius: var(--r-pill); }
textarea, #stateSelect, input[type="text"], input[type="search"] { border-radius: var(--r-md); }

/* focus: a clear amber ring everywhere; white on the red Emergency controls so it never blends in */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.emergency-top:focus-visible, .tile-emergency:focus-visible, .call-btn:focus-visible, .call-primary:focus-visible, .offline-cta:focus-visible { outline-color: #fff; }
.bn-link:focus-visible { outline-color: var(--amber); outline-offset: -4px; }

/* top bar: quieter surface, logo with a fine ring, Emergency stays the loudest thing on screen */
.topbar { background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(11, 18, 32, 0.97)); border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(251, 191, 36, 0.14), 0 6px 16px rgba(0, 0, 0, 0.25); }
.brand-icon { width: 38px; height: 38px; border-radius: 9px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 2px 6px rgba(0, 0, 0, 0.4); }
.brand-text strong { font-size: var(--fs-lg); letter-spacing: -0.01em; }
.emergency-top { box-shadow: 0 2px 10px rgba(185, 28, 28, 0.5); font-size: var(--fs-md); }
.guides-top { border-radius: var(--r-md); }

/* bottom bar: lifted from the page, bigger active marker */
@media (max-width: 699px) {
  html.has-bottom-nav .bottom-nav { box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px); }
}
.bn-link { font-size: var(--fs-xs); border-top-width: 3px; }
.bn-link[aria-current="page"] { background: linear-gradient(180deg, rgba(251, 191, 36, 0.12), #111827 70%); }
.bn-link .icon { width: 24px; height: 24px; }

/* the home screen keeps its footer below the first screen while the tiles load (stops the page jumping) */
#view-home { min-height: calc(100vh - 72px); }
@supports (height: 100svh) { #view-home { min-height: calc(100svh - 72px); } }

/* touch feedback only where motion is welcome */
@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled), .btn-primary:active, .btn-secondary:active { transform: none; }
  .tile, .tile:hover, .tile:active { transition: none; transform: none; }
}

/* more contrast when the person asks for it */
@media (prefers-contrast: more) {
  :root { --line: #94a3b8; }
  .card, .em-section, .set-section, .tile, .hub-item, .history-item, .aid-card, .topbar, .bottom-nav { border-color: #cbd5e1; }
  .tile-hint, .tile-avail, .brand-sub, .mini-note, .history-time, .label, .output-header { color: #f1f5f9; }
  .btn-secondary, .tool-btn, .hub-open, .collapse-toggle { border-color: #e2e8f0; }
}
@media (forced-colors: active) {
  .brand-icon { forced-color-adjust: none; }
  .tile-emergency, .emergency-top, .call-primary { border: 3px solid Highlight; }
  button, .btn-primary, .btn-secondary { border: 2px solid ButtonText; }
}

/* D3: no page jump while loading. A deep link shows its own screen from the first paint (see the data-boot hint in index.html),
   every screen keeps the footer below the first screen while its content arrives, and the top bar has a fixed height. */
html[data-boot]:not([data-boot="home"]) #view-home { display: none; }
html[data-boot="ask"] #view-ask, html[data-boot="plans"] #view-plans, html[data-boot="guides"] #view-guides, html[data-boot="checklists"] #view-checklists,
html[data-boot="settings"] #view-settings, html[data-boot="emergency"] #view-emergency { display: block !important; }
#view-ask, #view-plans, #view-guides, #view-checklists, #view-settings, #view-emergency { min-height: calc(100vh - 72px); }
@supports (height: 100svh) { #view-ask, #view-plans, #view-guides, #view-checklists, #view-settings, #view-emergency { min-height: calc(100svh - 72px); } }
.topbar { min-height: 65px; }
.conn-pill { min-width: 88px; justify-content: center; }
@media (max-width: 699px) { html[data-nav-boot] #guidesBtn { display: none; } }
#savedHub:empty { min-height: 420px; }
@media (min-width: 700px) { #savedHub:empty { min-height: 170px; } }

/* Stage 4: questions saved to send later. Status is always a word, never colour alone. */
.queue-panel { margin-top: var(--sp-4); padding: var(--sp-4); background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--r-md); }
.queue-panel[hidden] { display: none; }
.queue-title { font-size: var(--fs-lg); margin: 0 0 var(--sp-2); }
.queue-note { margin: 0 0 var(--sp-3); font-size: var(--fs-sm, 14px); color: var(--muted); }
.queue-note a { color: var(--amber); font-weight: bold; }
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.queue-item { padding: var(--sp-3); background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-md); }
.queue-item-top { display: flex; gap: var(--sp-2); align-items: flex-start; flex-wrap: wrap; }
.queue-q { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; font-weight: bold; }
.queue-chip { display: inline-block; padding: 2px 10px; border-radius: var(--r-pill); font-size: 13px; font-weight: bold; border: 1px solid var(--line-strong); background: var(--surface-2); color: #f8fafc; white-space: nowrap; }
.queue-chip-queued { border-color: #38bdf8; color: #bae6fd; }
.queue-chip-sending { border-color: #fbbf24; color: #fde68a; }
.queue-chip-answered { border-color: #10b981; color: #a7f3d0; }
.queue-chip-failed { border-color: #f87171; color: #fecaca; }
.queue-meta { margin: var(--sp-2) 0 0; font-size: 14px; color: var(--muted); }
.queue-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.queue-answer { margin-top: var(--sp-2); }
.queue-answer summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: bold; color: var(--amber); }
.queue-answer-body { padding: var(--sp-2) 0; line-height: 1.6; overflow-wrap: anywhere; }
.queue-badge { display: inline-block; margin-top: 3px; padding: 1px 8px; border-radius: var(--r-pill); background: #0c4a6e; color: #e0f2fe; border: 1px solid #38bdf8; font-size: 12px; font-weight: bold; line-height: 1.4; width: fit-content; }
.nav-badge { margin-top: 0; font-size: 10px; padding: 0 6px; }
.queue-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 95; max-width: min(92vw, 520px); width: max-content; display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-4); background: #064e3b; color: #ecfdf5; border: 1px solid #10b981; border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.queue-toast[hidden] { display: none; }
.queue-toast a { color: #fde68a; font-weight: bold; white-space: nowrap; }
.queue-toast-close { background: transparent; border: 0; color: inherit; font-size: 22px; min-width: 44px; min-height: 44px; cursor: pointer; }
@media (min-width: 700px) { .queue-toast { bottom: var(--sp-5); } }
@media (forced-colors: active) { .queue-chip, .queue-badge, .queue-toast { border: 2px solid CanvasText; } }
