:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #f0f2f5;
  --text: #17202a;
  --muted: #627082;
  --line: #d8dee8;
  --accent: #0f7b6c;
  --accent-strong: #095c51;
  --warn: #b15d00;
  --danger: #b3261e;
  --shadow: 0 18px 42px rgba(25, 33, 44, 0.12);
}
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 260px minmax(360px, 1.05fr) minmax(380px, 0.95fr);
  gap: 24px;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.conversation-sidebar,
.vision-pane,
.conversation-pane {
  min-width: 0;
}

.conversation-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 48px);
}

.video-wrap {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  height: calc(100vh - 174px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15191f;
  box-shadow: var(--shadow);
}

video,
#heatmap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#heatmap {
  opacity: 0.48;
  mix-blend-mode: screen;
  pointer-events: none;
}

.video-state {
  position: absolute;
  left: 16px;
  top: 16px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(12, 16, 22, 0.72);
  color: #ffffff;
  font-size: 14px;
}

.control-bar,
.metrics,
.app-header,
.ask-form,
.graph-panel,
.sidebar-header {
  border: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
}

.conversation-list {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.conversation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
}

.conversation-select {
  min-width: 0;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.conversation-select:hover,
.conversation-select.active {
  border-color: var(--accent);
  background: #eef8f4;
}

.conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.conversation-meta {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.pin-button {
  width: 44px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.pin-button:hover,
.pin-button.active {
  border-color: var(--warn);
  background: #fff7e8;
  color: var(--warn);
}

.control-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
}

.mic-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mic-primary-button {
  min-height: 44px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 650;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
  font-size: 18px;
}

.mic-primary-button:hover {
  background: var(--accent-strong);
}

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

.mic-primary-button.active {
  box-shadow: 0 0 0 4px rgba(15, 123, 108, 0.2);
}

.mic-visualizer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 44px;
  padding: 8px 0;
}

.visualizer-bar {
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  transition: height 0.08s ease;
  min-height: 8px;
}

.mic-prompt {
  color: var(--muted);
  font-size: 14px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.mic-stop {
  background: var(--danger);
  color: white;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.16s ease;
}

.mic-stop:hover {
  background: #911d18;
}

.primary-button,
.icon-button,
.text-button {
  border: 0;
  border-radius: 6px;
  transition: background 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.primary-button {
  min-height: 44px;
  padding: 0 18px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 650;
}

.primary-button.compact {
  min-height: 36px;
  padding: 0 12px;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button {
  width: 44px;
  height: 44px;
  background: var(--surface-strong);
  color: var(--text);
}

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

.text-button {
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  color: var(--accent);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 14px;
  border-radius: 8px;
}

.metrics div {
  min-width: 0;
  padding: 14px;
  background: var(--surface);
}

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

.metrics strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.conversation-pane {
  display: grid;
  grid-template-rows: auto minmax(240px, 1fr) auto auto;
  gap: 14px;
  min-height: calc(100vh - 48px);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

.app-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 13px;
}

.status-pill.ready {
  background: #dff4ed;
  color: var(--accent-strong);
}

.status-pill.busy {
  background: #fff1d8;
  color: var(--warn);
}

.status-pill.error {
  background: #fde5e2;
  color: var(--danger);
}

.chat-log {
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.message.user {
  margin-left: auto;
  background: #dff4ed;
}

.message.assistant {
  background: var(--surface-strong);
}

.message.system,
.message.error {
  max-width: 100%;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line);
}

.message.error {
  color: var(--danger);
  border-color: #f1b5ae;
}

.message.thinking {
  color: var(--accent);
  font-weight: 600;
  animation: thinking-pulse 1s ease-in-out infinite;
}

@keyframes thinking-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.ask-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
}

textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  color: var(--text);
  background: #ffffff;
}

textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 123, 108, 0.15);
}

.graph-panel {
  padding: 14px;
  border-radius: 8px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

h2 {
  font-size: 17px;
}

.graph-list {
  display: grid;
  gap: 8px;
  max-height: 176px;
  overflow: auto;
}

.entity {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-strong);
  font-size: 14px;
  transition: background 0.15s ease;
}

.entity:hover {
  background: #e6eef1;
}

.entity-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.entity-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.entity strong {
  font-weight: 650;
  font-size: 15px;
  line-height: 1.2;
}

.entity-detail {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .conversation-sidebar {
    min-height: auto;
  }

  .conversation-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    max-height: 220px;
  }

  .video-wrap {
    min-height: 320px;
    height: 52vh;
  }

  .conversation-pane {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-header,
  .ask-form {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
  }

  .ask-form {
    display: grid;
  }
}
