/* =========================================================
   FiveM Atlas - Bot Builder v3.8 FULL FIXED CSS
   Replace: public_html/tools/bot-builder.css
   Fixes: right panel scrolling, template card sizing, library cards,
   flow action buttons, readable settings, responsive layout.
========================================================= */

:root {
  --bg: #050914;
  --bg-soft: #071022;
  --panel: rgba(12, 22, 39, 0.96);
  --panel-2: rgba(15, 29, 51, 0.96);
  --panel-3: rgba(20, 42, 75, 0.95);
  --field: rgba(3, 9, 23, 0.78);
  --border: rgba(129, 164, 221, 0.24);
  --border-soft: rgba(129, 164, 221, 0.14);
  --border-strong: rgba(56, 189, 248, 0.48);
  --text: #f3f7ff;
  --muted: #9fb1ca;
  --blue: #38bdf8;
  --blue-2: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #facc15;
  --purple: #a855f7;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(37, 99, 235, 0.15), transparent 34%),
    radial-gradient(circle at 90% 20%, rgba(56, 189, 248, 0.08), transparent 28%),
    var(--bg);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

button,
input,
select,
textarea {
  outline: none;
}

/* =====================
   NAV
===================== */

.atlas-nav {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(3, 8, 18, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: inline-flex;
  align-items: center;
  color: #fff;
  font-size: 21px;
  font-weight: 900;
  text-decoration: none;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.logo::before {
  content: "";
  width: 11px;
  height: 11px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.9);
}

.atlas-nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
}

.atlas-nav-links a {
  color: #d7e1f3;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.atlas-nav-links a.active,
.atlas-nav-links a:hover {
  color: #fff;
}

/* =====================
   MAIN APP LAYOUT
===================== */

.builder-shell {
  height: calc(100vh - 64px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(410px, 460px) minmax(620px, 1fr) minmax(380px, 460px);
  gap: 16px;
  padding: 16px;
  overflow: hidden;
}

.panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.left-panel,
.right-panel,
.flow-canvas,
.template-modal {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar,
.flow-canvas::-webkit-scrollbar,
.template-modal::-webkit-scrollbar,
#output::-webkit-scrollbar,
.setting-textarea::-webkit-scrollbar {
  width: 8px;
}

.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb,
.flow-canvas::-webkit-scrollbar-thumb,
.template-modal::-webkit-scrollbar-thumb,
#output::-webkit-scrollbar-thumb,
.setting-textarea::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.left-panel,
.right-panel {
  height: 100%;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overflow-x: hidden;
}

/* =====================
   SHARED HEADINGS
===================== */

.panel-heading {
  padding: 18px 20px 14px;
}

.panel-heading.compact {
  padding: 16px 16px 10px;
}

.panel-heading h1,
.panel-heading h2,
.builder-topbar h1 {
  margin: 0;
  color: #fff;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.panel-heading h2,
.builder-topbar h1 {
  font-size: 22px;
}

.panel-heading p,
.builder-topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* =====================
   LEFT PANEL: TEMPLATES
===================== */

.collapsible-section {
  border-bottom: 1px solid var(--border);
}

.section-toggle {
  width: 100%;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, rgba(30, 64, 125, 0.7), rgba(12, 22, 39, 0.75));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  text-align: left;
}

.section-toggle strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.section-toggle small {
  display: block;
  margin-top: 4px;
  color: #b7cdf0;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 600;
}

.chevron {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--blue);
  background: rgba(3, 9, 23, 0.35);
}

.collapsible-section:not(.open) .section-body {
  display: none;
}

.template-list {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.template-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  width: 100%;
  min-height: 82px;
  padding: 13px;
  border-radius: 16px;
  border: 1px solid rgba(96, 165, 250, 0.24);
  background: linear-gradient(135deg, rgba(20, 42, 75, 0.88), rgba(7, 14, 29, 0.88));
  color: #fff;
  text-align: left;
  transition: 0.18s ease;
}

.template-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(37, 99, 235, 0.16);
}

.template-icon,
.block-icon {
  width: 52px;
  height: 52px;
  min-width: 52px;
  flex: 0 0 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.32);
  font-size: 22px;
  line-height: 1;
  overflow: hidden;
}

.template-title {
  display: block;
  max-width: 100%;
  color: #fff;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 900;
  white-space: normal;
  overflow-wrap: anywhere;
}

.template-meta {
  display: block;
  margin-top: 5px;
  color: #93c5fd;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
}

/* =====================
   LEFT PANEL: BLOCK LIBRARY
===================== */

.library-section {
  padding-bottom: 18px;
}

.search-input {
  width: calc(100% - 32px);
  height: 52px;
  margin: 0 16px 16px;
  padding: 0 16px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--field);
  color: #fff;
  font-size: 15px;
}

