/* Dream Workshop editor — liminal control room */

html, body { height: 100%; overflow: hidden; }

.editor {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 1fr;
  height: calc(100vh - 57px);
  min-height: 0;
}

.editor > .rail,
.editor > .panel { min-height: 0; }

/* ---- left rail ---- */
.rail {
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
  padding: 16px 12px;
}

.rail .group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  padding: 16px 10px 8px;
}

.rail .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.rail .nav-item:hover { background: var(--hover); color: var(--text-dim); }

.rail .nav-item.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

.rail .nav-item .n { font-family: var(--mono); font-size: 10px; color: var(--text-faint); width: 18px; }
.rail .nav-item .count { margin-left: auto; font-size: 10px; color: var(--text-faint); font-family: var(--mono); }

/* ---- main panel ---- */
.panel.flow-panel {
  overflow: hidden;
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel:not(.flow-panel) {
  overflow-y: auto;
  padding: 16px 18px 40px;
}

.panel.panel-error {
  overflow-y: auto;
  padding: 16px 18px 40px;
  position: relative;
  z-index: 1;
}

.panel.flow-panel .flow-studio {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  flex: 1;
}

.panel.flow-panel .panel-head,
.panel.flow-panel .panel-sub,
.panel.flow-panel .flow-header { flex: none; }

.panel.flow-panel .panel-head { margin-bottom: 4px; }
.panel.flow-panel .panel-sub { margin-bottom: 8px; }

.flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  margin-bottom: 4px;
  min-height: 28px;
  position: relative;
  z-index: 40;
}

.flow-header h2 {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text);
  margin: 0;
  flex: none;
}

.flow-header .flow-status-text {
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }

.panel-head h2 {
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--text);
}

.panel-head .hint { color: var(--text-faint); font-size: 13px; font-weight: 300; letter-spacing: 0; text-transform: none; }

.panel-sub {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 300;
  margin: 0 0 24px;
  line-height: 1.6;
  max-width: 720px;
  letter-spacing: 0;
  text-transform: none;
}

.panel-inner { max-width: 920px; }

.panel-inner > .card + .card { margin-top: 16px; }

.section-actions { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

/* item list */
.list { display: flex; flex-direction: column; gap: 10px; }

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: border-color var(--ease);
}

.item.selected { border-color: var(--accent); }

.item-head { display: flex; align-items: center; gap: 12px; }
.item-head .grow { flex: 1; }
.item-title { font-weight: 400; letter-spacing: 0.04em; }
.item-meta { font-size: 11px; color: var(--text-faint); letter-spacing: 0.04em; }
.item-actions { display: flex; gap: 6px; }
.drag-handle { cursor: grab; color: var(--text-faint); font-size: 18px; padding: 0 4px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- hotspot canvas ---- */
.hotspot-stage {
  position: relative;
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.hotspot-stage img { display: block; width: 100%; height: auto; pointer-events: none; }

.hotspot-stage .empty-bg {
  aspect-ratio: 2 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 13px;
}

.hs-rect {
  position: absolute;
  border: 1px solid var(--accent-2);
  background: rgba(168, 161, 143, 0.1);
  border-radius: 2px;
  cursor: move;
}

.hs-rect.invisible-area {
  border-style: dashed;
  border-color: var(--text-faint);
  background: rgba(255, 255, 255, 0.03);
}

.hs-rect.selected {
  border-color: var(--accent);
  background: rgba(122, 132, 113, 0.12);
}

.hs-rect .lbl {
  position: absolute;
  top: -22px;
  left: 0;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-1);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 2px;
  white-space: nowrap;
  color: var(--text-faint);
}

.hs-rect .grip {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 1px;
  cursor: nwse-resize;
}

.stage-hint { font-size: 13px; color: var(--text-faint); margin: 10px 0 16px; font-weight: 300; }

/* ---- flow diagram ---- */
.flow-studio { max-width: none !important; }

.flow-steps-wrap {
  flex: none;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.flow-steps-wrap summary {
  cursor: pointer;
  user-select: none;
  color: var(--text-faint);
  margin-bottom: 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
}

.flow-steps-wrap[open] summary { margin-bottom: 6px; color: var(--text-dim); }

.flow-steps {
  margin: 0 0 6px;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
  flex: none;
  font-weight: 300;
  letter-spacing: 0;
  text-transform: none;
}

.flow-steps li { margin-bottom: 2px; }
.flow-steps li:last-child { margin-bottom: 0; }

.flow-status-text { font-size: 10px; color: var(--text-faint); letter-spacing: 0.04em; }

.flow-add-wrap { position: relative; flex: none; }

.flow-add-menu[hidden] { display: none !important; }

.flow-add-menu:not([hidden]) {
  position: absolute;
  top: 0;
  left: calc(100% + 8px);
  z-index: 60;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 240px;
  max-height: min(70vh, 420px);
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.flow-add-menu.flow-add-menu--open {
  position: fixed;
  z-index: 10000;
}

.flow-add-menu button {
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 9px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--ease), color var(--ease);
}

.flow-add-menu button strong { font-weight: 400; letter-spacing: 0.04em; color: var(--text); }
.flow-add-menu button small { font-size: 11px; color: var(--text-faint); font-weight: 300; }
.flow-add-menu button:hover { background: var(--hover); }

.topbar-edit-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  margin: 0 4px;
}

.topbar-edit-actions .btn.sm {
  padding: 6px 11px;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.flow-warn {
  border-color: rgba(138, 125, 98, 0.35);
  margin-bottom: 10px;
  color: #a89870;
  font-size: 13px;
  flex: none;
  font-weight: 300;
}

.flow-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 36%) minmax(0, 64%);
  gap: 12px;
  overflow: hidden;
}

