:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0e8;
  --soft-line: #edf1f5;
  --accent: #167a62;
  --accent-strong: #0f624f;
  --blue: #2d6cdf;
  --danger: #bd3f32;
  --warning: #996311;
  --shadow: 0 12px 30px rgba(19, 31, 49, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(245, 247, 250, 0.94), rgba(245, 247, 250, 1)),
    url("/support-floor.svg");
  background-size:
    auto,
    cover;
  background-position: center;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease,
    transform 120ms ease;
}

button:hover:not(:disabled) {
  border-color: #9aaabd;
  background: #f8fafc;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
  background: #f2f4f7;
}

button.primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

button.primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

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

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.12);
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  margin-bottom: 18px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.18;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #98a2b3;
}

.status-pill[data-state="connected"] .status-dot {
  background: var(--accent);
}

.status-pill[data-state="working"] .status-dot {
  background: var(--warning);
}

.status-pill[data-state="error"] .status-dot {
  background: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  gap: 18px;
  min-height: calc(100vh - 116px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.side-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section {
  padding: 18px;
  border-bottom: 1px solid var(--soft-line);
}

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

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

#signalCanvas {
  width: 100%;
  height: 86px;
  margin: 16px 0 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #101828;
}

.call-stats {
  display: grid;
  gap: 8px;
  margin: 0;
}

.call-stats div,
.applicant-record div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  border-bottom: 1px solid var(--soft-line);
}

.call-stats div:last-child,
.applicant-record div:last-child {
  border-bottom: 0;
}

dt,
.label {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.cost-amount {
  display: grid;
  gap: 3px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #c8d8ff;
  border-radius: 8px;
  background: #f4f7ff;
}

.cost-amount span {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.cost-amount small,
.cost-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.cost-stats dd {
  font-variant-numeric: tabular-nums;
}

.cost-note {
  margin: 10px 0 0;
}

.applicant-record {
  margin-top: 10px;
}

.quick-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.quick-list button {
  justify-content: start;
  padding: 0 12px;
  text-align: left;
}

.transcript-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--soft-line);
}

.panel-header button {
  width: 72px;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 420px;
  padding: 18px;
  overflow-y: auto;
}

.message {
  width: min(78%, 720px);
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message .speaker {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.message.user {
  align-self: flex-end;
  background: #e8f0ff;
  border: 1px solid #c8d8ff;
}

.message.assistant {
  align-self: flex-start;
  background: #eef8f4;
  border: 1px solid #cdece0;
}

.message.system,
.message.tool {
  align-self: center;
  width: min(92%, 780px);
  color: #475467;
  background: #f8fafc;
  border: 1px dashed #cfd7e2;
  font-size: 13px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  padding: 18px;
  border-top: 1px solid var(--soft-line);
}

.kb-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
  margin-top: 12px;
}

.source-list,
.tool-log {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  max-height: 360px;
  overflow-y: auto;
}

.source-item,
.tool-item {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfe;
}

.source-item strong,
.tool-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.source-item p,
.tool-item p {
  margin: 0;
  color: #475467;
  font-size: 13px;
  line-height: 1.5;
}

.source-meta {
  display: inline-block;
  margin-top: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  border: 1px dashed #cfd7e2;
  border-radius: 8px;
  background: #fbfcfe;
  text-align: center;
}

.empty-state.compact {
  min-height: 74px;
  padding: 12px;
  font-size: 13px;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .workspace > .side-panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .message {
    width: 100%;
  }

  .composer,
  .kb-search {
    grid-template-columns: 1fr;
  }
}
