/* Studio 3D — Blender-like modeling viewport */

#panel-modeler.panel.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
}

.mod-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0.5rem 0.65rem 0.85rem;
  color: #e4e2ec;
  background: #1a1a1e;
}

.mod-top {
  flex: 0 0 auto;
  padding: 0.35rem 0.25rem 0.5rem;
}

.mod-top h2 {
  margin: 0 0 0.2rem;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f0ebe3;
}

.mod-hint {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: rgba(200, 195, 210, 0.65);
  max-width: 52rem;
}

/* Studio workspace tabs (3D | UV Editor) */
.mod-workspace-tabs {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
  padding: 0.2rem;
  border-radius: 10px;
  background: #121216;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: fit-content;
  max-width: 100%;
}

.mod-ws-tab {
  min-height: 32px;
  padding: 0.3rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(200, 198, 215, 0.75);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.mod-ws-tab:hover {
  color: #eee;
  background: rgba(255, 255, 255, 0.05);
}

.mod-ws-tab.is-active {
  background: #3d4a78;
  border-color: rgba(140, 160, 220, 0.45);
  color: #fff;
}

.mod-workspace {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.mod-workspace.is-active {
  display: flex;
}

.mod-workspace[hidden] {
  display: none !important;
}

/* UV Editor dock */
.mod-uv-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem 0.45rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #25252b;
  margin-bottom: 0.45rem;
}

.mod-uv-toolbar input[type="file"] {
  max-width: 11rem;
  font-size: 0.7rem;
  color: rgba(200, 198, 210, 0.9);
}

.mod-uv-body {
  display: flex;
  flex: 1;
  min-height: 420px;
  gap: 0.45rem;
}

.mod-uv-sidebar {
  flex: 0 0 220px;
  min-width: 180px;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: auto;
}

.mod-uv-mesh-name,
.mod-uv-info {
  font-size: 0.78rem;
  line-height: 1.35;
  color: #d8d6e2;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1a1a20;
  min-height: 1.6rem;
}

.mod-uv-canvas-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #121218;
}

#mod-uv-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  touch-action: none;
  cursor: crosshair;
}

.mod-uv-hud {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(12, 12, 16, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.72rem;
  color: rgba(220, 218, 230, 0.9);
  pointer-events: none;
}

.mod-keys-uv {
  margin: 0.35rem 0 0;
}

.mod-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem 0.45rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #25252b;
  margin-bottom: 0.45rem;
}

.mod-tool-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  padding-right: 0.45rem;
  margin-right: 0.2rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.mod-tool-group:last-child {
  border-right: none;
}

.mod-axis-hint {
  font-size: 0.65rem;
  opacity: 0.55;
  font-weight: normal;
}
.mod-box-select {
  position: absolute;
  border: 1px solid rgba(120, 180, 255, 0.85);
  background: rgba(80, 140, 255, 0.12);
  pointer-events: none;
  z-index: 20;
  box-sizing: border-box;
}
.mod-mini-hint {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: rgba(200, 195, 210, 0.55);
}
.mod-props textarea {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  padding: 0.35rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1c1c22;
  color: #e8e6f0;
  font: inherit;
  font-size: 0.72rem;
  line-height: 1.35;
}
.mod-shot-preview {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0d0d10;
}
.mod-num-row {
  display: flex;
  gap: 0.25rem;
  width: 100%;
}
.mod-num-row input {
  flex: 1;
  min-width: 0;
  max-width: 4.2rem;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1c1c22;
  color: #e8e6f0;
  font-size: 0.72rem;
}
.mod-props select {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1c1c22;
  color: #e8e6f0;
  font-size: 0.75rem;
}
.mod-axis-btn.is-active {
  background: #4a6a9a;
  border-color: rgba(140, 180, 255, 0.45);
  color: #fff;
}
.mod-btn {
  min-height: 30px;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #32323a;
  color: #e8e6f0;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.mod-btn:hover {
  background: #3c3c46;
  border-color: rgba(160, 170, 220, 0.35);
}

.mod-btn.is-active {
  background: #4a5a8a;
  border-color: rgba(140, 160, 220, 0.55);
  color: #fff;
}

.mod-btn.accent {
  background: #3d4a78;
  border-color: rgba(140, 160, 220, 0.45);
}

.mod-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mod-label {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(160, 158, 175, 0.75);
  margin-right: 0.15rem;
}

.mod-body {
  display: flex;
  flex: 1;
  min-height: 420px;
  gap: 0.45rem;
}

.mod-sf-dock {
  flex: 0 0 min(420px, 42vw);
  min-width: 280px;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 10px;
  border: 1px solid rgba(140, 160, 220, 0.35);
  background: #14141a;
  overflow: hidden;
}

.mod-sf-dock[hidden] {
  display: none !important;
}

.mod-sf-dock-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  padding: 0.4rem 0.55rem;
  background: #1e2030;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
}

.mod-sf-dock-bar strong {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e0e4f5;
}

.mod-sf-dock-note {
  flex: 1 1 auto;
  font-size: 0.7rem;
  color: rgba(160, 165, 190, 0.75);
}

