/* Editor chrome only — panel preview uses .sk-preview namespace */

:root {
  --props-w: 300px;
  --bg: #1a1d23;
  --surface: #252830;
  --border: #3d4450;
  --text: #e8eaed;
  --muted: #9aa0a8;
  --accent: #3b82f6;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.file-tree-panel {
  width: 240px;
  min-width: 180px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.file-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.file-tree-header h2 {
  margin: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border: none;
}

.file-tree-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.file-tree-new-btn,
.file-tree-delete-btn {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.file-tree-new-btn:hover:not(:disabled),
.file-tree-delete-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.file-tree-new-btn:disabled,
.file-tree-delete-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.file-tree-delete-btn {
  border-color: color-mix(in srgb, var(--danger, #c42b2b) 45%, var(--border));
  color: var(--danger, #b83232);
}

.file-tree {
  flex: 1;
  overflow: auto;
  padding: 8px;
  font-size: 13px;
}

.file-tree-hint {
  padding: 10px 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  border-top: 1px solid var(--border);
  margin: 0;
}

.file-tree-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.file-tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-tree-folder {
  margin-top: 4px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  list-style: none;
}

.file-tree-folder-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 5px 6px;
  margin: 0 0 2px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
}

.file-tree-folder-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.file-tree-chevron {
  display: inline-block;
  width: 1em;
  flex-shrink: 0;
  font-size: 9px;
  line-height: 1;
  opacity: 0.75;
}

.file-tree-folder-label {
  flex: 1;
  min-width: 0;
}

.file-tree-folder ul.file-tree-nested {
  list-style: none;
  margin: 4px 0 2px 10px;
  padding: 0;
}

.file-tree-nested {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 12px;
  margin-left: 0;
}

/* Each nested level steps in further (folder contents vs parent row). */
.file-tree-nested .file-tree-nested {
  margin-left: 4px;
}

.file-tree-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  margin: 1px 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.file-tree-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.file-tree-item.selected {
  background: rgba(59, 130, 246, 0.25);
  color: #fff;
}

.editor-workspace-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#mode-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#mode-panel.hidden {
  display: none !important;
}

#mode-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
}

#mode-text.hidden {
  display: none !important;
}

#mode-image {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
}

#mode-image.hidden {
  display: none !important;
}

.image-view-toolbar {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  word-break: break-all;
}

.image-view-toolbar code {
  font-size: 12px;
  color: var(--text);
}

.image-view-scroll {
  flex: 1;
  min-height: 200px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.image-view-img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  vertical-align: top;
}

.text-editor-toolbar {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.text-editor {
  flex: 1;
  width: 100%;
  min-height: 200px;
  padding: 12px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: none;
}

.project-toolbar .toolbar-group-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.project-toolbar .toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.save-progress-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: rgba(59, 130, 246, 0.12);
  border-bottom: 1px solid var(--accent);
}

