/* ============================================================
   Mythox - Builder Studio Workspace (Phase 6.5)
   ============================================================ */

.bld-ws-wrap {
  max-width: min(1320px, calc(100vw - 36px));
}

.bld-ws {
  display: grid;
  grid-template-columns: minmax(320px, .72fr) minmax(420px, 1.28fr);
  gap: 16px;
  align-items: stretch;
}

.bld-ws-left,
.bld-ws-right {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), var(--surface-grad-2));
}

.bld-ws-left {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(760px, calc(100vh - 210px));
  overflow: auto;
}

.bld-ws-right {
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr);
  min-height: min(780px, calc(100vh - 180px));
}

.bld-ws-card,
.bld-question-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  padding: 16px;
}

.bld-question-stack {
  display: grid;
  gap: 12px;
  margin: 12px 0 6px;
}

.bld-question-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bld-question-head span {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
}

.bld-question-head h3 {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.25;
}

.bld-auto-answer {
  flex: 0 0 auto;
  padding: 7px 11px;
  font-size: 12px;
}

.bld-mode-picker {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink-2, var(--surface));
  margin: 0 0 10px;
}

.bld-mode-pill {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
}

.bld-mode-pill:hover {
  color: var(--ivory);
  border-color: var(--line);
}

.bld-mode-pill.on {
  background: var(--ivory);
  border-color: var(--ivory);
  color: var(--ink, #090A0C);
}

.bld-mode-note {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 14px;
  line-height: 1.45;
  min-height: 36px;
}

.bld-ws-mobile-tabs {
  display: none;
}

.bld-ws-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 12px;
}

.bld-ws-preview-head span {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.bld-ws-preview-head b {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ivory);
}

.bld-ws-preview-head em {
  flex: 0 1 auto;
  min-height: 18px;
  color: var(--gold);
  font-style: normal;
  font-size: 12px;
  text-align: right;
}

.bld-edit-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.bld-edit-toggle.on {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}

.bld-edit-apply[hidden] {
  display: none;
}

.bld-ws-framebox {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--gold) 10%, transparent), transparent 46%),
    repeating-linear-gradient(90deg, transparent, transparent 22px, color-mix(in srgb, var(--ivory) 5%, transparent) 23px),
    var(--ink-2, var(--surface));
}

.bld-ws-framebox iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  opacity: 0;
  pointer-events: auto;
  transition: opacity .18s ease;
}

.bld-ws-framebox.has-preview iframe {
  opacity: 1;
}

.bld-ws-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.bld-edit-popover,
.bld-edit-enable {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 3;
  width: min(330px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 94%, black);
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.bld-edit-pop-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.bld-edit-pop-head b {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  color: var(--ivory);
}

.bld-edit-x {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.bld-edit-popover p,
.bld-edit-enable p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.bld-edit-popover .bld-token,
.bld-edit-popover .bld-goal {
  width: 100%;
  box-sizing: border-box;
}

.bld-edit-ai {
  min-height: 82px;
}

.bld-ws-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  color: var(--gold);
  font-weight: 900;
}

.bld-ws-empty b {
  color: var(--ivory);
  font-size: 15px;
}

.bld-ws-empty p {
  margin: 0;
  max-width: 34ch;
  font-size: 13px;
  line-height: 1.5;
}

.bld-ws .bld-card {
  margin-bottom: 0;
}

.bld-ws .bld-feed {
  max-height: 220px;
}

@media (max-width: 860px) {
  .bld-ws-wrap {
    max-width: 100%;
  }

  .bld-ws-mobile-tabs {
    display: inline-flex;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--ink-2, var(--surface));
    margin: 0 0 12px;
  }

  .bld-ws-tab {
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 14px;
    cursor: pointer;
  }

  .bld-ws-tab.on {
    background: var(--ivory);
    color: var(--ink, #090A0C);
  }

  .bld-ws {
    display: block;
  }

  .bld-ws-left,
  .bld-ws-right {
    max-height: none;
    min-height: 0;
  }

  .bld-ws-right {
    grid-template-rows: auto minmax(420px, 62vh);
  }

  .bld-ws-chat .bld-ws-right,
  .bld-ws-preview .bld-ws-left {
    display: none;
  }
}

@media (max-width: 560px) {
  .bld-ws-left,
  .bld-ws-right,
  .bld-question-card {
    border-radius: 12px;
  }

  .bld-question-head {
    display: grid;
  }

  .bld-auto-answer {
    justify-self: start;
  }

  .bld-mode-picker {
    width: 100%;
  }

  .bld-mode-pill {
    flex: 1;
  }
}
