:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-strong: #eef3f8;
  --text: #17202f;
  --muted: #5f6f83;
  --line: #d8e0ea;
  --accent: #177f70;
  --accent-strong: #0f665a;
  --warn: #9a5a12;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 32px;
  border-right: 1px solid var(--line);
  background: #eef4f8;
}

h1 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.1;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  background: var(--panel);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.video-builder {
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.voice-builder {
  border-bottom: 1px solid var(--line);
  background: #fbf8f2;
}

.mindmap-builder {
  border-bottom: 1px solid var(--line);
  background: #f6fbf8;
}

.gamify-builder {
  border-bottom: 1px solid var(--line);
  background: #f8faf4;
}

.floorplan-builder {
  border-bottom: 1px solid var(--line);
  background: #f4f8fb;
}

.speech-builder {
  border-bottom: 1px solid var(--line);
  background: #f7f8fd;
}

.animation-builder {
  border-bottom: 1px solid var(--line);
  background: #fbf7fb;
}

.math-animation-builder {
  border-bottom: 1px solid var(--line);
  background: #f5f9fc;
}

.sprite-animation-builder {
  border-bottom: 1px solid var(--line);
  background: #f8f7fb;
}

.hunyuan3d-builder {
  border-bottom: 1px solid var(--line);
  background: #f4faf8;
}

.image-manipulation-builder {
  border-bottom: 1px solid var(--line);
  background: #f8fbf8;
}

.image-generation-builder {
  border-bottom: 1px solid var(--line);
  background: #f7fbfd;
}

.vision-builder {
  border-bottom: 1px solid var(--line);
  background: #fbfaf4;
}

.segmentation-builder {
  border-bottom: 1px solid var(--line);
  background: #f3faf7;
}

.embedding-builder {
  border-bottom: 1px solid var(--line);
  background: #f8f9fc;
}

.rag-builder {
  border-bottom: 1px solid var(--line);
  background: #f6f8fb;
}

.ai-workflow-builder {
  border-bottom: 1px solid var(--line);
  background: #f5fafc;
}

.video-builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
}

.video-builder h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.mindmap-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: auto;
  max-height: 520px;
}

.gamify-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.gamify-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.gamify-frame {
  display: block;
  width: 100%;
  height: 680px;
  border: 0;
}

.floorplan-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.floorplan-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.floorplan-frame {
  display: block;
  width: 100%;
  height: 720px;
  border: 0;
}

.hunyuan3d-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.hunyuan3d-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.ai-workflow-board {
  display: grid;
  grid-auto-columns: minmax(180px, 220px);
  grid-auto-flow: column;
  align-items: stretch;
  gap: 28px;
  min-height: 170px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow-x: auto;
}

.ai-workflow-node {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 138px;
  padding: 14px;
  border: 1px solid #cfd9e5;
  border-radius: 8px;
  background: #f9fbfd;
}

.ai-workflow-node strong {
  font-size: 15px;
}

.ai-workflow-node p {
  font-size: 13px;
  line-height: 1.35;
}

.ai-workflow-node-type {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8f4f1;
  color: #0f665a;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.ai-workflow-arrow {
  position: absolute;
  right: -22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 800;
}

.ai-workflow-workspace {
  display: grid;
  grid-template-columns: 150px minmax(620px, 1fr) 220px;
  gap: 12px;
  align-items: stretch;
  margin-top: 12px;
}

.ai-workflow-palette,
.ai-workflow-inspector {
  min-height: 680px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.ai-workflow-palette {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-workflow-component {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 54px;
  padding: 9px;
  border: 1px solid #cfd9e5;
  border-radius: 8px;
  background: #f8fbfd;
  color: var(--text);
  cursor: pointer;
}

.ai-workflow-component span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-workflow-canvas-wrap {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(#eef3f8 1px, transparent 1px),
    linear-gradient(90deg, #eef3f8 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
  overflow: auto;
}

.ai-workflow-canvas {
  position: relative;
  min-width: 1200px;
  min-height: 680px;
}

.ai-workflow-canvas-node {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  width: 154px;
  min-height: 84px;
  padding: 9px;
  border: 1px solid #c7d4e3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  box-shadow: 0 10px 24px rgba(20, 31, 48, 0.08);
  cursor: grab;
  touch-action: none;
}

.ai-workflow-canvas-node:active {
  cursor: grabbing;
}

.ai-workflow-canvas-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 127, 112, 0.16), 0 10px 24px rgba(20, 31, 48, 0.08);
}

.ai-workflow-canvas-node span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-workflow-canvas-node strong {
  font-size: 13px;
}

.ai-workflow-canvas-node small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.ai-workflow-edge {
  position: absolute;
  z-index: 1;
  height: 2px;
  background: #9fb3c8;
  transform-origin: left center;
}

.ai-workflow-edge::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -4px;
  border-left: 8px solid #9fb3c8;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.ai-workflow-inspector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-workflow-inspector label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ai-workflow-inspector textarea {
  width: 100%;
  resize: vertical;
}

.ai-workflow-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ai-workflow-danger {
  border-color: #d6a1a1;
  color: #8b1f1f;
  background: #fff6f6;
}

.ai-workflow-validation {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #d8c68c;
  border-radius: 8px;
  background: #fffaf0;
  color: #6f4a00;
  line-height: 1.45;
}

.ai-workflow-validation.blocked {
  border-color: #d7a4a4;
  background: #fff6f6;
  color: #842323;
}

.ai-workflow-run-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ai-workflow-run-steps span {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .ai-workflow-workspace {
    grid-template-columns: 1fr;
  }

  .ai-workflow-palette,
  .ai-workflow-inspector {
    min-height: auto;
  }

  .ai-workflow-palette {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

.hunyuan3d-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.hunyuan3d-actions a,
.hunyuan3d-toolbar a {
  color: var(--accent);
  font-weight: 700;
}

.hunyuan3d-model-viewer {
  display: block;
  width: 100%;
  height: min(62vh, 620px);
  min-height: 420px;
  background:
    linear-gradient(135deg, rgba(23, 127, 112, 0.08), rgba(62, 83, 137, 0.08)),
    radial-gradient(circle at center, #ffffff 0, #f6faf9 58%, #edf4f2 100%);
}

.hunyuan3d-three-viewer {
  display: grid;
  place-items: center;
  width: 100%;
  height: min(62vh, 620px);
  min-height: 420px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(23, 127, 112, 0.08), rgba(62, 83, 137, 0.08)),
    radial-gradient(circle at center, #ffffff 0, #f6faf9 58%, #edf4f2 100%);
}

.hunyuan3d-three-viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.hunyuan3d-three-viewer canvas:active {
  cursor: grabbing;
}

.hunyuan3d-fallback {
  padding: 28px;
  color: var(--text);
  line-height: 1.5;
}

.mindmap-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.mindmap-toolbar button {
  min-width: 40px;
  margin: 0;
}

.mindmap-canvas {
  min-height: 520px;
  min-width: 900px;
}

.mindmap-svg {
  display: block;
  min-width: 100%;
  min-height: 520px;
  cursor: grab;
}

.mindmap-link {
  fill: none;
  stroke: #9aa9b8;
  stroke-width: 2;
}

.mindmap-svg-node rect {
  fill: #ffffff;
  stroke: rgba(23, 127, 112, 0.45);
  stroke-width: 2;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.22));
}

.mindmap-svg-node.depth-0 rect {
  fill: #dff3ee;
  stroke: var(--accent);
}

.mindmap-svg-node.depth-1 rect {
  fill: #e8f0ff;
  stroke: #6f96d8;
}

.mindmap-svg-label {
  width: 220px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  outline: none;
}

.video-builder p {
  font-size: 13px;
}

.video-form {
  display: grid;
  gap: 12px;
  padding: 0 28px 18px;
}

.video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
}

.image-manipulation-grid {
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1.3fr);
}

