:root {
  color-scheme: light;
  --ink: #211f1b;
  --muted: #6f7477;
  --line: rgba(36, 35, 32, 0.14);
  --paper: #fffdf8;
  --mist: #eef4f5;
  --green: #2f7d59;
  --green-deep: #216142;
  --coral: #c85f4b;
  --gold: #bf8e2f;
  --blue: #365f91;
  --violet: #6e5aa8;
  --panel: rgba(255, 253, 248, 0.9);
  --soft: rgba(238, 244, 245, 0.82);
  --shadow: 0 20px 55px rgba(33, 31, 27, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    linear-gradient(135deg, rgba(238, 244, 245, 0.94), rgba(255, 251, 242, 0.94)),
    repeating-linear-gradient(90deg, rgba(47, 125, 89, 0.06) 0 1px, transparent 1px 32px);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--green);
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

button.secondary {
  background: var(--blue);
}

button.accent {
  background: var(--coral);
}

button.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(520px, auto) auto;
  gap: 14px;
}

.topbar,
.flow-panel,
.video-panel,
.omni-panel,
.vlm-panel,
.pet-dock {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  min-width: 0;
  padding: 14px 16px;
  border-radius: 12px;
}

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

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

h1 {
  font-size: clamp(22px, 2vw, 30px);
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

.runtime-tools {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
  flex-wrap: wrap;
}

.runtime,
.status-pill,
.voice-meta,
#conversationCount,
#traceCount {
  color: var(--muted);
  font-size: 13px;
}

.model-select {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.model-select select {
  max-width: min(42vw, 290px);
  height: 34px;
  border: 1px solid rgba(54, 95, 145, 0.22);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.flow-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
}

.flow-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.52);
}

.flow-step p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.step-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: #9ca3a6;
  font-weight: 900;
}

.flow-step.active {
  border-color: rgba(47, 125, 89, 0.42);
  background: rgba(240, 250, 244, 0.86);
}

.flow-step.active .step-index {
  background: var(--green);
}

.flow-step.done {
  border-color: rgba(54, 95, 145, 0.32);
  background: rgba(239, 246, 255, 0.76);
}

.flow-step.done .step-index {
  background: var(--blue);
}

.stage-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(440px, 1.05fr) minmax(350px, 0.95fr);
  gap: 14px;
  align-items: stretch;
}

.video-panel,
.omni-panel,
.vlm-panel {
  min-width: 0;
  border-radius: 14px;
  padding: 14px;
}

.video-panel,
.omni-panel {
  display: grid;
  min-height: 0;
}

.video-panel {
  grid-template-rows: auto auto minmax(320px, 1fr) auto auto;
  gap: 12px;
}

.omni-panel {
  grid-template-rows: auto auto minmax(260px, 1fr) auto;
  gap: 12px;
  max-height: min(760px, calc(100vh - 190px));
  overflow: hidden;
}

.conversation-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.mini-button {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  white-space: nowrap;
}

.upload-drop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 86px;
  padding: 14px;
  border: 1px dashed rgba(47, 125, 89, 0.42);
  border-radius: 12px;
  background: rgba(240, 250, 244, 0.62);
}

.upload-drop.dragging {
  border-color: var(--green);
  background: rgba(226, 246, 234, 0.88);
}

.upload-drop input {
  display: none;
}

.upload-drop p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.player-shell {
  position: relative;
  min-width: 0;
  min-height: 320px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(34, 31, 28, 0.18);
  background: #11161b;
}

.player-shell video {
  width: 100%;
  height: 100%;
  min-height: 320px;
  display: block;
  object-fit: contain;
  background: #11161b;
}

.player-shell canvas {
  display: none;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  background: linear-gradient(135deg, rgba(17, 22, 27, 0.92), rgba(32, 39, 44, 0.82));
}

.control-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.frame-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(116px, 136px);
  gap: 8px;
  min-height: 86px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.frame-thumb {
  display: grid;
  gap: 6px;
  padding: 6px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.frame-thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #172029;
}

.frame-thumb span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-meter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.live-meter > div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.56);
}

.live-meter span {
  color: var(--muted);
  font-size: 12px;
}

.live-meter strong {
  font-size: 24px;
}

.conversation-list {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.52);
}

.message {
  display: grid;
  gap: 5px;
  max-width: 92%;
}

.message.user {
  align-self: end;
}

.message.assistant {
  align-self: start;
}