.editor-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.editor-toolbar input[type="text"] {
  width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.editor-toolbar button {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.editor-toolbar button[aria-busy="true"] {
  opacity: 0.65;
  cursor: wait;
}

.editor-toolbar button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.editor-toolbar button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.editor-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.editor-toolbar .hint {
  font-size: 12px;
  color: var(--muted);
  max-width: 420px;
}

.editor-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.preview-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #0f1115;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.preview-toolbar-hint {
  flex-shrink: 0;
}

.preview-toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.preview-toolbar button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.preview-toolbar button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.preview-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.preview-toolbar button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.preview-split {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.preview-split.html-pane-open .preview-visual-wrap {
  flex: 1;
  min-height: 180px;
}

.preview-visual-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.preview-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Room for “Insert before…” captions above the top row while dragging */
.preview-scroll:has(.sk-preview-dnd-active) {
  padding-top: 28px;
}

.panel-html-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  max-height: min(42vh, 480px);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.panel-html-pane.hidden {
  display: none !important;
}

.panel-html-toolbar {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.panel-html-source {
  flex: 1;
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin: 0;
  border: none;
  border-radius: 0;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

.panel-html-source:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Scaled-down preview of the panel */
.sk-preview-host {
  transform-origin: top center;
  background: #000;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.sk-preview #wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: auto;
}

/* Drop between rows / above first / below last — new row with one button */
.sk-preview .sk-row-insert-zone {
  width: 100%;
  min-height: 14px;
  height: auto;
  margin: 0;
  flex-shrink: 0;
  align-self: stretch;
  border-radius: 6px;
  box-sizing: border-box;
  pointer-events: none;
  position: relative;
  z-index: 1;
  transition:
    min-height 0.12s,
    background 0.12s,
    border-color 0.12s,
    opacity 0.12s;
}

.sk-preview.sk-preview-dnd-active .sk-row-insert-zone {
  min-height: 44px;
  pointer-events: auto;
  z-index: 12;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
}

.sk-preview.sk-preview-dnd-active .sk-row-insert-zone:not(.sk-row-insert-target) {
  opacity: 0.35;
}

.sk-preview.sk-preview-dnd-active .sk-row-insert-zone.sk-row-insert-target {
  opacity: 1 !important;
  min-height: 52px;
  border: 2px dashed #60a5fa;
  background: rgba(59, 130, 246, 0.2);
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.35);
}

.sk-preview.sk-preview-dnd-active .sk-row-insert-zone.sk-row-insert-target::after {
  content: "New row";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f8fafc;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(96, 165, 250, 0.85);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 2;
}

/* Drag near top/bottom of a row → new row above/below (also works over buttons) */
.sk-preview.sk-preview-dnd-active .row.sk-row-drag-insert-before {
  box-shadow: inset 0 4px 0 0 rgba(96, 165, 250, 0.95);
  background: rgba(59, 130, 246, 0.08);
}

.sk-preview.sk-preview-dnd-active .row.sk-row-drag-insert-after {
  box-shadow: inset 0 -4px 0 0 rgba(96, 165, 250, 0.95);
  background: rgba(59, 130, 246, 0.08);
}

.sk-preview .row {
  display: flex;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  margin: 2px 0;
  min-height: 24px;
  border: 1px dashed transparent;
  border-radius: 6px;
  position: relative;
}

/* Balance .sk-row-drop-tail (flex: 1) so button groups stay centered like the live site */
.sk-preview .sk-row-lead-spacer {
  flex: 1 1 40px;
  min-width: 36px;
  min-height: 56px;
  align-self: stretch;
  pointer-events: none;
  visibility: hidden;
}

.sk-preview .row.sk-row-target {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.06);
}

.sk-preview .sk-row-drop-tail {
  flex: 1 1 40px;
  min-width: 36px;
  min-height: 56px;
  align-self: stretch;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
  position: relative;
  transition:
    border-color 0.12s,
    background 0.12s,
    box-shadow 0.12s;
}

/* While dragging: dim other buttons so the active drop target reads clearly */
.sk-preview.sk-preview-dnd-active .column:not(.sk-col-drop-target) .container:not(.sk-dragging) {
  opacity: 0.52;
  filter: saturate(0.75);
  transition:
    opacity 0.15s,
    filter 0.15s;
}

.sk-preview.sk-preview-dnd-active .row:not(.sk-row-target) .sk-row-drop-tail:not(.sk-col-drop-target) {
  opacity: 0.35;
}

@keyframes sk-dnd-insert-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.85);
  }
  50% {
    opacity: 0.92;
    box-shadow: 0 0 18px rgba(96, 165, 250, 1);
  }
}

/* Insert-before target: glowing column + vertical insertion bar + caption */
.sk-preview.sk-preview-dnd-active .column.sk-col-drop-target {
  z-index: 6;
  border-radius: 8px;
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.95),
    0 0 28px rgba(37, 99, 235, 0.45);
  background: rgba(59, 130, 246, 0.08);
}

