/* ============================================================
   帮遛狗 · 全局样式与组件库
   依赖 tokens.css
   ============================================================ */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-deep);
  color: var(--ink);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: var(--primary); text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0; }

/* ---------- app shell ---------- */
.app-shell {
  position: relative;
  max-width: var(--app-max);
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
.appbar {
  flex: none;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.appbar .ab-title {
  flex: 1;
  font-size: var(--fs-lg);
  font-weight: 500;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar .ab-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  color: var(--ink-2);
  flex: none;
}
.appbar .ab-btn:active { background: var(--surface-3); }
.appbar .ab-slot { min-width: 38px; flex: none; display: flex; justify-content: flex-end; }

.screen {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--sp-5);
  scroll-behavior: smooth;
}
.screen.no-pad { padding-bottom: 0; }

.tabbar {
  flex: none;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  flex: 1;
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--fs-xs);
  color: var(--hint);
  transition: color .15s;
  position: relative;
}
.tabbar .tab.active { color: var(--primary); }
.tabbar .tab:active { background: var(--surface-2); }
.tabbar .tab .tab-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--red-600);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

/* ---------- layout helpers ---------- */
.pad      { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.pad-y    { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
.row      { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.row-top  { display: flex; align-items: flex-start; gap: var(--sp-2); }
.stack    { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.grow     { flex: 1; min-width: 0; }
.center   { text-align: center; }
.hidden   { display: none !important; }
.mt-4{margin-top:var(--sp-1)} .mt-8{margin-top:var(--sp-2)} .mt-12{margin-top:var(--sp-3)}
.mt-16{margin-top:var(--sp-4)} .mt-24{margin-top:var(--sp-6)}
.mb-4{margin-bottom:var(--sp-1)} .mb-8{margin-bottom:var(--sp-2)} .mb-12{margin-bottom:var(--sp-3)}
.mb-16{margin-bottom:var(--sp-4)} .mb-24{margin-bottom:var(--sp-6)}
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- typography ---------- */
.t-2xl  { font-size: var(--fs-2xl); font-weight: 500; line-height: 1.3; }
.t-xl   { font-size: var(--fs-xl);  font-weight: 500; line-height: 1.35; }
.t-lg   { font-size: var(--fs-lg);  font-weight: 500; }
.t-md   { font-size: var(--fs-base); font-weight: 500; }
.t-sm   { font-size: var(--fs-md); }
.muted  { color: var(--muted); }
.hint   { color: var(--hint); }
.sm     { font-size: var(--fs-sm); }
.xs     { font-size: var(--fs-xs); }
.mono   { font-variant-numeric: tabular-nums; }
.sec-title {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--muted);
  margin: var(--sp-5) var(--sp-4) var(--sp-2);
  letter-spacing: .02em;
}

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.card-tight { padding: var(--sp-3); }
.card-flat { background: var(--surface-2); }
.card-plain { border: none; box-shadow: none; background: transparent; }

/* ---------- button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 500;
  background: var(--surface-3);
  color: var(--ink);
  transition: transform .1s ease, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); opacity: .92; }
.btn:disabled { opacity: .4; transform: none; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-teal    { background: var(--teal);    color: #fff; }
.btn-amber   { background: var(--amber-600); color: #fff; }
.btn-danger  { background: var(--red);     color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); }
.btn-ghost   { background: transparent; color: var(--primary); }
.btn-block   { display: flex; width: 100%; }
.btn-lg      { padding: 14px 20px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn-sm      { padding: 6px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-icon    { width: 40px; height: 40px; padding: 0; border-radius: var(--r-md); }

/* ---------- action bar (吸底) ---------- */
.actionbar {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 72%, rgba(246,245,242,0));
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
  display: flex;
  gap: var(--sp-2);
  z-index: 15;
}
.actionbar .btn { flex: 1; }

/* ---------- form ---------- */
.field { margin-bottom: var(--sp-4); }
.field-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: var(--sp-2);
}
.field-label .req { color: var(--red-600); }
.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-base);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.input::placeholder, .textarea::placeholder { color: var(--hint); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.input-err { border-color: var(--red-600); }
.field-hint { font-size: var(--fs-sm); color: var(--hint); margin-top: 6px; line-height: 1.5; }
.field-err  { font-size: var(--fs-sm); color: var(--red); margin-top: 6px; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 64px; }
.input-suffix .sfx {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: var(--fs-md); color: var(--muted); padding: 6px 10px; border-radius: var(--r-sm);
}
.input-suffix .sfx.act { color: var(--primary); font-weight: 500; }
.input-suffix .sfx:disabled { color: var(--hint); }

/* ---------- choice ---------- */
.choice-group { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.choice {
  padding: 9px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: var(--fs-md);
  color: var(--ink-2);
  transition: all .15s;
}
.choice.on {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 500;
}
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.choice-grid .choice { text-align: center; }

/* ---------- check row ---------- */
.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  margin-bottom: var(--sp-2);
  transition: all .15s;
}
.check-row:last-child { margin-bottom: 0; }
.check-row.on { border-color: var(--primary); background: var(--primary-50); }
.check-box {
  width: 20px; height: 20px;
  flex: none;
  border-radius: 6px;
  border: 1.5px solid var(--line-2);
  background: #fff;
  display: grid;
  place-items: center;
  margin-top: 1px;
  color: transparent;
  transition: all .15s;
}
.check-row.on .check-box { background: var(--primary); border-color: var(--primary); color: #fff; }
.check-row .cr-text { flex: 1; font-size: var(--fs-md); line-height: 1.55; }
.check-row .cr-title { font-weight: 500; color: var(--ink); }
.check-row .cr-desc { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }

/* ---------- badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  line-height: 1.6;
}
.badge-pending   { background: var(--amber-50);   color: var(--amber); }
.badge-accepted  { background: var(--primary-50); color: var(--primary); }
.badge-walking   { background: var(--teal-50);    color: var(--teal); }
.badge-submitted { background: var(--amber-50);   color: var(--amber); }
.badge-completed { background: var(--teal-50);    color: var(--teal); }
.badge-cancelled { background: var(--gray-50);    color: var(--gray-600); }
.badge-disputed  { background: var(--red-50);     color: var(--red); }
.badge-ghost     { background: var(--surface-3);  color: var(--muted); }

/* ---------- list ---------- */
.list-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-3);
}
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px var(--sp-4);
  border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--surface-2); }