.message-meta {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.message.user .message-meta {
  justify-content: end;
}

.message-bubble {
  min-width: 0;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.48;
  word-break: break-word;
  background: rgba(238, 244, 245, 0.9);
}

.message.user .message-bubble {
  color: #fff;
  background: var(--blue);
}

.message.assistant .message-bubble {
  color: var(--ink);
  background: rgba(245, 240, 255, 0.9);
  border: 1px solid rgba(110, 90, 168, 0.18);
}

.message.audio .message-bubble {
  display: grid;
  gap: 6px;
}

.message-bubble.has-audio {
  display: grid;
  gap: 8px;
}

.message audio {
  width: min(260px, 100%);
}

.composer-strip {
  display: grid;
  gap: 8px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px;
  gap: 8px;
}

.composer input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.82);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.mic-button {
  background: var(--gold);
}

.mic-button.recording {
  background: var(--coral);
}

.send-button {
  background: var(--green);
}

.vlm-panel {
  min-height: 320px;
}

.vlm-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(300px, 1.15fr);
  gap: 12px;
  margin-top: 12px;
}

.vlm-summary,
.timeline-list,
.json-panel,
.trace-list {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
}

.vlm-summary {
  display: flex;
  align-content: start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
}

.summary-chip {
  display: grid;
  gap: 3px;
  min-width: 118px;
  padding: 9px 10px;
  border: 1px solid rgba(47, 125, 89, 0.18);
  border-radius: 9px;
  background: rgba(240, 250, 244, 0.62);
}

.summary-chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.summary-chip strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.vlm-context {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.timeline-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow-y: auto;
  padding: 10px;
}

.timeline-event {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.68);
}

.timeline-event.fired {
  border-color: rgba(47, 125, 89, 0.34);
  background: rgba(240, 250, 244, 0.88);
}

.event-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.event-meta strong {
  color: var(--ink);
}

.priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 22px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.priority.p0,
.priority.p1 {
  background: var(--coral);
}

.priority.p2 {
  background: var(--blue);
}

.priority.p3 {
  background: var(--muted);
}

.timeline-event p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.json-panel,
.trace-list {
  grid-column: 1 / -1;
  padding: 10px;
}

.json-panel summary,
.trace-item summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

pre {
  max-height: 300px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 8px;
  color: #e9eef1;
  background: #172029;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.trace-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.trace-item {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.56);
}

.empty {
  display: grid;
  place-items: center;
  min-height: 62px;
  padding: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.pet-dock {
  position: sticky;
  top: 18px;
  align-self: start;
  display: grid;
  gap: 10px;
  min-width: 0;
  width: 100%;
  border-radius: 16px;
  padding: 12px;
  z-index: 8;
}

.pet-dock.floating {
  max-width: calc(100vw - 20px);
}

.pet-dock.dragging {
  user-select: none;
  cursor: grabbing;
}

.drag-handle {
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(2, 18px);
  gap: 6px;
  padding: 6px 10px;
  cursor: grab;
}

.drag-handle span {
  height: 4px;
  border-radius: 999px;
  background: rgba(33, 31, 27, 0.24);
}

.pet-status {
  justify-self: center;
  min-height: 26px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  font-weight: 800;
}

.speech-bubble {
  position: relative;
  min-height: 78px;
  padding: 12px;
  border: 1px solid rgba(110, 90, 168, 0.18);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(245, 240, 255, 0.92);
  line-height: 1.48;
  word-break: break-word;
}

.pet-portrait {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(238, 244, 245, 0.72);
}

.pet-portrait img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
}

.pet-dock.thinking .pet-portrait {
  border: 1px solid rgba(191, 142, 47, 0.38);
}

.pet-dock.alert .speech-bubble {
  border-color: rgba(200, 95, 75, 0.34);
  background: rgba(255, 241, 238, 0.95);
}

.pet-dock.happy .speech-bubble {
  border-color: rgba(47, 125, 89, 0.28);
  background: rgba(240, 250, 244, 0.95);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .pet-dock {
    position: relative;
    top: 0;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: center;
  }

  .drag-handle,
  .pet-status {
    display: none;
  }

  .pet-portrait {
    grid-row: 1 / span 2;
    aspect-ratio: 1 / 1;
    min-height: 0;
  }
}

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

  .topbar,
  .section-head,
  .upload-drop {
    align-items: start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .flow-panel,
  .stage-grid,
  .vlm-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace {
    grid-template-rows: auto;
  }

  .player-shell video {
    min-height: 240px;
  }

  .json-panel,
  .trace-list {
    grid-column: auto;
  }

  .pet-dock {
    grid-template-columns: 100px minmax(0, 1fr);
  }
}
