:root {
  color: #18201c;
  background: #f3f5f3;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #18201c;
  --muted: #657069;
  --line: #d8ddd9;
  --surface: #ffffff;
  --green: #167451;
  --green-dark: #0c563b;
  --coral: #d94b3d;
}

* {
  box-sizing: border-box;
}

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

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

button,
.button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.button:hover {
  background: var(--green-dark);
}

button:disabled {
  cursor: wait;
  opacity: .55;
}

.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary:hover {
  background: #eef1ef;
}

.danger {
  background: #fff;
  border-color: #e7b3ae;
  color: #a52d25;
}

.danger:hover {
  background: #fff2f0;
}

.topbar {
  height: 88px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.conversation h2,
.login-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  width: min(210px, 42vw);
  height: auto;
  max-height: 42px;
  object-fit: contain;
  object-position: left center;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.2;
}

.eyebrow,
.field-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.identity {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.workspace {
  min-height: calc(100vh - 88px);
}

.login-panel {
  width: min(440px, calc(100% - 40px));
  margin: 72px auto;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.test-duration-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.phone-login-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.phone-login-form label,
.control-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid #cbd2cd;
  border-radius: 5px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible,
.button:focus-visible {
  outline: 3px solid rgba(22, 116, 81, .18);
  outline-offset: 1px;
}

.error-text {
  min-height: 20px;
  margin: 0;
  color: #a52d25;
  font-size: 13px;
}

.test-layout {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  min-height: calc(100vh - 88px);
}

.control-panel {
  padding: 28px clamp(20px, 3vw, 36px);
  background: #fff;
  border-right: 1px solid var(--line);
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 56px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.connection-state strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.state-indicator {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 3px solid #c4cbc6;
  border-radius: 50%;
}

.state-indicator[data-state="ready"],
.state-indicator[data-state="listening"] {
  border-color: var(--green);
  background: #50c391;
}

.state-indicator[data-state="connecting"],
.state-indicator[data-state="thinking"] {
  border-color: #d2a025;
  background: #f6d266;
}

.state-indicator[data-state="speaking"] {
  border-color: #3874bd;
  background: #82b4ee;
}

.state-indicator[data-state="error"] {
  border-color: var(--coral);
  background: #f2968d;
}

.level-wrap {
  margin-top: 22px;
}

.level-track {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #e5e9e6;
}

#micLevel {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 80ms linear;
}

.control-field {
  margin-top: 22px;
}

.select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 7px;
}

.icon-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  font-size: 22px;
}

.icon-button:hover {
  background: #eef1ef;
}

.session-meta {
  margin: 24px 0 0;
  padding: 15px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.session-meta div {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  padding: 4px 0;
}

.session-meta dt {
  color: var(--muted);
  font-size: 12px;
}

.session-meta dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.actions {
  display: grid;
  gap: 9px;
  margin-top: 24px;
}

#remoteAudio {
  display: none;
}

.conversation {
  min-width: 0;
  padding: 30px clamp(22px, 4vw, 58px);
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 920px;
  margin: 0 auto 20px;
}

.conversation h2 {
  font-size: 20px;
}

.text-button {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.text-button:hover {
  background: #e7ebe8;
  color: var(--ink);
}

.messages {
  max-width: 920px;
  height: calc(100vh - 178px);
  margin: 0 auto;
  padding: 4px 2px 60px;
  overflow-y: auto;
}

.empty-state {
  margin: 80px 0 0;
  color: #8b948e;
  text-align: center;
}

.message {
  max-width: min(78%, 700px);
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.message.user {
  margin-left: auto;
  border-color: #b8d9cc;
  background: #edf8f3;
}

.message-speaker {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.message p {
  margin: 0;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.system-message {
  margin: 12px auto;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .topbar {
    height: 74px;
    padding: 0 18px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .eyebrow {
    display: none;
  }

  .test-layout {
    display: block;
    min-height: calc(100vh - 74px);
  }

  .control-panel {
    padding: 20px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .control-field {
    margin-top: 15px;
  }

  .session-meta {
    display: none;
  }

  .actions {
    margin-top: 18px;
  }

  .conversation {
    padding: 22px 16px;
  }

  .messages {
    height: auto;
    min-height: 360px;
    max-height: 60vh;
  }

  .message {
    max-width: 90%;
  }

  .login-panel {
    margin-top: 36px;
    padding: 22px;
  }
}

.persona-panel {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9f8;
}

.persona-panel strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
}

.persona-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.persona-panel .persona-tip {
  color: var(--green);
}