.sk-preview.sk-preview-dnd-active .column.sk-col-drop-target::before {
  content: "";
  position: absolute;
  left: -8px;
  top: -4px;
  bottom: -4px;
  width: 6px;
  border-radius: 4px;
  background: linear-gradient(180deg, #93c5fd, #2563eb);
  animation: sk-dnd-insert-pulse 1.1s ease-in-out infinite;
  pointer-events: none;
}

.sk-preview.sk-preview-dnd-active .column.sk-col-drop-target::after {
  content: "Insert before this column";
  position: absolute;
  left: 50%;
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.95);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(96, 165, 250, 0.65);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 8;
}

.sk-preview.sk-preview-dnd-active .sk-raw-block.sk-col-drop-target {
  position: relative;
  z-index: 6;
  border-radius: 8px;
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.95),
    0 0 28px rgba(37, 99, 235, 0.45);
  outline: none;
}

.sk-preview.sk-preview-dnd-active .sk-raw-block.sk-col-drop-target::before {
  content: "";
  position: absolute;
  left: -8px;
  top: -4px;
  bottom: -4px;
  width: 6px;
  border-radius: 4px;
  background: linear-gradient(180deg, #93c5fd, #2563eb);
  animation: sk-dnd-insert-pulse 1.1s ease-in-out infinite;
  pointer-events: none;
}

.sk-preview.sk-preview-dnd-active .sk-raw-block.sk-col-drop-target::after {
  content: "Insert before this block";
  position: absolute;
  left: 50%;
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.95);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(96, 165, 250, 0.65);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 8;
}

.sk-preview.sk-preview-dnd-active .sk-raw-block:not(.sk-col-drop-target) {
  opacity: 0.52;
  filter: saturate(0.75);
  transition:
    opacity 0.15s,
    filter 0.15s;
}

.sk-preview.sk-preview-dnd-active .sk-raw-block.sk-col-drop-target {
  opacity: 1;
  filter: none;
}

/* Row tail = append to this row */
.sk-preview.sk-preview-dnd-active .sk-row-drop-tail.sk-col-drop-target {
  opacity: 1 !important;
  border: 2px dashed #60a5fa;
  background: rgba(59, 130, 246, 0.2);
  box-shadow:
    inset 0 0 24px rgba(59, 130, 246, 0.12),
    0 0 0 2px rgba(37, 99, 235, 0.35);
}

.sk-preview.sk-preview-dnd-active .sk-row-drop-tail.sk-col-drop-target::after {
  content: "Drop at end of row";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #eff6ff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 2;
}

.sk-preview.sk-preview-dnd-active .row.sk-row-target {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(59, 130, 246, 0.08);
}

.sk-preview .container[draggable="true"] {
  cursor: grab;
}

.sk-preview .container[draggable="true"]:active {
  cursor: grabbing;
}

.sk-preview .container.sk-dragging {
  opacity: 0.45;
}

.sk-preview .column {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 10px;
  position: relative;
}

