:root {
  --page: #e8e8e8;
  --surface: #f7f7f7;
  --panel: #ffffff;
  --soft: #f1f1f1;
  --text: #161616;
  --muted: #747474;
  --line: #e2e2e2;
  --line-strong: #d0d0d0;
  --black: #1b1b1b;
  --good: #167548;
  --warn: #9d6a12;
  --bad: #b73535;
  --blue: #1769e0;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.app {
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
}

.view {
  width: 100%;
}

.hidden {
  display: none !important;
}

.intro-view,
.done-view,
.rating-view {
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 18px;
  padding: 28px;
}

.intro-view {
  max-width: 900px;
  margin: 0 auto;
  background: var(--surface);
}

.interview-view {
  display: grid;
  grid-template-columns: 320px minmax(520px, 1fr) 380px;
  min-height: 100vh;
}

.sidebar,
.inspector {
  min-width: 0;
  background: #f4f4f4;
  padding: 22px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--line);
}

.inspector {
  display: grid;
  align-content: start;
  gap: 14px;
  border-left: 1px solid var(--line);
}

.main {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(320px, 1fr);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  padding: 12px;
}

.intro-brand {
  width: min(100%, 360px);
}

.brand strong {
  display: block;
  font-size: 20px;
  line-height: 1.05;
}

.brand span:last-child {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--black);
  box-shadow: none;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.brand-mark::after {
  inset: 14px;
  background: #fff;
}

.panel,
.agent-card,
.answer-panel,
.manual-box,
.transcript-panel,
.recommendation-card,
.rating-form fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 1.2;
}

.intro-copy {
  display: grid;
  gap: 8px;
  max-width: 680px;
}

.intro-copy h1,
.done-view h1,
.rating-view h1 {
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.1;
}

.intro-copy p:not(.panel-kicker),
.done-view p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.start-form,
.rating-form {
  width: min(100%, 620px);
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.field span,
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 120px;
  resize: vertical;
  padding: 11px;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--black);
}

.toggle-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  color: #555;
  font-size: 14px;
  font-weight: 700;
}

.toggle-row input {
  width: 20px;
  height: 20px;
}

.primary,
.ghost,
.record-button,
.score-button {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
}

.primary {
  background: var(--black);
  color: #fff;
  font-weight: 800;
}

.start-form .primary,
.rating-form .primary {
  min-height: 52px;
}

.ghost,
.score-button {
  border: 1px solid var(--line-strong);
  background: #fff;
}

.wide {
  width: 100%;
  margin-top: 14px;
}

.button-row,
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row.end {
  justify-content: flex-end;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfb;
  padding: 0 24px;
}

.status-box,
.summary-box {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  color: #444;
  font-size: 13px;
  line-height: 1.45;
}

.status-box strong {
  font-size: 16px;
}

.round-list {
  display: grid;
  gap: 8px;
}

.round-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px 12px;
  color: #555;
  font-size: 13px;
  font-weight: 750;
}

.round-item.active {
  border-color: var(--black);
  background: #fff;
  color: var(--text);
}

.round-item.done {
  background: #e8f6ef;
  color: var(--good);
}

.state-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aaa;
}

.state-dot.running {
  background: var(--blue);
}

.state-dot.speaking {
  background: var(--good);
}

.state-dot.recording {
  background: #d73535;
}

.state-dot.error {
  background: var(--bad);
}

.agent-card {
  display: grid;
  gap: 12px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  box-shadow: none;
  background: #f7f7f7;
  padding: 22px 24px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#latestAgentText {
  margin: 0;
  color: #333;
  font-size: clamp(19px, 2.5vw, 28px);
  font-weight: 850;
  line-height: 1.45;
}

.answer-panel {
  display: grid;
  gap: 10px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  box-shadow: none;
  background: #fbfbfb;
  padding: 18px 24px;
}

.record-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(100%, 520px);
  min-height: 58px;
  border: 1px solid #222;
  background: #fff;
  font-size: 18px;
  font-weight: 850;
}

#recordDot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #999;
}

.record-button.recording #recordDot {
  background: #d73535;
  box-shadow: 0 0 0 8px rgba(215, 53, 53, 0.12);
}

.latest-asr {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.manual-box {
  margin: 18px 24px 0;
  box-shadow: none;
}

.manual-box summary {
  color: #444;
  font-size: 13px;
  font-weight: 800;
}

.transcript-panel {
  display: grid;
  min-height: 0;
  margin: 18px 24px 24px;
  padding: 0;
  overflow: hidden;
}

.transcript-panel h2 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.transcript {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  overflow: auto;
  padding: 18px;
}

.message {
  display: grid;
  max-width: 88%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 12px;
}

.message.agent {
  justify-self: start;
}

.message.user {
  justify-self: end;
  background: var(--soft);
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.message p {
  margin: 0;
  color: #333;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  padding: 12px;
}

.stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1;
}

.recommendation-card {
  width: min(100%, 860px);
}

.recommendation-card pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  color: #333;
  line-height: 1.65;
}

.rating-form fieldset {
  margin: 0;
}

.rating-form legend {
  padding: 0 8px;
  color: var(--text);
  font-weight: 850;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 10px;
}

.score-button {
  min-height: 52px;
  font-weight: 850;
}

.score-button.active {
  border-color: var(--black);
  background: var(--soft);
}

.done-view {
  text-align: left;
}

.done-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--black);
  color: #fff;
  font-size: 30px;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .interview-view {
    grid-template-columns: 280px minmax(420px, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .app,
  .intro-view,
  .interview-view,
  .rating-view,
  .done-view {
    min-height: 100svh;
  }

  .intro-view,
  .rating-view,
  .done-view {
    padding: 16px;
  }

  .interview-view {
    display: block;
  }

  .sidebar,
  .inspector {
    padding: 14px;
    border: 0;
  }

  .sidebar {
    gap: 10px;
  }

  .sidebar .panel:nth-of-type(3) {
    display: none;
  }

  .inspector {
    display: grid;
    gap: 10px;
  }

  .topbar {
    min-height: auto;
    padding: 16px;
  }

  .agent-card,
  .answer-panel {
    padding: 16px;
  }

  .manual-box,
  .transcript-panel {
    margin: 14px 16px;
  }

  .record-button {
    width: 100%;
    min-height: 72px;
  }

  .stats-grid,
  .score-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .message {
    max-width: 100%;
  }
}
