:root {
  --brand: #0a6970;
  --brand-strong: #07484d;
  --on-brand: #ffffff;
  --brand-soft: #d2ebe9;
  --on-brand-soft: #093c40;
  --bg: #eef3f2;
  --surface: #ffffff;
  --surface-2: #e2ebea;
  --line: #c6d3d2;
  --text: #13262b;
  --muted: #4b5b5e;
  --warn-bg: #ffdcbd;
  --warn-text: #4f2700;
  --error: #a3261f;
  --shadow: 0 1px 2px rgb(19 38 43 / 8%), 0 1px 6px rgb(19 38 43 / 6%);
  --radius: 18px;
  --tabs-h: 64px;
  color-scheme: light;

  --f-aa: #dce4ff; --f-aa-text: #1b3a8a;
  --f-na: #d0ecd2; --f-na-text: #1c5a26;
  --f-refuge: #ffe3bd; --f-refuge-text: #6f3b00;
  --f-dharma: #f2ddf4; --f-dharma-text: #642a6c;
  --f-cma: #ffdcd8; --f-cma-text: #85201a;
  --f-smart: #d4eef6; --f-smart-text: #0b5063;
  --f-wellbriety: #f0e4cc; --f-wellbriety-text: #584015;
  --f-other: #e1e5e5; --f-other-text: #39464a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7fd3d6;
    --brand-strong: #a6e6e8;
    --on-brand: #00373a;
    --brand-soft: #1f4a4d;
    --on-brand-soft: #c6eeee;
    --bg: #0d1415;
    --surface: #172021;
    --surface-2: #233031;
    --line: #3a4a4b;
    --text: #dfe8e8;
    --muted: #b3c3c3;
    --warn-bg: #5a3510;
    --warn-text: #ffdcbd;
    --error: #ffb4ab;
    --shadow: none;
    color-scheme: dark;

    --f-aa: #2b3a66; --f-aa-text: #d9e1ff;
    --f-na: #1f4426; --f-na-text: #c9ecce;
    --f-refuge: #573611; --f-refuge-text: #ffe0b8;
    --f-dharma: #4c2852; --f-dharma-text: #f6d9f8;
    --f-cma: #5c2420; --f-cma-text: #ffd9d4;
    --f-smart: #153f4b; --f-smart-text: #cdeef7;
    --f-wellbriety: #4a3b1d; --f-wellbriety-text: #f2e3c4;
    --f-other: #333c3e; --f-other-text: #dbe2e3;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0 auto;
  max-width: 760px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}

body[data-view="detail"], body[data-view="about"] { padding-bottom: calc(env(safe-area-inset-bottom) + 32px); }

a { color: var(--brand); }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }

