:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #eef2f5;
  color: #17212b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f9fb 0%, #e5ebf0 100%);
}

button,
input {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  width: min(1180px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.workspace,
.side {
  background: #ffffff;
  border: 1px solid #d7dee6;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(30, 48, 68, 0.08);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #e3e8ee;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.tts-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: 180px;
  padding: 3px;
  border: 1px solid #cbd5df;
  border-radius: 8px;
  background: #f8fafc;
}

.tts-option {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #607080;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.tts-option.active {
  background: #17212b;
  color: #fff;
}

.tts-metric {
  min-width: 86px;
  color: #607080;
  font-size: 12px;
  text-align: right;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.3;
}

h2 {
  font-size: 16px;
  margin-top: 18px;
}

h2:first-child {
  margin-top: 0;
}

#status {
  margin-top: 6px;
  color: #607080;
  font-size: 13px;
}

.conversation {
  overflow: auto;
  padding: 18px 20px;
}

.message {
  max-width: 78%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user {
  margin-left: auto;
  background: #1f6feb;
  color: #fff;
}

.message.assistant {
  margin-right: auto;
  background: #f1f4f8;
  color: #17212b;
}

.composer {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 84px;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #e3e8ee;
}

.record,
.send,
.icon-text {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.record {
  display: grid;
  place-items: center;
  width: 48px;
  height: 44px;
  background: #17212b;
}

#recordDot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f04438;
}

.record.active {
  background: #f04438;
}

.record.active #recordDot {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #fff;
}

input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid #cbd5df;
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: #1f6feb;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.14);
}

.send,
.icon-text {
  background: #0f766e;
  color: #fff;
  font-weight: 600;
}

.icon-text {
  min-height: 36px;
  padding: 0 12px;
  background: #334155;
}

.side {
  padding: 18px;
  overflow: auto;
}

.assistant-visual {
  margin-bottom: 18px;
}

.assistant-viewport {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 30%, #ffffff 0%, #edf5f8 54%, #dfe8ee 100%);
}

.assistant-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.assistant-fallback {
  position: absolute;
  inset: auto 12px 12px;
  padding: 7px 9px;
  border: 1px solid #dbe2ea;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  color: #607080;
  font-size: 12px;
  text-align: center;
}

.assistant-viewport[data-state="ready"] .assistant-fallback {
  display: none;
}

.assistant-viewport[data-state="error"] .assistant-fallback {
  color: #b42318;
}

.assistant-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.assistant-meta h2 {
  margin-top: 0;
}

.assistant-meta p {
  color: #0f766e;
  font-size: 13px;
  font-weight: 600;
}

.assistant-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.assistant-actions button {
  min-width: 0;
  min-height: 32px;
  border: 1px solid #cbd5df;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.assistant-actions button.active {
  border-color: #0f766e;
  background: #e6f5f2;
  color: #0f766e;
}

.sources {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.alarm-info {
  min-height: 80px;
  margin: 12px 0 0;
  padding: 10px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.source {
  padding: 10px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.45;
}

.empty {
  color: #6b7785;
  font-size: 13px;
}

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

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    width: min(100vw - 20px, 720px);
    margin: 10px auto;
  }

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

  .top-actions {
    width: 142px;
  }

  .tts-switch {
    width: 142px;
  }

  .tts-option {
    font-size: 12px;
  }

  .tts-metric {
    width: 100%;
    min-width: 0;
  }

  .side {
    min-height: 150px;
  }

  .assistant-viewport {
    height: 210px;
  }

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