/* ==========================================================================
   少走弯路 · 书房问答 (/talk/) — 独立沉浸式对话间
   对标 learnbuffett.com/talk/ 仪式感与克制礼貌度 + kevinsolo.cn 配色体系
   ========================================================================== */
:root {
  --bg-top: #F7F2E9;
  --bg-bot: #EFE8DA;
  --card: #FFFFFF;
  --cream: #FAF6EC;
  --olive: #3F4A2E;
  --olive-light: #52613D;
  --gold: #B08D57;
  --gold-dark: #8A6A38;
  --gold-glow: rgba(176, 141, 87, 0.14);
  --text: #232624;
  --text2: #585D57;
  --text3: #838881;
  --border: #DDD5C6;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.78;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bot) 100%);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--gold-dark); text-decoration: none; }
button { font: inherit; background: none; border: none; cursor: pointer; color: inherit; }

.talk-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 20px 28px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* 顶部极简书房抬头 */
.talk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.th-brand { display: flex; align-items: center; gap: 12px; }
.th-emblem { width: 38px; height: 38px; flex-shrink: 0; }
.th-title {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  color: var(--olive);
  line-height: 1.25;
}
.th-title span { color: var(--gold); }
.th-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.th-sub strong { color: var(--gold-dark); font-weight: 600; }
.back-lib {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.72);
  padding: 5px 12px;
  white-space: nowrap;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}
.back-lib:hover { color: var(--olive); border-color: var(--gold); background: #FFFFFF; }
.back-lib.accent { border-color: rgba(176, 141, 87, 0.65); color: var(--gold-dark); background: #FAF6EE; font-weight: 600; }
.back-lib.accent:hover { border-color: var(--gold-dark); background: #F5ECDC; }

/* 中部流式内容区 */
.talk-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.welcome-view {
  margin: auto 0;
  padding: 28px 0 36px;
  text-align: center;
}
.welcome-lead {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--olive);
  margin: 12px 0 8px;
}
.welcome-note {
  font-size: 13.5px;
  color: var(--text2);
  max-width: 540px;
  margin: 0 auto 24px;
}
.starter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  text-align: left;
}
.starter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 15px 16px;
  transition: transform 0.13s ease, border-color 0.13s ease, background 0.13s ease;
}
.starter-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  background: var(--cream);
}
.sc-tag { font-size: 11px; color: var(--gold-dark); font-weight: 600; margin-bottom: 4px; }
.sc-q { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.48; }

/* 对话消息流 */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 24px;
}
.msg-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--olive);
  color: #F4EFE6;
  padding: 12px 18px;
  border-radius: 14px 14px 3px 14px;
  font-size: 15px;
  line-height: 1.65;
}
.msg-assistant {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 4px 20px rgba(35, 38, 36, 0.05);
}
.ma-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #EFE9DC;
  font-size: 12.5px;
  color: var(--text3);
}
.ma-badge {
  color: var(--olive);
  font-weight: 600;
  background: rgba(63, 74, 46, 0.08);
  padding: 2px 9px;
  border-radius: 99px;
}
.ma-body p { margin-bottom: 12px; }
.ma-body h3 { font-family: var(--serif); font-size: 16.5px; color: var(--olive); margin: 16px 0 8px; }
.ma-body blockquote {
  background: var(--cream);
  border-left: 3.5px solid var(--gold);
  padding: 12px 16px;
  margin: 12px 0;
  font-family: var(--serif);
}
/* 暗金虚线可点引用（对标 learnbuffett/talk/） */
.concept-link {
  color: var(--gold-dark);
  border-bottom: 1px dashed var(--gold);
  padding: 0 3px;
  font-weight: 600;
  cursor: pointer;
}
.concept-link:hover {
  background: var(--gold-glow);
  border-bottom-style: solid;
  color: var(--olive);
}

.failed-note {
  background: #FDF4EE;
  border: 1px solid #E3BE9F;
  border-left: 3.5px solid #A8542C;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: #6B3215;
  margin-bottom: 14px;
}

.cite-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.cite-label { font-size: 12px; color: var(--text3); margin-bottom: 8px; font-weight: 600; }
.cite-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cite-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 6px;
  background: var(--cream);
  border: 1px solid rgba(176, 141, 87, 0.35);
  font-size: 12.5px;
  color: var(--text);
}
.cite-chip:hover { border-color: var(--gold); color: var(--olive); }

