:root {
  --paper: #f3eee5;
  --paper-deep: #e9e1d5;
  --ink: #22302b;
  --muted: #6f766f;
  --line: rgba(44, 61, 54, 0.13);
  --accent: #e35e4f;
  --accent-dark: #b84136;
  --sage: #667c6d;
  --card: rgba(255, 253, 249, 0.82);
  --shadow: 0 24px 80px rgba(51, 61, 55, 0.12);
  --radius: 28px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(227, 94, 79, 0.13), transparent 27rem),
    radial-gradient(circle at 90% 36%, rgba(102, 124, 109, 0.16), transparent 31rem),
    linear-gradient(145deg, #f7f2ea 0%, #f0e9de 54%, #f5f1e9 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

button { font: inherit; }

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}

.ambient-one {
  width: 20rem;
  height: 20rem;
  left: -11rem;
  top: 32%;
  border: 1px solid rgba(227, 94, 79, 0.18);
}

.ambient-two {
  width: 28rem;
  height: 28rem;
  right: -18rem;
  top: -8rem;
  border: 1px solid rgba(102, 124, 109, 0.18);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #fffaf4;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(227, 94, 79, 0.25);
  font-size: 17px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.58);
  color: var(--muted);
  font-size: 13px;
  backdrop-filter: blur(10px);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a5aaa4;
}

