/* ============ 基础 ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #2b2118;
  background:
    radial-gradient(1000px 500px at 10% -10%, #ffe6d1 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 20%, #ffd8dc 0%, transparent 55%),
    linear-gradient(180deg, #fff8ef 0%, #fdf3e7 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============ 生成器页 ============ */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}
.hero {
  padding: 20px 4px 26px;
  text-align: left;
}
.hero-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #2b2118;
  color: #ffd7a0;
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.hero h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #c0392b, #d97b2f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  color: #7a6a5c;
  margin: 8px 0 0;
  font-size: 14px;
}

.card {
  background: #fff;
  border: 1px solid #f1e4d0;
  border-radius: 18px;
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px -18px rgba(120, 60, 20, 0.35);
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: #4a3a2c;
  margin: 14px 0 10px;
}
.card-title:first-child { margin-top: 4px; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  position: relative;
  cursor: pointer;
  user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fdf3e7;
  border: 1px solid #f0dfc2;
  color: #7a5a3c;
  font-size: 14px;
  transition: all 0.15s;
}
.chip input:checked + span {
  background: linear-gradient(120deg, #ff6b6b, #ff8c42);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px -4px rgba(255, 107, 107, 0.55);
}

textarea {
  width: 100%;
  border: 1px solid #eadcbf;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #fffcf6;
  color: #2b2118;
}
textarea:focus { outline: none; border-color: #ff8c42; }

#wordCount { resize: none; }

/* 补充要求·快捷预设词条 */
.preset-row {
  gap: 6px;
}
.preset-chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fffaf1;
  border: 1px dashed #f0c78a;
  color: #a05a1e;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-chip:hover {
  background: #fff2df;
  border-color: #ff8c42;
  color: #c0392b;
}
.preset-chip:active {
  transform: scale(0.96);
}
.preset-chip.picked {
  background: linear-gradient(120deg, #ff6b6b, #ff8c42);
  color: #fff;
  border-style: solid;
  border-color: transparent;
}

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff5f6d, #ff8c42);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgba(255, 95, 109, 0.7);
  transition: transform 0.1s;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.primary-btn.small {
  margin-top: 0;
  padding: 10px 14px;
  font-size: 14px;
  width: auto;
}

.ghost-btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #ecd9b7;
  background: #fffdf7;
  color: #6b4a2b;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ghost-btn:active { background: #fdf3e7; }

.tip {
  margin: 10px 0 0;
  font-size: 13px;
  color: #a89377;
  min-height: 18px;
}

.result-card { border-color: #ffd6bb; }
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: #2b2118;
  color: #ffcd93;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.result-text {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fffaf1;
  border: 1px dashed #f1d9b3;
  border-radius: 12px;
  padding: 14px;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  color: #2b2118;
  margin: 6px 0 12px;
  max-height: 340px;
  overflow: auto;
}
.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.qr-box {
  margin-top: 14px;
  padding: 14px;
  background: #fffaf1;
  border-radius: 14px;
  border: 1px solid #f1d9b3;
  text-align: center;
}
.qr-box img {
  width: 200px;
  height: 200px;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}
.qr-desc {
  margin: 10px 0 6px;
  font-size: 13px;
  color: #6b4a2b;
}
.qr-url {
  font-size: 11px;
  color: #a89377;
  word-break: break-all;
  margin: 0;
}
.qr-warn {
  margin: 12px auto 4px;
  padding: 10px 12px;
  background: #fff3cd;
  border: 1px solid #ffcd6a;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #6b4a2b;
  text-align: left;
  max-width: 300px;
}
.qr-warn b { color: #b7791f; }

.history-list .empty { color: #a89377; font-size: 13px; text-align: center; padding: 12px 0; margin: 0; }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fffaf1;
  border: 1px solid #f4e3c9;
  margin-bottom: 8px;
  font-size: 13px;
}
.history-item .h-main { flex: 1; margin-right: 10px; overflow: hidden; }
.history-item .h-proj { font-weight: 700; color: #4a3a2c; }
.history-item .h-preview { color: #86715a; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .h-open {
  color: #ff5f6d;
  font-weight: 700;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #ffb5b5;
  background: #fff;
}

.foot { text-align: center; color: #b39d84; font-size: 12px; margin-top: 20px; }

.back-link {
  display: inline-block;
  margin-top: 10px;
  color: #c0392b;
  font-size: 13px;
  text-decoration: none;
  font-weight: 600;
}
.back-link:active { opacity: 0.7; }

/* 知识库管理页 */
.kb-block {
  border-top: 1px solid #f4e3c9;
  padding-top: 14px;
  margin-top: 14px;
}
.kb-block:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.kb-title {
  font-size: 15px;
  font-weight: 700;
  color: #4a3a2c;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kb-count {
  display: inline-block;
  min-width: 22px;
  padding: 1px 8px;
  background: #ff5f6d;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.kb-list { margin-bottom: 10px; }
.kb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fffaf1;
  border: 1px solid #f4e3c9;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 14px;
  color: #2b2118;
}
.kb-item.review .kb-text {
  font-size: 13px;
  line-height: 1.5;
  color: #6b4a2b;
  white-space: pre-wrap;
}
.kb-text { flex: 1; word-break: break-word; }
.kb-del {
  flex-shrink: 0;
  background: none;
  border: 1px solid #f0c1c1;
  color: #c0392b;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.kb-del:active { background: #ffe5e5; }

.kb-add-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.kb-input {
  flex: 1;
  border: 1px solid #eadcbf;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: #fffcf6;
  resize: vertical;
}
.kb-input:focus { outline: none; border-color: #ff8c42; }
.kb-add-btn {
  flex-shrink: 0;
  padding: 9px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff5f6d, #ff8c42);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px -8px rgba(255, 95, 109, 0.6);
}
.kb-tip { font-size: 11px; color: #a89377; margin: 6px 0 0; }

/* 命名条目（含介绍） */
.kb-item.named {
  flex-direction: row;
  align-items: flex-start;
  padding: 12px;
}
.kb-item.named .kb-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kb-name {
  font-weight: 700;
  color: #2b2118;
  font-size: 14.5px;
}
.kb-desc {
  font-size: 13px;
  color: #6b4a2b;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.kb-desc.empty { color: #b39d84; font-style: italic; }

.kb-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.kb-edit-btn {
  background: #fff;
  border: 1px solid #f1d9b3;
  color: #b7791f;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.kb-edit-btn:active { background: #fff3cd; }

/* 编辑态 */
.kb-item.editing {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: #fffaef;
  border-color: #ff8c42;
  padding: 12px;
}
.kb-edit-name,
.kb-edit-desc,
.kb-edit-item {
  width: 100%;
  border: 1px solid #eadcbf;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  resize: vertical;
  box-sizing: border-box;
}
.kb-edit-name:focus,
.kb-edit-desc:focus,
.kb-edit-item:focus { outline: none; border-color: #ff8c42; }

.kb-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.kb-save,
.kb-save-plain {
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff5f6d, #ff8c42);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.kb-cancel {
  padding: 6px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #ddd;
  color: #666;
  font-size: 13px;
  cursor: pointer;
}

/* 添加"名称 + 介绍"面板 */
.kb-add-named {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #fffaf1;
  border: 1px dashed #f1d9b3;
  border-radius: 12px;
}
.kb-input-name,
.kb-input-desc {
  width: 100%;
  border: 1px solid #eadcbf;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  resize: vertical;
  box-sizing: border-box;
}
.kb-input-name:focus,
.kb-input-desc:focus { outline: none; border-color: #ff8c42; }
.kb-add-named .kb-add-btn { align-self: flex-end; }

.tips { padding-left: 20px; margin: 6px 0 0; color: #6b4a2b; font-size: 13px; line-height: 1.7; }
.tips b { color: #c0392b; }

/* ============ 落地页 ============ */
.page-note {
  background:
    radial-gradient(700px 400px at 20% -10%, #ffe6d1 0%, transparent 65%),
    radial-gradient(700px 400px at 100% 30%, #ffd8dc 0%, transparent 60%),
    linear-gradient(180deg, #fff8ef 0%, #fdf3e7 100%);
}
.note-app {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}
.note-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.note-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #c0392b, #d97b2f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 6px 14px -6px rgba(192, 57, 43, 0.6);
}
.note-brand-name { font-weight: 800; font-size: 18px; color: #2b2118; }
.note-brand-sub { font-size: 12px; color: #a89377; }

.note-card {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  border: 1px solid #f1e4d0;
  box-shadow: 0 12px 30px -18px rgba(120, 60, 20, 0.35);
  margin-bottom: 18px;
}
.note-label {
  font-size: 13px;
  color: #ff5f6d;
  font-weight: 700;
  margin-bottom: 8px;
}
.note-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.75;
  color: #2b2118;
}

.note-copy-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff5f6d, #ff8c42);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 26px -10px rgba(255, 95, 109, 0.7);
  margin-bottom: 20px;
  position: sticky;
  bottom: 10px;
}
.note-copy-btn.copied { background: linear-gradient(135deg, #22c55e, #16a34a); }

.note-guide {
  background: #fff;
  border: 1px dashed #f1d9b3;
  border-radius: 16px;
  padding: 14px 16px;
}
.note-guide h3 { margin: 0 0 10px; font-size: 14px; color: #4a3a2c; }
.note-guide ol { margin: 0; padding-left: 20px; color: #6b4a2b; font-size: 14px; line-height: 1.9; }
.note-guide b { color: #ff5f6d; }

.note-foot { text-align: center; color: #b39d84; font-size: 12px; margin-top: 24px; }

.note-hint { margin: 8px 0 0; font-size: 12px; color: #a89377; text-align: center; }

/* 全屏点击复制引导层 */
.tap-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 50% 40%, rgba(255,140,66,0.96), rgba(192,57,43,0.98));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: tapFadeIn 0.28s ease-out;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tap-overlay.hide { opacity: 0; transition: opacity 0.25s ease-out; }
.tap-inner {
  text-align: center;
  padding: 30px;
  animation: tapPulse 1.6s ease-in-out infinite;
}
.tap-emoji { font-size: 88px; line-height: 1; margin-bottom: 20px; filter: drop-shadow(0 6px 12px rgba(0,0,0,0.2)); }
.tap-title { font-size: 26px; font-weight: 800; line-height: 1.4; letter-spacing: 0.5px; }
.tap-sub { margin-top: 14px; font-size: 15px; opacity: 0.9; }
.tap-btn {
  display: inline-block;
  margin-top: 34px;
  padding: 14px 32px;
  background: #fff;
  color: #c0392b;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.35);
  animation: tapBtn 1.4s ease-in-out infinite;
}
@keyframes tapFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes tapPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
@keyframes tapBtn {
  0%, 100% { transform: translateY(0); box-shadow: 0 12px 30px -10px rgba(0,0,0,0.35); }
  50% { transform: translateY(-4px); box-shadow: 0 18px 34px -10px rgba(0,0,0,0.45); }
}

/* 环境提示 banner */
.env-banner {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  border-radius: 12px;
  color: #874d00;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.env-banner span:first-child { flex-shrink: 0; }

/* 微信"复制成功后"引导层 */
.wx-guide {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(20, 12, 8, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: tapFadeIn 0.24s ease-out;
}
.wx-guide-inner {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.4);
  animation: wxPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.wx-check {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-size: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px -8px rgba(34, 197, 94, 0.5);
}
.wx-guide-inner h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: #2b2118;
}
.wx-desc {
  margin: 0 0 18px;
  font-size: 14px;
  color: #6b4a2b;
  line-height: 1.6;
}
.wx-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  padding: 10px 12px;
  background: #fdf3e7;
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 14px;
  color: #4a3a2c;
  line-height: 1.5;
}
.wx-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff5f6d, #ff8c42);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wx-close-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff5f6d, #ff8c42);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgba(255, 95, 109, 0.7);
}
.wx-tip { margin: 12px 0 0; font-size: 12px; color: #a89377; }

.jump-btn {
  background: linear-gradient(135deg, #ff2442, #ff5f6d) !important;
  box-shadow: 0 12px 26px -10px rgba(255, 36, 66, 0.6) !important;
  font-size: 17px !important;
}

/* 微信里"右上角"箭头引导 */
.wx-arrow-hint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  background: linear-gradient(120deg, #fff3cd, #ffe4b3);
  border: 1px dashed #ff8c42;
  border-radius: 12px;
  margin-bottom: 14px;
  text-align: left;
}
.wx-arrow {
  font-size: 42px;
  line-height: 1;
  color: #ff5f6d;
  font-weight: 900;
  animation: arrowBounce 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.wx-arrow-text {
  font-size: 14px;
  color: #6b4a2b;
  line-height: 1.5;
}
.wx-arrow-text b { color: #ff2442; font-size: 15px; }
@keyframes arrowBounce {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(4px, -4px); }
}
@keyframes wxPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: rgba(43, 33, 24, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
