/* 情绪天气 · 样式
   粉彩天空 + 圆角白卡 + 一点暖色点缀。移动优先。 */

:root {
  --paper: #eef4ff;
  --paper-deep: #e6edfb;
  --ink: #2a3350;
  --ink-soft: rgba(42, 51, 80, 0.62);
  --ink-faint: rgba(42, 51, 80, 0.38);
  --line: rgba(42, 51, 80, 0.09);
  --line-strong: rgba(42, 51, 80, 0.16);
  --accent: #7b6cf0;
  --accent-soft: rgba(123, 108, 240, 0.12);
  --radius: 24px;
  --shadow-card: 0 34px 64px -34px rgba(58, 78, 132, 0.42), 0 2px 10px rgba(58, 78, 132, 0.06);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mood-a: #dcebff;
  --mood-b: #e8e1ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(168deg, #edf4ff 0%, #f3edff 44%, #e9f7f2 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(46% 30% at 6% 2%, rgba(255, 255, 255, 0.9) 0%, transparent 72%),
    radial-gradient(38% 26% at 96% 8%, var(--mood-b) 0%, transparent 68%),
    radial-gradient(52% 34% at 50% 108%, rgba(200, 232, 255, 0.72) 0%, transparent 70%),
    radial-gradient(34% 22% at 88% 92%, rgba(255, 255, 255, 0.66) 0%, transparent 70%);
  transition: background 0.9s ease;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(26% 13% at 14% 12%, rgba(255, 255, 255, 0.75) 0%, transparent 68%),
    radial-gradient(20% 10% at 24% 17%, rgba(255, 255, 255, 0.6) 0%, transparent 70%),
    radial-gradient(24% 12% at 82% 78%, rgba(255, 255, 255, 0.55) 0%, transparent 70%);
}

[hidden] {
  display: none !important;
}

/* ---------- 布局 ---------- */

.app {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 18px 20px calc(48px + env(safe-area-inset-bottom));
}

.view {
  animation: rise 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 22px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd08a, #ff9e9e 55%, #a99bff);
  box-shadow: 0 0 0 4px rgba(255, 190, 150, 0.18);
}

.pill {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}

/* ---------- 标题 ---------- */