.video-audio-options {
  display: grid;
  grid-template-columns: auto auto minmax(160px, 1fr);
  gap: 12px;
  align-items: end;
}

.video-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.video-form input[type="text"],
.video-form input[type="number"],
.video-form input[type="file"],
.video-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.video-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.consent-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 10px;
}

.consent-row input {
  width: 16px;
  height: 16px;
}

.voice-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.voice-tools {
  display: grid;
  gap: 8px;
  align-content: start;
}

.voice-tools button {
  min-width: 78px;
  min-height: 42px;
  padding: 0 12px;
}

.hidden {
  display: none;
}

.messages {
  overflow-y: auto;
  padding: 28px;
}

.message {
  display: flex;
  margin-bottom: 18px;
}

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

.bubble {
  width: min(760px, 100%);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  line-height: 1.55;
  white-space: pre-wrap;
}

.user .bubble {
  border-color: rgba(23, 127, 112, 0.45);
  background: #e2f4ef;
}

.meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.generated-image {
  display: block;
  width: min(100%, 640px);
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

audio {
  display: block;
  width: min(100%, 640px);
  margin-top: 14px;
}

.generated-video {
  display: block;
  width: min(100%, 720px);
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.media-preview {
  margin-top: 12px;
}

.code-output {
  width: min(100%, 900px);
  max-height: 520px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151f;
  color: #edf3ff;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.55;
}

.result-link {
  display: inline-block;
  margin: 10px 10px 0 0;
  color: var(--accent);
  font-weight: 700;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 20px 28px 28px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

textarea {
  resize: vertical;
  min-height: 72px;
  max-height: 220px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}

textarea:focus {
  outline: 2px solid rgba(80, 200, 168, 0.35);
  border-color: var(--accent);
}

button {
  align-self: end;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

code {
  color: var(--accent-strong);
}

.admin-shell {
  display: grid;
  gap: 24px;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

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

.admin-header h1 {
  margin-bottom: 8px;
}

.admin-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.admin-card {
  display: grid;
  gap: 10px;
  min-height: 124px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-card strong {
  font-size: 30px;
  line-height: 1;
}

.admin-card.wide {
  grid-column: span 1;
}

.hardware-cards .admin-card {
  min-height: 112px;
}

.hardware-cards p {
  margin: 0;
  color: var(--text);
  line-height: 1.4;
}

.admin-section {
  display: grid;
  gap: 12px;
}

.admin-section h2 {
  margin: 0;
  font-size: 18px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-actions button {
  align-self: auto;
  min-height: 38px;
  padding: 0 14px;
}

.admin-actions span,
#hf-version-summary,
#memory-summary {
  color: var(--muted);
  font-size: 14px;
}

.fit-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.fit-good {
  background: rgba(33, 145, 101, 0.14);
  color: #146c4a;
}

.fit-remote {
  background: rgba(50, 105, 190, 0.14);
  color: #214f91;
}

.fit-warn {
  background: rgba(189, 126, 35, 0.16);
  color: #8a5a12;
}

.fit-bad {
  background: rgba(185, 59, 59, 0.14);
  color: #8e2f2f;
}

.fit-neutral {
  background: rgba(88, 96, 110, 0.14);
  color: #4d5562;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

td a {
  color: var(--accent-strong);
}

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

  .sidebar {
    padding: 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .video-audio-options {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .admin-shell {
    width: min(100% - 28px, 1180px);
    padding-top: 20px;
  }

  .admin-header,
  .admin-cards {
    grid-template-columns: 1fr;
  }

  .admin-header {
    display: grid;
  }
}
