:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  color: #1f2933;
  background: #edf3f8;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="text"],
input[type="file"] {
  min-height: 34px;
  border: 1px solid #cbd7e2;
  border-radius: 5px;
  background: #fff;
}

button {
  padding: 0 12px;
  color: #263746;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #3284d6;
  color: #1768b0;
}

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

input[type="text"],
select {
  width: 100%;
  padding: 0 10px;
  color: #1f2933;
}

input[type="file"] {
  width: 100%;
  padding: 5px 7px;
  color: #536574;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  padding: 0 16px;
  border-bottom: 1px solid #d5e0ea;
  background: #fff;
}

.brand-block,
.topbar-status,
.inline-control,
.button-row,
.progress-line,
.panel-title,
.event-toolbar,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  min-width: 0;
  gap: 12px;
}

.brand-block strong {
  color: #172635;
  font-size: 16px;
}

.endpoint {
  max-width: 360px;
  color: #647482;
  font-family: Consolas, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-status {
  gap: 8px;
}

.status-badge {
  padding: 4px 8px;
  border: 1px solid;
  border-radius: 4px;
  font-size: 12px;
}

.status-off {
  color: #9b3f3f;
  border-color: #e6bcbc;
  background: #fff4f4;
}

.status-on {
  color: #176b4d;
  border-color: #a9d8c7;
  background: #eef9f4;
}

.status-muted {
  color: #687987;
  border-color: #d8e0e7;
  background: #f5f7f9;
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(360px, 0.95fr) minmax(330px, 0.8fr);
  gap: 10px;
  min-height: 0;
  flex: 1;
  padding: 10px;
}

.control-panel,
.conversation-panel,
.diagnostics-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid #d5e0ea;
  border-radius: 6px;
  background: #fff;
}

.control-panel {
  padding: 0 14px 14px;
  overflow-y: auto;
}

.conversation-panel,
.diagnostics-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-title {
  justify-content: space-between;
  min-height: 44px;
  color: #172635;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid #e7edf2;
}

.control-panel > .panel-title {
  position: sticky;
  z-index: 2;
  top: 0;
  margin-bottom: 12px;
  background: #fff;
}

.conversation-panel > .panel-title,
.diagnostics-panel > .panel-title {
  padding: 0 14px;
}

.panel-meta {
  color: #758592;
  font-size: 12px;
  font-weight: 400;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 11px;
}

.field label,
.section-label {
  color: #5e6f7c;
  font-size: 12px;
}

.control-section {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid #e8eef3;
}

.control-section > .section-label {
  margin-bottom: 9px;
  color: #334756;
  font-weight: 600;
}

.inline-control {
  gap: 7px;
}

.inline-control select {
  min-width: 0;
  flex: 1;
}

.button-row {
  gap: 8px;
}

.button-row button {
  min-width: 0;
  flex: 1;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.primary-button {
  color: #fff;
  border-color: #287bc1;
  background: #287bc1;
}

.primary-button:hover:not(:disabled) {
  color: #fff;
  border-color: #1768b0;
  background: #1768b0;
}

.danger-button {
  color: #a73535;
  border-color: #d9aaaa;
  background: #fff7f7;
}

.icon-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #526572;
  font-size: 12px;
}

.checkbox-row input {
  width: 15px;
  height: 15px;
  accent-color: #287bc1;
}

.file-summary,
.current-file {
  margin-top: 8px;
  color: #71818e;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.progress-track {
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 3px;
  background: #e8eef3;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #2d8b67;
  transition: width 160ms ease;
}

.progress-line {
  justify-content: space-between;
  margin-top: 6px;
  color: #637582;
  font-size: 12px;
}

.connection-actions {
  margin-top: 13px;
}

.conversation-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  background: #f8fafc;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: #93a1ad;
  font-size: 13px;
  text-align: center;
}

.bubble-row {
  display: flex;
}

.bubble-row.patient {
  justify-content: flex-end;
}

