:root {
  color-scheme: light;
  --bg: #f8fafc;
  --card: #ffffff;
  --soft: #f1f5f9;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #60a5fa;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --indigo: #6366f1;
  --teal: #14b8a6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { border: 0; cursor: pointer; }

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.phone-shell {
  position: relative;
  width: min(430px, 100%);
  height: min(850px, 100vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
  border: 8px solid #fff;
  border-radius: 40px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
}

.app-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 38px 24px 18px;
  background: #fff;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

h1, h2, p { margin: 0; }
h1 { font-size: 21px; line-height: 1.2; letter-spacing: 0; }
.app-header p { margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 700; }

.state-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cbd5e1;
  box-shadow: 0 0 0 6px rgba(203, 213, 225, 0.22);
}
.state-dot.listening { background: var(--green); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.16); }
.state-dot.processing, .state-dot.confirming { background: var(--amber); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.16); }
.state-dot.speaking { background: var(--blue); box-shadow: 0 0 0 8px rgba(96, 165, 250, 0.16); }
.state-dot.done { background: var(--red); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.14); }

.setup-panel {
  display: grid;
  gap: 14px;
  margin: 16px;
  padding: 18px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}
.setup-panel p, .consent { color: var(--muted); font-size: 14px; line-height: 1.55; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 800; }
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}
.consent { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; }
.consent input { width: 18px; min-height: 18px; margin-top: 2px; }

.primary {
  min-height: 46px;
  border-radius: 16px;
  background: var(--teal);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.chat-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 28px;
  background: #fff;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.chat-card.listening { border-color: var(--green); box-shadow: 0 0 20px rgba(34, 197, 94, 0.22); }
.chat-card.processing, .chat-card.confirming { border-color: var(--amber); box-shadow: 0 0 20px rgba(245, 158, 11, 0.2); }
.chat-card.speaking { border-color: var(--blue); box-shadow: 0 0 20px rgba(96, 165, 250, 0.2); }
.chat-card.done { border-color: var(--red); }

.chat-feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}
.event-row { display: flex; gap: 8px; max-width: 88%; }
.event-row.user { align-self: flex-end; flex-direction: row-reverse; }
.event-row strong {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: transparent;
}
.event-row.assistant strong { background: #ccfbf1; }
.event-row.user strong { background: #e0e7ff; }
.event-row.assistant strong::before { content: "AI"; color: #0f766e; font-size: 11px; font-weight: 900; }
.event-row.user strong::before { content: "你"; color: #4f46e5; font-size: 13px; font-weight: 900; }
.event-row p {
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--soft);
  color: #334155;
  font-size: 14px;
  line-height: 1.55;
}
.event-row.user p { background: var(--indigo); color: #fff; border-top-right-radius: 4px; }
.event-row.assistant p { border-top-left-radius: 4px; }

.typing-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 88%;
  margin: 0 16px 14px;
}
.typing-row.assistant { align-self: flex-start; }
.typing-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.typing-row strong {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: transparent;
}
.typing-row.assistant strong { background: #ccfbf1; }
.typing-row.user strong { background: #e0e7ff; }
.typing-row.assistant strong::before { content: "AI"; color: #0f766e; font-size: 11px; font-weight: 900; }
.typing-row.user strong::before { content: "你"; color: #4f46e5; font-size: 13px; font-weight: 900; }
.typing-row p {
  min-height: 43px;
  min-width: 52px;
  max-width: 100%;
  margin: 0;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--soft);
  color: #334155;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.typing-row.assistant p { border-top-left-radius: 4px; }
.typing-row.user p {
  background: var(--indigo);
  color: #fff;
  border-top-right-radius: 4px;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 24px;
  min-height: 20px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: bounce 0.8s infinite ease-in-out;
}
.typing-row.user .typing-dots span { background: #fff; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 50% { transform: translateY(-5px); } }

.bottom-grid {
  flex: 0 0 220px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 138px;
  gap: 14px;
}
.avatar-card, .progress-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}
.avatar-card {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(224, 231, 255, 0.68), rgba(252, 231, 243, 0.68));
}
.avatar-orb { position: relative; width: 128px; height: 156px; }
.avatar-head, .avatar-body {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.avatar-head { top: 12px; width: 76px; height: 76px; border-radius: 50%; }
.avatar-body { bottom: 8px; width: 104px; height: 76px; border-radius: 42px 42px 20px 20px; }

.control-stack { display: grid; grid-template-rows: minmax(0, 1fr) 72px; gap: 12px; }
.progress-card {
  display: grid;
  grid-template-rows: minmax(76px, 1fr) auto auto;
  align-items: center;
  justify-items: center;
  gap: 12px;
  padding: 14px 12px;
  min-width: 0;
  overflow: hidden;
}
.progress-meter {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
}
.progress-ring { width: 76px; height: 76px; transform: rotate(-90deg); }
.progress-ring path { fill: none; stroke-width: 3.5; }
.ring-bg { stroke: #e2e8f0; }
.ring-value {
  stroke: var(--indigo);
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 260ms ease;
}
.progress-card strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}
.coverage-dots {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: min(100%, 82px);
}
.coverage-dot { width: 8px; height: 8px; border-radius: 50%; background: #e2e8f0; }
.coverage-dot.partial { background: #fbbf24; }
.coverage-dot.covered { background: var(--green); }
.pipeline-dots {
  display: flex;
  align-items: center;
  width: min(100%, 92px);
}
.pipeline-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; }
.pipeline-dot.active, .pipeline-dot.ready { background: var(--teal); }
.pipeline-dot.done { background: var(--red); }
.pipeline-line { flex: 1; height: 2px; background: #e2e8f0; }

.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.icon-action {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 22px;
}
.icon-action.pause { background: #fffbeb; color: #d97706; }
.icon-action.pause.is-paused { background: #ecfdf5; color: var(--green); }
.icon-action.stop { background: #fef2f2; color: var(--red); }
.pause-glyph {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
}
.pause-glyph::before,
.pause-glyph::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 5px;
  height: 14px;
  border-radius: 2px;
  background: currentColor;
}
.pause-glyph::before { left: 3px; }
.pause-glyph::after { right: 3px; }
.icon-action.pause.is-paused .pause-glyph::before {
  left: 5px;
  top: 1px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid currentColor;
  border-radius: 0;
  background: transparent;
}
.icon-action.pause.is-paused .pause-glyph::after { display: none; }

.confirm-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(8px);
}
.confirm-card {
  display: grid;
  gap: 14px;
  width: min(300px, 100%);
  padding: 22px;
  border-radius: 28px;
  background: #fff;
  text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}
.confirm-card strong { font-size: 18px; }
.confirm-card p { color: var(--muted); font-size: 14px; }
.confirm-card div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ghost, .danger {
  min-height: 42px;
  border-radius: 16px;
  font-weight: 800;
}
.ghost { background: var(--soft); color: var(--ink); }
.danger { background: var(--red); color: #fff; }

.report-panel {
  position: absolute;
  inset: 92px 14px 14px;
  z-index: 10;
  overflow: auto;
  padding: 16px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.16);
}
.report-panel article { margin-top: 12px; font-size: 13px; line-height: 1.6; }
.report-panel pre { overflow: auto; padding: 10px; border-radius: 12px; background: #0f172a; color: #e5e7eb; white-space: pre-wrap; }

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 16px;
  z-index: 30;
  padding: 12px 14px;
  border-radius: 16px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
}

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 460px) {
  .page { padding: 0; }
  .phone-shell {
    width: 100%;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }
}