.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }
.icon.tiny { width: 16px; height: 16px; }
.icon.brand, .brand { color: var(--brand); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---- Top bar ---- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 8px 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.top h1 { flex: 1; font-size: 26px; font-weight: 500; letter-spacing: -0.3px; }
.detail-top { padding-left: 8px; }
.detail-top h1 { font-size: 22px; }
.top-actions { display: flex; gap: 2px; margin-left: auto; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.brand { color: var(--brand); }
.fav.on { color: #c2185b; }
@media (prefers-color-scheme: dark) { .fav.on { color: #ff8fb8; } }

.search-row { padding: 0 16px 8px; }
.search-row input, .field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* ---- Area bar and chips ---- */

.area-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 4px 16px 10px;
  padding-right: 6px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.area-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 8px 10px 18px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.area-text { flex: 1; display: grid; }
.area-text strong { font-size: 17px; font-weight: 600; }
.area-text small { color: var(--muted); font-size: 14px; }

.chips {
  display: flex;
  gap: 8px;
  padding: 2px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; padding-left: 0; padding-right: 0; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { border-color: transparent; background: var(--brand-soft); color: var(--on-brand-soft); font-weight: 600; }

.lang-row { display: flex; align-items: center; gap: 12px; padding: 0 16px 6px; }
.pad { padding: 0 16px 6px; }

/* ---- Lists ---- */

.list { display: grid; gap: 10px; padding: 4px 16px 8px; }

.section { margin: 10px 2px 0; color: var(--brand); font-size: 16px; font-weight: 600; }

.card {
  position: relative;
  display: flex;
  align-items: flex-start;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card.dim { opacity: 0.6; }
.card-main {
  flex: 1;
  display: flex;
  gap: 16px;
  min-width: 0;
  padding: 16px 0 16px 18px;
  color: inherit;
  text-decoration: none;
}
.card .fav { margin: 8px 6px 0 0; }
.when { display: grid; align-content: start; width: 64px; flex: none; }
.when .hm { font-size: 23px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.when .ap, .when .tz { color: var(--muted); font-size: 14px; font-weight: 600; }
.what { min-width: 0; display: grid; gap: 3px; }
.what h3 { font-size: 18px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.where { color: var(--muted); }
.status { color: var(--brand); font-weight: 600; }
.types { color: var(--muted); font-size: 14px; }

.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  background: var(--f-other);
  color: var(--f-other-text);
}
.badge.wide { font-size: 15px; padding: 4px 10px; }
.f-aa { background: var(--f-aa); color: var(--f-aa-text); }
.f-na { background: var(--f-na); color: var(--f-na-text); }
.f-refuge { background: var(--f-refuge); color: var(--f-refuge-text); }
.f-dharma { background: var(--f-dharma); color: var(--f-dharma-text); }
.f-cma { background: var(--f-cma); color: var(--f-cma-text); }
.f-smart { background: var(--f-smart); color: var(--f-smart-text); }
.f-wellbriety { background: var(--f-wellbriety); color: var(--f-wellbriety-text); }
.att { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; }

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 14px 16px 14px 18px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--on-brand-soft);
}
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice > div:first-child { flex: 1 1 220px; display: grid; gap: 2px; }
.notice h3 { font-size: 16px; }
.notice p { font-size: 14px; }
.notice-actions { display: flex; gap: 4px; margin-left: auto; }
.notice .text-btn { color: inherit; }

.welcome, .empty {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 22px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.welcome { background: var(--brand-soft); color: var(--on-brand-soft); }
.welcome h2, .empty h2 { font-size: 20px; }
.empty { justify-items: center; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }
.warn-text { color: var(--error); }

.foot { display: grid; gap: 6px; margin: 14px 2px 0; color: var(--muted); font-size: 14px; }
.foot > a { font-weight: 600; font-size: 15px; }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn .icon { width: 20px; height: 20px; }
.btn.tonal { background: var(--brand-soft); color: var(--on-brand-soft); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.6; }
.text-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.list > .text-btn { justify-self: start; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.about h3 { font-size: 16px; margin-top: 8px; }
.plain-list { margin: 4px 0 12px; padding-left: 20px; display: grid; gap: 6px; }
.link { font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* ---- Bottom tabs ---- */

.tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  width: 100%;
  max-width: 760px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.tab .icon { width: 56px; height: 30px; padding: 3px 0; border-radius: 15px; }
.tab.on { color: var(--text); }
.tab.on .icon { background: var(--brand-soft); color: var(--on-brand-soft); }

/* ---- Meeting detail ---- */

.detail { display: grid; gap: 22px; padding: 4px 20px 24px; }
.detail-name { font-size: 28px; font-weight: 500; line-height: 1.2; overflow-wrap: anywhere; }
.d-section { display: flex; gap: 16px; }
.d-section > div { flex: 1; min-width: 0; display: grid; gap: 8px; justify-items: start; }
.d-section h2 { color: var(--brand); font-size: 15px; font-weight: 600; }
.big { font-size: 18px; }
.strong { font-weight: 600; }
.accent { color: var(--brand); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); font-size: 15px; font-weight: 500; }

/* ---- Lists and help ---- */

.about { display: grid; gap: 14px; padding: 4px 16px 24px; }
.card-block { display: grid; gap: 10px; padding: 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-block h2 { font-size: 18px; }
.crisis { background: var(--brand-soft); color: var(--on-brand-soft); }
.source-list { list-style: none; margin: 0; padding: 0; display: grid; }
.source-list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.source-list li:first-child { border-top: 0; }
.source-list li > div { flex: 1; display: grid; gap: 1px; min-width: 0; }
.source-list small { color: var(--muted); font-size: 14px; }

/* ---- Sheets (dialogs) ---- */

dialog.sheet {
  width: min(560px, 100vw);
  max-width: 100vw;
  max-height: min(88vh, 760px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -4px 24px rgb(0 0 0 / 20%);
}
@media (min-width: 600px) {
  dialog.sheet { margin: auto; border-radius: 24px; }
}
dialog.sheet::backdrop { background: rgb(0 0 0 / 45%); }
.sheet-body { display: grid; gap: 12px; padding: 16px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head h2 { flex: 1; font-size: 21px; font-weight: 600; }
.sheet-body h3 { font-size: 15px; color: var(--brand); margin-top: 4px; }
.sheet-actions { display: flex; justify-content: flex-end; }
.field { position: relative; display: block; }
.field .icon { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.field input { padding-left: 44px; }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.suggestion, .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.suggestion:hover, .menu-item:hover { background: var(--surface-2); }
.suggestion .icon, .menu-item .icon { color: var(--brand); }
.error { color: var(--error); }
.line { display: grid; gap: 4px; padding: 6px 0; }
.line-head { display: flex; align-items: center; gap: 8px; }
.call { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-weight: 600; text-decoration: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 20px);
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #1f2b2d;
  color: #eef6f6;
  font-size: 15px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Tonal buttons on tinted cards need their own background to stand out. */
.welcome .btn.tonal, .crisis .btn.tonal { background: var(--surface); color: var(--text); }
.list > .more { justify-self: center; margin-top: 4px; }

/* Help-test page */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.step { display: flex; gap: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.step > div { display: grid; gap: 8px; min-width: 0; }
.step h3 { font-size: 17px; }
.step-n { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-weight: 700; }
