:root {
  color-scheme: light;
  font-family: Inter, Arial, sans-serif;
  --bg: #edf5f9;
  --card: #ffffff;
  --text: #0f1720;
  --muted: #546778;
  --border: #d6e3ee;
  --accent: #0f1720;
  --accent-soft: #edf4ff;
  --shadow: 0 18px 40px rgba(15, 23, 32, 0.08);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(30, 136, 229, 0.12), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f1f7fb 100%);
  color: var(--text);
}
body {
  padding: 20px;
  overflow-x: auto;
}
button, input, select, textarea { font: inherit; }
button { border: 0; border-radius: 14px; cursor: pointer; }
.app-shell {
  max-width: 1880px;
  min-width: 1380px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}
.eyebrow {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1e5da8;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 10px 0 0;
  font-size: clamp(32px, 3.2vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.04em;
}
.hero p {
  max-width: 96ch;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}
.hero-version {
  flex: 0 0 auto;
  padding: 11px 15px;
  border-radius: 999px;
  background: #0f1720;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(1080px, 1.62fr) minmax(420px, 0.58fr);
  gap: 18px;
  align-items: start;
}
.left-column,
.right-column {
  display: grid;
  gap: 18px;
  align-content: start;
}
.right-column {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding-right: 6px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head-wrap { align-items: flex-start; }
.section-head h2 { margin: 0; font-size: 19px; }
.subtle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.toolbar-stack {
  display: grid;
  gap: 10px;
  justify-items: end;
  min-width: 280px;
}
.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.small-btn {
  min-height: 40px;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: #1e5da8;
  font-weight: 800;
  border: 1px solid var(--border);
}
.clear-btn {
  background: #fff4f1;
  color: #ba4a2d;
}
.tag {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.selected-pill {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fbff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}
.layout-legend {
  display: grid;
  gap: 6px;
}
.legend-item {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}
.preview-stage {
  display: grid;
  gap: 10px;
}
.preview-pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
#previewCanvas,
#thermalCanvas {
  display: block;
  background: #fff;
  border-radius: 24px;
  border: 1px solid var(--border);
}
#previewCanvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  cursor: grab;
  touch-action: none;
}
#previewCanvas.dragging {
  cursor: grabbing;
}
#thermalCanvas {
  width: min(420px, 100%);
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
}
.scale-controls {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}
.scale-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.scale-row {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 10px;
  align-items: center;
}
#scaleRangeInput {
  width: 100%;
  min-height: 44px;
}
.compact-hint {
  margin-top: 0;
}
.thermal-drawer {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fbfdff;
  overflow: hidden;
}
.thermal-drawer summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
}
.thermal-drawer summary::-webkit-details-marker {
  display: none;
}
.thermal-drawer summary div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.thermal-drawer-body {
  padding: 0 16px 16px;
  display: grid;
  gap: 14px;
}
.thermal-preview-wrap {
  display: flex;
  justify-content: flex-start;
}
.thermal-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
#jsonOutput {
  width: 100%;
  min-height: 420px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #f7fbff;
  resize: vertical;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.45;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.meta-grid label, .element-card label, .asset-row label, .thermal-controls label {
  display: grid;
  gap: 6px;
}
.meta-grid span, .element-card span, .asset-row span, .thermal-controls span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
input, select {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 10px 12px;
}
.editor-list, .asset-list {
  display: grid;
  gap: 12px;
}
.element-card, .asset-row {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  background: #fbfdff;
  display: grid;
  gap: 12px;
}
.element-card.is-selected {
  border-color: #8ab8f1;
  box-shadow: inset 0 0 0 1px rgba(30, 136, 229, 0.2);
}
.element-card-header, .asset-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.element-card-header strong, .asset-row-header strong { font-size: 15px; }
.element-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.element-card-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
}
.checkbox-row input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
}
.asset-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.asset-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1e5da8;
  font-size: 11px;
  font-weight: 800;
}
.asset-preview {
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.file-input { display: none; }
@media (max-width: 1500px) {
  .app-shell {
    min-width: 0;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .right-column {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}
@media (max-width: 980px) {
  .toolbar-stack {
    width: 100%;
    justify-items: stretch;
    min-width: 0;
  }
  .meta-grid, .element-card-grid, .thermal-controls {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  body { padding: 12px; }
  .hero, .section-head, .element-card-header, .asset-row-header, .thermal-drawer summary div {
    flex-direction: column;
    align-items: flex-start;
  }
  .legend-item { text-align: left; }
  .scale-head, .scale-row {
    grid-template-columns: 1fr;
  }
}
