:root {
  --bg: #080a0d;
  --panel: #101319;
  --panel-2: #151923;
  --line: #2a303b;
  --text: #eaf0f7;
  --muted: #8c96a6;
  --accent: #00f2a8;
  --danger: #ff4141;
  --button-size: 28px;
  --button-x: 0px;
  --button-y: 0px;
  --button-opacity: 1;
  --chat-image: none;
  --chat-opacity: 0.35;
  --chat-size: cover;
  --chat-x: 50%;
  --chat-y: 50%;
  --preview-scale: 3;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.workbench {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1.35fr) minmax(0, 0.65fr);
  gap: 10px;
  width: 100vw;
  min-height: 112vh;
  padding: 10px;
}

.quadrant {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.demo-quadrant {
  grid-column: 1 / -1;
  padding: 0;
}

.demo-shell {
  position: relative;
  display: grid;
  grid-template-columns: 150px minmax(0, 0.72fr) 260px minmax(120px, 0.28fr);
  grid-template-rows: 35px minmax(0, 1fr) 58px;
  width: 100%;
  height: 100%;
  background: #0d0f12;
  transform-origin: top left;
  transition: grid-template-columns 0.25s ease;
}

.demo-shell.wide-on {
  grid-template-columns: 150px minmax(0, 1fr) 260px 0;
}

.guide-svg {
  position: absolute;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}

.guide-svg line {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-opacity: 0.82;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
}

.guide-svg circle {
  fill: var(--accent);
  fill-opacity: 0.9;
  filter: drop-shadow(0 0 8px rgba(0, 242, 168, 0.75));
}

.guide-label {
  position: absolute;
  z-index: 31;
  padding: 4px 8px;
  border: 1px solid rgba(0, 242, 168, 0.55);
  border-radius: 999px;
  color: #06140f;
  background: var(--accent);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -125%);
  pointer-events: none;
  transition: opacity 0.7s ease;
}

.demo-shell.guide-visible .guide-svg,
.demo-shell.guide-visible .guide-label {
  opacity: 1;
}

.demo-topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 24px 58px 180px 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-bottom: 1px solid #191d24;
  background: #111418;
}

.menu-btn {
  display: grid;
  gap: 3px;
  width: 22px;
  border: 0;
  color: #fff;
  background: transparent;
}

.menu-btn span {
  height: 2px;
  background: currentColor;
}

.demo-logo {
  font-size: 18px;
  font-weight: 900;
}

.demo-topbar nav {
  display: flex;
  gap: 14px;
  font-weight: 800;
}

.demo-topbar nav a:first-child {
  color: var(--accent);
}

.demo-topbar input {
  width: 100%;
  height: 24px;
  padding: 0 12px;
  border: 1px solid #343a45;
  border-radius: 14px;
  color: var(--text);
  background: #0f1217;
}

.demo-sidebar {
  grid-column: 1;
  grid-row: 2 / 4;
  display: grid;
  align-content: start;
  gap: 11px;
  padding: 14px 10px;
  border-right: 1px solid #191d24;
  background: #101318;
  font-size: 12px;
  font-weight: 800;
}

.demo-sidebar a {
  color: #dce5ef;
}

.demo-player {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  min-width: 0;
  background: #000;
}

.screen {
  position: absolute;
  inset: 0 0 41px;
  background: #000;
}

.screen span {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--danger);
  font-weight: 900;
  font-size: 10px;
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 10px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), transparent);
}

.controls input[type="range"] {
  height: 12px;
  margin: 0;
  appearance: none;
  accent-color: var(--accent);
  background: transparent;
}

.controls input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
}

.controls input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border: 0;
  border-radius: 50%;
  appearance: none;
  background: var(--accent);
}

.controls input[type="range"].has-image::-webkit-slider-thumb {
  width: var(--demo-size, var(--button-size));
  height: var(--demo-size, var(--button-size));
  margin-top: calc((4px - var(--demo-size, var(--button-size))) / 2);
  border-radius: 0;
  background: var(--demo-image, var(--custom-image)) center / contain no-repeat;
  opacity: var(--demo-opacity, 1);
}

.controls > input {
  width: 100%;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.control-row > div {
  display: flex;
  align-items: center;
  gap: 5px;
}

.control-row button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  color: #edf4ff;
  background: transparent;
}

.demo-shell .is-target {
  outline: 2px solid transparent;
  border-radius: 6px;
  box-shadow: none;
  transition:
    color 0.7s ease,
    outline-color 0.7s ease,
    box-shadow 0.7s ease,
    filter 0.7s ease;
}

.demo-shell.guide-visible .is-target {
  color: var(--accent);
  outline-color: rgba(0, 242, 168, 0.65);
  box-shadow: 0 0 14px rgba(0, 242, 168, 0.28);
}

.control-row button.has-image {
  color: transparent;
  background-image: var(--demo-image, var(--custom-image));
  background-repeat: no-repeat;
  background-position: calc(50% + var(--demo-x, var(--button-x))) calc(50% + var(--demo-y, var(--button-y)));
  background-size: var(--demo-size, var(--button-size)) var(--demo-size, var(--button-size));
  opacity: var(--demo-opacity, 1);
}

[data-guide-target="volume"] {
  width: 48px;
}

.controls input.is-target {
  outline: 0;
  filter: none;
}

