/* ==========================================================
   嘴替事务所 · 设计系统
   纸张质感 + 墨黑 + 一点朱红，克制但有个性
   ========================================================== */

:root {
  --paper: #f7f3ec;
  --paper-2: #fffdfa;
  --paper-3: #f1eadd;
  --ink: #1b1a17;
  --ink-2: #46423a;
  --muted: #8b8478;
  --line: #e5ddcf;
  --line-strong: #d3c8b6;
  --accent: #cf4f38;
  --accent-deep: #a83a25;
  --accent-soft: #fbe8e2;
  --green: #4a7c59;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(27, 26, 23, 0.04), 0 4px 12px rgba(27, 26, 23, 0.03);
  --shadow-md: 0 2px 6px rgba(27, 26, 23, 0.05), 0 18px 40px -18px rgba(27, 26, 23, 0.22);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC",
    "SimSun", ui-serif, Georgia, serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, #fffdf7 0%, rgba(255, 253, 247, 0) 60%),
    radial-gradient(900px 500px at 100% 0%, #fbf1e6 0%, rgba(251, 241, 230, 0) 55%),
    var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* 细颗粒纸张纹理 */
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

::selection { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  background: rgba(247, 243, 236, 0.82);
  border-bottom: 1px solid rgba(229, 221, 207, 0.9);
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding-bottom: 10px;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.12);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.brand-text em {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 253, 250, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--ink); color: var(--paper); }

.tab-count {
  font-size: 10.5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.tab.is-active .tab-count { background: rgba(255, 255, 255, 0.2); }
.tab:not(.is-active) .tab-count { background: var(--paper-3); color: var(--ink-2); }

/* ---------------- 版面 ---------------- */
.shell {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px 72px;
}

.view { animation: rise 0.4s cubic-bezier(0.22, 0.8, 0.3, 1) both; }
.view.is-hidden { display: none; }

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

/* ---------------- Hero ---------------- */
.hero { padding: 54px 0 34px; max-width: 640px; }

.eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.hero h1 {
  margin: 0;
  font-size: clamp(34px, 6.2vw, 54px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.hero-em {
  background: linear-gradient(transparent 64%, rgba(207, 79, 56, 0.22) 64%);
  padding-bottom: 2px;
}

.lede {
  margin: 18px 0 0;
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--ink-2);
  max-width: 560px;
}

/* ---------------- 输入卡片 ---------------- */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.composer { padding: 22px 24px 24px; transition: box-shadow 0.25s ease, border-color 0.25s ease; }
.composer:focus-within { border-color: var(--line-strong); }

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.field-head label,
.field-head > span:first-child {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  text-transform: uppercase;
}

.counter, .field-tip {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.field-tip { text-align: right; }

#scene {
  width: 100%;
  border: 0;
  background: transparent;
  resize: vertical;
  min-height: 92px;
  font-family: inherit;
  font-size: 16.5px;
  line-height: 1.78;
  color: var(--ink);
  padding: 0;
  outline: none;
}
#scene::placeholder { color: #b3aa9b; }

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.preset {
  appearance: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--paper-3);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.preset:hover {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink);
  transform: translateY(-1px);
}
.preset::before { content: "＋"; margin-right: 4px; color: var(--muted); font-size: 11px; }

.rule {
  height: 1px;
  background: linear-gradient(90deg, var(--line) 0%, rgba(229, 221, 207, 0.2) 100%);
  margin: 20px 0 18px;
}

.tones { display: flex; flex-wrap: wrap; gap: 8px; }

.tone {
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.tone:hover { border-color: var(--ink-2); color: var(--ink); background: #fff; }
.tone.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  box-shadow: 0 6px 16px -8px rgba(27, 26, 23, 0.6);
}

.submit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.btn-primary {
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  color: var(--paper);
  background: var(--ink);
  border-radius: var(--radius-md);
  padding: 14px 22px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 10px 24px -14px rgba(27, 26, 23, 0.9);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 30px -16px rgba(27, 26, 23, 0.85); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: progress; }
.btn-primary.small { font-size: 13.5px; padding: 11px 18px; margin-top: 18px; }

.btn-arrow { font-size: 16px; transition: transform 0.2s ease; }
.btn-primary:hover:not(:disabled) .btn-arrow { transform: translateX(3px); }

.fineprint { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------------- 结果 ---------------- */
.result-area { margin-top: 40px; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.result-head h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.link-btn:hover { border-bottom-color: var(--accent); }

.replies {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.reply {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: cardIn 0.45s cubic-bezier(0.22, 0.8, 0.3, 1) both;
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}
.reply:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}
.reply.saved { border-color: #d9c3b6; background: #fffaf7; }

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

.reply-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reply-idx {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--line-strong);
  letter-spacing: 0.06em;
}

.reply-tone {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 600;
}

.reply-text {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
}

.reply-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  padding-left: 10px;
  border-left: 2px solid var(--paper-3);
}

.reply-actions { display: flex; gap: 6px; margin-top: 2px; }

.mini {
  appearance: none;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--paper-3);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.mini:hover { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.mini.is-done { background: #e8f0e9; color: var(--green); border-color: #d2e2d6; }

/* 骨架屏 */
.reply.skeleton { pointer-events: none; }
.sk-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--paper-3) 25%, #f8f3ea 37%, var(--paper-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.sk-line.w-90 { width: 90%; }
.sk-line.w-75 { width: 75%; }
.sk-line.w-60 { width: 60%; }
@keyframes shimmer {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}

/* ---------------- 我的语录 ---------------- */
.saved-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 50px 0 26px;
}

.saved-head .eyebrow { margin-bottom: 8px; }
.saved-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.btn-ghost {
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-ghost:hover { background: #fff; border-color: var(--ink); }

.tools {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  transition: border-color 0.18s ease;
}
.search:focus-within { border-color: var(--line-strong); }
.search svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  flex: none;
}
.search input {
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 12px 0;
  width: 100%;
}
.search input::placeholder { color: #b3aa9b; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.select {
  appearance: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--paper-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238b8478' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 36px 11px 14px;
  cursor: pointer;
  outline: none;
}

.saved-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.saved-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: cardIn 0.4s cubic-bezier(0.22, 0.8, 0.3, 1) both;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.saved-card:hover { box-shadow: var(--shadow-sm); border-color: var(--line-strong); }
.saved-card.is-pinned { border-left: 3px solid var(--accent); }

.saved-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.tag {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 8px;
  font-weight: 600;
}
.pin-flag { color: var(--accent); font-size: 11px; }
.saved-meta time { margin-left: auto; font-variant-numeric: tabular-nums; }

.saved-reply {
  margin: 0;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  word-break: break-word;
}

.saved-scene {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.saved-scene::before { content: "对方 · "; color: var(--line-strong); }

.saved-actions {
  display: flex;
  gap: 6px;
  padding-top: 10px;
  margin-top: 2px;
  border-top: 1px dashed var(--line);
}
.saved-actions .mini { background: transparent; }
.saved-actions .mini:hover { background: var(--paper-3); }
.saved-actions .danger:hover { color: var(--accent); border-color: #edc9c1; background: var(--accent-soft); }

/* 空状态 */
.empty {
  text-align: center;
  padding: 46px 24px 56px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 250, 0.55);
}
.empty-art { width: 92px; height: 92px; color: var(--line-strong); margin-bottom: 12px; }
.empty-title { margin: 0; font-size: 16px; font-weight: 600; }
.empty-text { margin: 8px auto 0; font-size: 13.5px; color: var(--muted); max-width: 340px; line-height: 1.75; }

.no-result {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 13.5px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

/* ---------------- 页脚 ---------------- */
.footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.footer .dot { color: var(--line-strong); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 16px 36px -14px rgba(27, 26, 23, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 60;
  max-width: min(88vw, 420px);
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--accent-deep); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .replies { grid-template-columns: 1fr; }
  .saved-list { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar-inner { padding: 12px 16px; }
  .brand-text em { display: none; }
  .shell { padding: 0 16px 56px; }
  .hero { padding: 36px 0 26px; }
  .lede { font-size: 14.5px; }
  .composer { padding: 18px 16px 20px; }
  #scene { font-size: 16px; min-height: 84px; }
  .submit-row { gap: 12px; }
  .btn-primary { width: 100%; justify-content: center; }
  .fineprint { width: 100%; text-align: center; font-size: 11.5px; }
  .saved-head { padding: 32px 0 20px; align-items: center; }
  .tabs { padding: 3px; }
  .tab { padding: 6px 12px; font-size: 12.5px; }
  .field-tip { display: none; }
  .footer { margin-top: 40px; }
}

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