:root {
  --bg: #f3f8f5;
  --card: #ffffff;
  --text: #1a2e24;
  --muted: #4a6356;
  --line: #d7e6dc;
  --primary: #2f9e6a;
  --primary-dark: #1f7a4d;
  --primary-soft: #e5f6ee;
  --warn: #b86a0a;
  --danger: #b83228;
  --shadow: 0 10px 28px rgba(28, 64, 46, 0.09);
  --radius: 18px;
  --radius-btn: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --fs-body: 17px;
  --fs-title: 1.45rem;
  --fs-hero: 1.55rem;
  --btn-h: 52px;
  --btn-h-lg: 56px;
  --tap: 12px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

#app {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: calc(108px + var(--safe-bottom));
}

/* ——— 顶栏 ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  background: rgba(243, 248, 245, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.community-btn {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 4px 0;
  text-align: left;
  min-width: 0;
  flex: 1;
}
.loc-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.community-name {
  max-width: 62vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.35;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chev {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 4px;
}
.user-chip, .notify-chip {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--primary-soft);
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.notify-chip {
  background: #eef2f0;
  color: var(--muted);
}
.notify-chip.on {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.notify-chip.off {
  background: #fff1d6;
  color: var(--warn);
}
.notify-chip.denied {
  background: #fdecea;
  color: var(--danger);
}
.linkish {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 10px 6px;
  min-height: 44px;
}

/* ——— 提示条 / 通知引导 ——— */
.hint-bar {
  margin: 12px 16px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
}
.install-hint {
  background: #eef6ff;
  border-color: #c5daf5;
  color: #1e3a5f;
}
.notify-banner {
  background: #e8f8ef;
  border-color: #9fd4b6;
  color: var(--text);
}
.notify-banner.warn {
  background: #fff8e8;
  border-color: #f0d9a0;
  color: #6a4b12;
}
.notify-banner.ok {
  background: var(--primary-soft);
  border-color: #9fd4b6;
}
.hint-text {
  flex: 1 1 180px;
  min-width: 0;
  font-size: 1rem;
  line-height: 1.45;
}
.hint-text strong {
  display: block;
  font-size: 1.12rem;
  margin-bottom: 4px;
  font-weight: 800;
}
.hint-text span { color: inherit; opacity: 0.92; }
.hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.hint-dismiss {
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: inherit;
  opacity: 0.65;
  padding: 8px 10px;
  min-width: 44px;
  min-height: 44px;
}

.safety-banner {
  margin: 12px 16px 0;
  padding: 14px 16px;
  background: #fff8e8;
  border: 1px solid #f0d9a0;
  border-radius: var(--radius);
  color: #5c4010;
  font-size: 1.02rem;
  line-height: 1.5;
}
.safety-banner strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.12rem;
  font-weight: 800;
}

.main { padding: 14px 16px 28px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 14px;
}
.section-head h1 {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 800;
}
.back-btn, .ghost-btn {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 8px;
  min-height: 48px;
}
.ghost-btn.compact, .primary-btn.compact, .secondary-btn.compact {
  min-height: 48px;
  padding: 10px 16px;
  font-size: 1rem;
  width: auto;
  margin-top: 0;
}