.bubble {
  max-width: 82%;
  min-width: 160px;
  padding: 9px 11px;
  border: 1px solid #dfe7ee;
  border-radius: 6px;
  background: #fff;
}

.bubble-row.patient .bubble {
  border-color: #b8dbc6;
  background: #e7f7ed;
}

.bubble.partial {
  color: #526572;
  border-color: #cbdbe8;
  background: #f0f6fb;
}

.bubble-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  color: #71818e;
  font-size: 11px;
}

.bubble-text {
  color: #253642;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.voiceprint-info {
  margin-top: 5px;
  color: #28795c;
  font-size: 11px;
}

.tab-buttons {
  display: flex;
  gap: 2px;
}

.tab-button {
  min-height: 28px;
  border-color: transparent;
  background: transparent;
  font-size: 12px;
}

.tab-button.active {
  color: #1768b0;
  border-color: #b9d4eb;
  background: #eef6fc;
}

.tab-content {
  display: none;
  min-height: 0;
  flex: 1;
  overflow: auto;
}

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

.metrics-list {
  margin: 0;
  padding: 4px 14px;
}

.metrics-list div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px dashed #e2e9ef;
}

.metrics-list dt {
  color: #657785;
  font-size: 12px;
}

.metrics-list dd {
  margin: 0;
  color: #273844;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 12px;
  text-align: right;
  word-break: break-all;
}

.result-summary {
  padding: 10px 14px 14px;
}

.result-summary pre {
  min-height: 130px;
  margin: 8px 0 0;
  padding: 10px;
  overflow: auto;
  color: #2c3e49;
  border: 1px solid #dce5ec;
  border-radius: 5px;
  background: #f7f9fb;
  font: 12px/1.6 Consolas, "Microsoft YaHei UI", monospace;
  white-space: pre-wrap;
}

.event-toolbar {
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #e7edf2;
}

.event-log {
  min-height: 0;
  padding: 10px 12px 18px;
  color: #2f414d;
  font: 11px/1.6 Consolas, monospace;
}

.event-item {
  padding: 6px 0;
  border-bottom: 1px dashed #e4eaf0;
  word-break: break-word;
}

.event-item.error {
  color: #9f3434;
}

.event-time {
  margin-right: 7px;
  color: #82909b;
}

dialog {
  width: min(520px, calc(100vw - 30px));
  padding: 0;
  border: 1px solid #cbd7e2;
  border-radius: 7px;
  box-shadow: 0 16px 44px rgb(41 57 70 / 22%);
}

dialog::backdrop {
  background: rgb(29 43 54 / 35%);
}

.dialog-content {
  padding: 18px;
}

.dialog-title {
  margin-bottom: 16px;
  color: #172635;
  font-size: 16px;
  font-weight: 600;
}

.reading-prompt {
  margin: 12px 0;
  padding: 11px 12px;
  border: 1px solid #d9e5ee;
  border-radius: 5px;
  background: #f3f8fc;
}

.reading-prompt span {
  color: #5d7080;
  font-size: 12px;
}

.reading-prompt p {
  margin: 7px 0 0;
  color: #273b48;
  font-size: 14px;
  line-height: 1.7;
}

.dialog-status {
  min-height: 24px;
  color: #5e7180;
  font-size: 12px;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.toast-region {
  position: fixed;
  z-index: 30;
  top: 60px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(340px, calc(100vw - 32px));
}

.toast {
  padding: 10px 12px;
  color: #2b3d49;
  border: 1px solid #cdd9e2;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 8px 24px rgb(42 58 70 / 14%);
  font-size: 13px;
  line-height: 1.5;
}

.toast.error {
  color: #8f3030;
  border-color: #e0b2b2;
  background: #fff7f7;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100%;
  }

  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .diagnostics-panel {
    grid-column: 1 / -1;
    min-height: 420px;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

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

  .workspace {
    display: flex;
    flex-direction: column;
    padding: 8px;
  }

  .control-panel,
  .conversation-panel,
  .diagnostics-panel {
    min-height: 520px;
  }

  .control-panel {
    min-height: auto;
  }
}