.list-item .li-title { font-size: var(--fs-base); font-weight: 500; }
.list-item .li-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.list-item .li-arrow { color: var(--hint); flex: none; }

/* ---------- avatar ---------- */
.avatar {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 500;
  font-size: var(--fs-lg);
  overflow: hidden;
}
.avatar-sm { width: 34px; height: 34px; border-radius: 11px; font-size: var(--fs-md); }
.avatar-lg { width: 64px; height: 64px; border-radius: 20px; font-size: var(--fs-2xl); }
.avatar-teal { background: var(--teal-50); color: var(--teal); }
.avatar-amber { background: var(--amber-50); color: var(--amber); }

/* ---------- money ---------- */
.money { font-weight: 500; color: var(--amber-600); font-variant-numeric: tabular-nums; }
.money-lg { font-size: var(--fs-xl); font-weight: 500; color: var(--amber-600); font-variant-numeric: tabular-nums; }
.money-2xl { font-size: var(--fs-2xl); font-weight: 500; color: var(--amber-600); font-variant-numeric: tabular-nums; }

/* ---------- divider / kv ---------- */
.divider { height: 1px; background: var(--line); margin: var(--sp-3) 0; }
.kv { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-md); padding: 6px 0; }
.kv .k { color: var(--muted); flex: none; }
.kv .v { color: var(--ink); text-align: right; }
.kv.total .k, .kv.total .v { font-weight: 500; font-size: var(--fs-base); }

/* ---------- stepper ---------- */
.stepper { display: flex; align-items: center; gap: 5px; margin-bottom: var(--sp-4); }
.stepper .st { flex: 1; height: 4px; border-radius: 2px; background: var(--line-2); transition: background .2s; }
.stepper .st.on { background: var(--primary); }
.stepper .st.warn { background: var(--amber-600); }
.stepper .st.done { background: var(--teal); }
.stepper .st.danger { background: var(--red-600); }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 5px; top: 8px; bottom: 8px;
  width: 1.5px;
  background: var(--line-2);
}
.tl-item { position: relative; margin-bottom: var(--sp-4); }
.tl-item:last-child { margin-bottom: 0; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -21px; top: 5px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-sizing: content-box;
}
.tl-item.done::before { background: var(--teal); }
.tl-item.pending::before { background: var(--line-2); }
.tl-item .tl-t { font-size: var(--fs-md); font-weight: 500; }
.tl-item .tl-d { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.tl-item .tl-time { font-size: var(--fs-xs); color: var(--hint); margin-top: 2px; }

/* ---------- media grid ---------- */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.media-grid .mi {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--hint);
  overflow: hidden;
  position: relative;
}
.media-grid .mi .mi-time {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(44,44,42,.55);
  color: #fff;
  font-size: 10px;
  padding: 2px 5px;
  text-align: left;
}