/* ——— 会话卡片 ——— */
.session-list { display: flex; flex-direction: column; gap: 14px; }
.card, .session-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.session-card { padding: 18px 16px; }
.session-card .spot {
  font-size: var(--fs-hero);
  font-weight: 800;
  margin: 0 0 10px;
  line-height: 1.3;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 1.02rem;
  font-weight: 700;
  min-height: 40px;
}
.tag.neutral { background: #eef2f0; color: var(--muted); }
.tag.warn { background: #fff1d6; color: var(--warn); }
.count-line {
  font-size: 1.2rem;
  margin: 0 0 6px;
  font-weight: 600;
}
.count-line strong {
  color: var(--primary-dark);
  font-size: 1.55rem;
  font-weight: 800;
}
.sub-line {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1.02rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.actions button { flex: 1 1 calc(50% - 10px); min-height: var(--btn-h); }

/* ——— 按钮 ——— */
.primary-btn, .secondary-btn, .danger-btn, .tiny-btn {
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  padding: 14px 16px;
  font-weight: 800;
  font-size: 1.08rem;
  min-height: var(--btn-h);
}
.primary-btn {
  background: var(--primary);
  color: #fff;
}
.primary-btn:active { background: var(--primary-dark); }
.secondary-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}
.danger-btn {
  background: #fff5f4;
  border-color: #f0c7c2;
  color: var(--danger);
}
.tiny-btn {
  min-height: 44px;
  padding: 10px 14px;
  font-size: 0.98rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  border-radius: 14px;
  flex: 0 0 auto !important;
}
.block { width: 100%; margin-top: 12px; }

/* ——— 空态 ——— */
.empty {
  text-align: center;
  padding: 40px 18px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}
.empty-icon { font-size: 2.8rem; margin-bottom: 10px; }
.empty-title {
  font-size: 1.28rem;
  font-weight: 800;
  margin: 0 0 10px;
}
.empty-desc {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 1.05rem;
  line-height: 1.5;
}
.empty-actions { display: flex; flex-direction: column; gap: 12px; }

/* ——— 表单 ——— */
.form.card { padding: 18px 16px; }
.field { display: block; margin-bottom: 18px; }
.field > span {
  display: block;
  font-weight: 800;
  font-size: 1.08rem;
  margin-bottom: 10px;
}
.field input, .field select, .share-url {
  width: 100%;
  min-height: var(--btn-h);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 12px 14px;
  background: #fff;
  font-size: 1.08rem;
  line-height: 1.4;
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c7366' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}
.location-summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.location-summary-text {
  flex: 1;
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.4;
  min-width: 140px;
}
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.seg#myStateSeg { grid-template-columns: 1fr 1fr; }
.seg button {
  min-height: var(--btn-h);
  border-radius: var(--radius-btn);
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 10px 8px;
}
.seg button.on {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.stepper {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 10px;
  align-items: center;
}
.stepper button {
  min-height: var(--btn-h);
  border-radius: var(--radius-btn);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.6rem;
  font-weight: 800;
}
.stepper input {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  min-height: var(--btn-h);
  width: 100%;
}
.form-hint {
  min-height: 1.3em;
  color: var(--danger);
  font-size: 1rem;
  margin: 0 0 10px;
  font-weight: 600;
}
.form-hint.ok { color: var(--primary-dark); }
.muted { color: var(--muted); font-size: 1.02rem; line-height: 1.5; }

/* ——— FAB ——— */
.fab-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 14px 16px calc(14px + var(--safe-bottom));
  pointer-events: none;
  max-width: 520px;
  margin: 0 auto;
}
.fab {
  pointer-events: auto;
  width: 100%;
  min-height: var(--btn-h-lg);
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #36b078, var(--primary-dark));
  color: #fff;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 32px rgba(47, 158, 106, 0.38);
}
.fab.hidden-fab { display: none; }

/* ——— 弹层 ——— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 24, 0.48);
}
.modal-sheet {
  position: relative;
  width: min(520px, 100%);
  max-height: 90dvh;
  overflow: auto;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 22px 18px calc(22px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
}
.modal-sheet h2 {
  margin: 0 0 10px;
  font-size: 1.4rem;
  font-weight: 800;
}
.loc-sheet .loc-step-hint { margin: 0 0 14px; }
.loc-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.loc-steps span {
  text-align: center;
  padding: 8px 4px;
  border-radius: 999px;
  background: #eef2f0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}
.loc-steps span.on {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.loc-steps span.done {
  background: #d8f0e4;
  color: var(--primary-dark);
}
.row { display: flex; gap: 10px; align-items: stretch; }
.row input { flex: 1; min-width: 0; }
.row .secondary-btn { flex-shrink: 0; white-space: nowrap; }
.choice-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 18px; }
.choice-list button {
  min-height: 56px;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  font-size: 1.08rem;
}
.choice-list button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  background: rgba(26, 46, 36, 0.94);
  color: #fff;
  padding: 14px 18px;
  border-radius: 14px;
  max-width: min(92vw, 420px);
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.4;
}

@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-sheet {
    border-radius: 22px;
    padding-bottom: 22px;
  }
}

/* 更大触控：老年友好补充 */
@media (max-width: 420px) {
  .community-name { max-width: 58vw; font-size: 1.05rem; }
  .user-chip { display: none; }
  .actions button { flex: 1 1 100%; }
}
