:root {
  --blue: #3B6BFF;
  --blue-soft: #EAF0FF;
  --red: #FF4D6A;
  --teal: #00B4A6;
  --orange: #FF8A3D;
  --purple: #8B5CF6;
  --ink: #232838;
  --ink-2: #5B6379;
  --dim: #8A90A6;
  --line: #ECEFF7;
  --bg: #F5F7FC;
  --card: #FFFFFF;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(35, 40, 56, .06), 0 10px 30px rgba(35, 40, 56, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font: inherit; }
.hidden { display: none !important; }

.phone {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: calc(62px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  background: rgba(245, 247, 252, .88);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(236, 239, 247, .9);
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--blue-soft); display: grid; place-items: center; font-size: 22px; flex: none;
}
.tb-text { min-width: 0; }
.tb-text h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.tb-text p { margin: 0; font-size: 12.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-btn {
  flex: none; padding: 8px 13px; border-radius: 999px;
  background: var(--blue); color: #fff; font-size: 13px; font-weight: 600;
}
.tb-btn:active { opacity: .85; }

.content { padding: 12px 14px 8px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-sub { font-size: 11.5px; color: var(--dim); }
.hint { margin: 6px 2px 0; font-size: 12px; color: var(--dim); line-height: 1.5; }
.link-btn { font-size: 12.5px; color: var(--blue); font-weight: 600; padding: 2px 0; }
.link-btn.primary { font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ---------- 状态大卡 ---------- */
.hero {
  border-radius: 20px; padding: 18px; margin-bottom: 12px; color: #fff;
  box-shadow: 0 8px 24px rgba(59, 107, 255, .22);
  background: linear-gradient(135deg, #4C79FF 0%, #3B6BFF 55%, #2F55E0 100%);
  position: relative; overflow: hidden;
}
.hero.home { background: linear-gradient(135deg, #35C7A8 0%, #12A88F 100%); box-shadow: 0 8px 24px rgba(18, 168, 143, .22); }
.hero.soon { background: linear-gradient(135deg, #FFA348 0%, #F87F26 100%); box-shadow: 0 8px 24px rgba(248, 127, 38, .22); }
.hero::after {
  content: ''; position: absolute; right: -30px; top: -40px;
  width: 170px; height: 170px; border-radius: 50%; background: rgba(255, 255, 255, .12);
}
.hero-tag { font-size: 12.5px; opacity: .9; letter-spacing: .4px; }
.hero-city { font-size: 30px; font-weight: 700; margin: 2px 0 6px; letter-spacing: .5px; }
.hero-line { font-size: 13.5px; opacity: .94; }
.hero-line + .hero-line { margin-top: 2px; }
.hero-foot { margin-top: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  background: rgba(255, 255, 255, .2); border-radius: 999px; padding: 4px 11px;
  font-size: 12px; backdrop-filter: blur(4px);
}
.pill.solid { background: #fff; color: var(--blue); font-weight: 700; }

/* ---------- 快捷按钮 ---------- */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.big-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 15px 8px; border-radius: var(--radius); font-size: 15px; font-weight: 650;
  box-shadow: var(--shadow); transition: transform .08s ease;
}
.big-btn:active { transform: scale(.98); }
.big-btn.primary { background: linear-gradient(135deg, #4C79FF, #2F55E0); color: #fff; }
.big-btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.bb-icon { font-size: 17px; }

/* ---------- 行程卡片 ---------- */
.trip {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff; border-radius: 14px; padding: 12px 13px;
  box-shadow: 0 1px 4px rgba(35, 40, 56, .05);
  border-left: 3px solid var(--line);
  width: 100%; text-align: left;
}
.trip:active { background: #FAFBFF; }
.trip.ongoing { border-left-color: var(--red); }
.trip.upcoming { border-left-color: var(--blue); }
.trip.done { border-left-color: #D6DAE6; opacity: .85; }
.trip-body { flex: 1; min-width: 0; }
.trip-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.trip-city { font-size: 16px; font-weight: 650; }
.badge { font-size: 11px; padding: 1.5px 7px; border-radius: 6px; font-weight: 600; }
.badge.red { background: #FFEDF0; color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #F0F2F8; color: #7C839A; }
.badge.orange { background: #FFF1E4; color: #D9720F; }
.trip-meta { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.trip-note { font-size: 12px; color: var(--dim); margin-top: 2px; }
.trip-side { text-align: right; flex: none; }
.trip-day { font-size: 12px; color: var(--dim); }
.trip-del { font-size: 12px; color: #C3C8D6; padding: 0 2px; }
.trip-wrap { position: relative; }
.trip-wrap:hover .trip-del { color: var(--red); }

.empty { text-align: center; padding: 26px 10px; color: var(--dim); font-size: 13.5px; }
.empty-emoji { font-size: 30px; display: block; margin-bottom: 6px; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips.tight { margin-top: 6px; gap: 5px; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; font-size: 13px;
  background: #F1F3F9; color: var(--ink-2); border: 1px solid transparent;
}
.chip.active { background: var(--blue-soft); color: var(--blue); font-weight: 650; border-color: #CFDEFF; }
.chip.tiny { padding: 4px 9px; font-size: 12px; background: #F4F6FC; }
.chip.sel { background: var(--blue); color: #fff; font-weight: 600; }

/* ---------- 迷你指标 ---------- */
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.mini-item { background: #F8F9FE; border-radius: 12px; padding: 10px 4px; }
.mini-num { font-size: 20px; font-weight: 700; color: var(--blue); }
.mini-label { font-size: 11.5px; color: var(--dim); margin-top: 1px; }

.stat-hero {
  background: linear-gradient(135deg, #2F3A63 0%, #1F2743 100%);
  color: #fff; border-radius: 20px; padding: 18px; margin-bottom: 12px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center;
}
.stat-hero .sn { font-size: 24px; font-weight: 700; }
.stat-hero .sl { font-size: 11.5px; opacity: .75; }
.stat-hero .su { font-size: 10.5px; opacity: .6; }

/* ---------- 图表 ---------- */
.donut-wrap { display: flex; align-items: center; gap: 12px; }
.donut-wrap > div:first-child { width: 150px; flex: none; }
.legend { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.lg-item { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.lg-item i { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------- 地图 ---------- */
.map-card { padding-bottom: 10px; }
.map-box { width: 100%; height: 320px; border-radius: 12px; overflow: hidden; background: #EEF1F8; }
.map-fallback { padding: 10px 0 0; }
.map-pop {
  background: #fff; border-radius: 10px; padding: 8px 11px; min-width: 170px;
  box-shadow: 0 6px 20px rgba(35, 40, 56, .16); font-size: 12.5px; color: var(--ink);
}
.map-pop b { font-size: 14px; }
.mp-badge { font-size: 10.5px; background: var(--blue-soft); color: var(--blue); padding: 1px 6px; border-radius: 5px; margin-left: 6px; }
.mp-line { margin-top: 3px; }
.mp-dim { color: var(--dim); }
.map-legend { display: flex; gap: 14px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.map-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot.red { background: var(--red); }
.dot.blue { background: var(--blue); }
.dot.gray { background: #B6BCD0; }
.city-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.city-cloud span { background: #F4F6FC; border-radius: 8px; padding: 4px 10px; font-size: 12.5px; color: var(--ink-2); }

/* ---------- 表单弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(23, 27, 40, .42); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 480px; background: #fff; border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto;
  animation: up .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes up { from { transform: translateY(24px) } to { transform: translateY(0) } }
.sheet-bar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; position: sticky; top: 0; background: #fff; }
.sheet-bar b { font-size: 15px; }
.field { margin-bottom: 14px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.input {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: #F8F9FE; outline: none; font-size: 14.5px; color: var(--ink);
}
.input:focus { border-color: var(--blue); background: #fff; }
.sug { border: 1px solid var(--line); border-radius: 12px; margin-top: 6px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.sug button { display: block; width: 100%; text-align: left; padding: 9px 12px; font-size: 14px; border-bottom: 1px solid #F3F5FA; }
.sug button:last-child { border-bottom: none; }
.sug button:active { background: #F6F8FF; }
.sug small { color: var(--dim); font-size: 11.5px; }
.more { margin-bottom: 12px; }
.more summary { font-size: 12.5px; color: var(--blue); font-weight: 600; padding: 4px 0; cursor: pointer; }
.more .input { margin-top: 6px; }
.sheet-foot:empty { display: none; }
.sheet-foot { padding-top: 4px; }
.sheet-foot button { width: 100%; padding: 11px; border-radius: 12px; background: #FFF0F3; color: var(--red); font-size: 14px; font-weight: 600; }

/* ---------- 行按钮 ---------- */
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-btn {
  padding: 8px 13px; border-radius: 10px; background: #F3F5FB; color: var(--ink-2);
  font-size: 13px; font-weight: 600; display: inline-block; cursor: pointer;
}
.mini-btn.danger { background: #FFF0F3; color: var(--red); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .94); backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 6px; font-size: 11px; color: var(--dim); }
.tab span { font-size: 19px; line-height: 1.1; }
.tab.active { color: var(--blue); font-weight: 650; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 90;
  background: rgba(28, 32, 46, .93); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 13.5px; max-width: 84%; text-align: center; animation: fade .2s ease;
}

/* 只读（家人）模式：隐藏编辑入口 */
.readonly .quick, .readonly #btnShare, .readonly #dataCard { display: none; }
.readonly .trip-del { display: none; }
.readonly .hint { display: none; }

@media (min-width: 520px) {
  .phone { box-shadow: 0 0 40px rgba(35, 40, 56, .08); min-height: 100vh; }
}
