:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5d6b78;
  --line: #d9dee3;
  --brand: #1565c0;
  --brand-text: #ffffff;
  --ok: #1b873f;
  --warn: #b85c00;
  --danger: #c62828;
  --soft: #eef2f6;
  --paper: #fffdf6;
  --paper-ink: #1d232a;
  --paper-muted: #6b6455;
  --paper-line: #cfc8b8;
  --field: #edf0f4;
  --field-line: #dde2e8;
  --btn-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  --focus: #ffb300;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #11161b;
    --panel: #1a2128;
    --text: #e8edf2;
    --muted: #9aa8b5;
    --line: #2d3843;
    --brand: #4f9be8;
    --brand-text: #0b1520;
    --ok: #4cc276;
    --warn: #f0a04b;
    --danger: #ef6b6b;
    --soft: #222b34;
  --paper: #ece8dc;
  --paper-ink: #1d232a;
  --paper-muted: #5e5747;
  --paper-line: #b9b09c;
  --field: #12181e;
  --field-line: #2a333d;
  --btn-bg: #232c35;
  --btn-line: #36424e;
  --btn-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --scroll-thumb: #4a5866;
  --scroll-track: #1a2128;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #11161b;
  --panel: #1a2128;
  --text: #e8edf2;
  --muted: #9aa8b5;
  --line: #2d3843;
  --brand: #4f9be8;
  --brand-text: #0b1520;
  --ok: #4cc276;
  --warn: #f0a04b;
  --danger: #ef6b6b;
  --soft: #222b34;
  --paper: #ece8dc;
  --paper-ink: #1d232a;
  --paper-muted: #5e5747;
  --paper-line: #b9b09c;
  --field: #12181e;
  --field-line: #2a333d;
  --btn-bg: #232c35;
  --btn-line: #36424e;
  --btn-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --scroll-thumb: #4a5866;
  --scroll-track: #1a2128;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
}
h1,
h2,
h3 {
  margin: 0 0 0.5em;
  line-height: 1.2;
}
h2 {
  font-size: 1.2rem;
}
h3 {
  font-size: 1rem;
}
a {
  color: var(--brand);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.hidden {
  display: none !important;
}

/* Buttons sit up (a light fill, border and a soft shadow); places to type sit in (a flat,
   lighter-grey fill), so the two never look alike (owner, 2026-11-19). */
button,
.btn {
  font: inherit;
  border: 1px solid var(--btn-line, var(--line));
  background: var(--btn-bg, var(--panel));
  box-shadow: var(--btn-shadow);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5em 0.9em;
  cursor: pointer;
  min-height: 40px;
}
button:hover {
  filter: brightness(0.97);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
input:focus,
select:focus,
textarea:focus {
  background: var(--panel);
  border-color: var(--brand);
}
/* Dark mode: scrollbars match (the browser's own light one showed as a white bar in pop-ups). */
:root[data-theme='dark'],
:root[data-theme='dark'] dialog {
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']),
  :root:not([data-theme='light']) dialog {
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  }
}
button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-text);
  font-weight: 600;
}
button.ok {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  font-weight: 600;
}
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}
button.warn {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
  font-weight: 600;
}
button.link {
  border: none;
  background: none;
  box-shadow: none;
  color: var(--brand);
  padding: 0.25em;
  min-height: 0;
  text-decoration: underline;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* The hidden attribute always hides, even on elements whose class sets a display (like .row). */
[hidden] {
  display: none !important;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--field-line);
  border-radius: 8px;
  padding: 0.5em 0.6em;
  min-height: 40px;
  max-width: 100%;
}
label {
  display: block;
  margin: 0.6em 0 0.25em;
  font-weight: 600;
  font-size: 0.9rem;
}
.field input,
.field select,
.field textarea {
  width: 100%;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.grow {
  flex: 1;
}
.dot {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  vertical-align: -0.05em;
  margin-right: 0.35em;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1em 0.6em;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--soft);
  color: var(--muted);
  white-space: nowrap;
}
.chip.ok {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
}
.chip.warn {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}
.chip.danger {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}
.chip.brand {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: var(--brand);
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 1.25rem;
  width: min(520px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.modal-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.modal-body {
  max-height: 65vh;
  overflow: auto;
  overscroll-behavior: contain; /* scrolling a pop-up never moves the page behind it */
}

/* Short messages at the bottom. Hidden = faded out and untouchable, wherever it sits: sliding
   it down isn't enough on phones, where it sits above the tab bar and would land on top of it. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 0.75rem);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: #222;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  display: flex;
  gap: 1rem;
  align-items: center;
  max-width: calc(100vw - 32px);
  transition: opacity 0.3s, transform 0.3s, visibility 0s linear 0.3s;
  z-index: 3000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.2s, transform 0.2s, visibility 0s;
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transform: translate(-50%, 0);
  }
}
.toast.error {
  background: #8e1c1c;
}
.toast-action {
  background: #fff;
  color: #111;
  font-weight: 700;
  border: none;
}

.auth-wrap {
  max-width: 420px;
  margin: 8vh auto;
  padding: 0 16px;
}
.auth-wrap h1 {
  font-size: 1.8rem;
  letter-spacing: 0.08em;
}
.auth-wrap .card button.primary {
  width: 100%;
  margin-top: 1rem;
}
.error-text {
  color: var(--danger);
  font-weight: 600;
  min-height: 1.4em;
  margin-top: 0.5rem;
}

/* ---------- AVA brand (sign-in screens and landing page) ---------- */
header.brand { text-align: center; margin: 0.5rem 0 1.5rem; }
.brand-name { margin: 0 0 0.5rem; line-height: 0; }
/* The wordmark (logoMark in ui.js): one image per theme. */
.logo-mark { display: inline-flex; align-items: center; }
.logo-mark img { display: block; height: 100%; width: auto; }
.logo-mark .on-dark { display: none; }
.logo-mark.big { height: 64px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .logo-mark .on-light { display: none; }
  :root:not([data-theme='light']) .logo-mark .on-dark { display: block; }
}
:root[data-theme='dark'] .logo-mark .on-light { display: none; }
:root[data-theme='dark'] .logo-mark .on-dark { display: block; }
.brand-full { margin: 0.2rem 0 0; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand); }
.brand-sub { margin: 0.9rem 0 0; }

/* A button still working on its last click (see guardedClick in ui.js). */
button[data-busy] {
  cursor: progress;
  opacity: 0.6;
}

/* A button (or row of buttons) right under a form field, e.g. "Find on map" under
   the address: give it room so it doesn't touch the box or its focus outline. */
.field + .row,
.field + button,
.field + .btn {
  margin-top: 0.75rem;
}

/* The apps restore the scroll position themselves after redrawing (keepScroll in
   ui.js); the browser's own "scroll anchoring" would fight that and nudge the page. */
main,
.wrap {
  overflow-anchor: none;
}

/* While a pop-up is open, the page behind it stays still. */
body:has(dialog[open]) {
  overflow: hidden;
}
