/* =========================================================
   决策工作台 Decision Desk — H5 样式
   严格还原画布设计稿：暖纸底色 / 墨黑 / 墨绿(sage) 强调
   ========================================================= */

:root {
  /* 配色（与设计稿一致） */
  --paper: #FAFAF7;        /* 画布暖纸底 */
  --ink: #1F1B16;          /* 主文字 墨黑 */
  --sage: #7A8471;         /* 克制强调色 墨绿 */
  --paper-aged: #F2EFE8;   /* aged-paper 区块（摘要/引文） */
  --card: #FFFFFF;         /* 卡片底 */
  --border: #E8E4DD;       /* 细分隔线 */
  --text-2: #5C5648;       /* 次级文字 暖灰 */
  --placeholder: #A89F90;  /* 占位符 */

  /* 圆角 */
  --radius-card: 12px;
  --radius-btn: 10px;

  /* 间距 */
  --gap: 24px;
  --pad-x: 20px;

  /* 字体（仅系统字体，遵循 PRD） */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-noto-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "STSong", "SimSun", serif;

  /* 极淡阴影 */
  --shadow-card: 0 1px 6px rgba(107, 168, 160, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

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

body {
  background: #E7E4DD;
  font-family: var(--font-sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 手机外框（桌面预览居中，移动端满宽） */
.phone {
  position: relative;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  overflow: hidden;
}

/* ---------- 屏幕通用 ---------- */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--paper);
}
.screen:not(.hidden) { display: flex; }

#screen-splash {
  position: relative;
  overflow: hidden;
}
#screen-splash.is-leaving {
  opacity: 0;
  transform: scale(0.985);
  transition: opacity .22s ease, transform .22s ease;
}

.screen-header {
  flex: none;
  padding: 28px var(--pad-x) 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#screen-input .screen-header,
#screen-dump .screen-header {
  padding-top: 28px;
  gap: 14px;
}
#screen-input .screen-title,
#screen-dump .screen-title {
  margin-bottom: 0;
}
.screen-header.row {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding-top: 24px;
  padding-bottom: 16px;
}
.kicker {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--sage);
  font-weight: 500;
}
#screen-input .kicker,
#screen-dump .kicker {
  transform: translateY(-3px);
}
.screen-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.screen-title-sm {
  margin: 0;
  font-family: var(--font-noto-sans);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.subtitle {
  margin: 0;
  font-family: var(--font-noto-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  color: var(--text-2);
}
.icon-btn {
  border: none;
  background: transparent;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ---------- 开屏闪屏 ---------- */
.splash-body {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0 calc(26px + env(safe-area-inset-bottom));
}
.splash-art-wrap {
  position: relative;
  width: 100%;
  max-width: 430px;
}
.splash-art {
  display: block;
  width: 100%;
  height: auto;
}
.splash-loading {
  position: absolute;
  left: 50%;
  top: 71.2%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
}
.splash-loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage);
  opacity: 0.32;
  box-shadow: 0 0 0 3px rgba(122, 132, 113, 0.06);
  animation: splashPulse 1s ease-in-out infinite;
}
.splash-loading span:nth-child(2) { animation-delay: .14s; }
.splash-loading span:nth-child(3) { animation-delay: .28s; }
@keyframes splashPulse {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  40% { opacity: 0.9; transform: translateY(-3px); }
}

@media (max-width: 390px) {
  .splash-loading {
    top: 70.4%;
  }
}

/* ---------- 内容滚动区 ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px var(--pad-x) calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ---------- 输入字段 ---------- */
.field { display: flex; flex-direction: column; gap: 10px; }
.field-label {
  font-family: var(--font-noto-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--card);
  padding: 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 22px;
  color: var(--ink);
  resize: none;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder {
  color: var(--placeholder);
  font-family: var(--font-noto-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 22px;
}
.input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(122, 132, 113, 0.12);
}

/* ---------- 情绪标签 ---------- */
.emotion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font-noto-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: all .15s ease;
}
.tag.is-selected {
  background: var(--sage);
  border-color: var(--sage);
  color: #FFFFFF;
  font-weight: 500;
}

.action-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- 主按钮 ---------- */
.btn-primary {
  margin-top: 0;
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, opacity .15s ease;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled,
.btn-outline:disabled {
  cursor: default;
  opacity: 0.55;
}
.form-hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--placeholder);
}

