/* === 听风树（树洞）样式 ===
   视觉：一棵中空的古树，树干有一扇暖光小门，树根半包围形成"接住"的空间。
   洞内暖黄，外围保持地图的蓝紫暮色。整体延续 paper/clay/sun 纸感体系。 */

/* —— 页面容器 —— */
.th-page {
  display: block;
  padding: var(--space-5) var(--space-4) 120px;
}

/* —— 树的场景（入口处） —— */
.th-tree-scene {
  position: relative;
  width: 100%;
  height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 244, 208, 0.95), transparent 40%),
    linear-gradient(to top, #2c3a52 0%, #46527a 34%, #7a87ad 60%, #c7cfe6 100%);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-md);
}

.th-tree {
  position: relative;
  width: 100%;
  height: 100%;
}

/* 树干 */
.th-tree__trunk {
  position: absolute;
  left: 50%;
  bottom: -8%;
  transform: translateX(-50%);
  width: 118px;
  height: 190px;
  background: linear-gradient(100deg, #6b4a33, #8a5f40 45%, #6b4a33);
  border-radius: 34% 34% 26% 26% / 22% 22% 8% 8%;
  clip-path: polygon(12% 0, 88% 0, 78% 30%, 96% 55%, 84% 88%, 100% 100%, 0 100%, 16% 88%, 4% 55%, 22% 30%);
  box-shadow: inset -14px 0 20px rgba(0, 0, 0, 0.25);
}

/* 树干中部的暖光小门 */
.th-tree__door {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 54px;
  border-radius: 22px 22px 12px 12px;
  background: radial-gradient(circle at 38% 30%, #ffe9b0, #f2b84b 55%, #d98f2b);
  box-shadow: 0 0 22px rgba(255, 209, 120, 0.95), 0 0 46px rgba(255, 190, 90, 0.55);
}

/* 树冠 */
.th-tree__canopy {
  position: absolute;
  left: 50%;
  top: 2%;
  transform: translateX(-50%);
  width: 210px;
  height: 130px;
}

.th-tree__leaf {
  position: absolute;
  display: block;
  border-radius: 46% 54% 52% 48% / 52% 46% 54% 48%;
  background: radial-gradient(circle at 35% 30%, #3e5a46, #243a2c 72%);
  box-shadow: 0 10px 18px rgba(16, 28, 22, 0.45);
}
.th-tree__leaf:nth-child(1) { width: 120px; height: 92px; left: 6px; top: 18px; transform: rotate(-14deg); }
.th-tree__leaf:nth-child(2) { width: 104px; height: 84px; right: 4px; top: 8px; transform: rotate(16deg); }
.th-tree__leaf:nth-child(3) { width: 118px; height: 96px; left: 46px; top: -10px; }
.th-tree__leaf:nth-child(4) { width: 74px; height: 62px; right: 34px; bottom: -14px; transform: rotate(24deg); }

/* 树枝上挂着的风铃与小灯 */
.th-tree__wind {
  position: absolute;
  right: 12%;
  top: 18%;
  color: rgba(255, 236, 180, 0.85);
  font-size: 18px;
  letter-spacing: 6px;
  animation: th-wind 3.6s ease-in-out infinite;
}

@keyframes th-wind {
  0%, 100% { transform: translateX(0); opacity: 0.75; }
  50% { transform: translateX(-6px); opacity: 1; }
}

.th-tree-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  text-align: center;
  color: rgba(255, 250, 232, 0.96);
  font-size: 13px;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(20, 28, 44, 0.7);
  margin: 0;
}

/* —— 问候区 —— */
.th-greeting {
  text-align: center;
  margin-bottom: var(--space-5);
}
.th-greeting h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0.5px;
}

/* —— 五种模式卡片 —— */
.th-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: var(--space-5);
}

.th-mode-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  text-align: left;
  padding: 14px 14px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.86);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.th-mode-card:active {
  transform: scale(0.98);
}
.th-mode-card:hover {
  box-shadow: var(--shadow-md);
}

.th-mode-card__icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--th-accent) 22%, white);
  color: var(--th-accent);
  font-size: 17px;
  margin-bottom: 4px;
}
.th-mode-card__label {
  font-weight: 700;
  font-size: 15px;
}
.th-mode-card__tag {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ============================================================
   新版听风树首页 —— 童话树屋
   ============================================================ */

/* —— 主视觉插画 —— */
.th-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-md);
}
.th-hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.th-hero__veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(20, 24, 38, 0.55) 0%,
    rgba(20, 24, 38, 0.15) 40%,
    transparent 70%);
  pointer-events: none;
}
.th-hero__text {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px 22px 18px;
  pointer-events: none;
}
.th-hero__title {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.th-hero__scene {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 250, 235, 0.92);
  text-shadow: 0 1px 8px rgba(0,0,0,0.5);
}

