/* Discovery / Lorca-era bridge: cold glass, fine telemetry, restrained amber. */
:root {
  color-scheme: dark;
  --bg: #060d17;
  --surface: #0c1a2a;
  --surface-2: #11263b;
  --surface-3: #091421;
  --text: #e1f2ff;
  --muted: #a2bdd1;
  --line: #2c4e68;
  --accent: #70d6fa;
  --accent-strong: #a2e5ff;
  --accent-soft: #12354a;
  --danger: #ffaaa5;
  --danger-soft: #402328;
  --warning: #f6c277;
  --warning-soft: #35291a;
  --shadow: 0 18px 48px #0005;
  --radius: 4px;
  --focus: 0 0 0 3px #70d6fa80;
}
body {
  background: radial-gradient(ellipse at 80% 0, #12344d70, transparent 52%),
    linear-gradient(#18304724 1px, transparent 1px),
    linear-gradient(90deg, #18304724 1px, transparent 1px), var(--bg);
  background-size: auto, 56px 56px, 56px 56px, auto;
}
.app-shell { width: min(1320px,100%); padding-top: 24px; }
.bridge-strip {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 12px; padding: 0 2px 11px;
  border-bottom: 1px solid var(--line); color: var(--accent);
  font: 600 .72rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .12em; text-transform: uppercase;
}
.bridge-ship { display: inline-flex; align-items: center; gap: 10px; }
.bridge-ship::before { content: ''; width: 5px; height: 22px; background: var(--accent); box-shadow: 9px 0 #70d6fa30; margin-right: 9px; }
.bridge-registry { color: var(--muted); }
.hero {
  border-radius: 3px; border-top: 2px solid var(--accent); padding: 36px;
  background: linear-gradient(110deg,#0c1b2bef,#112b42dd), repeating-linear-gradient(0deg,transparent 0 7px,#70d6fa12 7px 8px);
  box-shadow: inset 0 0 40px #70d6fa05, var(--shadow);
}
.hero::after { content: ''; position: absolute; bottom: 0; left: 0; width: 34%; height: 3px; background: linear-gradient(90deg,var(--accent) 0 60%,transparent 60% 63%,#467f9a 63% 90%,transparent 90% 93%,var(--warning) 93%); }
.hero-mark { opacity: .08; filter: grayscale(1); }
.hero .eyebrow { padding-right: 205px; }
.eyebrow, .field label, .time-label, .detail-label, .count, .meta-pill, .badge, .map-status {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.eyebrow { color: var(--accent); letter-spacing: .16em; font-weight: 600; }
h1 { max-width: 770px; font-weight: 550; letter-spacing: -.035em; font-size: clamp(2rem,4.6vw,3.8rem); }
.hero-copy { max-width: 720px; font-size: 1rem; line-height: 1.65; }
.meta-strip { gap: 0; margin-top: 24px; }
.meta-pill { border: 0; border-left: 2px solid var(--line); border-radius: 0; background: #07142155; padding: 6px 12px; font-size: .72rem; margin: 3px 14px 3px 0; }
.meta-pill:first-child { border-color: var(--warning); color: var(--warning); }
.secondary-button, .primary-button, .danger-button, .toggle-button, .map-control, .view-switch, .view-switch button {
  border-radius: 3px; min-height: 44px; font-size: .87rem; font-weight: 650;
}
.primary-button { color: #061622; background: var(--accent); border-color: var(--accent); }
.primary-button:hover { background: var(--accent-strong); }
.secondary-button, .toggle-button, .map-control { background: #0b1b2c; border-color: #426681; }
.secondary-button:hover, .toggle-button:hover, .map-control:hover { background: #18384e; border-color: var(--accent); }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
.controls-wrap { border-radius: 3px; background: #0b1928f5; border-color: var(--line); box-shadow: 0 6px 28px #0006; }
.field label { font-size: .72rem; letter-spacing: .08em; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.field select, .field input { border-radius: 3px; min-height: 46px; background: var(--surface-3); border-color: #426681; color: var(--text); }
.view-switch { padding: 3px; gap: 3px; }
.view-switch button { min-height: 38px; }
.view-switch button[aria-pressed='true'] { background: var(--accent-soft); box-shadow: inset 0 -2px var(--accent); }
.view-head { border-bottom: 1px solid var(--line); padding-bottom: 13px; margin-top: 28px; }
.view-head h2 { font-weight: 550; font-size: clamp(1.18rem,3vw,1.7rem); letter-spacing: -.015em; }
.count { font-size: .75rem; color: var(--accent); }
.timeline { border-radius: 3px; background: #081521; }
.time-slot { grid-template-columns: 116px 1fr; }
.time-label { background: linear-gradient(90deg,#16324a,#0c1c2c); color: var(--accent); font-size: .84rem; font-weight: 600; padding-top: 22px; }
.meeting-stack { gap: 9px; padding: 10px; }
.meeting-card { border-radius: 3px; border-left-width: 3px; background: linear-gradient(115deg,#102337,#0c1a2a); }
.meeting-card:hover { transform: none; border-color: #5689a6; border-left-color: var(--kind); background: #132c42; box-shadow: inset 0 0 24px #70d6fa05; }
.card-open { padding: 15px 10px 15px 14px; }
.card-open strong { font-weight: 650; font-size: 1rem; }
.card-place { margin-top: 7px; }
.badge { border-radius: 2px; font-size: .68rem; font-weight: 600; }
.badge.kind-aa, .badge.kind-aca { color: #9bc9ff; }
.badge.kind-na, .badge.kind-cma, .badge.kind-coda { color: #cfb3ed; }
.badge.kind-ca, .badge.kind-oa, .badge.kind-celebrate-recovery, .badge.kind-ga { color: #f2bf85; }
.badge.kind-smart-recovery, .badge.kind-recovery-dharma { color: #88dfdf; }
.badge.kind-al-anon, .badge.kind-alateen { color: #a0d5b4; }
.badge.kind-saa { color: #c1d1dc; }
.meeting-card.kind-aa, .meeting-card.kind-aca { --kind: #7baadc; }
.meeting-card.kind-na, .meeting-card.kind-cma, .meeting-card.kind-coda { --kind: #b596d1; }
.meeting-card.kind-ca, .meeting-card.kind-oa, .meeting-card.kind-celebrate-recovery, .meeting-card.kind-ga { --kind: #d3a16b; }
.meeting-card.kind-smart-recovery, .meeting-card.kind-recovery-dharma { --kind: #70bdbd; }
.meeting-card.kind-al-anon, .meeting-card.kind-alateen { --kind: #84b89a; }
.star-button { width: 44px; height: 44px; }
.star-button.is-favorite, .icon-button.is-favorite { color: var(--warning); }
.card-distance { border-radius: 2px; }
.contact-card, .notes, .empty-state, .map-panel, .map-popup, .modal-panel, .auth-card, .passkey-row, .note-editor, .note-editor textarea, .detail-grid, .occurrence-callout, .caveat { border-radius: 4px; }
.modal-panel, .auth-card { border-top: 2px solid var(--accent); background: linear-gradient(140deg,#0f2235,#091522); }
.modal-head { background: #0c1c2ef5; }
.modal-head h3 { font-weight: 600; }
.occurrence-callout { border-left: 2px solid var(--accent); }
.auth-card { box-shadow: 0 0 80px #48bfff12, var(--shadow); }
.auth-logo { filter: grayscale(1) brightness(1.6); }
.auth-card .eyebrow { color: var(--accent); }
.map-viewport { background: #0b1b2a; }
.map-tiles { filter: brightness(.8) saturate(.65); }
.map-popup-actions .is-favorite { color: var(--warning); background: var(--warning-soft); }
.toast { background: #173a50; color: var(--text); border-color: var(--accent); border-radius: 3px; }
.notes summary { color: var(--muted); font-size: .88rem; }
.footer { border-top: 1px solid var(--line); margin-top: 24px; }
@media (max-width: 800px) {
  .app-shell { padding-top: 12px; }
  .bridge-strip { font-size: .62rem; letter-spacing: .07em; gap: 8px; }
  .bridge-registry { text-align: right; max-width: 120px; }
  .hero { padding: 22px; }
  .hero .eyebrow { padding-right: 0; }
  .header-actions { margin-bottom: 20px; }
  .hero-copy { font-size: .92rem; }
  .meta-strip { margin-top: 16px; }
  .meta-pill { margin-right: 8px; font-size: .67rem; }
  .time-slot { grid-template-columns: 92px 1fr; }
  .time-label { padding: 20px 10px; font-size: .75rem; }
  .mobile-controls-summary { font-weight: 500; }
  .mobile-controls-button { flex-shrink: 0; }
}
@media (max-width: 500px) {
  .time-slot { grid-template-columns: 1fr; }
  .time-label { padding: 8px 12px; border-left: 2px solid var(--accent); background: #122b40; }
  .hero { padding: 18px; }
  .hero h1 { font-size: 2.1rem; }
  .view-head { margin-top: 21px; }
  .card-open strong { font-size: .95rem; }
  .modal-panel, .modal-scroll { max-height: 92dvh; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #eee; --text: #111; --muted: #333; --accent: #174c6b; --accent-strong: #174c6b; --line: #aaa; }
  body, .hero, .meeting-card, .timeline, .time-label { background: #fff; color: #111; }
  .bridge-strip { display: none; }
  .badge[class] { color: #222; }
}

/* The same Discovery console in daylight; preference is applied before paint. */
.auth-theme { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.hero .eyebrow { padding-right: 315px; }
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #eaf1f7; --surface: #ffffff; --surface-2: #e1ecf4; --surface-3: #f3f7fb;
  --text: #102d45; --muted: #476279; --line: #a7bece;
  --accent: #17648a; --accent-strong: #104e71; --accent-soft: #d8eaf4;
  --danger: #a33332; --danger-soft: #fce9e7;
  --warning: #89500b; --warning-soft: #fff0d9;
  --shadow: 0 12px 36px #183e6110; --focus: 0 0 0 3px #17648a50;
}
:root[data-theme='light'] body {
  background: linear-gradient(#597e9c0b 1px,transparent 1px),linear-gradient(90deg,#597e9c0b 1px,transparent 1px),var(--bg);
  background-size: 56px 56px;
}
:root[data-theme='light'] .hero { background: linear-gradient(115deg,#fff,#e2eef7); }
:root[data-theme='light'] .meta-pill { background: #fff8; }
:root[data-theme='light'] .primary-button { color: #fff; }
:root[data-theme='light'] .secondary-button,
:root[data-theme='light'] .toggle-button,
:root[data-theme='light'] .map-control { background: #f7fbff; border-color: #8eafc5; }
:root[data-theme='light'] .secondary-button:hover,
:root[data-theme='light'] .toggle-button:hover,
:root[data-theme='light'] .map-control:hover { background: #dcecf6; }
:root[data-theme='light'] .controls-wrap { background: #f5f9fcf5; box-shadow: 0 6px 28px #183e6112; }
:root[data-theme='light'] .field select,
:root[data-theme='light'] .field input { border-color: #8eafc5; }
:root[data-theme='light'] .timeline { background: #eaf2f8; }
:root[data-theme='light'] .time-label { background: linear-gradient(90deg,#d9e9f4,#edf5fa); }
:root[data-theme='light'] .meeting-card { background: linear-gradient(115deg,#fff,#f4f8fc); }
:root[data-theme='light'] .meeting-card:hover { background: #e7f2f9; border-color: #537e9b; }
:root[data-theme='light'] .badge.kind-aa,
:root[data-theme='light'] .badge.kind-aca { color: #245891; }
:root[data-theme='light'] .badge.kind-na,
:root[data-theme='light'] .badge.kind-cma,
:root[data-theme='light'] .badge.kind-coda { color: #72488d; }
:root[data-theme='light'] .badge.kind-ca,
:root[data-theme='light'] .badge.kind-oa,
:root[data-theme='light'] .badge.kind-celebrate-recovery,
:root[data-theme='light'] .badge.kind-ga { color: #874b15; }
:root[data-theme='light'] .badge.kind-smart-recovery,
:root[data-theme='light'] .badge.kind-recovery-dharma { color: #12656a; }
:root[data-theme='light'] .badge.kind-al-anon,
:root[data-theme='light'] .badge.kind-alateen { color: #326344; }
:root[data-theme='light'] .badge.kind-saa { color: #476174; }
:root[data-theme='light'] .modal-panel,
:root[data-theme='light'] .auth-card { background: linear-gradient(140deg,#fff,#edf5fa); }
:root[data-theme='light'] .modal-head { background: #f4f9fdf5; }
:root[data-theme='light'] .auth-logo { filter: none; }
:root[data-theme='light'] .map-viewport { background: #dbe6e8; }
:root[data-theme='light'] .map-tiles { filter: none; }
:root[data-theme='light'] .toast { background: #e0f0fa; }
@media (max-width: 800px) {
  .hero .eyebrow { padding-right: 0; }
  .header-actions { flex-wrap: wrap; }
}

/* Solid safe-area and navigation surfaces avoid blurring text behind the PWA chrome. */
:root { --safe-top: env(safe-area-inset-top, 0px); }
html { background: var(--bg); }
body::before { content: ''; position: fixed; inset: 0 0 auto; height: var(--safe-top); background: var(--bg); z-index: 70; pointer-events: none; }
.app-shell { padding-top: calc(24px + var(--safe-top)); padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px)); }
.quick-controls {
  position: sticky; top: var(--safe-top); z-index: 40;
  display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 8px;
  border: 1px solid var(--line); border-radius: 3px; background: var(--surface);
}
.quick-context { flex: 1; color: var(--muted); font-size: .85rem; }
.quick-controls .view-switch { width: auto; min-width: 160px; flex: none; }
.quick-controls .view-switch button { min-height: 44px; min-width: 72px; }
.quick-controls .mobile-controls-button { display: none; }
.controls-wrap, :root[data-theme='light'] .controls-wrap {
  position: static; margin-top: 8px; background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none;
}
.controls { grid-template-columns: minmax(200px,1.2fr) minmax(135px,.8fr) minmax(180px,1fr) auto; }
.controls-wrap, .view-head { scroll-margin-top: calc(84px + var(--safe-top)); }
.modal-head, :root[data-theme='light'] .modal-head { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
.modal-backdrop { padding-top: max(12px,var(--safe-top)); padding-bottom: max(12px,env(safe-area-inset-bottom,0px)); }
.map-gesture-hint { color: var(--muted); font-size: .78rem; margin: 5px 0 0; }
.map-zoom-controls { position: absolute; top: 12px; right: 12px; z-index: 25; display: grid; gap: 6px; }
.map-zoom-controls .map-control { width: 52px; height: 52px; font-size: 1.7rem; line-height: 1; padding: 0; box-shadow: 0 2px 8px #0003; }
.map-popup { touch-action: pan-y; }
.map-popup-actions > *, .modal-calendar { display: inline-flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; min-height: 46px; line-height: 1.3; padding: 10px 12px; }
.map-popup-actions > * { flex: 1 1 125px; }
@media (max-width: 980px) { .controls { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) {
  .app-shell { padding-top: calc(12px + var(--safe-top)); }
  .quick-controls { gap: 8px; justify-content: space-between; }
  .quick-controls .view-switch { min-width: 128px; }
  .quick-controls .view-switch button { min-width: 58px; }
  .quick-controls .quick-locate-button { min-width: 82px; }
  .quick-context { display: none; }
  .quick-controls .mobile-controls-button { display: block; min-height: 50px; }
  .controls-wrap:not(.mobile-controls-open) { display: none; }
  .controls-wrap .controls { padding-top: 0; }
}
@media (max-width: 500px) { .controls { grid-template-columns: 1fr; } }
@media print { .quick-controls, body::before { display: none !important; } }
