:root {
  --bg: #f4f0ea;
  --card: #fffcf8;
  --ink: #2a221c;
  --muted: #7a6f66;
  --line: #e7dfd4;
  --primary: #8b4513;
  --primary-dark: #6e3610;
  --accent: #1f6f54;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --shadow: 0 8px 24px rgba(42, 34, 28, 0.08);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --bar-h: 64px;
  --nav-h: 52px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: #1c1410; color: var(--ink);
  min-height: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

#app {
  width: min(430px, 100vw);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.page {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.page.active { display: flex; }

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--bar-h) + var(--safe-bottom) + 18px);
  -webkit-overflow-scrolling: touch;
}
.page-body.center-pad { padding-top: 48px; }
.page-body.has-top-nav { padding-top: 18px; }
.home-body { padding-bottom: calc(72px + var(--safe-bottom) + 18px); }

.top-nav {
  height: var(--nav-h);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 48px 1fr 56px;
  align-items: center;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 240, 234, 0.96);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 20;
}
.nav-title { text-align: center; font-weight: 650; font-size: 16px; }
.nav-back, .nav-text, .icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); font-size: 24px;
}
.nav-text { width: auto; padding: 0 8px; font-size: 14px; color: var(--primary); }
.icon-btn { background: #efe8df; font-size: 16px; font-weight: 700; }

.progress { height: 3px; background: #e8e0d6; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #c47a3a); transition: width .25s ease; }

.bottom-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: rgba(255, 252, 248, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  display: grid; gap: 8px;
}
.bottom-bar.dual { grid-template-columns: 1fr 1.4fr; }

.btn {
  min-height: 48px; border-radius: 14px; padding: 12px 16px;
  font-weight: 650; font-size: 15px;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.secondary { background: #efe8df; color: var(--ink); }
.btn.ghost { background: transparent; color: var(--muted); min-height: 40px; }
.btn:disabled { opacity: .45; }

.brand-mark {
  display: inline-block; letter-spacing: .28em; font-size: 12px;
  color: var(--primary); border: 1px solid #d8c3ad; border-radius: 999px;
  padding: 6px 12px; margin-bottom: 18px; background: #fff8f1;
}
.hero-title { margin: 0 0 8px; font-size: 28px; letter-spacing: .02em; }
.hero-sub { margin: 0 0 28px; color: var(--muted); line-height: 1.6; font-size: 15px; }

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); padding: 12px 14px; outline: none;
}
.field input:focus, .field select:focus { border-color: #c9a27d; box-shadow: 0 0 0 3px rgba(139,69,19,.08); }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.linkish { color: var(--primary); font-weight: 650; text-decoration: underline; padding: 0 2px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

.section-title { font-size: 18px; font-weight: 700; margin: 8px 0 6px; }
.section-desc { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 14px; }
.section-label {
  margin: 18px 0 10px; font-size: 13px; font-weight: 700; color: var(--muted);
  letter-spacing: .04em;
}
.row-between { display: flex; justify-content: space-between; align-items: center; }

.choice-grid { display: grid; gap: 10px; }
.choice-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.choice {
  text-align: left; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 14px; padding: 14px; min-height: 52px; box-shadow: var(--shadow);
}
.choice .c-title { font-weight: 650; font-size: 15px; }
.choice .c-desc { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.choice.selected {
  border-color: var(--primary); background: #fff6ec;
  box-shadow: 0 0 0 3px rgba(139,69,19,.08);
}
.choice.multi.selected::after { content: "✓"; float: right; color: var(--primary); font-weight: 700; }

.home-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.home-store { font-size: 20px; font-weight: 750; }
.home-city { color: var(--muted); font-size: 13px; margin-top: 2px; }

.week-card, .card, .shot-card, .job-item, .big-card, .tip-item, .check-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.week-card { padding: 14px; }
.week-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 10px; }
.week-track { height: 8px; background: #efe8df; border-radius: 999px; overflow: hidden; }
.week-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #3d9b78); transition: width .3s ease; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pill {
  font-size: 12px; padding: 4px 8px; border-radius: 999px; background: #efe8df; color: var(--muted);
}
.pill.ok { background: #e8f7ef; color: var(--ok); }
.pill.warn { background: #fff4e5; color: var(--warn); }
.pill.bad { background: #fef3f2; color: var(--danger); }

.big-card {
  width: 100%; text-align: left; padding: 16px; margin-bottom: 10px;
}
.big-card.primary-card {
  background: linear-gradient(135deg, #8b4513, #a45b28);
  color: #fff; border: 0;
}
.big-card.primary-card .big-card-desc { color: rgba(255,255,255,.82); }
.big-card.disabled { opacity: .45; }
.big-card-title { font-size: 16px; font-weight: 750; }
.big-card-desc { margin-top: 6px; font-size: 13px; color: var(--muted); }

.tip-list, .job-list { display: grid; gap: 8px; }
.tip-item, .job-item { padding: 12px 14px; text-align: left; }
.tip-item strong, .job-item strong { display: block; font-size: 14px; }
.meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,252,248,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.tab { color: var(--muted); font-size: 12px; font-weight: 650; }
.tab.active { color: var(--primary); }

.result-hero {
  padding: 16px; margin-bottom: 12px; background: linear-gradient(160deg, #fff8f1, #f7efe4);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.result-kicker { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .06em; }
.result-title { margin: 8px 0 12px; font-size: 20px; line-height: 1.35; font-weight: 780; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  background: rgba(255,255,255,.7); border-radius: 12px; padding: 10px;
  font-size: 12px; color: var(--muted);
}
.stat b { display: block; margin-top: 4px; color: var(--ink); font-size: 14px; }

.shot-card { padding: 14px; margin-bottom: 10px; }
.shot-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.shot-time {
  font-size: 12px; font-weight: 750; color: var(--primary);
  background: #fff1e4; padding: 4px 8px; border-radius: 999px;
}
.shot-line { margin: 6px 0; font-size: 13px; line-height: 1.5; }
.shot-line span { color: var(--muted); }
.tip-box {
  margin-top: 10px; background: #f3faf6; color: #176844; border-radius: 12px;
  padding: 10px 12px; font-size: 12px; line-height: 1.5;
}
.mini-actions { display: flex; gap: 8px; margin-top: 10px; }
.mini-btn {
  flex: 1; min-height: 40px; border-radius: 12px; background: #efe8df;
  font-size: 13px; font-weight: 650;
}

.fold { margin: 12px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); }
.fold summary {
  list-style: none; padding: 14px; font-weight: 700; cursor: pointer; background: #fbf7f2;
}
.fold summary::-webkit-details-marker { display: none; }
.fold-body { padding: 0 14px 14px; font-size: 13px; line-height: 1.6; color: var(--ink); }
.mono {
  white-space: pre-wrap; background: #f7f2eb; border-radius: 12px; padding: 12px;
  font-size: 13px; line-height: 1.55;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  min-height: 36px; padding: 8px 12px; border-radius: 999px; background: #efe8df;
  font-size: 13px; font-weight: 650;
}
.chip.selected { background: #8b4513; color: #fff; }

.check-list { display: grid; gap: 8px; margin-top: 8px; }
.check-item {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  padding: 12px; border-radius: 12px; background: #fbf7f2; border: 1px solid var(--line);
}
.check-item input { margin-top: 2px; width: 18px; height: 18px; }

.risk-banner {
  margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 650;
}
.risk-banner.green { background: #e8f7ef; color: var(--ok); }
.risk-banner.yellow { background: #fff4e5; color: var(--warn); }
.risk-banner.red { background: #fef3f2; color: var(--danger); }

.toast {
  position: absolute; left: 50%; bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(42,34,28,.92); color: #fff; padding: 10px 14px; border-radius: 999px;
  font-size: 13px; z-index: 50; white-space: nowrap; max-width: 90%;
  overflow: hidden; text-overflow: ellipsis;
}

.modal {
  position: absolute; inset: 0; background: rgba(28,20,16,.45);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
.modal-card {
  width: 100%; background: var(--card); border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
}
.modal-title { font-size: 18px; font-weight: 750; margin-bottom: 8px; }
.modal-text { color: var(--muted); line-height: 1.6; font-size: 14px; margin-bottom: 16px; }

.empty {
  padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px;
  border: 1px dashed var(--line); border-radius: 14px; background: rgba(255,255,255,.4);
}

@media (min-width: 860px) {
  body {
    display: grid; place-items: center; min-height: 100vh;
    background: radial-gradient(circle at top, #3a2a22, #120d0b 60%);
  }
  #app {
    min-height: 860px; height: 900px; border-radius: 28px; overflow: hidden;
    border: 8px solid #2a211c;
  }
}

#wizardBody,
#onboardBody,
#resultBody {
  padding: 18px 16px calc(var(--bar-h) + var(--safe-bottom) + 28px);
  overflow-y: auto;
  flex: 1;
}
