.model-node {
  min-width: 200px;
  max-width: 240px;
}

body:not(.app-slava-restraint) .model-node {
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12px;
  color: #ccc;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body:not(.app-slava-restraint) .model-node--selected {
  border-color: #555;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.model-node--idle { }
body:not(.app-slava-restraint) .model-node--queued { border-color: #555; }
body:not(.app-slava-restraint) .model-node--executing {
  border-color: #2196F3;
  animation: pulse-border 2s ease-in-out infinite;
}
.model-node--complete { }
body:not(.app-slava-restraint) .model-node--error { border-color: #F44336; }

@keyframes pulse-border {
  0%, 100% { border-color: #2196F3; }
  50% { border-color: #1565C0; }
}

.model-node__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
}

body:not(.app-slava-restraint) .model-node__header {
  border-bottom: 1px solid #2a2a2a;
}

.model-node__category-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.model-node__label {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body:not(.app-slava-restraint) .model-node__label {
  color: #eee;
}

.model-node__badge { font-size: 11px; flex-shrink: 0; }
body:not(.app-slava-restraint) .model-node__badge--warning { color: #FFC107; }

.model-node__id-chip {
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

body:not(.app-slava-restraint) .model-node__id-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 500;
  color: #777;
  background: #252525;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 1px 5px;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}

body:not(.app-slava-restraint) .model-node__id-chip:hover {
  color: #d8e8f5;
  background: #2a3b4f;
  border-color: #3a5070;
}

.model-node__id-chip:active { cursor: grabbing; }

.model-node__ports { padding: 6px 0; }

.model-node__port-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  position: relative;
}

.model-node__port-row--output { justify-content: flex-end; }

.model-node__port-label { font-size: 11px; }
body:not(.app-slava-restraint) .model-node__port-label { color: #888; }

body:not(.app-slava-restraint) .model-node__handle {
  width: 10px !important;
  height: 10px !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 50% !important;
  transition: transform 0.15s ease;
}

body:not(.app-slava-restraint) .model-node__handle:hover { transform: scale(1.4); }

.model-node__preview {
  position: relative;
}

.model-node__mask-composite .model-node__preview-image,
.model-node__mask-composite .model-node__mask-overlay {
  display: block;
  width: 100%;
  height: auto;
}

.model-node__mask-overlay {
  position: absolute;
  inset: 0;
  object-fit: contain;
  opacity: 0.55;
  pointer-events: none;
  mix-blend-mode: screen;
}

body:not(.app-slava-restraint) .model-node__preview {
  padding: 6px 10px;
  border-top: 1px solid #2a2a2a;
}

body:not(.app-slava-restraint) .model-node__download {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #ccc;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
  z-index: 2;
}

body:not(.app-slava-restraint) .model-node__preview:hover .model-node__download {
  opacity: 1;
}

body:not(.app-slava-restraint) .model-node__download:hover {
  background: rgba(40, 40, 40, 0.95);
  color: #fff;
}

body:not(.app-slava-restraint) .model-node__loop-toggle {
  position: absolute;
  top: 12px;
  right: 48px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #ccc;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s, border-color 0.12s;
  z-index: 2;
}

body:not(.app-slava-restraint) .model-node__preview:hover .model-node__loop-toggle {
  opacity: 1;
}

body:not(.app-slava-restraint) .model-node__loop-toggle:hover {
  background: rgba(40, 40, 40, 0.95);
  color: #fff;
}

body:not(.app-slava-restraint) .model-node__loop-toggle--on {
  color: #6ee7b7;
  border-color: rgba(110, 231, 183, 0.45);
}

body:not(.app-slava-restraint) .model-node__loop-toggle--on:hover {
  color: #a7f3d0;
  border-color: rgba(110, 231, 183, 0.65);
}

body:not(.app-slava-restraint) .model-node__preview-placeholder {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 8px;
  text-align: center;
  color: #555;
  font-size: 11px;
}

body:not(.app-slava-restraint) .model-node__error {
  padding: 4px 10px;
  font-size: 10px;
  color: #F44336;
  background: rgba(244, 67, 54, 0.1);
  border-top: 1px solid #2a2a2a;
}

/* Safety/moderation blocks: calmer amber treatment — still an error state, but
   not a red "failure" (the request was understood and declined). */
body:not(.app-slava-restraint) .model-node__error--blocked {
  color: #E0A030;
  background: rgba(224, 160, 48, 0.12);
}

/* Structural bits shared across skins (color comes from the skin rules above). */
.model-node__error-message {
  display: block;
}
.model-node__error-details {
  margin-top: 3px;
}
.model-node__error-details summary {
  cursor: pointer;
  opacity: 0.7;
  font-size: 9px;
  list-style: revert;
}
.model-node__error-raw {
  display: block;
  margin-top: 3px;
  opacity: 0.75;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- Before/after compare slider (image-compare node) --- */
/* structural (skin-agnostic) */
.before-after {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 4px;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  line-height: 0;
}
.before-after__img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.before-after__before {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.before-after__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-1px);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.before-after__handle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
/* visual (skin-scoped) */
body:not(.app-slava-restraint) .before-after__divider { background: rgba(255, 255, 255, 0.9); }
body:not(.app-slava-restraint) .before-after__handle {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
body.app-slava-restraint .before-after__divider { background: var(--sr-accent, #ff5a1f); }
body.app-slava-restraint .before-after__handle {
  background: var(--sr-accent, #ff5a1f);
  box-shadow: 0 0 0 2px var(--sr-canvas, #f4f1ea);
}

body:not(.app-slava-restraint) .model-node__preview-image {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

body:not(.app-slava-restraint) .model-node__preview-image--streaming {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  opacity: 0.85;
  outline: 1px dashed var(--accent, #888);
}

.model-node__preview-image[draggable='true'] {
  cursor: grab;
}

.model-node__preview-image[draggable='true']:active {
  cursor: grabbing;
}

body:not(.app-slava-restraint) .model-node__preview-video {
  display: block;
  width: 100%;
  border-radius: 4px;
}

body:not(.app-slava-restraint) .model-node__preview-audio {
  width: 100%;
  border-radius: 4px;
}

/* Loading indicator */
body:not(.app-slava-restraint) .model-node__loading {
  padding: 8px 10px;
  border-top: 1px solid #2a2a2a;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

body:not(.app-slava-restraint) .model-node__loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #333;
  border-top-color: #2196F3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

body:not(.app-slava-restraint) .model-node__loading-text {
  font-size: 11px;
  color: #888;
  flex: 1;
}

body:not(.app-slava-restraint) .model-node__loading .model-node__progress {
  width: 100%;
  padding: 0;
  border-top: none;
}

body:not(.app-slava-restraint) .model-node__progress {
  padding: 4px 10px;
  border-top: 1px solid #2a2a2a;
}

body:not(.app-slava-restraint) .model-node__progress-bar {
  height: 2px;
  background: #2196F3;
  border-radius: 1px;
  transition: width 0.3s ease;
}

body:not(.app-slava-restraint) .model-node__preview-text {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: #aaa;
  max-height: 120px;
  overflow-y: auto;
  white-space: break-spaces;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

body:not(.app-slava-restraint) .model-node__preview-text--streaming {
  border-color: #2196F3;
  color: #ccc;
}

body:not(.app-slava-restraint) .model-node__preview-text--streaming::after {
  content: '\25AE';
  animation: blink-cursor 0.8s step-end infinite;
  color: #2196F3;
  margin-left: 1px;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---------- Inline textarea (text-input nodes) ---------- */

body:not(.app-slava-restraint) .model-node__inline-textarea {
  padding: 6px 8px;
  border-top: 1px solid #2a2a2a;
}

body:not(.app-slava-restraint) .model-node__textarea {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 72px;
  max-height: 200px;
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 6px 8px;
  color: #ccc;
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

body:not(.app-slava-restraint) .model-node__textarea:focus {
  outline: none;
  border-color: #555;
  box-shadow: none;
}

body:not(.app-slava-restraint) .model-node__textarea::placeholder {
  color: #444;
}

body:not(.app-slava-restraint) .model-node__enhance {
  margin-top: 6px;
  width: 100%;
  padding: 5px 0;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  color: #999;
  font-size: 10px;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

body:not(.app-slava-restraint) .model-node__enhance:hover {
  background: #242424;
  border-color: #3a3a3a;
  color: #ddd;
}

/* ---------- Reroute node (minimal dot) ---------- */

body:not(.app-slava-restraint) .reroute-node {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #444;
  border: 2px solid #666;
  position: relative;
  cursor: crosshair;
}

body:not(.app-slava-restraint) .reroute-node:hover {
  background: #555;
  border-color: #888;
}

.reroute-node__handle {
  width: 8px !important;
  height: 8px !important;
  background: transparent !important;
  border: none !important;
  min-width: 8px !important;
  min-height: 8px !important;
}

body:not(.app-slava-restraint) .dynamic-node__model-badge {
  padding: 2px 8px;
  margin: 0 8px 4px;
  font-size: 10px;
  color: #aaa;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'SF Mono', 'Menlo', monospace;
}

/* Mesh 3D Preview */
.mesh-preview {
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

body:not(.app-slava-restraint) .mesh-preview {
  min-height: 150px;
  border-radius: 4px;
  background: #161616;
}

body:not(.app-slava-restraint) .mesh-preview__viewer {
  width: 100%;
  height: 150px;
  background: #161616;
}

body:not(.app-slava-restraint) .mesh-preview__placeholder {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  pointer-events: none;
}

body:not(.app-slava-restraint) .mesh-preview--loading .mesh-preview__placeholder,
body:not(.app-slava-restraint) .mesh-preview--error .mesh-preview__placeholder {
  display: grid;
}

body:not(.app-slava-restraint) .mesh-preview__mesh {
  width: 76px;
  height: 50px;
  border-radius: 3px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.20) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.20) 1px, transparent 1px);
  background-size: 10px 10px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
  opacity: 0.72;
  transform: perspective(150px) rotateX(58deg) rotateZ(-12deg);
}

body:not(.app-slava-restraint) .mesh-preview__hud {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #aaa;
  font-family: monospace;
  font-size: 10px;
  text-transform: uppercase;
}

/* Full-screen modal overlay */
.mesh-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body:not(.app-slava-restraint) .mesh-modal-overlay {
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
}

.mesh-modal {
  position: relative;
  width: 80vw;
  height: 80vh;
  overflow: hidden;
}

body:not(.app-slava-restraint) .mesh-modal {
  background: #1a1a1a;
  border-radius: 8px;
  border: 1px solid #333;
}

.mesh-modal__viewer {
  width: 100%;
  height: 100%;
}

body:not(.app-slava-restraint) .mesh-modal__viewer {
  background: #161616;
}

.mesh-modal__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

body:not(.app-slava-restraint) .mesh-modal__fallback {
  background: #161616;
}

body:not(.app-slava-restraint) .mesh-modal__fallback .mesh-preview__mesh {
  width: 180px;
  height: 118px;
  background-size: 18px 18px;
}

.mesh-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 24px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

body:not(.app-slava-restraint) .mesh-modal__close {
  z-index: 10001;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #555;
  border-radius: 50%;
  color: #fff;
}

body:not(.app-slava-restraint) .mesh-modal__close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.mesh-modal__info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body:not(.app-slava-restraint) .mesh-modal__info {
  background: rgba(0, 0, 0, 0.7);
}

body:not(.app-slava-restraint) .mesh-modal__format {
  color: #999;
  font-size: 13px;
  font-family: monospace;
}

.mesh-modal__download {
  padding: 6px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

body:not(.app-slava-restraint) .mesh-modal__download {
  background: #00BCD4;
  color: #000;
  border: none;
  border-radius: 4px;
}

body:not(.app-slava-restraint) .mesh-modal__download:hover {
  background: #00E5FF;
}

/* ---------- New structural wrappers (Flora-paradigm shells) ----------
 * Added 2026-05-04 alongside the Slava — Restraint skin exploration.
 * These elements are present on every node but invisible by default —
 * skins that want them (currently slava-restraint) opt into rendering
 * them. The .model-node__card wrapper exists so a skin can move the
 * card visual onto a child element instead of .model-node directly,
 * letting the type label and settings bar float OUTSIDE the card.
 *
 * Default + Hermes skins are unchanged: type-label and settings-bar
 * stay hidden, .model-node__card is transparent (the existing .model-node
 * background still paints the card). */
.model-node__type-label,
.model-node__settings-bar,
.model-node__media-toolbar {
  display: none;
}

.model-node__card {
  display: contents;  /* skipped in layout — children participate in .model-node's flow */
}