.demo-shell.guide-visible .controls input.is-target {
  filter: drop-shadow(0 0 8px rgba(0, 242, 168, 0.8));
}

.live {
  width: auto !important;
  color: #fff !important;
  font-size: 11px;
  font-weight: 800;
}

.demo-chat {
  grid-column: 3;
  grid-row: 2 / 4;
  position: relative;
  display: grid;
  grid-template-rows: 34px 1fr 44px;
  overflow: hidden;
  border-left: 1px solid #191d24;
  background: #0d0f12;
}

.demo-chat::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: var(--chat-opacity);
  background-image: var(--chat-image);
  background-repeat: no-repeat;
  background-position: var(--chat-x) var(--chat-y);
  background-size: var(--chat-size);
  pointer-events: none;
}

.demo-chat > * {
  position: relative;
  z-index: 1;
}

.demo-chat header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.demo-chat header button {
  position: absolute;
  right: 8px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.chat-body {
  background: repeating-linear-gradient(180deg, transparent, transparent 22px, rgba(255, 255, 255, 0.015) 23px);
}

.demo-chat footer {
  display: flex;
  align-items: center;
  margin: 8px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--muted);
  background: #252a32;
  font-size: 11px;
}

.demo-info {
  grid-column: 2;
  grid-row: 3;
  padding: 10px 16px;
  background: #0d0f12;
}

.demo-info h1 {
  margin: 0;
  font-size: 17px;
}

.demo-info p {
  margin: 3px 0 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.tool-panel {
  position: relative;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 22px;
}

.tool-panel header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-panel header span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #07120f;
  background: var(--accent);
  font-weight: 900;
}

.tool-panel h2 {
  margin: 0;
  font-size: 22px;
}

.top-actions {
  position: absolute;
  top: 22px;
  right: 22px;
  display: flex;
  gap: 8px;
}

.top-actions button {
  min-width: 104px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #37404d;
  border-radius: 6px;
  color: var(--text);
  background: #0d1016;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 112px;
  border: 1px dashed #495262;
  border-radius: 8px;
  color: var(--text);
  background: #0d1016;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.dropzone.compact {
  min-height: 88px;
}

.dropzone input {
  display: none;
}

.dropzone small {
  color: var(--muted);
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: rgba(0, 242, 168, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 242, 168, 0.35);
}

.size-hint {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.preview-card {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 18px;
  padding: 16px;
  border-radius: 8px;
  background: var(--panel-2);
}

.preview-card span {
  color: var(--muted);
  font-weight: 800;
}

.chat-tool {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chat-tool h3 {
  margin: 0;
  font-size: 16px;
}

.asset-preview,
#dialogAssetPreview {
  display: grid;
  place-items: center;
  justify-self: center;
  width: calc(var(--preview-width, 22px) * var(--preview-scale));
  height: calc(var(--preview-height, 22px) * var(--preview-scale));
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: #07090d;
  background-image: var(--custom-image);
  background-repeat: no-repeat;
  background-position: calc(50% + var(--button-x)) calc(50% + var(--button-y));
  background-size: var(--button-size) var(--button-size);
  font-size: 28px;
}

.asset-preview.is-chat-preview {
  width: min(100%, calc(var(--preview-width, 220px) * var(--preview-scale)));
  height: calc(var(--preview-height, 180px) * var(--preview-scale));
  background-position: var(--chat-x) var(--chat-y);
  background-size: var(--chat-size);
  font-size: 22px;
}

.asset-preview.has-image,
#dialogAssetPreview.has-image {
  color: transparent;
  opacity: var(--button-opacity);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 56px;
  align-items: end;
  gap: 14px;
}

output {
  height: 38px;
  padding-top: 9px;
  color: var(--accent);
  font-weight: 900;
  text-align: right;
}

button {
  cursor: pointer;
}

.primary {
  border-color: transparent !important;
  color: #07120f !important;
  background: var(--accent) !important;
  font-weight: 900;
}

.success {
  border-color: transparent !important;
  color: #07120f !important;
  background: var(--accent) !important;
  font-weight: 900;
}

.danger {
  border-color: transparent !important;
  color: #fff !important;
  background: #d83a3a !important;
  font-weight: 900;
}

.danger:hover {
  background: #ef4444 !important;
}

.tool-panel button {
  height: 40px;
  border: 1px solid #3d4654;
  border-radius: 7px;
  color: var(--text);
  background: #1a202a;
}

.save-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

pre {
  min-height: 136px;
  max-height: 220px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #b8c4d5;
  background: #07090d;
  white-space: pre-wrap;
}

dialog {
  width: 430px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--panel);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

dialog header,
dialog menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  margin: 0 0 16px;
}

dialog p {
  margin: 0 0 18px;
  color: var(--text);
}

dialog header button {
  width: 30px;
  height: 30px;
  border: 0;
  color: var(--text);
  background: transparent;
  font-size: 22px;
}

.dialog-preview {
  display: grid;
  place-items: center;
  height: 130px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: #07090d;
}

dialog .preview-card {
  margin-bottom: 16px;
}

dialog menu {
  gap: 10px;
  margin-top: 18px;
}

dialog menu button {
  flex: 1;
  height: 38px;
  border: 1px solid #3d4654;
  border-radius: 7px;
  color: var(--text);
  background: #1a202a;
}