.status-pill[data-status="reading"] .status-dot,
.status-pill[data-status="analyzing"] .status-dot {
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.status-pill[data-status="done"] .status-dot { background: #4c8260; }
.status-pill[data-status="error"] .status-dot { background: #b84136; }

.hero {
  max-width: 870px;
  padding: 78px 0 54px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.hero h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: clamp(42px, 6.4vw, 78px);
  font-weight: 600;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.hero h1 em {
  color: var(--accent);
  font-style: normal;
}

.hero-copy {
  max-width: 620px;
  margin: 27px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.9;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.send-panel {
  display: flex;
  flex-direction: column;
  padding: 30px;
}

.result-panel {
  display: flex;
  min-height: 570px;
  flex-direction: column;
  padding: 30px;
  background:
    linear-gradient(160deg, rgba(39, 57, 49, 0.97), rgba(30, 44, 38, 0.98));
  color: #f8f4ed;
  box-shadow: 0 30px 90px rgba(32, 45, 39, 0.24);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.step-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.result-panel .step-label { color: rgba(244, 239, 230, 0.58); }

.privacy-note,
.result-badge {
  color: var(--sage);
  font-size: 12px;
}

.result-badge {
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(250, 246, 238, 0.72);
  background: rgba(255, 255, 255, 0.05);
}

.mail-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.field { padding: 18px 19px; }

.field-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.field code {
  overflow: hidden;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.divider {
  height: 1px;
  margin: 0 19px;
  background: var(--line);
}

.icon-button,
.text-button {
  border: 0;
  color: var(--accent-dark);
  background: transparent;
  cursor: pointer;
}

.icon-button {
  flex: none;
  padding: 5px 0 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.primary-button {
  display: inline-flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  border: 0;
  border-radius: 15px;
  color: #fffaf4;
  background: var(--accent);
  box-shadow: 0 12px 30px rgba(227, 94, 79, 0.23);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.primary-button:hover {
  background: var(--accent-dark);
  box-shadow: 0 15px 36px rgba(184, 65, 54, 0.27);
  transform: translateY(-1px);
}

.primary-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.steps {
  display: grid;
  gap: 0;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.steps li {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 52px;
}

.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 39px;
  bottom: -13px;
  width: 1px;
  background: var(--line);
}

.steps span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  font-weight: 800;
}

.steps p {
  margin: 0;
  color: #626b65;
  font-size: 13px;
}

.tip {
  margin: auto 0 0;
  padding-top: 24px;
  color: #8a8d87;
  font-size: 11px;
  line-height: 1.7;
}

.result-body {
  position: relative;
  overflow: auto;
  min-height: 360px;
  max-height: 600px;
  flex: 1;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.empty-state {
  display: flex;
  height: 100%;
  min-height: 350px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.radar {
  position: relative;
  display: grid;
  width: 112px;
  height: 112px;
  margin-bottom: 26px;
  place-items: center;
}

.radar-ring {
  position: absolute;
  border: 1px solid rgba(242, 236, 225, 0.16);
  border-radius: 50%;
}

.ring-one { inset: 14px; }
.ring-two { inset: 0; }

.radar-core {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  color: #f8b1a8;
  background: rgba(227, 94, 79, 0.14);
  font-size: 24px;
}

.result-panel.is-streaming .radar-ring {
  animation: radar-breathe 1.8s ease-out infinite;
}

.result-panel.is-streaming .ring-two {
  animation-delay: 0.6s;
}

.result-panel.is-streaming .radar-core {
  animation: core-pulse 1.4s ease-in-out infinite;
}

@keyframes radar-breathe {
  0% { opacity: 0.2; transform: scale(0.72); }
  65% { opacity: 0.62; }
  100% { opacity: 0; transform: scale(1.18); }
}

@keyframes core-pulse {
  0%, 100% { transform: scale(1); background: rgba(227, 94, 79, 0.14); }
  50% { transform: scale(1.08); background: rgba(227, 94, 79, 0.24); }
}

.empty-state h2 {
  margin: 0 0 11px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 23px;
  font-weight: 500;
}

.empty-state p {
  max-width: 300px;
  margin: 0;
  color: rgba(245, 240, 231, 0.5);
  font-size: 13px;
  line-height: 1.8;
}

.result-text {
  min-height: 100%;
  margin: 0;
  padding: 4px 6px 28px 0;
  color: rgba(252, 249, 243, 0.9);
  font-family: "Songti SC", "STSong", "Noto Serif SC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.95;
  word-break: break-word;
}

.result-markdown { white-space: normal; }
.result-markdown.plain-fallback { white-space: pre-wrap; }
.result-markdown > :first-child { margin-top: 0; }
.result-markdown > :last-child { margin-bottom: 0; }
.result-markdown p { margin: 0 0 1em; }
.result-markdown h1,
.result-markdown h2,
.result-markdown h3,
.result-markdown h4 {
  margin: 1.35em 0 0.55em;
  color: #fffaf3;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.45;
}
.result-markdown h1 { font-size: 1.45em; }
.result-markdown h2 { font-size: 1.28em; }
.result-markdown h3 { font-size: 1.12em; }
.result-markdown h4 { font-size: 1em; }
.result-markdown strong { color: #fffaf3; font-weight: 750; }
.result-markdown em { color: #f1c1ba; }
.result-markdown a {
  color: #f3a99f;
  text-decoration-color: rgba(243, 169, 159, 0.45);
  text-underline-offset: 3px;
}
.result-markdown ul,
.result-markdown ol { margin: 0 0 1em; padding-left: 1.45em; }
.result-markdown li { margin: 0.3em 0; padding-left: 0.2em; }
.result-markdown li::marker { color: #e98b7f; }
.result-markdown blockquote {
  margin: 1em 0;
  padding: 0.65em 1em;
  border-left: 2px solid rgba(233, 139, 127, 0.6);
  border-radius: 0 10px 10px 0;
  color: rgba(250, 246, 238, 0.7);
  background: rgba(255, 255, 255, 0.045);
}
.result-markdown blockquote p:last-child { margin-bottom: 0; }
.result-markdown code {
  padding: 0.14em 0.38em;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 5px;
  color: #f4c7bf;
  background: rgba(255, 255, 255, 0.06);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
}
.result-markdown pre {
  overflow: auto;
  margin: 1em 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(13, 23, 19, 0.5);
  line-height: 1.65;
}
.result-markdown pre code { padding: 0; border: 0; background: transparent; }
.result-markdown hr {
  height: 1px;
  margin: 1.5em 0;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
}
.result-markdown table {
  display: block;
  overflow-x: auto;
  width: max-content;
  max-width: 100%;
  margin: 1em 0;
  border-collapse: collapse;
  font-size: 0.88em;
}
.result-markdown th,
.result-markdown td {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  text-align: left;
}
.result-markdown th { color: #fffaf3; background: rgba(255, 255, 255, 0.055); }

.result-panel.is-streaming .result-text::after {
  content: "▍";
  color: #ef8b7f;
  animation: blink 900ms steps(1) infinite;
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.result-footer p {
  max-width: 390px;
  margin: 0;
  color: rgba(245, 240, 231, 0.38);
  font-size: 10px;
  line-height: 1.6;
}

.text-button {
  flex: none;
  color: rgba(250, 224, 218, 0.72);
  font-size: 11px;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 4px 0;
  color: #858a84;
  font-size: 11px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  padding: 11px 16px;
  border-radius: 999px;
  color: #fffaf4;
  background: rgba(31, 45, 39, 0.94);
  box-shadow: 0 10px 30px rgba(30, 42, 36, 0.2);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 94, 79, 0.32); }
  50% { box-shadow: 0 0 0 5px rgba(227, 94, 79, 0); }
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

@media (max-width: 860px) {
  .shell { width: min(100% - 30px, 680px); padding-top: 20px; }
  .hero { padding: 56px 0 38px; }
  .hero h1 { font-size: clamp(40px, 10vw, 64px); }
  .workspace { grid-template-columns: 1fr; }
  .result-panel { min-height: 520px; }
}

@media (max-width: 520px) {
  .shell { width: calc(100% - 22px); }
  .brand { font-size: 17px; }
  .brand-mark { width: 34px; height: 34px; font-size: 15px; }
  .status-pill { padding: 7px 11px; font-size: 11px; }
  .hero { padding: 44px 6px 30px; }
  .hero h1 { font-size: 40px; line-height: 1.14; }
  .hero-copy { margin-top: 20px; font-size: 14px; }
  .send-panel, .result-panel { padding: 22px 19px; border-radius: 22px; }
  .panel-heading { margin-bottom: 18px; }
  .field { padding: 16px; }
  .field code { font-size: 11px; }
  .steps p { font-size: 12px; }
  .result-panel { min-height: 480px; }
  .result-body { min-height: 320px; }
  .empty-state { min-height: 310px; }
  .result-footer { align-items: flex-start; flex-direction: column; }
  .page-footer { align-items: flex-start; flex-direction: column; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.identity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -3px 0 20px;
  padding: 15px 16px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.identity-bar[hidden] { display: none; }
.identity-copy { min-width: 0; }
.identity-kicker {
  display: block;
  margin-bottom: 5px;
  color: rgba(245, 240, 231, 0.4);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.18em;
}
.identity-copy strong { color: #fffaf3; font-size: 13px; font-weight: 650; }
.identity-copy p {
  max-width: 330px;
  margin: 5px 0 0;
  color: rgba(245, 240, 231, 0.48);
  font-size: 10px;
  line-height: 1.6;
}

.identity-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

.role-toggle {
  display: inline-flex;
  min-width: 0;
  overflow: hidden;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(13, 23, 19, 0.32);
}

.role-toggle button {
  min-width: 0;
  max-width: 180px;
  min-height: 30px;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 0;
  border-radius: 7px;
  color: rgba(247, 242, 234, 0.5);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.role-toggle button[aria-pressed="true"] {
  color: #fffaf3;
  background: rgba(227, 94, 79, 0.82);
}

.reanalyze-button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: #fffaf3;
  background: rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.reanalyze-button:hover { border-color: rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.13); }
.role-toggle button:disabled,
.reanalyze-button:disabled { cursor: wait; opacity: 0.45; }

@media (max-width: 520px) {
  .identity-bar { align-items: stretch; flex-direction: column; gap: 12px; }
  .identity-actions { justify-content: space-between; }
  .role-toggle { flex: 1; }
  .role-toggle button { flex: 1; }
  .reanalyze-button { flex: none; }
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

.result-actions .text-button[hidden] { display: none; }
.result-actions .text-button:disabled { cursor: wait; opacity: 0.45; }

.transcript-panel {
  margin-top: 18px;
  padding: 27px 30px 30px;
}

.transcript-panel[hidden] { display: none; }
.transcript-heading { margin-bottom: 17px; }
.transcript-heading h2 {
  margin: 7px 0 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.transcript-role {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.45);
  font-size: 10px;
  font-weight: 700;
}

.transcript-panel pre {
  overflow: auto;
  max-height: 440px;
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: #35433d;
  background: rgba(255, 255, 255, 0.5);
  font: 13px/1.9 "SFMono-Regular", Consolas, "Microsoft YaHei", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 520px) {
  .result-actions { align-items: flex-end; flex-direction: column; gap: 8px; }
  .transcript-panel { padding: 22px 19px; border-radius: 22px; }
  .transcript-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .transcript-heading h2 { font-size: 22px; }
  .transcript-panel pre { padding: 15px; font-size: 12px; }
}
