:root {
  --bg: #1e2530;
  --panel: #2b3442;
  --panel-2: #34404f;
  --border: #475569;
  --text: #e6edf3;
  --muted: #94a3b8;
  --accent: #4ea1ff;
  --accent-2: #7dd3fc;
  --ok: #4ade80;
  --warn: #fbbf24;
  --hint-bg: #f6f9fc;
  --hint-border: #c7d8ea;
  --hint-text: #1f2937;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #0b1220;
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

.demo-wrap {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 16px;
}

.demo-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.demo-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.demo-runtime {
  font-size: 12px;
  color: var(--muted);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.qgis-chrome {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 28px 1fr;
}

.qgis-titlebar {
  grid-column: 1 / 3;
  background: #1a2230;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  color: var(--muted);
  gap: 6px;
}

.qgis-titlebar .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #3b4658;
}

.dock {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.dock-tabs {
  display: flex;
  background: #232d3b;
  border-bottom: 1px solid var(--border);
}

.dock-tab {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: default;
  border-right: 1px solid var(--border);
  transition: background 200ms ease, color 200ms ease;
}

.dock-tab:last-child { border-right: none; }

.dock-tab.active {
  color: var(--text);
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
}

.dock-tab.hovered {
  background: #2d384a;
  color: var(--text);
}

.dock-body {
  padding: 10px;
  font-size: 12px;
  flex: 1;
  overflow: hidden;
}

.dock-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 6px 0 4px;
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
}

.tree li {
  padding: 3px 0 3px 14px;
  position: relative;
  color: var(--text);
  opacity: 0.95;
  transition: background 200ms ease;
  border-radius: 3px;
}

.tree li.indent-1 { padding-left: 26px; }
.tree li.indent-2 { padding-left: 38px; }
.tree li.indent-3 { padding-left: 50px; }

.tree li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--muted);
  font-size: 10px;
  top: 4px;
}

.tree li.leaf::before { content: "•"; left: 4px; }

.tree li.selected {
  background: rgba(78, 161, 255, 0.18);
  outline: 1px solid rgba(78, 161, 255, 0.35);
}

.tree li.appearing {
  animation: nodeIn 400ms ease both;
}

@keyframes nodeIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.canvas {
  position: relative;
  background:
    linear-gradient(135deg, #1e3a5f 0%, #25527a 60%, #2b6699 100%);
  overflow: hidden;
}

.canvas-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
}

.canvas-label {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(0,0,0,0.35);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--muted);
}

.mock-poly {
  position: absolute;
  border: 2px solid rgba(255, 220, 120, 0.85);
  background: rgba(255, 220, 120, 0.18);
  border-radius: 4px;
  transition: opacity 400ms ease, background 400ms ease, border-color 400ms ease;
}

.mock-poly.feature-1 { left: 22%; top: 28%; width: 18%; height: 22%; }
.mock-poly.feature-2 { left: 46%; top: 18%; width: 14%; height: 18%; transform: rotate(8deg); }
.mock-poly.feature-3 { left: 36%; top: 52%; width: 22%; height: 18%; transform: rotate(-4deg); }
.mock-poly.feature-4 { left: 64%; top: 44%; width: 16%; height: 20%; }

.mock-poly.selected {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.28);
}

/* Pipeline strip: Workspace -> Study -> Analysis -> Task -> Result */
.pipeline {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.45);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
}

.pipeline-step {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  transition: background 300ms ease, color 300ms ease, transform 300ms ease;
}

.pipeline-step.active {
  background: var(--accent);
  color: #0b1220;
  font-weight: 600;
  transform: scale(1.05);
}

.pipeline-arrow {
  color: var(--muted);
  font-size: 12px;
}

/* Dialog overlay */
.dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.dialog-overlay.open {
  opacity: 1;
}

.dialog {
  width: 520px;
  max-width: 90%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  transform: translateY(8px) scale(0.98);
  transition: transform 300ms ease;
}

.dialog-overlay.open .dialog {
  transform: translateY(0) scale(1);
}

.dialog-title {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  background: #232d3b;
  border-radius: 8px 8px 0 0;
}

.dialog-body {
  padding: 14px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialog-buttons {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #232d3b;
  border-radius: 0 0 8px 8px;
}

.btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  color: #0b1220;
  border-color: var(--accent);
  font-weight: 600;
}

.btn.highlight {
  box-shadow: 0 0 0 3px rgba(78, 161, 255, 0.35);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 11px;
  color: var(--muted);
}

.field-input {
  background: #1a2230;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  min-height: 16px;
  font-family: inherit;
}

.field-input.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.25);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;
}

.checkbox-row .box {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #1a2230;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--accent);
}

.checkbox-row.checked .box::after {
  content: "✓";
  color: #0b1220;
}

.checkbox-row.checked .box {
  background: var(--accent);
  border-color: var(--accent);
}

.hint-panel {
  background: var(--hint-bg);
  color: var(--hint-text);
  border: 1px solid var(--hint-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.4;
}

.hint-panel .hint-title {
  font-weight: 600;
  margin-bottom: 2px;
}

/* Cursor */
.cursor {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  transition: top 700ms cubic-bezier(0.22, 0.61, 0.36, 1),
              left 700ms cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 50;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

.cursor svg { width: 100%; height: 100%; display: block; }

.cursor.clicking::after {
  content: "";
  position: absolute;
  left: 4px; top: 4px;
  width: 24px; height: 24px;
  border: 2px solid var(--accent-2);
  border-radius: 50%;
  animation: clickRipple 500ms ease-out;
}

@keyframes clickRipple {
  from { transform: scale(0.2); opacity: 1; }
  to   { transform: scale(1.4); opacity: 0; }
}

/* Progress bar (task run) */
.progress {
  width: 70%;
  height: 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
  position: absolute;
  left: 50%; bottom: 24%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 300ms ease;
}

.progress.visible { opacity: 1; }

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width 200ms linear;
}

.banner {
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 400ms ease;
  border: 1px solid rgba(255,255,255,0.1);
}

.banner.visible { opacity: 1; }

/* Result viewer tabs */
.viewer {
  position: absolute;
  left: 12%; top: 12%;
  right: 12%; bottom: 28%;
  background: #1a2230;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 300ms ease, transform 300ms ease;
}

.viewer.visible {
  opacity: 1;
  transform: translateY(0);
}

.viewer-tabs {
  display: flex;
  background: #232d3b;
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
}

.viewer-tab {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--muted);
  border-right: 1px solid var(--border);
}

.viewer-tab.active {
  color: var(--text);
  background: #1a2230;
  border-bottom: 2px solid var(--accent);
}

.viewer-body {
  flex: 1;
  padding: 12px;
  overflow: hidden;
  font-size: 12px;
}

.value-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.value-table th, .value-table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}

.value-table th { color: var(--muted); font-weight: 500; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 100%;
  padding: 8px 12px;
}

.bar {
  flex: 1;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-radius: 3px 3px 0 0;
  position: relative;
}

.bar::after {
  content: attr(data-label);
  position: absolute;
  bottom: -18px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}

.transport {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.transport button {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.transport button:hover {
  background: #3e4a5b;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-track .fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 120ms linear;
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  min-width: 80px;
  text-align: right;
}

.caption-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 64px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.caption-box .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.caption-box .text {
  min-height: 1.5em;
  transition: opacity 200ms ease;
}

.demo-footer {
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.demo-footer code {
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 3px;
}