/* ---------- stat ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 10px;
  text-align: center;
}
.stat .st-v { font-size: var(--fs-xl); font-weight: 500; font-variant-numeric: tabular-nums; }
.stat .st-k { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

/* ---------- callout ---------- */
.callout {
  border-left: 3px solid;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: 11px 14px;
  font-size: var(--fs-md);
  line-height: 1.65;
  margin: var(--sp-3) 0;
}
.callout b { font-weight: 500; }
.callout-info   { border-color: var(--primary); background: var(--primary-50); color: var(--primary-900); }
.callout-warn   { border-color: var(--amber-100); background: var(--amber-50); color: #633806; }
.callout-danger { border-color: var(--red-100); background: var(--red-50); color: #791F1F; }
.callout-ok     { border-color: var(--teal-100); background: var(--teal-50); color: #085041; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 64px 32px; color: var(--hint); }
.empty .em-ic { margin: 0 auto var(--sp-3); opacity: .45; width: 44px; height: 44px; }
.empty .em-t { font-size: var(--fs-base); color: var(--muted); font-weight: 500; }
.empty .em-d { font-size: var(--fs-sm); margin-top: 4px; line-height: 1.6; }

/* ---------- seg ---------- */
.seg {
  display: flex;
  background: var(--surface-3);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.seg .sg {
  flex: 1;
  text-align: center;
  padding: 7px 6px;
  border-radius: 8px;
  font-size: var(--fs-md);
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg .sg.on { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-1); }

/* ---------- overlay ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(44,44,42,.42);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: wd-fade .18s ease;
}
.mask.center { align-items: center; padding: var(--sp-5); }
@keyframes wd-fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: var(--app-max);
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-5) var(--sp-5) calc(var(--sp-5) + env(safe-area-inset-bottom));
  max-height: 86dvh;
  overflow-y: auto;
  animation: wd-up .22s ease;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.sheet-title { font-size: var(--fs-lg); font-weight: 500; }

.modal {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  max-height: 82dvh;
  overflow-y: auto;
  animation: wd-pop .2s ease;
}
@keyframes wd-up { from { transform: translateY(28px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
@keyframes wd-pop { from { transform: scale(.94); opacity: .5; } to { transform: scale(1); opacity: 1; } }

/* ---------- toast ---------- */
.toast-wrap {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 88vw;
}
.toast {
  background: rgba(44,44,42,.93);
  color: #fff;
  font-size: var(--fs-md);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  animation: wd-toast .22s ease;
  line-height: 1.5;
}
.toast.err { background: var(--red); }
.toast.ok  { background: var(--teal); }
@keyframes wd-toast { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- timer ---------- */
.timer-wrap { text-align: center; padding: var(--sp-5) 0; }
.timer-k { font-size: var(--fs-md); color: var(--muted); margin-bottom: var(--sp-1); }
.timer {
  font-size: 46px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--ink);
}
.timer.pulse { color: var(--teal); }

/* ---------- gallery (拍照占位) ---------- */
.shot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.shot {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--hint);
  border: 1px dashed var(--line-2);
  position: relative;
  overflow: hidden;
}
.shot .shot-lb { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; text-align: center; padding: 2px; background: rgba(44,44,42,.5); color: #fff; }
.shot.b1 { background: #E1F5EE; }
.shot.b2 { background: #E6F1FB; }
.shot.b3 { background: #FAEEDA; }
.shot.b4 { background: #FAECE7; }

/* ---------- misc ---------- */
.role-tip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--muted);
  background: var(--surface-3);
  border-radius: var(--r-pill);
  padding: 5px 12px;
}
.switch-track {
  width: 44px; height: 26px;
  border-radius: var(--r-pill);
  background: var(--line-2);
  position: relative;
  transition: background .2s;
  flex: none;
}
.switch-track.on { background: var(--primary); }
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
  box-shadow: var(--shadow-1);
}
.switch-track.on::after { transform: translateX(18px); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: wd-sk 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes wd-sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.fade-in { animation: wd-in .22s ease; }
@keyframes wd-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 400px) {
  .timer { font-size: 40px; }
}

/* ============================================================
   启动加载态（在线模式同步服务端数据时显示）
   ============================================================ */
.boot-splash {
  padding: 88px 32px;
  text-align: center;
}
.boot-splash .bs-dog {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-50);
  color: var(--primary);
  animation: wd-pulse 1.4s ease-in-out infinite;
}
.boot-splash .bs-t { font-size: var(--fs-lg); font-weight: 500; color: var(--ink); }
.boot-splash .bs-d { font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; line-height: 1.6; }
@keyframes wd-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.92); opacity: .72; }
}