.search-input::placeholder {
  color: #7891b3;
}

.category-list {
  display: grid;
  gap: 12px;
  padding: 0 12px 20px;
}

.block-category {
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: rgba(7, 14, 29, 0.42);
}

.category-header {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  padding: 12px 16px;
  background: rgba(30, 64, 125, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: left;
}

.category-header span:first-child,
.category-header strong:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.category-count {
  min-width: 30px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: #dff6ff;
  background: rgba(14, 165, 233, 0.22);
  border: 1px solid rgba(56, 189, 248, 0.42);
  font-size: 13px;
  font-weight: 900;
}

.category-body {
  display: none;
  padding: 12px;
  gap: 12px;
}

.block-category.open .category-body {
  display: grid;
}

.library-block {
  width: 100%;
  min-height: 112px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(129, 164, 221, 0.22);
  background: rgba(9, 18, 36, 0.88);
  color: #fff;
  text-align: left;
  transition: 0.18s ease;
}

.library-block:hover {
  border-color: var(--border-strong);
  background: rgba(13, 32, 64, 0.88);
}

.block-text {
  min-width: 0;
  max-width: 100%;
}

.block-title {
  display: block;
  max-width: 100%;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 900;
  white-space: normal;
  overflow-wrap: anywhere;
}

.block-desc {
  display: block;
  margin-top: 6px;
  color: #b4c8e8;
  font-size: 14px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.block-type {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-top: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #c9f7ff;
  background: rgba(8, 145, 178, 0.18);
  border: 1px solid rgba(34, 211, 238, 0.4);
  font-size: 11px;
  line-height: 1.1;
  font-weight: 900;
  overflow-wrap: anywhere;
}

/* =====================
   CENTER PANEL
===================== */

.center-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.builder-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.topbar-actions,
.footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill,
.mini-btn,
.btn {
  border-radius: 12px;
  border: 1px solid var(--border);
  color: #eaf2ff;
  background: rgba(15, 23, 42, 0.82);
  font-weight: 800;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 13px;
  font-size: 13px;
}

.mini-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 13px;
}

.mini-btn.danger {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
}

.btn.primary {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #fff;
}

.btn.secondary:hover,
.mini-btn:hover {
  border-color: var(--border-strong);
}

.bot-config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.bot-config-grid input,
.bot-config-grid select,
.setting-control,
.setting-textarea {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--field);
  color: #fff;
  padding: 0 14px;
  font-size: 14px;
}

.bot-config-grid input::placeholder,
.setting-control::placeholder,
.setting-textarea::placeholder {
  color: #7e93b4;
}

.setting-textarea {
  min-height: 116px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.45;
}

.flow-canvas {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px;
  background-color: rgba(6, 12, 25, 0.64);
  background-image: radial-gradient(rgba(96, 165, 250, 0.2) 1px, transparent 1px);
  background-size: 24px 24px;
}

.empty-flow {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 2px dashed rgba(129, 164, 221, 0.28);
  border-radius: 22px;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.empty-flow h2 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 24px;
}

.empty-flow p {
  max-width: 480px;
  margin: 0;
  line-height: 1.4;
}

.flow-list {
  max-width: 820px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.flow-block {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(96, 165, 250, 0.3);
  background: linear-gradient(135deg, rgba(17, 34, 64, 0.96), rgba(9, 18, 36, 0.96));
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25);
}

.flow-block.selected {
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12), 0 18px 42px rgba(0, 0, 0, 0.28);
}

.flow-index {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.12);
  color: #dff6ff;
  font-weight: 900;
}

.flow-main {
  min-width: 0;
}

.flow-title {
  margin: 0;
  color: #fff;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.flow-desc {
  margin: 6px 0 0;
  color: #c7d7ed;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.flow-badge {
  display: inline-flex;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.13);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #c9f7ff;
  font-size: 11px;
  font-weight: 900;
}

.flow-actions {
  display: flex;
  gap: 6px;
}

