:root {
  color-scheme: light;
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
  color: #17211d;
  background: #f4f6f4;
  --surface: #ffffff;
  --surface-soft: #eef2ef;
  --border: #d9dfdb;
  --text: #17211d;
  --muted: #65716b;
  --green: #14775f;
  --green-dark: #0c5946;
  --amber: #b87016;
  --red: #b64a48;
  --charcoal: #1d2924;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f4f6f4;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: 76px;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #f8fbf9;
  background: var(--charcoal);
  border-bottom: 3px solid #d7a84d;
}

.brand-block,
.topbar-actions,
.phone-field,
.connection-state,
.playback-state {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 13px;
  min-width: 260px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid #456057;
  border-radius: 6px;
  background: #263630;
}

.brand-mark span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #62c7a3;
}

.brand-mark span:nth-child(1) {
  transform: translate(-9px, 7px);
}

.brand-mark span:nth-child(2) {
  transform: translate(0, -8px);
  background: #e2b559;
}

.brand-mark span:nth-child(3) {
  transform: translate(9px, 7px);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  width: 19px;
  height: 1px;
  background: #698078;
  transform-origin: center;
}

.brand-mark::before {
  transform: rotate(34deg);
}

.brand-mark::after {
  transform: rotate(-34deg);
}

.brand-block h1,
.brand-block p,
.panel-heading h2,
.inspector-header h2 {
  margin: 0;
}

.brand-block h1 {
  font-size: 17px;
  font-weight: 700;
}

.brand-block p {
  margin-top: 2px;
  color: #aebbb5;
  font-size: 12px;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 20px;
}

.phone-field {
  gap: 9px;
  color: #aebbb5;
  font-size: 12px;
}

.phone-field input {
  width: 126px;
  height: 36px;
  padding: 0 10px;
  color: #ffffff;
  background: #2a3a34;
  border: 1px solid #4a5e56;
  border-radius: 5px;
  outline: none;
}

.phone-field input:focus {
  border-color: #6bc3a4;
}

.connection-state {
  gap: 8px;
  color: #d7dfdb;
  font-size: 12px;
}

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

.connection-state.connected .status-dot {
  background: #57c698;
  box-shadow: 0 0 0 3px rgb(87 198 152 / 15%);
}

.connection-state.error .status-dot {
  background: #df6b68;
}

.playback-state {
  gap: 8px;
  color: #b8c4bf;
  font-size: 12px;
}

.playback-state svg {
  width: 17px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
}

.conversation-panel,
.inspector-panel {
  min-height: 0;
  background: var(--surface);
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  border-right: 1px solid var(--border);
}

.panel-heading,
.inspector-header {
  min-height: 76px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--green);
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
}

.panel-heading h2,
.inspector-header h2 {
  font-size: 18px;
  line-height: 1.2;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
}

.icon-button svg,
.button svg,
.record-button svg {
  width: 18px;
  height: 18px;
}

.icon-button.quiet {
  color: #69756f;
  background: transparent;
}

.icon-button.quiet:hover {
  color: var(--red);
  background: #f4eceb;
}