/* ---------- 加载页 ---------- */
.loading-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 48px var(--pad-x) 64px;
}
.ripple {
  position: relative;
  width: 120px;
  height: 120px;
}
.ripple .ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid var(--sage);
  opacity: 0;
  animation: ripple 2.4s ease-out infinite;
}
.ripple .r1 { width: 100px; height: 100px; animation-delay: 0s; }
.ripple .r2 { width: 68px;  height: 68px;  animation-delay: .6s; }
.ripple .r3 { width: 36px;  height: 36px;  animation-delay: 1.2s; }
.ripple .ring-core {
  position: absolute;
  top: 50%; left: 50%;
  width: 9px; height: 9px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--sage);
}
@keyframes ripple {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  20%  { opacity: .5; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
.loading-main {
  margin: 0;
  text-align: center;
  font-family: var(--font-noto-sans);
  font-size: 17px;
  font-weight: 500;
  line-height: 28px;
  color: var(--ink);
}
.sub-prompts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-2);
}
.sub-item .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--sage);
}
.loading-error {
  width: 100%;
  max-width: 320px;
  background: var(--paper-aged);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 16px 16px;
}
.loading-error-text {
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 22px;
  color: var(--ink);
}
.loading-error-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.btn-secondary {
  color: var(--ink);
  border-color: var(--border);
}