.flow-actions button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(129, 164, 221, 0.24);
  background: rgba(3, 9, 23, 0.72);
  color: #eaf2ff;
  font-size: 14px;
  line-height: 1;
  font-weight: 900;
  padding: 0;
}

.flow-actions button:hover {
  border-color: var(--border-strong);
  background: rgba(56, 189, 248, 0.12);
}

.flow-actions button.delete:hover {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

.builder-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

#saveStatus {
  color: #86efac;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

/* =====================
   RIGHT PANEL - FIXED SCROLL
===================== */

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.settings-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(7, 14, 29, 0.5);
  overflow: visible;
}

.output-card {
  min-height: 360px;
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr);
  flex: 1 0 420px;
}

.row-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.settings-panel-empty {
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.settings-empty-icon {
  font-size: 30px;
  margin-bottom: 8px;
}

.settings-form {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.setting-group label {
  display: block;
  margin-bottom: 6px;
  color: #d7e5fa;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.variable-chips,
.custom-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 14px;
}

.var-chip {
  border: 1px solid rgba(56, 189, 248, 0.38);
  background: rgba(56, 189, 248, 0.1);
  color: #c9f7ff;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 900;
  white-space: nowrap;
}

#output {
  width: calc(100% - 32px);
  height: auto;
  min-height: 280px;
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(3, 9, 23, 0.78);
  color: #d8e6ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
}

/* =====================
   MODAL
===================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.modal-backdrop.open {
  display: flex;
}

.template-modal {
  position: relative;
  width: min(760px, 96vw);
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 24px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  background: linear-gradient(135deg, rgba(15, 29, 51, 0.98), rgba(5, 10, 22, 0.98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  padding: 28px;
}

.modal-close {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.modal-template-head {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 16px;
  align-items: center;
  padding-right: 44px;
}

.modal-template-head .template-icon {
  width: 64px;
  height: 64px;
  font-size: 28px;
}

.modal-template-head h2 {
  margin: 0;
  color: #fff;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.modal-template-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 22px;
}

.modal-box {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(7, 14, 29, 0.55);
}

.modal-box-wide {
  grid-column: 1 / -1;
}

.modal-box h3 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #c9f7ff;
}

.modal-box ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: #dce9ff;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  display: none;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-strong);
  color: #fff;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

/* =====================
   EXTRA COMPATIBILITY FIXES
   These catch older class names from earlier builder versions.
===================== */

.builder-layout {
  height: calc(100vh - 64px);
  min-height: 0;
  overflow: hidden;
}

.sidebar,
.settings-panel {
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overflow-x: hidden;
}

.block-card {
  width: 100%;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(129, 164, 221, 0.22);
  background: rgba(9, 18, 36, 0.88);
  color: #fff;
}

.block-card .icon,
.block-card .block-icon {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.32);
}

.block-card .text,
.block-card .block-text {
  min-width: 0;
}

.block-card .title,
.block-card .block-title {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.block-card .desc,
.block-card .block-desc {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.35;
  color: #b4c8e8;
  overflow-wrap: anywhere;
}

.block-card .type,
.block-card .block-type {
  display: inline-flex;
  margin-top: 10px;
}

/* =====================
   RESPONSIVE
===================== */

@media (max-width: 1450px) {
  .builder-shell {
    grid-template-columns: minmax(390px, 430px) minmax(580px, 1fr) minmax(360px, 420px);
  }
}

@media (max-width: 1350px) {
  .builder-shell {
    grid-template-columns: 380px minmax(540px, 1fr) 380px;
  }

  .bot-config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  html,
  body {
    overflow: auto;
  }

  .builder-shell {
    height: auto;
    min-height: calc(100vh - 64px);
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .left-panel,
  .right-panel,
  .center-panel {
    max-height: none;
    min-height: 520px;
    overflow: visible;
  }

  .right-panel {
    display: grid;
  }

  .flow-canvas {
    min-height: 520px;
  }
}

@media (max-width: 700px) {
  .atlas-nav {
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .atlas-nav-links {
    width: 100%;
    flex-wrap: wrap;
    gap: 12px;
  }

  .builder-shell {
    padding: 10px;
  }

  .builder-topbar,
  .builder-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .bot-config-grid,
  .setting-row,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .flow-block {
    grid-template-columns: 1fr;
  }

  .flow-actions {
    justify-content: flex-start;
  }
}

/* =========================================================
   v3.9 NIGHT BUILD ADDITIONS
   Workspace, embed preview, IF/ELSE visual hints
========================================================= */

.workspace-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.workspace-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.project-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.project-card {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 8px;
  align-items: stretch;
  border: 1px solid var(--border-soft);
  background: rgba(3, 9, 23, 0.55);
  border-radius: 14px;
  overflow: hidden;
}

.project-card.active {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12), 0 0 28px rgba(56, 189, 248, 0.08);
}

.project-open {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  min-width: 0;
}

.project-open strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-open span,
.project-empty {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.project-delete {
  border: 0;
  border-left: 1px solid var(--border-soft);
  background: rgba(239, 68, 68, 0.08);
  color: #fecaca;
  font-size: 18px;
  font-weight: 900;
}

.project-delete:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #fff;
}

.embed-builder-preview {
  margin-top: 14px;
  padding: 14px 14px 12px;
  border-radius: 12px;
  background: rgba(3, 9, 23, 0.86);
  border: 1px solid var(--border-soft);
  border-left: 5px solid var(--blue);
}

.embed-preview-label {
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.embed-builder-preview strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 6px;
}

.embed-builder-preview p {
  margin: 0 0 10px;
  color: #c8d6ee;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.embed-builder-preview small {
  color: var(--muted);
  font-size: 11px;
}

.color-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  align-items: center;
}

.color-input {
  min-height: 46px;
  padding: 6px !important;
}

.flow-block.logic-block {
  border-color: rgba(168, 85, 247, 0.45);
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.25), rgba(3, 9, 23, 0.72));
}

