:root {
  --bg: #fff8f0;
  --ink: #1c1c1c;
  --white: #ffffff;
  --yellow: #ffd54a;
  --orange: #ff8a4c;
  --green: #3ecf8e;
  --blue: #4da3ff;
  --violet: #9b8cff;
  --pink: #ff6b9d;
  --gray: #c8c4bc;
  --radius: 28px;
  --font: "Nunito", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  min-height: 100dvh;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  min-height: 100%;
  min-height: 100dvh;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  min-width: 0;
}
.top h1 {
  margin: 0;
  min-width: 0;
  flex: 1;
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 900;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.chip {
  width: 44px;
  height: 44px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.chip:active { transform: scale(0.94); }
.chip svg { display: block; }
.fab {
  width: 56px;
  height: 56px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}
.fab:active { transform: scale(0.94); }

/* 顶部状态色块 — 像 Kids 分类卡片 */
.tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.tile {
  appearance: none;
  border: none;
  border-radius: 22px;
  padding: 14px 8px 12px;
  cursor: pointer;
  text-align: center;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.12s ease;
}
.tile:active { transform: scale(0.96); }
.tile .n {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}
.tile .l {
  font-size: 12px;
  font-weight: 800;
  opacity: 0.85;
}
.tile[data-filter="all"] { background: var(--yellow); }
.tile[data-filter="cooling"] { background: var(--orange); }
.tile[data-filter="ready"] { background: var(--green); }
.tile[data-filter="bought"] { background: var(--blue); }
.tile[data-filter="dropped"] { background: var(--violet); }
.tile:not(.active) { opacity: 0.55; transform: scale(0.96); }
.tile.active { opacity: 1; outline: 4px solid var(--ink); outline-offset: 2px; }

/* 列表：大色块卡片 */
.list {
  display: grid;
  gap: 14px;
}
.empty {
  padding: 64px 20px;
  text-align: center;
  background: var(--white);
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 800;
  color: #999;
}

.card {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font: inherit;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  min-height: 110px;
  transition: transform 0.12s ease;
}
.card:active { transform: scale(0.98); }
.card.cooling { background: var(--orange); }
.card.ready { background: var(--green); }
.card.bought { background: var(--blue); }
.card.dropped { background: var(--violet); color: #fff; }

.card .name {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
  grid-column: 1 / -1;
  word-break: break-word;
}
.card .price {
  font-size: 16px;
  font-weight: 800;
  opacity: 0.75;
}
.card .badge {
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
}

/* 全屏聚焦层 */
.focus {
  border: none;
  padding: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
}
.focus::backdrop { background: var(--bg); }
.focus[data-tone="info"] { background: var(--yellow); }
.focus[data-tone="info"]::backdrop { background: var(--yellow); }
.focus.onboard-screen,
.focus.onboard-screen::backdrop {
  background: var(--yellow);
}
.focus[data-tone="settings"] { background: #eef4ff; color: var(--ink); }
.focus[data-tone="settings"]::backdrop { background: #eef4ff; }

.settings-body {
  justify-content: flex-start !important;
  gap: 22px;
  overflow: auto;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-title {
  margin: 0;
  font-size: 32px;
  font-weight: 900;
}
.help-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
  flex: none;
}
.help-btn:active { transform: scale(0.94); }
.help-lead {
  margin: -8px 0 4px;
  font-size: 16px;
  font-weight: 800;
  opacity: 0.55;
}
.cool-rows {
  display: grid;
  gap: 10px;
}
.cool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 22px;
  padding: 16px 20px;
  font-weight: 900;
}
.cool-score {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.cool-days {
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.cool-days small {
  font-size: 14px;
  margin-left: 2px;
  opacity: 0.7;
}
.cool-row.t3 { background: var(--green); }
.cool-row.t7 { background: #8fe0b0; }
.cool-row.t14 { background: var(--yellow); }
.cool-row.t21 { background: var(--orange); }
.cool-row.t30 { background: var(--pink); color: #fff; }
.cool-row.t30 .cool-days small { opacity: 0.85; }
.settings-sec {
  display: grid;
  gap: 10px;
}
.settings-label {
  font-size: 14px;
  font-weight: 800;
  opacity: 0.55;
  letter-spacing: 0.04em;
}
.settings-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.settings-stat {
  border-radius: 22px;
  padding: 16px 10px;
  text-align: center;
  color: var(--ink);
}
.settings-stat.dropped { background: var(--violet); color: #fff; }
.settings-stat.saved { background: var(--green); }
.settings-stat.cooling { background: var(--orange); }
.settings-stat b {
  display: block;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.1;
}
.settings-stat span {
  font-size: 12px;
  font-weight: 800;
  opacity: 0.75;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: 20px;
  padding: 8px 8px 8px 18px;
}
.settings-row .k {
  flex: 1;
  font-size: 18px;
  font-weight: 800;
}
.settings-row input {
  width: 96px;
  border: none;
  border-radius: 14px;
  background: #f3f6fb;
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  padding: 12px 10px;
  text-align: right;
  outline: none;
}
.focus[data-tone="quiz"] { background: var(--pink); }
.focus[data-tone="quiz"]::backdrop { background: var(--pink); }
.focus[data-tone="done"] { background: var(--green); }
.focus[data-tone="done"]::backdrop { background: var(--green); }
.focus[data-tone="detail"] { background: var(--bg); }
.focus[data-tone="detail"]::backdrop { background: var(--bg); }
.focus[data-tone="cooling"] { background: var(--orange); }
.focus[data-tone="cooling"]::backdrop { background: var(--orange); }
.focus[data-tone="ready"] { background: var(--green); }
.focus[data-tone="ready"]::backdrop { background: var(--green); }
.focus[data-tone="bought"] { background: var(--blue); }
.focus[data-tone="bought"]::backdrop { background: var(--blue); }
.focus[data-tone="dropped"] { background: var(--violet); color: #fff; }
.focus[data-tone="dropped"]::backdrop { background: var(--violet); }

.focus-inner {
  margin: 0;
  height: 100%;
  max-width: 560px;
  margin-inline: auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}
.x {
  align-self: flex-end;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.12);
  color: inherit;
  font-size: 28px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
}
.focus-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 12px 0;
}
.focus-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.detail-foot {
  display: grid;
  gap: 12px;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.confirm {
  border: none;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 48px);
}
.confirm::backdrop {
  background: rgba(28, 28, 28, 0.45);
}
.confirm-card {
  background: var(--white);
  color: var(--ink);
  border-radius: 28px;
  padding: 28px 24px 20px;
  min-width: min(320px, 100%);
  box-shadow: none;
}
.confirm-text {
  margin: 0 0 22px;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: stretch;
}
.confirm-actions .btn {
  flex: 1;
  justify-content: center;
  text-align: center;
}

.field input {
  width: 100%;
  border: none;
  border-radius: 20px;
  background: rgba(255,255,255,0.7);
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  padding: 18px 20px;
  outline: none;
  color: var(--ink);
}
.field input::placeholder { color: rgba(0,0,0,0.35); }

.q-index {
  font-size: 16px;
  font-weight: 800;
  opacity: 0.7;
}
.q-title {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.2;
}
.opts {
  display: grid;
  gap: 10px;
}
.opt {
  appearance: none;
  border: none;
  border-radius: 20px;
  background: rgba(255,255,255,0.85);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  padding: 18px 20px;
  text-align: left;
  cursor: pointer;
}
.opt:active { transform: scale(0.98); }
.opt.picked {
  background: var(--ink);
  color: #fff;
}

.result-num {
  font-size: 96px;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.04em;
}
.result-days {
  font-size: 28px;
  font-weight: 900;
}

.detail-name {
  margin: 0;
  font-size: 36px;
  font-weight: 900;
  line-height: 1.15;
}
.blocks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.block {
  background: rgba(255,255,255,0.75);
  border-radius: 22px;
  padding: 16px 12px;
  text-align: center;
  color: var(--ink);
}
.block b {
  display: block;
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
}
.block span {
  font-size: 13px;
  font-weight: 800;
  opacity: 0.6;
}
.note {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  opacity: 0.7;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  padding: 14px 22px;
  cursor: pointer;
  background: rgba(0,0,0,0.12);
  color: inherit;
}
.btn.primary {
  background: var(--ink);
  color: #fff;
}
.btn.buy {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}
.btn:disabled { opacity: 0.4; }

.detail-actions {
  max-width: 100%;
}
.detail-actions .btn {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  justify-content: center;
  padding-left: 12px;
  padding-right: 12px;
  font-size: 15px;
}

.onboard-body {
  justify-content: center !important;
  gap: 28px;
  overflow: auto;
}
.onboard-intro {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.65;
  opacity: 0.82;
}
.onboard-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
  font-size: 16px;
  font-weight: 800;
  opacity: 0.7;
}
.onboard-steps li {
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.onboard-steps li::before {
  content: counter(step);
  counter-increment: step;
  font-variant-numeric: tabular-nums;
  opacity: 0.4;
  min-width: 1.2em;
}
.onboard-body { counter-reset: step; }
.onboard-ps {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.65;
  opacity: 0.82;
}
.onboard-foot {
  justify-content: stretch;
}
.onboard-foot .btn {
  flex: 1;
  text-align: center;
  justify-content: center;
  background: rgba(0,0,0,0.12);
  color: var(--ink);
}
.onboard-foot .btn.primary {
  background: var(--ink);
  color: #fff;
}

@media (max-width: 560px) {
  .tiles {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }
  .tile {
    min-height: 72px;
    min-width: 0;
    padding: 10px 2px 8px;
    border-radius: 14px;
  }
  .tile .n { font-size: 20px; }
  .tile .l {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
  }
  .tile.active { outline-width: 3px; outline-offset: 1px; }
  .card { padding: 18px 16px 14px; min-height: 96px; }
  .card .name { font-size: 18px; }
  .card .badge { font-size: 28px; }
  .q-title { font-size: 24px; }
  .result-num { font-size: 64px; }
  .detail-name { font-size: 26px; }
  .fab { width: 48px; height: 48px; font-size: 30px; }
  .chip { width: 40px; height: 40px; }
  .blocks { gap: 8px; }
  .block { padding: 12px 8px; }
  .block b { font-size: 18px; }
}