.flow-col-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.flow-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--panel);
  overflow: hidden;
  isolation: isolate;
}

.flow-map-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(8, 8, 8, 0.94) 0%, rgba(8, 8, 8, 0.72) 70%, transparent 100%);
  pointer-events: none;
}

.flow-map-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  flex: none;
}

.flow-map-bar .flow-add-wrap { pointer-events: auto; }

.flow-map-bar .btn.sm {
  padding: 5px 10px;
  font-size: 10px;
}

.flow-preview-slot { min-width: 0; min-height: 0; overflow: hidden; }

.flow-canvas { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
.flow-svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.flow-link-temp { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

.flow-inspector {
  flex: 0 0 auto;
  height: min(280px, 36%);
  max-height: 280px;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.flow-wrap > .flow-wrap-label,
.flow-map-bar .flow-wrap-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  pointer-events: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-wrap .flow-add-menu:not([hidden]) {
  top: calc(100% + 6px);
  left: 0;
  right: auto;
}

.flow-insp-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 14px 14px;
}

.flow-insp-empty { color: var(--text-dim); font-size: 13px; line-height: 1.6; padding-top: 8px; font-weight: 300; }

.flow-inspector > .flow-wrap-label {
  position: static;
  padding: 12px 14px 6px;
  flex: none;
}

.flow-insp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-top: 4px; }

.flow-insp-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 2px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-faint);
}

.flow-insp-type.room { color: var(--accent); border-color: rgba(122, 132, 113, 0.3); }
.flow-insp-type.puzzle { color: var(--warn); border-color: rgba(138, 125, 98, 0.3); }
.flow-insp-type.video { color: var(--accent-2); border-color: rgba(168, 161, 143, 0.3); }
.flow-insp-type.finale { color: var(--ok); border-color: rgba(106, 117, 98, 0.3); }
.flow-insp-type.eye { color: #9aa8c8; border-color: rgba(154, 168, 200, 0.35); }
.flow-insp-type.dream { color: var(--text-dim); }

.flow-insp-body .field { margin-bottom: 12px; }

.flow-details { margin-top: 10px; font-size: 13px; color: var(--text-dim); font-weight: 300; }
.flow-details summary { cursor: pointer; margin-bottom: 8px; color: var(--text-faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.flow-preview {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.flow-node {
  position: absolute;
  min-width: 140px;
  max-width: 180px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 28px 10px 12px;
  cursor: grab;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 3;
  transition: border-color var(--ease);
}

.flow-node.selected { border-color: var(--accent); }

.flow-node .ntype {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.flow-node .nlabel { font-weight: 400; margin-top: 3px; word-break: break-word; letter-spacing: 0.02em; }

.flow-node.room { border-left: 2px solid var(--accent); }
.flow-node.puzzle { border-left: 2px solid var(--warn); }
.flow-node.video { border-left: 2px solid var(--accent-2); }
.flow-node.text { border-left: 2px solid #9a9588; }
.flow-node.audio { border-left: 2px solid #8a8278; }
.flow-node.apparition { border-left: 2px solid var(--warn); }
.flow-node.entity { border-left: 2px solid var(--danger); }
.flow-node.jumpscare { border-left: 2px solid var(--danger); }
.flow-node.prop { border-left: 2px solid var(--text-faint); }
.flow-node.eye { border-left: 2px solid #9aa8c8; }
.flow-node.dream { border-left: 2px solid var(--text-dim); min-width: 120px; }
.flow-node.finale { border-left: 2px solid var(--ok); }
.flow-node.unreachable { outline: 1px solid var(--danger); opacity: 0.55; }
.flow-node:hover { border-color: rgba(255, 255, 255, 0.14); }

.flow-port {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--accent);
  cursor: crosshair;
  z-index: 2;
}

.flow-port.out { right: -5px; top: 50%; transform: translateY(-50%); }
.flow-port.in { left: -5px; top: 50%; transform: translateY(-50%); border-color: var(--text-faint); }

.port-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--accent); vertical-align: middle; }
.port-dot.out { background: var(--accent); }

.flow-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

.flow-badges span {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  padding: 2px 6px;
  border-radius: 2px;
  color: var(--text-faint);
  border: 1px solid var(--line-soft);
}

.flow-edge { cursor: pointer; }

.flow-connect-menu {
  position: fixed;
  z-index: 200;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px;
  box-shadow: var(--shadow);
  min-width: 180px;
}

.flow-connect-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 10px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.04em;
  transition: background var(--ease), color var(--ease);
}

.flow-connect-menu button:hover { background: var(--hover); color: var(--text); }

.live-preview {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.live-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.live-preview-head strong {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 400;
}

.live-preview-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.live-preview-status { font-size: 10px; color: var(--text-faint); font-family: var(--mono); letter-spacing: 0.04em; }

.live-preview-hint {
  flex: none;
  margin: 0 12px 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 300;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.preview-edit-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.sheet-grid {
  display: grid;
  gap: 1px;
  margin-top: 8px;
  max-width: 200px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sheet-grid span {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-faint);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line-soft);
}

.live-preview iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #000;
  min-height: 0;
}

@media (max-width: 1100px) {
  .flow-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 34vh) minmax(380px, 1fr);
    overflow-y: auto;
  }
  .flow-col-left { max-height: 34vh; }
  .flow-inspector { max-height: 140px; }
}

@media (max-width: 1100px) {
  .flow-main { grid-template-columns: 1fr; }
  .flow-inspector { max-height: 360px; }
}

.preview-frame {
  width: 100%;
  aspect-ratio: 16/9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
}

.badge-saved { font-size: 11px; color: var(--text-faint); font-family: var(--mono); letter-spacing: 0.04em; }
.badge-saved.dirty { color: var(--warn); }
.badge-saved.saving { color: var(--accent-2); }

.pill-id {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--text-dim);
}

.help { font-size: 13px; color: var(--text-faint); margin-top: 6px; font-weight: 300; }

.boot-msg { padding: 16px 12px; font-size: 14px; line-height: 1.55; font-weight: 300; }
.boot-panel { max-width: 520px; }
.boot-panel h2 { font-size: 13px; margin-bottom: 10px; letter-spacing: 0.14em; }

.boot-panel code,
.boot-code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: inline-block;
  color: var(--text-dim);
}