.flow-block.event-block {
  border-color: rgba(34, 197, 94, 0.38);
  background: linear-gradient(135deg, rgba(20, 83, 45, 0.22), rgba(3, 9, 23, 0.72));
}

.flow-block.action-block {
  border-color: rgba(56, 189, 248, 0.28);
}

.logic-tree {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.logic-tree span {
  display: block;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.13);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 1280px) {
  .workspace-actions {
    grid-template-columns: 1fr;
  }

  .logic-tree {
    grid-template-columns: 1fr;
  }
}


/* ===============================
   V4 FULL NIGHT BUILD ADDITIONS
================================ */
.v4-node-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(56, 189, 248, 0.16);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.72));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.node-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.node-card-head h2 {
  margin: 4px 0 0;
  font-size: 18px;
  color: #f8fafc;
}
.pill.small {
  font-size: 11px;
  padding: 6px 10px;
}
.node-graph,
.node-graph-empty {
  min-height: 160px;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: radial-gradient(circle at top left, rgba(56,189,248,.13), transparent 35%), rgba(15,23,42,.52);
  border: 1px solid rgba(148,163,184,.14);
  color: rgba(226,232,240,.8);
}
.node-graph-empty {
  justify-content: center;
  text-align: center;
}
.v4-node {
  position: relative;
  flex: 0 0 178px;
  min-height: 100px;
  border-radius: 18px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .88);
  box-shadow: 0 12px 35px rgba(0,0,0,.22);
}
.v4-node.event { border-color: rgba(34,197,94,.38); }
.v4-node.logic { border-color: rgba(250,204,21,.42); }
.v4-node.action { border-color: rgba(56,189,248,.35); }
.v4-node.external { border-color: rgba(168,85,247,.38); }
.v4-node:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -23px;
  top: 42%;
  color: rgba(56,189,248,.9);
  font-size: 22px;
  font-weight: 900;
}
.v4-node.logic:not(:last-child)::before {
  content: "ELSE";
  position: absolute;
  right: -31px;
  bottom: -18px;
  font-size: 10px;
  color: #facc15;
  border: 1px solid rgba(250,204,21,.22);
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(15,23,42,.95);
}
.node-icon {
  font-size: 24px;
  margin-bottom: 8px;
}
.node-title {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  color: #fff;
  font-weight: 800;
}
.node-meta {
  display: block;
  margin-top: 7px;
  font-size: 11px;
  color: rgba(203,213,225,.72);
}
.v4-guide-card .upgrade-list {
  display: grid;
  gap: 8px;
}
.v4-guide-card .upgrade-list span {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(56,189,248,.07);
  border: 1px solid rgba(56,189,248,.12);
  color: #dbeafe;
  font-size: 13px;
  font-weight: 700;
}
@media (max-width: 1200px) {
  .node-graph, .node-graph-empty { min-height: 120px; }
  .v4-node { flex-basis: 150px; }
}