.conversation {
  min-height: 360px;
  overflow-y: auto;
  padding: 26px clamp(22px, 5vw, 72px);
  background:
    linear-gradient(#e8ece9 1px, transparent 1px),
    linear-gradient(90deg, #e8ece9 1px, transparent 1px);
  background-size: 32px 32px;
  background-color: #f8faf8;
}

.message {
  max-width: min(680px, 82%);
  margin-bottom: 22px;
}

.message.user {
  margin-left: auto;
}

.message-meta {
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: 11px;
}

.message.user .message-meta {
  text-align: right;
}

.message-body {
  padding: 13px 16px;
  line-height: 1.7;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 4px 18px rgb(24 41 34 / 5%);
}

.message.user .message-body {
  color: #ffffff;
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.message.system {
  max-width: 100%;
  margin: 4px 0 18px;
  text-align: center;
}

.message.system .message-body {
  display: inline-block;
  padding: 6px 11px;
  color: var(--muted);
  font-size: 12px;
  background: #eef2ef;
  box-shadow: none;
}

.message audio {
  width: min(360px, 100%);
  height: 36px;
  margin-top: 10px;
  display: block;
}

.confirm-panel {
  margin: 0 24px 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #e2c489;
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  background: #fffaf0;
}

.confirm-panel[hidden] {
  display: none;
}

.confirm-panel strong,
.confirm-panel span {
  display: block;
}

.confirm-panel strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.confirm-panel span {
  color: #746344;
  font-size: 12px;
}

.confirm-actions {
  display: flex;
  gap: 8px;
}

.button {
  min-height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
}

.button.primary {
  color: #ffffff;
  background: var(--green);
}

.button.secondary {
  color: #4f5c56;
  border-color: #cfd7d2;
  background: #ffffff;
}

.composer {
  min-height: 92px;
  padding: 17px 24px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.record-button {
  width: 52px;
  height: 52px;
  position: relative;
  display: grid;
  place-items: center;
  color: #ffffff;
  border: 0;
  border-radius: 50%;
  background: var(--green);
}

.record-button.recording {
  background: var(--red);
}

.record-ring {
  position: absolute;
  inset: -5px;
  border: 1px solid transparent;
  border-radius: 50%;
}

.record-button.recording .record-ring {
  border-color: rgb(182 74 72 / 45%);
  animation: pulse 1.2s ease-out infinite;
}

@keyframes pulse {
  70% {
    transform: scale(1.16);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.voice-prompt {
  min-width: 0;
}

.voice-prompt strong,
.voice-prompt span {
  display: block;
}

.voice-prompt strong {
  color: var(--text);
  font-size: 14px;
}

.voice-prompt span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.record-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.inspector-panel {
  display: flex;
  flex-direction: column;
  background: #f7f9f7;
}

.latency-badge {
  min-width: 50px;
  padding: 5px 8px;
  color: #52615a;
  text-align: center;
  font-family: Consolas, monospace;
  font-size: 11px;
  border: 1px solid #d0d8d3;
  border-radius: 4px;
  background: #ffffff;
}

.pipeline {
  padding: 10px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.stage {
  min-height: 62px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #e3e8e5;
  color: #7b8781;
}

.stage:last-child {
  border-bottom: 0;
}

.stage-index {
  font-family: Consolas, monospace;
  font-size: 10px;
}

.stage strong,
.stage div span {
  display: block;
}

.stage strong {
  color: #46534d;
  font-size: 13px;
}

.stage div span {
  margin-top: 3px;
  font-size: 11px;
}

.stage svg {
  width: 17px;
}

.stage.active {
  color: var(--amber);
}

.stage.active strong {
  color: #8f5c17;
}

.stage.done {
  color: var(--green);
}

.stage.done strong {
  color: var(--green-dark);
}

.stage.error {
  color: var(--red);
}

.tabs {
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.tab-button {
  min-height: 44px;
  padding: 0 2px;
  margin-right: 24px;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-size: 12px;
}

.tab-button.active {
  color: var(--green-dark);
  border-color: var(--green);
  font-weight: 700;
}

.tab-panel {
  min-height: 0;
  padding: 18px 20px;
  display: none;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

.result-list {
  margin: 0;
}

.result-list div {
  min-height: 38px;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  border-bottom: 1px solid #e2e7e4;
  font-size: 12px;
}

.result-list dt {
  color: var(--muted);
}

.result-list dd {
  margin: 0;
  color: var(--text);
  font-family: Consolas, "Microsoft YaHei", monospace;
  overflow-wrap: anywhere;
}

.result-data {
  margin-top: 20px;
}

.result-data > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 11px;
  line-height: 1.6;
}

#result-json,
#event-log {
  padding: 13px;
  color: #d9e5df;
  border-radius: 5px;
  background: #1e2b25;
}

#event-log {
  min-height: 280px;
}

.footer {
  min-height: 34px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #718079;
  font-size: 10px;
  border-top: 1px solid var(--border);
  background: #edf1ee;
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .conversation-panel {
    min-height: 70vh;
    border-right: 0;
  }

  .inspector-panel {
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 13px 16px;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .phone-field span {
    display: none;
  }

  .phone-field input {
    width: 120px;
  }

  .panel-heading,
  .inspector-header {
    padding: 16px;
  }

  .conversation {
    min-height: 390px;
    padding: 20px 15px;
  }

  .message {
    max-width: 92%;
  }

  .confirm-panel {
    margin: 0 14px 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .confirm-actions .button {
    flex: 1;
  }

  .composer {
    padding: 14px;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
  }

  .record-button {
    width: 46px;
    height: 46px;
  }

  .footer {
    padding: 8px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }
}