/* —— 主提问 —— */
.th-ask {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 var(--space-4);
  color: var(--ink);
}

/* —— 三个主入口 —— */
.th-entries {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: var(--space-4);
}
.th-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.9);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.th-entry:active { transform: scale(0.98); }
.th-entry:hover  { box-shadow: var(--shadow-md); }
.th-entry--primary {
  background: linear-gradient(135deg, rgba(255, 248, 230, 0.95), rgba(255, 238, 210, 0.9));
  border-color: rgba(232, 168, 78, 0.4);
}
.th-entry__num {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--clay-light, #e8ddd0);
  color: var(--clay, #8a6f5a);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.th-entry--primary .th-entry__num {
  background: rgba(232, 168, 78, 0.2);
  color: #b8782a;
}
.th-entry__body { display: flex; flex-direction: column; gap: 2px; }
.th-entry__title { font-weight: 700; font-size: 16px; color: var(--ink); }
.th-entry__desc  { font-size: 12px; line-height: 1.5; color: var(--ink-soft); }

/* —— 轻量入口（只想待一会儿）—— */
.th-quiet-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  margin-bottom: var(--space-4);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.th-quiet-entry:hover { background: rgba(184, 201, 232, 0.1); }
.th-quiet-entry__moon { font-size: 18px; color: #b8c9e8; }

/* —— 语气选择 —— */
.th-tone-wrap {
  margin-bottom: var(--space-4);
  animation: th-fade-in 0.25s ease;
}
@keyframes th-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.th-tone-back {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  padding: 4px 0 10px;
  cursor: pointer;
}
.th-tone-hint {
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.th-tone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.th-tone-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.9);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease;
}
.th-tone-card:active { transform: scale(0.97); }
.th-tone-card__label { font-weight: 700; font-size: 14px; color: var(--ink); }
.th-tone-card__desc  { font-size: 11px; line-height: 1.5; color: var(--ink-soft); }

/* —— 聊天中的候选记忆卡 —— */
.th-mem-candidates {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 0 var(--space-3);
}
.th-mem-cand-card {
  padding: 14px 16px;
  border: 1.5px solid rgba(217, 143, 43, 0.35);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 248, 230, 0.95), rgba(255, 240, 215, 0.9));
  box-shadow: var(--shadow-sm);
  animation: th-fade-in 0.3s ease;
}
.th-mem-cand-card__hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 6px;
}
.th-mem-cand-card__content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 12px;
  font-style: italic;
}
.th-mem-cand-card__ops {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.chip--primary {
  background: var(--sun, #e88a2e);
  color: #fff;
  border-color: var(--sun, #e88a2e);
}

/* —— 联网搜索确认卡 —— */
.th-search-card {
  padding: 14px 16px;
  border: 1.5px solid rgba(107, 138, 160, 0.4);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(235, 242, 248, 0.95), rgba(225, 235, 245, 0.9));
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-3);
  animation: th-fade-in 0.3s ease;
}
.th-search-card__hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.th-search-card__label {
  font-size: 11px;
  color: var(--ink-soft);
  margin: 0 0 4px;
}
.th-search-card__query {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 12px;
  font-style: italic;
}
.th-search-card__ops {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* —— 记忆入口与承诺 —— */
.th-mem-entry {
  margin-bottom: var(--space-4);
  cursor: pointer;
}
.th-promise {
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-soft);
  margin: var(--space-5) 0 0;
}

/* ============================================================
   聊天视图
   ============================================================ */
.th-chat {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  /* 用负 margin 抵消 .th-page 与 .screen 的 padding，让聊天区撑满整屏 */
  margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-4)) -112px;
  padding: 12px 16px 96px; /* 底部 96px 留给固定导航 */
  overflow: hidden;
}