.sk-preview .container {
  position: relative;
  width: 150px;
  height: 100px;
  background: linear-gradient(135deg, #2a2a2a, #4b4b4b);
  border: 2px solid #00ff00;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s;
}

.sk-preview .container:hover {
  transform: scale(1.02);
}

.sk-preview .container.sk-edit-selected {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  z-index: 2;
}

.sk-preview .container.eject {
  border-color: red;
}
.sk-preview .container.eject .centered {
  color: red;
}
.sk-preview .container.emergency {
  border-color: orange;
}
.sk-preview .container.emergency .centered {
  color: orange;
}
.sk-preview .container.blue {
  border-color: blue;
}
.sk-preview .container.blue .centered {
  color: #66b3ff;
  text-shadow: 0 0 10px #66b3ff;
}
.sk-preview .container.yellow {
  border-color: yellow;
}
.sk-preview .container.yellow .centered {
  color: #ffcc00;
  text-shadow: 0 0 10px #ffcc00;
}
.sk-preview .container.blue2 {
  border-color: #3366cc;
  background: linear-gradient(135deg, #003399, #3366cc);
}
.sk-preview .container.blue2 .centered {
  color: #3399ff;
  text-shadow: 0 0 10px #3399ff;
}
.sk-preview .container.blue3 {
  border-color: #6699ff;
}
.sk-preview .container.blue3 .centered {
  color: #99ccff;
  text-shadow: 0 0 10px #99ccff;
}
.sk-preview .container.green {
  border-color: #00ff00;
}
.sk-preview .container.green .centered {
  color: #00ff00;
  text-shadow: 0 0 10px #00ff00;
}
.sk-preview .container.dgreen {
  border-color: #00ff00;
  background: linear-gradient(135deg, #003300, #004d00);
  box-shadow: 0 0 15px #004d00;
}
.sk-preview .container.dgreen .centered {
  color: #99ff99;
}
.sk-preview .container.active {
  background: linear-gradient(135deg, #002244, #0055aa);
  border: 3px solid blue;
  box-shadow: 0 0 20px blue;
}
.sk-preview .container.active .centered {
  color: #66b3ff;
  font-weight: bold;
}
.sk-preview .container.active2 {
  background: linear-gradient(135deg, #99ccff, #cce7ff);
  border: 3px solid #99ccff;
  box-shadow: 0 0 15px #99ccff;
}
.sk-preview .container.active2 .centered {
  color: #e6f3ff;
  font-weight: bold;
}
.sk-preview .container.critical {
  border-color: #8b0000;
  background: linear-gradient(135deg, #4b0000, #8b0000);
  box-shadow: 0 0 15px #8b0000;
}
.sk-preview .container.critical .centered {
  color: #2b0000;
  font-weight: bold;
}
.sk-preview .container.emergency2 {
  border-color: #ffd580;
  background: none;
  box-shadow: none;
}
.sk-preview .container.emergency2 .centered {
  color: #8b4513;
  font-weight: bold;
}

.sk-preview .centered {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1em;
}

/* Image buttons: colored border frame only — no inner gradient filler around the graphic */
.sk-preview .container.sk-container--image {
  background: transparent !important;
  box-shadow: none !important;
}

.sk-preview .container.sk-container--image .centered {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
}

.sk-preview .centered .small-text {
  font-size: 0.8em;
  display: block;
}

.sk-preview .sk-raw-block {
  border: 1px dashed #666;
  padding: 8px;
  border-radius: 6px;
  color: #aaa;
  font-size: 12px;
  max-width: 280px;
}

.sk-preview .sk-raw-block.sk-edit-selected {
  outline: 2px solid var(--accent);
}

.properties {
  width: var(--props-w);
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-width: 260px;
}

.properties h2 {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.props-body {
  padding: 12px 14px;
  overflow: auto;
  flex: 1;
  font-size: 13px;
}

.props-body fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
}

.props-body legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.props-body label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.props-body input[type="text"],
.props-body input[type="number"],
.props-body textarea,
.props-body select {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.props-body textarea {
  min-height: 72px;
  resize: vertical;
}

.props-body .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.props-body .props-actions--edges {
  margin-bottom: 12px;
}

.props-body .props-actions--edges:last-child {
  margin-top: 12px;
  margin-bottom: 0;
}

.props-body .props-actions--edges .actions {
  margin-top: 8px;
}

.props-body .props-actions--edges .actions:first-child {
  margin-top: 0;
}

.props-body button {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.props-body button.danger {
  border-color: var(--danger);
  color: #fca5a5;
}

.props-body button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.props-macro-hint {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.props-macro-hint code {
  font-size: 11px;
}

.prop-content-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 10px;
}

.prop-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.props-hint {
  font-size: 11px;
  color: var(--muted);
  margin: -4px 0 8px;
  line-height: 1.35;
}

.props-hint code {
  font-size: 10px;
}

.prop-image-section {
  margin-top: 8px;
}

.prop-image-grid-label {
  margin-bottom: 6px;
}

.prop-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.prop-image-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
}

.prop-image-tile:hover {
  border-color: var(--accent);
}

.prop-image-tile--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.prop-image-tile-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  overflow: hidden;
}

.prop-image-tile-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.prop-image-tile-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.prop-image-missing {
  font-size: 16px;
  color: var(--muted);
}

.props-image-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.props-image-hint code {
  font-size: 11px;
}

.sk-preview-placeholder {
  font-size: 12px;
  color: var(--muted);
  padding: 6px;
  text-align: center;
}

.sk-preview .container.sk-container--image .sk-preview-button-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.sk-preview .container:not(.sk-container--image) .centered img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  vertical-align: middle;
}

.prop-image-sizing-wrap {
  margin-bottom: 10px;
}

.prop-subsection-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.prop-image-layout-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 10px;
}

.prop-image-layout-row .prop-radio {
  margin-bottom: 0;
}

.prop-image-layout-panel {
  margin-bottom: 8px;
}

.prop-image-layout-panel.hidden {
  display: none !important;
}

.prop-image-scale-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.prop-image-scale-row input[type="range"] {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.prop-image-scale-row input[type="number"]#prop-image-scale-num {
  width: 4.5em;
  flex-shrink: 0;
  margin-bottom: 0;
  padding: 6px 8px;
}

.prop-scale-readout {
  min-width: 3.2em;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#prop-image-fit-preview {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

#prop-image-fit-preview:hover {
  border-color: var(--accent);
}

.prop-image-dim-hint {
  margin-top: 0;
}

.props-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-bar {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.status-bar.error {
  color: #fca5a5;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-dialog {
  position: relative;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.modal-dialog-narrow {
  width: min(400px, 100%);
}

.modal-dialog-wide {
  width: min(560px, 100%);
}

.modal-dialog-directions .directions-body {
  margin: 0 0 16px;
  max-height: min(62vh, 520px);
  overflow-y: auto;
  padding-right: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.directions-section {
  margin-bottom: 18px;
}

.directions-section:last-child {
  margin-bottom: 0;
}

.directions-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.directions-section ul {
  margin: 0;
  padding-left: 1.15rem;
}

.directions-section li {
  margin-bottom: 8px;
}

.directions-section li:last-child {
  margin-bottom: 0;
}

.directions-section-note p {
  margin: 0 0 10px;
}

.directions-section-note p:last-child {
  margin-bottom: 0;
}

.directions-section-note {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.modal-dialog h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.modal-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.save-as-section {
  margin: 0 0 18px;
  padding: 14px 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.save-as-section-dimmed {
  opacity: 0.38;
  pointer-events: none;
}

.save-as-section-lead {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.save-as-section-lead:last-child {
  margin-bottom: 0;
}

.save-as-step-detail {
  margin: -4px 0 12px;
}

.save-as-section .modal-btn {
  margin-bottom: 0;
}

#save-as-section-2 #save-as-pick-parent-change {
  margin-bottom: 14px;
}

.modal-summary {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text);
}

.modal-btn {
  margin-bottom: 16px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.modal-btn:hover {
  filter: brightness(1.08);
}

.modal-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.save-as-path-block {
  margin: 0 0 10px;
}

.save-as-path-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.save-as-path-box {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

.save-as-path-line {
  display: block;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-as-path-line-placeholder {
  color: var(--muted);
  font-style: italic;
}

.modal-path-note {
  margin: 0 0 14px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.modal-path-note code {
  font-size: 10px;
}

.save-as-progress {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid var(--accent);
  border-radius: 8px;
}

.save-as-progress-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: save-as-spin 0.7s linear infinite;
}

@keyframes save-as-spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.modal-label input,
.modal-label select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.modal-label select {
  cursor: pointer;
}

.modal-error {
  margin: 8px 0 0;
  font-size: 13px;
  color: #fca5a5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.modal-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* --- Root .conf editor (findRootConfigPath) --- */

#mode-root-conf {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#mode-root-conf.hidden {
  display: none !important;
}

.root-conf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.root-conf-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.root-conf-path {
  font-size: 13px;
  color: var(--text);
}

.root-conf-toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.root-conf-toolbar button {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.root-conf-toolbar button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.root-conf-toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.root-conf-lead {
  margin: 0;
  padding: 8px 16px 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.root-conf-error {
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.35);
  border-bottom: 1px solid var(--border);
}

.root-conf-error.hidden {
  display: none !important;
}

.root-conf-split {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.root-conf-split.root-conf-pane-open .root-conf-visual-wrap {
  flex: 0 0 auto;
  max-height: min(46vh, 480px);
  overflow: auto;
}

.root-conf-visual-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 18px;
}

.root-conf-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
}

.root-conf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.root-conf-field-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.root-conf-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.root-conf-field input:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--accent);
}

.root-conf-raw-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 120px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.root-conf-raw-pane.hidden {
  display: none !important;
}

.root-conf-raw-toolbar {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.root-conf-source {
  flex: 1;
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin: 0;
  border: none;
  border-radius: 0;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

.root-conf-source:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* --- Macro JSON editor (root file from .conf macroname) --- */

#mode-macro-json {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#mode-macro-json.hidden {
  display: none !important;
}

.macro-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.macro-editor-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.macro-editor-path {
  font-size: 13px;
  color: var(--text);
}

.macro-editor-toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.macro-editor-toolbar button {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.macro-editor-toolbar button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.macro-editor-toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.macro-editor-error {
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.35);
  border-bottom: 1px solid var(--border);
}

.macro-editor-error.hidden {
  display: none !important;
}

.macro-help-panel {
  max-height: min(38vh, 360px);
  overflow-y: auto;
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  line-height: 1.5;
}

.macro-help-panel.hidden {
  display: none !important;
}

.macro-help-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.macro-help-lead {
  margin: 0 0 12px;
  color: var(--muted);
}

.macro-help-body details {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
}

.macro-help-body summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.macro-help-body details p {
  margin: 8px 0 0;
  color: var(--text);
}

.macro-split {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.macro-split.macro-json-pane-open .macro-visual-wrap {
  flex: 0 0 auto;
  max-height: min(42vh, 420px);
  overflow: auto;
}

.macro-json-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.macro-json-pane.hidden {
  display: none !important;
}

.macro-json-toolbar {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.macro-json-source {
  flex: 1;
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin: 0;
  border: none;
  border-radius: 0;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

.macro-json-source:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.macro-visual-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 18px;
}

.macro-editor-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.macro-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.macro-row--run {
  border-left: 4px solid var(--accent);
}

.macro-add-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.macro-add-actions--top {
  margin-bottom: 12px;
}

.macro-add-actions--bottom {
  margin-top: 12px;
}

.macro-row-fields {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(72px, 100px) 1fr;
  grid-template-areas:
    "num desc"
    "val val";
  gap: 10px 14px;
}

@media (max-width: 720px) {
  .macro-row-fields {
    grid-template-columns: 1fr;
    grid-template-areas:
      "num"
      "desc"
      "val";
  }
}

.macro-field-num {
  grid-area: num;
}

.macro-field-desc {
  grid-area: desc;
}

.macro-field-val {
  grid-area: val;
}

.macro-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.macro-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.macro-field input,
.macro-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.macro-field-val textarea {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
  min-height: 88px;
}

.macro-row-delete {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 22px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}

.macro-row-delete:hover {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.5);
}

.macro-add-btn {
  margin-top: 4px;
}

.hidden {
  display: none !important;
}