/* ---------- 决策便签摘要卡 ---------- */
.summary-card {
  background: var(--paper-aged);
  border-radius: var(--radius-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.section-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.5px;
  color: var(--sage);
}
.one-liner {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 21px;
  line-height: 31px;
  color: var(--ink);
}
.summary-detail {
  margin: 0;
  font-family: var(--font-noto-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 25px;
  color: var(--text-2);
}

/* ---------- 板块通用 ---------- */
#sectionsRoot {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.block { display: flex; flex-direction: column; gap: 20px; }
.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.block-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.badge {
  font-size: 11px;
  color: var(--sage);
  background: var(--paper-aged);
  border-radius: 999px;
  padding: 3px 8px;
}

/* ---------- 可展开词条卡 ---------- */
.term-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.term-header {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.term-header:focus-visible {
  outline: 2px solid rgba(122, 132, 113, 0.32);
  outline-offset: -2px;
}
.term-name {
  font-family: var(--font-noto-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}
.term-chevron {
  flex: none;
  width: 16px; height: 16px;
  transition: transform .3s ease;
  color: var(--placeholder);
}
.term-card.open .term-chevron { transform: rotate(180deg); color: var(--sage); }

/* 高度动画：grid-template-rows 0fr → 1fr */
.term-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.term-card.open .term-body { grid-template-rows: 1fr; }
.term-body-inner {
  overflow: hidden;
  min-height: 0;
}
.term-body-pad {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sub-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .5px;
  color: var(--sage);
}
.term-def {
  margin: 0;
  font-family: var(--font-noto-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 23px;
  color: var(--text-2);
}
.term-interp {
  margin: 0;
  font-family: var(--font-noto-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 23px;
  color: var(--ink);
}
.divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ---------- 芒格五问 ---------- */
.questions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 4px;
}
.q-item { display: flex; gap: 12px; align-items: flex-start; }
.q-num {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--sage);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-text {
  margin: 0;
  font-family: var(--font-noto-sans);
  font-size: 15px;
  font-weight: 400;
  font-size: 15px;
  line-height: 23px;
  color: var(--ink);
}

/* ---------- 芒格原话引文 ---------- */
.quote-block {
  background: var(--paper-aged);
  border-radius: var(--radius-btn);
  padding: 20px;
}
.quote-inner {
  border-left: 3px solid var(--sage);
  padding-left: 14px;
}
.quote-text {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 21px;
  line-height: 31px;
  color: var(--ink);
}
.quote-attr {
  margin: 26px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

.export-canvas {
  position: fixed;
  left: -99999px;
  top: 0;
  width: 430px;
  padding: 20px 20px 28px;
  background: var(--paper);
  z-index: -1;
}
.export-canvas .content {
  overflow: visible;
  min-height: auto;
  padding: 0;
}
.export-canvas .summary-card,
.export-canvas .term-card,
.export-canvas .quote-block {
  box-shadow: none;
}
.export-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1.25;
  color: var(--ink);
}
.export-subtitle {
  margin: 0 0 24px;
  font-size: 13px;
  line-height: 22px;
  color: var(--text-2);
}
.export-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 20px;
  color: var(--placeholder);
}

/* ---------- 导出底栏 ---------- */
.export-bar {
  flex: none;
  padding: 12px var(--pad-x) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--paper);
}
.btn-outline {
  width: 100%;
  height: 52px;
  border: 1.5px solid var(--sage);
  border-radius: var(--radius-btn);
  background: var(--card);
  color: var(--sage);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.btn-outline:active { transform: scale(0.98); background: var(--paper-aged); }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(31, 27, 22, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 50;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; }

/* ---------- 无障碍：减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  .ripple .ring { animation: none; opacity: .2; }
  .term-body { transition: none; }
  .term-chevron { transition: none; }
  .splash-loading span { animation: none; opacity: .6; }
  #screen-splash.is-leaving { transition: none; }
  * { scroll-behavior: auto !important; }
  .home-card { transition: none; }
}

/* =========================================================
   双入口首页 · #screen-home（上下两张图片卡）
   ========================================================= */
/* 稳健布局：不依赖 100dvh，也不裁切。卡片用 aspect-ratio 兜底高度，
   即使微信下父级高度算不出来，卡片也有确定高度，绝不塌成 0 或白屏。 */
#screen-home {
  padding: 12px;
  gap: 12px;
  justify-content: center;
}
.home-cards {
  box-sizing: border-box;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.home-card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;         /* 主要高度来源，不依赖视口高度 */
  min-height: 180px;           /* 不支持 aspect-ratio 的旧内核兜底 */
  display: block;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: pointer;
  background: var(--paper-aged);
  transition: transform .18s ease, box-shadow .18s ease;
}
.home-card:active { transform: scale(0.99); }
/* 高屏设备上让两张卡撑满、平分高度；矮屏则退回 aspect-ratio 自然高度 */
@media (min-height: 560px) {
  #screen-home { min-height: 100vh; min-height: 100dvh; }
  .home-cards { flex: 1; min-height: 0; }
  .home-card { flex: 1; aspect-ratio: auto; }
}
.home-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* 占位：图片缺失时的底纹 */
.home-card--placeholder {
  background:
    linear-gradient(135deg, rgba(122,132,113,0.18), rgba(122,132,113,0.05)),
    var(--paper-aged);
}
.home-card--placeholder::after {
  content: "封面待补";
  position: absolute;
  top: 14px; right: 14px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--placeholder);
}
/* 底部渐变遮罩上叠标题，标题始终在卡片内 */
.home-card-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px 18px 18px;
  text-align: left;
  background: linear-gradient(to top, rgba(31,27,22,0.78) 0%, rgba(31,27,22,0.45) 55%, rgba(31,27,22,0) 100%);
}
.home-card-kicker {
  font-size: 12px;
  letter-spacing: 1px;
  color: #fff;
  opacity: 0.92;
  font-weight: 600;
  margin-bottom: 8px;
}
.home-card-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
}

/* =========================================================
   焦虑倒出输入 · #screen-dump
   ========================================================= */
.dump-input {
  min-height: 220px;
  line-height: 1.7;
  resize: vertical;
}

/* 焦虑拆解清单复用芒格版的 .term-card / .block / .badge 样式 */
/* 矛盾欲望盒：四角圆角、无左侧竖线，与左右缩进一致 */
.conflict-box {
  background: var(--paper-aged);
  border-radius: 10px;
  padding: 12px 14px;
}
.conflict-box-text {
  margin: 0;
  font-family: var(--font-noto-sans);
  font-size: 14px;
  line-height: 23px;
  color: var(--ink);
}