.mod-sf-dock-mount {
  flex: 1 1 auto;
  min-height: 360px;
  position: relative;
  background: #0c0c10;
}

.mod-sf-dock-mount .mod-sf-iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
  background: #0c0c10;
}

.mod-sidebar {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
}

.mod-panel {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #222228;
  padding: 0.45rem 0.5rem;
  min-height: 0;
}

.mod-panel h3 {
  margin: 0 0 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(180, 175, 195, 0.8);
  font-weight: 600;
}

.mod-outliner {
  flex: 1 1 auto;
  overflow: auto;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mod-outliner-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #d8d6e0;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.mod-outliner-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mod-outliner-item.is-selected {
  background: rgba(80, 100, 160, 0.35);
  border-color: rgba(140, 160, 220, 0.4);
}

.mod-outliner-empty {
  font-size: 0.78rem;
  color: rgba(150, 148, 165, 0.6);
  padding: 0.35rem;
}

.mod-props {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mod-prop-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.mod-prop-row label {
  font-size: 0.68rem;
  color: rgba(160, 158, 175, 0.85);
}

.mod-prop-row input[type="text"],
.mod-prop-row input[type="number"],
.mod-prop-row select {
  min-height: 28px;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1a1a20;
  color: #eee;
  font: inherit;
  font-size: 0.8rem;
}

.mod-prop-row input[type="color"] {
  width: 100%;
  height: 32px;
  padding: 0.15rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1a1a20;
  cursor: pointer;
}

.mod-prop-row input[type="range"] {
  width: 100%;
  accent-color: #7a8fd4;
}

.mod-prop-val {
  float: right;
  color: rgba(180, 185, 210, 0.9);
  font-variant-numeric: tabular-nums;
}

.mod-mat-mode {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mod-mat-mode-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem !important;
  color: rgba(210, 208, 220, 0.95) !important;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.mod-mat-mode-opt:has(input:checked) {
  border-color: rgba(122, 143, 212, 0.55);
  background: rgba(122, 143, 212, 0.15);
}

.mod-prop-row input[type="file"] {
  width: 100%;
  font-size: 0.72rem;
  color: rgba(200, 198, 210, 0.9);
}

.mod-mat-img-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.mod-mat-img-preview {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #121218;
}

.mod-viewport-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0d0d10;
}

#mod-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  touch-action: none;
}

.mod-css-layer {
  overflow: hidden;
}

.mod-sf-frame {
  width: 1280px;
  height: 800px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px #2a2e3a,
    0 0 0 6px #12141a,
    0 24px 60px rgba(0, 0, 0, 0.55);
  background: #0c0c10;
  display: flex;
  flex-direction: column;
}

.mod-sf-chrome {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  background: linear-gradient(180deg, #2a2e3c 0%, #1c1e28 100%);
  color: #c8c6d4;
  font: 600 13px/1.2 system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mod-sf-chrome em {
  font-style: normal;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(160, 165, 190, 0.75);
}

.mod-sf-iframe {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0a0a0e;
  display: block;
}

/* Keeps Spellforge alive for canvas capture when not in Plane UI mode */
.mod-sf-offscreen-host {
  position: fixed !important;
  left: -12000px !important;
  top: 0 !important;
  width: 1280px !important;
  height: 800px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  z-index: -1 !important;
}

.mod-sf-offscreen-host .mod-sf-iframe {
  width: 1280px !important;
  height: 800px !important;
}

/* Full-page embed for Spellforge Plane iframe */
html.embed-spellforge,
body.embed-spellforge {
  margin: 0 !important;
  padding: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
  background: #0c0c10 !important;
}

body.embed-spellforge .site-header,
body.embed-spellforge .site-tabs,
body.embed-spellforge .site-footer,
body.embed-spellforge .money-hud,
body.embed-spellforge .xai-credits-hud,
body.embed-spellforge footer,
body.embed-spellforge .panel:not(#panel-spellforge) {
  display: none !important;
}

body.embed-spellforge #panel-spellforge.panel,
body.embed-spellforge #panel-spellforge {
  display: block !important;
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: auto !important;
  z-index: 9999 !important;
  background: #0c0c10 !important;
}

.mod-viewport-hud {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  pointer-events: none;
  font-size: 0.68rem;
  color: rgba(200, 200, 220, 0.55);
  font-variant-numeric: tabular-nums;
}

.mod-status {
  min-height: 1.1rem;
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: rgba(180, 185, 210, 0.75);
}

.mod-status.err {
  color: #f0a8a8;
}

.mod-status.ok {
  color: #a8dcc0;
}

.mod-keys {
  font-size: 0.72rem;
  color: rgba(150, 148, 165, 0.7);
  margin: 0.25rem 0 0;
}

@media (max-width: 900px) {
  .mod-body {
    flex-direction: column;
  }
  .mod-sidebar {
    flex: 0 0 auto;
    max-height: none;
  }
  .mod-outliner {
    max-height: 140px;
  }
  #mod-canvas {
    min-height: 360px;
  }
}