.boot-error {
  max-width: 560px;
  border: 1px solid rgba(110, 79, 79, 0.35);
  border-radius: var(--radius);
  background: rgba(110, 79, 79, 0.08);
  padding: 22px 24px;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.boot-error h2 { color: var(--danger-text); margin-bottom: 10px; font-size: 12px; }

.boot-error .btn { pointer-events: auto; cursor: pointer; margin-top: 12px; }

.file-warn {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.file-warn-box {
  max-width: 520px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow);
}

.file-warn-box h1 { margin: 0 0 14px; font-size: 13px; letter-spacing: 0.16em; }

.file-warn-box pre {
  font-family: var(--mono);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 0;
  text-align: left;
  color: var(--text-dim);
}

.thumb {
  width: 64px;
  height: 36px;
  border-radius: 2px;
  background: var(--bg-3);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
  flex: none;
}

.media-preview {
  max-width: 320px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-top: 8px;
  display: block;
}

audio.media-preview { width: 320px; height: 38px; }

/* ---- template picker ---- */
.template-picker { max-width: none; height: 100%; display: flex; flex-direction: column; min-height: 0; }

.template-picker-head { flex: none; margin-bottom: 14px; }

.template-picker-head h2 {
  font-size: 12px;
  letter-spacing: 0.16em;
  margin-bottom: 6px;
}

.template-picker-sub {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 300;
  margin: 0;
  letter-spacing: 0;
  text-transform: none;
}

.template-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 42%);
  gap: 14px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-content: start;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.template-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--ease), opacity var(--ease);
  color: inherit;
  font: inherit;
}

.template-card:hover { border-color: rgba(255, 255, 255, 0.14); }
.template-card.active { border-color: var(--accent); }

.template-cover {
  aspect-ratio: 16 / 9;
  background: var(--bg-3) center / cover no-repeat;
  border-bottom: 1px solid var(--line);
}

.template-card-body { padding: 12px 14px 14px; }

.template-source { margin-bottom: 6px; }

.template-name {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 4px;
}

.template-desc {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.45;
  font-weight: 300;
}

.template-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.template-preview-head {
  flex: none;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.template-preview-head strong {
  display: block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 400;
  margin-bottom: 4px;
}

.template-preview iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #000;
  min-height: 280px;
}

.template-preview-actions {
  flex: none;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1000px) {
  .template-layout { grid-template-columns: 1fr; grid-template-rows: 1fr minmax(280px, 40vh); }
}

.template-studio { padding-bottom: 48px; }

.library-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.library-section h3 {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.library-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: border-color var(--ease);
}

.library-card:hover { border-color: rgba(255, 255, 255, 0.14); }

.library-thumb {
  aspect-ratio: 2 / 1;
  background: var(--bg-3) center / cover no-repeat;
  border-bottom: 1px solid var(--line);
}

.library-label {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.library-audio {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text-dim);
  font: inherit;
  transition: border-color var(--ease), background var(--ease);
}

.library-audio:hover { border-color: rgba(255, 255, 255, 0.14); background: var(--hover); }
.library-audio span { font-size: 13px; color: var(--text); }
.library-audio small { font-size: 11px; color: var(--text-faint); }

.lib-pick {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.lib-pick select { flex: 1; min-width: 160px; }