.lede {
  margin: 6px 0 8px;
  font-family: var(--sans);
  font-size: 34px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.lede-sub {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 0.02em;
}

.live-note {
  display: inline-flex;
  align-items: center;
  margin: -14px 0 22px;
  padding: 6px 14px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.view-title {
  margin: 2px 0 6px;
  font-family: var(--sans);
  font-size: 29px;
  font-weight: 800;
  line-height: 1.32;
  letter-spacing: -0.01em;
}

.view-sub {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* ---------- 问题块 ---------- */

.question {
  margin-bottom: 26px;
}

.question h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 11px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 16px -12px rgba(58, 78, 132, 0.5);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease,
    box-shadow 0.18s ease;
}

.chip:nth-child(5n + 1) {
  background: #eef3ff;
}

.chip:nth-child(5n + 2) {
  background: #fff1f3;
}

.chip:nth-child(5n + 3) {
  background: #eefaf4;
}

.chip:nth-child(5n + 4) {
  background: #fff7e9;
}

.chip:nth-child(5n + 5) {
  background: #f4f0ff;
}

.chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px -12px rgba(58, 78, 132, 0.55);
}

.chip:active {
  transform: scale(0.97);
}

.chip[aria-pressed="true"] {
  background: linear-gradient(135deg, #8fa4ff, #a78bfa);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 12px 22px -12px rgba(123, 108, 240, 0.85);
}

.chip:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 18px;
  padding: 13px 15px;
  box-shadow: 0 8px 18px -16px rgba(58, 78, 132, 0.45);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  resize: none;
  line-height: 1.7;
  min-height: 84px;
}

textarea::placeholder,
input::placeholder {
  color: var(--ink-faint);
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: rgba(123, 108, 240, 0.45);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.counter {
  margin-top: 6px;
  text-align: right;
  font-size: 11.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.field-error {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: #c25a48;
}

.is-invalid {
  border-color: rgba(194, 90, 72, 0.55) !important;
  box-shadow: 0 0 0 4px rgba(194, 90, 72, 0.08) !important;
}

/* ---------- 按钮 ---------- */

.primary-btn {
  width: 100%;
  height: 56px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffd79a 0%, #ffb992 55%, #ff9fa8 100%);
  color: #4a3324;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 20px 34px -18px rgba(255, 150, 120, 0.75);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 24px 38px -18px rgba(255, 150, 120, 0.85);
}

.primary-btn:active {
  transform: scale(0.99);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

.ghost-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 16px -14px rgba(58, 78, 132, 0.5);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 1);
}

.ghost-btn.wide {
  width: 100%;
  height: 52px;
  border-radius: 16px;
  font-size: 14.5px;
  color: var(--ink);
}

.ghost-btn.danger {
  color: #c25a48;
  border-color: rgba(194, 90, 72, 0.28);
}

.ghost-btn.danger:hover {
  background: rgba(194, 90, 72, 0.07);
}

.footnote {
  margin: 16px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
}

/* ---------- 生成中 ---------- */

.view-loading {
  min-height: 72dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
}

.loading-sky {
  position: relative;
  width: 260px;
  height: 150px;
}

.cloud {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 18px 30px -18px rgba(43, 38, 32, 0.4);
  animation: drift 5.6s ease-in-out infinite alternate;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.c1 {
  width: 150px;
  height: 44px;
  left: 20px;
  top: 54px;
}

.c1::before {
  width: 62px;
  height: 62px;
  left: 26px;
  top: -30px;
}

.c1::after {
  width: 46px;
  height: 46px;
  left: 84px;
  top: -18px;
}

.c2 {
  width: 96px;
  height: 30px;
  right: 12px;
  top: 26px;
  opacity: 0.72;
  animation-delay: -1.8s;
}

.c2::before {
  width: 42px;
  height: 42px;
  left: 18px;
  top: -22px;
}

.c2::after {
  width: 32px;
  height: 32px;
  left: 54px;
  top: -12px;
}

.c3 {
  width: 70px;
  height: 22px;
  left: 4px;
  top: 112px;
  opacity: 0.5;
  animation-delay: -3.2s;
}

.c3::before {
  width: 30px;
  height: 30px;
  left: 14px;
  top: -16px;
}

@keyframes drift {
  from {
    transform: translateX(-8px);
  }
  to {
    transform: translateX(10px);
  }
}

.rain {
  position: absolute;
  bottom: 6px;
  width: 2px;
  height: 26px;
  border-radius: 2px;
  background: linear-gradient(to bottom, rgba(43, 38, 32, 0), rgba(43, 38, 32, 0.28));
  animation: fall 1.4s linear infinite;
}

.r1 {
  left: 84px;
}
.r2 {
  left: 132px;
  animation-delay: -0.5s;
}
.r3 {
  left: 178px;
  animation-delay: -0.9s;
}

@keyframes fall {
  0% {
    transform: translateY(-16px);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: translateY(26px);
    opacity: 0;
  }
}

.loading-text {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  animation: breathe 2.2s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- 卡片 ---------- */

.card-frame {
  border-radius: 30px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-card);
  line-height: 0;
  animation: cardIn 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card-frame canvas {
  display: block;
  width: 100%;
  height: auto;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.actions-row {
  display: flex;
  gap: 10px;
}

.actions-row .wide {
  flex: 1;
}

/* ---------- 迷你趋势 ---------- */

.mini-trend {
  margin-top: 16px;
  padding: 14px 16px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 12px 24px -20px rgba(58, 78, 132, 0.5);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.mini-trend:hover {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(255, 255, 255, 1);
}

.mini-trend-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
}

.mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 46px;
}

.mini-bar {
  flex: 1;
  min-height: 4px;
  border-radius: 5px;
  background: var(--accent-soft);
  position: relative;
}

.mini-bar span {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

/* ---------- 本周 ---------- */

.week-chart {
  display: flex;
  align-items: stretch;
  gap: 7px;
  padding: 18px 12px 12px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 28px -22px rgba(58, 78, 132, 0.5);
  min-height: 190px;
}

.week-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.week-bar-wrap {
  width: 100%;
  height: 104px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.week-bar {
  width: 68%;
  max-width: 26px;
  border-radius: 8px 8px 5px 5px;
  transition: height 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.week-val {
  font-size: 11px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.week-day {
  font-size: 10.5px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.week-weather {
  font-size: 10.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.week-empty {
  margin-top: 18px;
  padding: 22px;
  text-align: center;
  border: 1px dashed rgba(123, 108, 240, 0.28);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink-soft);
  font-size: 14px;
}

.week-empty p {
  margin: 0 0 6px;
}

.week-empty .hint {
  margin: 0;
}

.week-empty .primary-btn {
  margin-top: 18px;
  height: 50px;
  font-size: 15px;
}

.week-report {
  margin-top: 16px;
  padding: 22px 20px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.66));
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 22px 44px -32px rgba(58, 78, 132, 0.55);
}

.week-summary {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.week-insight {
  margin: 0 0 12px;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.8;
}

.week-suggestion {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--accent);
  line-height: 1.7;
}

.week-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.week-tag {
  font-size: 11.5px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---------- 分享 ---------- */

.share-lede {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ---------- 安全提示 ---------- */

.view-crisis {
  min-height: 78dvh;
  display: flex;
  align-items: center;
}

.crisis-card {
  width: 100%;
  padding: 28px 24px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-card);
}

.crisis-card h2 {
  margin: 0 0 12px;
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.crisis-card p {
  margin: 0 0 12px;
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--ink-soft);
}

.hotline {
  display: block;
  margin: 6px 0 16px;
  font-family: var(--sans);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #d2604a;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

.crisis-sub {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(123, 108, 240, 0.08);
  color: var(--ink) !important;
  font-size: 13.5px !important;
}

.crisis-note {
  font-size: 12.5px !important;
  color: var(--ink-faint) !important;
}

/* ---------- 弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 48, 82, 0.32);
  backdrop-filter: blur(4px);
  animation: fade 0.25s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 12px 22px calc(26px + env(safe-area-inset-bottom));
  background: #f7f9ff;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -24px 60px -30px rgba(40, 50, 90, 0.45);
  animation: sheetUp 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes sheetUp {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  margin: 4px auto 16px;
}

.modal-sheet h2 {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.sheet-note {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.sheet-warn {
  margin: 4px 0 18px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-faint);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  z-index: 60;
  max-width: min(86vw, 380px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(42, 51, 80, 0.94);
  color: #f6f8ff;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 16px 30px -18px rgba(30, 40, 80, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 桌面 ---------- */

@media (min-width: 720px) {
  .app {
    max-width: 520px;
    padding-top: 40px;
  }

  .lede {
    font-size: 38px;
  }

  .modal {
    align-items: center;
  }

  .modal-sheet {
    border-radius: 26px;
    margin-bottom: 6vh;
  }

  .sheet-handle {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