.ma-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #EFE9DC;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ma-act-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-soft {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: #FAF6EC;
  font-size: 12.5px;
  color: var(--olive);
  font-weight: 500;
}
.btn-soft:hover { border-color: var(--gold); background: #F4ECDD; }
.btn-gold {
  padding: 6px 14px;
  border-radius: 99px;
  background: var(--gold);
  color: #1F241B;
  font-size: 12.5px;
  font-weight: 700;
}
.btn-gold:hover { background: #C29E66; }

/* 底部输入控制台（模仿 learnbuffett/talk/ 的轻工具条 + 暗金边框输入框） */
.composer-wrap {
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(239, 232, 218, 0) 0%, var(--bg-bot) 26%);
}
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--text2);
}
.ct-left, .ct-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ct-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  color: var(--text2);
}
.ct-btn:hover { border-color: var(--gold); color: var(--olive); }
.ct-btn.active { background: var(--olive); border-color: var(--olive); color: #F4EFE6; font-weight: 600; }
.mode-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px;
}
.ms-opt {
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  color: var(--text2);
}
.ms-opt.active { background: var(--olive); color: #F4EFE6; font-weight: 600; }

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid rgba(176, 141, 87, 0.6);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 4px 18px rgba(35, 38, 36, 0.06);
}
.input-box:focus-within { border-color: var(--olive); }
.chat-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 16px;
  line-height: 1.55;
  max-height: 140px;
  min-height: 28px;
  background: transparent;
  color: var(--text);
}
.send-btn {
  padding: 8px 18px;
  min-height: 38px;
  border-radius: 8px;
  background: var(--olive);
  color: #F4EFE6;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.send-btn:hover { background: var(--olive-light); }
.send-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.attach-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 10px;
  background: rgba(63, 74, 46, 0.1);
  color: var(--olive);
  border-radius: 99px;
  margin-bottom: 6px;
}
.talk-disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 9px;
}

/* 弹窗（出处预览 / 历史 / 兑换与账号 / 额度用完体面提示 / 分享卡） */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(25, 31, 21, 0.55);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay.open { display: flex; }
.dialog {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.22);
}
.dialog.wide { max-width: 640px; }
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #EFE9DC;
}
.dlg-title { font-family: var(--serif); font-size: 18px; font-weight: 700; color: var(--olive); }
.field-in {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
}
.field-in:focus { border-color: var(--olive); }
.tab-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-item {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FAF6EC;
  font-size: 13px;
  color: var(--text2);
}
.tab-item.active { background: var(--olive); border-color: var(--olive); color: #F4EFE6; font-weight: 600; }
.path-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #FCF9F2;
}
.path-box.featured { border-color: var(--gold); background: var(--cream); }
.path-title { font-weight: 700; color: var(--olive); font-size: 14.5px; margin-bottom: 6px; }
.prod-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.prod-card { background: #FFF; border: 1px solid var(--border); border-radius: 8px; padding: 12px; }

.share-preview {
  background: #F4EFE6;
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 20px;
  margin: 12px 0 16px;
}
.share-img-wrap {
  margin: 10px 0 12px;
  text-align: center;
}
.share-card-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(35, 38, 36, 0.12);
  -webkit-touch-callout: default;
  user-select: none;
}
.share-mobile-tip {
  background: #FAF6EE;
  border: 1px solid rgba(176, 141, 87, 0.5);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--olive);
  font-weight: 600;
  text-align: center;
  margin-bottom: 10px;
}
@media (max-width: 640px) {
  .talk-shell { padding: 12px 14px 12px; }
  .talk-header { padding-bottom: 10px; margin-bottom: 10px; }
  .th-emblem { width: 32px; height: 32px; }
  .th-title { font-size: 17.5px; }
  .th-sub { font-size: 12px; }
  .welcome-view { margin: 0; padding: 4px 0 12px; }
  .welcome-lead { font-size: 16.5px; margin: 4px 0 6px; line-height: 1.45; }
  .welcome-note { font-size: 12.5px; line-height: 1.55; margin: 0 auto 12px; }
  .starter-grid { grid-template-columns: 1fr; gap: 8px; }
  .starter-card { padding: 10px 13px; }
  .sc-tag { font-size: 10.5px; margin-bottom: 2px; }
  .sc-q { font-size: 13.5px; line-height: 1.4; }
  .composer-wrap { padding-top: 8px; }
  .talk-disclaimer { font-size: 11px; line-height: 1.45; margin-top: 6px; }
  .msg-assistant { padding: 16px 16px; }
  .dialog { padding: 16px 16px; max-height: 90vh; max-height: 90dvh; }
  .dlg-title { font-size: 16px; }
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  background: #21291B;
  color: #F4EFE6;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 13px;
  display: none;
}
.toast.show { display: block; }

@media (max-width: 600px) {
  .talk-header { flex-direction: column; align-items: flex-start; }
  .starter-grid, .prod-grid { grid-template-columns: 1fr; }
  .msg-assistant { padding: 16px; }
}