.th-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 10px;
  border-bottom: 1.5px solid var(--line);
  margin-bottom: 8px;
  flex: none;
}
.th-chat-head .grow {
  min-width: 0;
}
.th-chat-head .muted {
  font-size: 11px;
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.th-thread {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 2px 10px;
  scroll-behavior: smooth;
}

/* 气泡 */
.th-bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.th-bubble--tree {
  align-self: flex-start;
  background: rgba(255, 253, 247, 0.94);
  border: 1.5px solid var(--line);
  border-top-left-radius: 5px;
  box-shadow: var(--shadow-sm);
}
.th-bubble--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #f2c36b, #e8b956);
  color: #3a2f12;
  border-bottom-right-radius: 5px;
}
.th-bubble__who {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--clay);
  margin-bottom: 3px;
}

/* 听风树正在听… 动画 */
.th-typing { color: var(--clay); font-size: 13px; }
.th-dot { animation: th-blink 1.2s infinite; display: inline-block; }
.th-dot:nth-child(2) { animation-delay: 0.2s; }
.th-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes th-blink {
  0%, 60%, 100% { opacity: 0.25; }
  30% { opacity: 1; }
}

/* 呼吸按钮（陪我待一会儿） */
.th-breath {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  margin-top: 4px;
  border-radius: var(--radius-round);
  border: 1.5px dashed color-mix(in srgb, var(--th-accent) 60%, transparent);
  background: color-mix(in srgb, var(--th-accent) 12%, white);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
.th-breath__ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--th-accent);
  animation: th-ring 3.2s ease-in-out infinite;
}
@keyframes th-ring {
  0%, 100% { transform: scale(0.7); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* 输入区 */
.th-composer {
  flex: none;
  padding: 10px 0 0;
  border-top: 1.5px solid var(--line);
  background: var(--paper);
}

/* ============================================================
   收尾（done）视图
   ============================================================ */
.th-done {
  padding-bottom: 130px;
}

.th-done-recaps {
  margin: var(--space-4) 0 var(--space-5);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.85);
  border: 1.5px solid var(--line);
}
.th-recaps {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.9;
}

.th-note {
  padding: var(--space-4);
  font-size: 13px;
  color: var(--ink-soft);
}

.th-done-memory {
  margin: var(--space-4) 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fdf6e0, #f8eed0);
  border: 1.5px solid rgba(184, 150, 60, 0.35);
}
.th-done-memory .eyebrow {
  margin: 0 0 4px;
}

.th-cand {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(184, 150, 60, 0.4);
}
.th-cand:last-child {
  border-bottom: 0;
}
.th-cand input[type="checkbox"] {
  margin-top: 4px;
  accent-color: var(--clay);
  width: 16px;
  height: 16px;
}
.th-cand p {
  margin: 0 0 6px;
  font-size: 13px;
}
.th-cand-detail {
  font-size: 12px !important;
  background: rgba(255, 255, 255, 0.7) !important;
}

.th-manual-memory {
  margin-top: 10px;
}

/* 联动区 */
.th-bridge {
  margin: var(--space-4) 0;
}
.th-bridge-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.th-bridge-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: rgba(255, 253, 247, 0.9);
  cursor: pointer;
  font-size: 13px;
}
.th-bridge-item--confirm {
  border-color: var(--clay);
  background: var(--clay-pale);
}

/* ============================================================
   记忆管理视图
   ============================================================ */
.th-memory {
  padding-bottom: 120px;
}

.th-pause-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}
.th-pause-bar--off {
  background: rgba(222, 216, 200, 0.6);
}
.th-pause-bar p {
  margin: 0;
}
.th-pause-bar .tiny {
  margin-top: 3px;
}

.th-mem-group {
  margin-bottom: var(--space-5);
}
.th-mem-group h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--ink-soft);
}

.th-mem-card {
  margin-bottom: 10px;
}
.th-mem-card--paused {
  opacity: 0.62;
}
.th-mem-card--expired {
  opacity: 0.5;
}
.th-mem-title {
  margin: 0 0 5px;
  font-size: 14px;
}
.th-mem-card .muted {
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 5px;
}
.th-mem-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.th-mem-ops .chip {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: var(--radius-round);
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.85);
  cursor: pointer;
}
.chip--danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent) !important;
}

.th-mem-card--edit .form-field {
  margin-bottom: 8px;
}
.th-mem-card--edit .form-field label {
  font-size: 12px;
  color: var(--ink-soft);
}

.th-empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--ink-soft);
}
.th-empty__mark {
  font-size: 34px;
  margin: 0 0 8px;
  color: var(--clay);
}

.th-mem-danger {
  text-align: center;
  margin-top: var(--space-6);
}
.text-danger {
  color: var(--danger);
}
