.crm-studio {
  display: none;
  gap: 18px;
  padding: 18px;
}

.crm-studio.show {
  display: grid;
}

.crm-hero {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(32, 197, 168, 0.12), rgba(255, 204, 77, 0.12)),
    #fff;
}

.crm-hero h2 {
  max-width: 560px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.94;
}

#crmLoginForm h1 {
  max-width: 560px;
  font-size: clamp(2.35rem, 5vw, 4.1rem);
  line-height: 0.98;
}

.crm-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.08);
  color: #111;
  transition: max-width 0.2s ease, margin 0.2s ease, background .2s ease, color .2s ease;
}

.crm-preview.mobile-preview {
  max-width: 300px;
  margin: 0 auto;
}

.crm-preview-frame {
  display: block;
  width: 100%;
  min-height: 520px;
  border: 0;
  background: #fff;
}

.crm-preview.mobile-preview .crm-preview-frame {
  min-height: 640px;
}

.crm-preview[data-template="restaurant-classic"] { background: #eee6cd; color: #24150d; font-family: Georgia, serif; }
.crm-preview[data-template="creator-profile"] { background: #111326; color: #f7f2ff; }
.crm-preview[data-template="service-local"] { background: #f4f9fb; color: #102a43; }
.crm-preview[data-template="starter-clean"] { background: #fff; color: #111; }

.crm-editor-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.74fr) minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}

.cms-rail {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.cms-step {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.cms-step-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 950;
}

.cms-step strong,
.cms-step span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cms-step span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
}

.template-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-card {
  min-height: 230px;
  display: grid;
  grid-template-rows: 146px auto 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  /* Surface token, not white: the card chrome follows the theme. The little
     page PREVIEW inside stays whatever the template itself is. */
  background: var(--jw-surface);
  color: var(--ink);
  cursor: pointer;
  padding: 10px;
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.template-card:hover,
.template-card.active {
  transform: translateY(-1px);
  border-color: var(--jw-accent);
  box-shadow: var(--jw-shadow-md);
}

.template-preview {
  display: grid;
  grid-template-rows: 22px 1fr 24px;
  height: 146px;
  overflow: hidden;
  border: 1px solid rgba(17, 17, 17, .12);
  border-radius: 8px;
  background: #f8f5ed;
  color: #17130f;
  font-family: Georgia, serif;
}

.template-preview-nav { display: flex; align-items: center; gap: 5px; padding: 0 7px; border-bottom: 1px solid currentColor; font: 700 6px/1 Arial, sans-serif; }
.template-preview-nav b { margin-right: auto; font-size: 8px; }
.template-preview-nav i { width: 16px; height: 2px; background: currentColor; opacity: .45; }
.template-preview-hero { display: grid; align-content: center; justify-items: start; gap: 5px; padding: 10px 12px; background: radial-gradient(circle at 80% 35%, rgba(255,255,255,.12), transparent 28%), linear-gradient(125deg, transparent 58%, rgba(0,0,0,.22)); }
.template-preview-hero small { font: 800 6px/1 Arial, sans-serif; letter-spacing: .14em; }
.template-preview-hero b { max-width: 78%; font-size: 16px; line-height: .94; }
.template-preview-hero em { padding: 4px 7px; border: 1px solid currentColor; border-radius: 99px; font: 700 6px/1 Arial, sans-serif; font-style: normal; }
.template-preview-detail { padding: 6px 8px; font: 700 6px/1 Arial, sans-serif; letter-spacing: .04em; }
.template-preview-restaurant-classic { background: #eee6cd; color: #24150d; }
.template-preview-restaurant-classic .template-preview-hero { background-color: #dfd0a8; }
.template-preview-creator-profile { background: #111326; color: #f7f2ff; font-family: Arial, sans-serif; }
.template-preview-creator-profile .template-preview-hero { background: radial-gradient(circle at 75% 25%, #7447ff, transparent 34%), linear-gradient(135deg, #171a35, #10121e); }
.template-preview-service-local { background: #f4f9fb; color: #102a43; font-family: Arial, sans-serif; }
.template-preview-service-local .template-preview-hero { background: linear-gradient(120deg, #dceef7 62%, #65b7db 62%); }
.template-preview-starter-clean { background: #fff; color: #111; font-family: Arial, sans-serif; }
.template-preview-starter-clean .template-preview-hero { background: linear-gradient(120deg, #fff 58%, #20c5a8 58%); }

.template-card strong {
  font-size: 0.9rem;
  line-height: 1.08;
}

.template-card span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
  line-height: 1.25;
}

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

.quick-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f8f8;
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
  padding: 0 10px;
}

.crm-studio-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.crm-studio-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.crm-studio-tab {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f6f6;
  color: #444;
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 880;
  cursor: pointer;
}

.crm-studio-tab.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.crm-publish-state {
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 900;
}

.crm-card.sticky-preview {
  position: sticky;
  top: 84px;
}

.crm-wysiwyg {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(32,197,168,.08), rgba(255,204,77,.08)), #fff;
  padding: 16px;
}

.visual-editor-heading,
.visual-editor-actions,
.visual-editor-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.visual-editor-heading h3 { margin: 3px 0 5px; font-size: clamp(1.35rem, 3vw, 2rem); }
.visual-editor-heading > div:first-child { max-width: 680px; }
.visual-editor-actions { justify-content: flex-end; }
.visual-editor-actions .button { min-height: 38px; padding-inline: 16px; }
.visual-editor-hint { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px 12px; color: var(--muted); font-size: .78rem; font-weight: 820; }
.visual-editor-hint span { display: inline-flex; align-items: center; gap: 7px; }
.visual-editor-hint strong { color: var(--green); }
.visual-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--mint); box-shadow: 0 0 0 3px rgba(32,197,168,.18); }
.visual-canvas-shell { overflow: hidden; border: 1px solid rgba(17,17,17,.18); border-radius: 12px; background: #e9eceb; padding: 10px; box-shadow: 0 24px 60px rgba(0,0,0,.12); }
.visual-editor-frame { display: block; width: 100%; min-height: 760px; border: 0; border-radius: 8px; background: #fff; }

body.visual-editor-fullscreen { overflow: hidden; }
.crm-wysiwyg.visual-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  grid-template-rows: minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  padding: 0;
  background: #111;
}
.crm-wysiwyg.visual-fullscreen .visual-editor-heading {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1002;
  width: auto;
  pointer-events: none;
}
.crm-wysiwyg.visual-fullscreen .visual-editor-heading > div:first-child,
.crm-wysiwyg.visual-fullscreen .visual-editor-hint { display: none; }
.crm-wysiwyg.visual-fullscreen .visual-editor-actions {
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  background: rgba(17,17,17,.88);
  padding: 7px;
  box-shadow: 0 18px 52px rgba(0,0,0,.28);
  backdrop-filter: blur(18px);
}
.crm-wysiwyg.visual-fullscreen .visual-editor-actions .cms-mini-button,
.crm-wysiwyg.visual-fullscreen .visual-editor-actions .button { min-height: 34px; border-color: rgba(255,255,255,.2); }
.crm-wysiwyg.visual-fullscreen .visual-canvas-shell { min-height: 0; width: 100vw; height: 100vh; border: 0; border-radius: 0; padding: 0; box-shadow: none; }
.crm-wysiwyg.visual-fullscreen .visual-editor-frame { width: 100vw; height: 100vh; min-height: 0; border-radius: 0; }
.crm-wysiwyg.visual-fullscreen #visualEditorStatus {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 1002;
  max-width: min(520px, calc(100vw - 24px));
  border-radius: 8px;
  background: rgba(17,17,17,.82);
  color: #fff;
  padding: 8px 11px;
  backdrop-filter: blur(16px);
}
.crm-wysiwyg.visual-fullscreen #visualFullscreenButton { background: #111; color: #fff; }

.crm-studio.visual-mode .crm-editor-grid > .cms-rail,
.crm-studio.visual-mode .crm-editor-grid > .sticky-preview,
.crm-studio.visual-mode .crm-editor-grid > #crmEditForm,
.crm-studio.visual-mode .crm-editor-grid > .session-card { display: none; }

.crm-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.crm-card h3 {
  font-size: 1.08rem;
}

.card-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 820;
  line-height: 1.35;
}

.cms-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.builder-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.segmented {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f5f5;
  padding: 3px;
}

.segmented button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 900;
  padding: 0 10px;
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.cms-mini-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  padding: 0 12px;
}
.content-blocks,
.page-section-list,
.napplet-list,
.source-raster {
  display: grid;
  gap: 10px;
}

.public-cms-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.public-cms-block h3 {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.public-cms-block p {
  color: #333;
  font-weight: 610;
  white-space: pre-wrap;
}

.public-module {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(32, 197, 168, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(32, 197, 168, 0.11), rgba(255, 204, 77, 0.1)),
    #fff;
}

.public-module span {
  color: #157060;
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.public-module strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.content-block,
.page-section,
.napplet-tile,
.source-tile {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8f8f8;
  padding: 10px;
  cursor: grab;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.page-section {
  background: #fff;
  cursor: grab;
}

.napplet-tile {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  background: #fff;
  cursor: default;
}

.napplet-tile span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.page-section.disabled {
  opacity: 0.58;
}

.page-section.drag-over,
.content-block.drag-over,
.source-tile.drag-over {
  border-color: rgba(32, 197, 168, 0.62);
  box-shadow: 0 0 0 4px rgba(32, 197, 168, 0.12);
}

.page-section-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.section-type {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.section-fields {
  display: grid;
  gap: 8px;
}

.section-fields.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.source-tile {
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  min-height: 70px;
}

.content-block {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, rgba(255, 204, 77, 0.26), rgba(32, 197, 168, 0.22), rgba(39, 100, 255, 0.16)) border-box;
}

.block-grip {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f5f5;
  color: var(--muted);
  font-weight: 950;
}

.block-body {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.block-head strong {
  overflow: hidden;
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.block-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0 9px;
}

.content-block input,
.content-block textarea {
  width: 100%;
  border-radius: 8px;
  background: var(--jw-white);
}

.content-block textarea {
  min-height: 92px;
}

.content-block.dragging,
.page-section.dragging,
.source-tile.dragging {
  opacity: 0.58;
  transform: scale(0.98);
}

.content-block.drag-over,
.source-tile.drag-over {
  border-color: rgba(39, 100, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(39, 100, 255, 0.08);
}

.source-tile strong,
.source-tile span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-tile span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.source-tile .platform-logo.large {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  font-size: 1.1rem;
}

.source-tile .platform-logo.facebook.large {
  font-size: 2rem;
}

.tile-remove {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 950;
}

.inline-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.source-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

.source-card .platform-logo.large {
  width: 112px;
  height: 112px;
}

.source-card div {
  min-width: 0;
  padding: 12px 12px 12px 0;
}

.source-card h3 {
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.gallery {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gallery img {
  width: 100%;
  aspect-ratio: 1.15;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 32, 29, 0.08);
}

.side-stack {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.side-panel {
  padding: 18px;
}

.side-panel h2 {
  font-size: 1.35rem;
}

.side-panel p {
  margin-top: 9px;
  color: var(--muted);
  font-weight: 680;
}

.hidden { display: none !important; }
.session-heading,
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.session-heading h3 { margin-bottom: .25rem; }
.session-list { display: grid; gap: .65rem; margin-top: 1rem; }
.session-row { padding: .8rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.session-copy { display: grid; gap: .15rem; min-width: 0; }
.session-copy span { color: var(--muted); font-size: .82rem; }

.owner-recovery-panel {
  display: grid;
  gap: .75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.owner-recovery-panel.hidden { display: none; }
