/* ==========================================================================
   STUDIO LAYOUT FIXES: phones (to 900px), tablets, desktop
   Loaded after admin.css. Fills gaps and prevents overflow.
   ========================================================================== */

/* Flex children may shrink below their content width, which pushed wide
   canvases and drawers out of view on tablets and desktops */
.studio-workspace > * { min-width: 0; }
.studio-canvas-viewport {
  min-width: 0;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.canvas-device-frame { max-width: 100%; min-width: 0; }
.canvas-device-frame img { max-width: 100%; height: auto; }

/* Dialogs scroll on short screens instead of clipping */
.modal-box {
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  /* The inspector becomes a bottom sheet only when a field is selected */
  .studio-right-inspector { display: none; }
  .studio-right-inspector.is-open { display: flex !important; }
  .studio-workspace.has-open-inspector .studio-canvas-viewport { padding-bottom: 60vh; }

  .studio-left-drawer {
    max-height: calc(100dvh - var(--topbar-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ext-section { padding: 0.75rem; }
  .icon-lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .iq-fields { grid-template-columns: 1fr; }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .studio-left-drawer { width: 260px; }
  .studio-canvas-viewport { padding: 1.5rem 1rem 6rem; }
}

/* ==========================================================================
   PREVIEW SCROLLING (verified in a browser at desktop, tablet and phone widths)
   The canvas was a flex row whose device frame was clipped at the viewport
   height, so the preview could not scroll. The canvas is now a normal block
   scroller and the device frame grows with its content.
   ========================================================================== */
.studio-canvas-viewport { display: block !important; }
.canvas-device-frame {
  height: auto !important;
  min-height: 0 !important;
  margin: 0 auto;
  overflow: visible !important;
}

/* ==========================================================================
   PREVIEW PANEL: the site in a frame that fills the panel and follows the device width.
   The panel is positioned, so the frame fills it whatever the height of the surrounding layout.
   ========================================================================== */
.studio-canvas-viewport:has(#canvasLiveTarget iframe.studio-frame) { padding: 0; overflow: hidden; }
/* The wrapper around the preview fills the panel, so the preview's own width is the device width */
.studio-canvas-viewport:has(#canvasLiveTarget iframe.studio-frame) #canvasDeviceFrame {
  position: absolute;
  inset: 0;
  width: auto;
  max-width: none !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 0;
}
#canvasLiveTarget {
  position: absolute;
  top: 12px;
  height: calc(100% - 24px);
  min-height: 0;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 960px;
  display: flex;
  flex-direction: column;
  transition: max-width 0.25s ease;
}
#canvasLiveTarget iframe.studio-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
#canvasLiveTarget .studio-note { padding: 2rem 1rem; text-align: center; color: #57534e; font-size: 14px; }

/* Page list: the buttons keep their words on one line and wrap as a group */
.pt-row { flex-wrap: wrap; row-gap: 4px; }
.pt-btn { white-space: nowrap; }

/* A settings box the preview has just pointed to */
.studio-flash { animation: studio-flash 1.6s ease-out 1; }
@keyframes studio-flash { 0% { box-shadow: 0 0 0 4px rgba(28, 25, 23, 0.35); } 100% { box-shadow: 0 0 0 0 rgba(28, 25, 23, 0); } }


/* ==========================================================================
   Site Kit: a navigation strip, and collapsible groups of settings
   ========================================================================== */
.kit-nav { position: sticky; top: 0; z-index: 3; display: flex; gap: 6px; overflow-x: auto; padding: 8px 2px 10px; margin: 0 -2px; background: #ffffff; scrollbar-width: none; }
.kit-nav::-webkit-scrollbar { display: none; }
.kit-chip { flex: 0 0 auto; border: 1px solid #d6d3d1; background: #ffffff; color: #292524; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.kit-chip:hover { border-color: #1c1917; }
.kit-group { border: 1px solid #e7e5e4; border-radius: 14px; margin: 0 0 12px; background: #ffffff; box-shadow: 0 1px 2px rgba(28, 25, 23, 0.04); }
.kit-group > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: #1c1917; }
.kit-group > summary::-webkit-details-marker { display: none; }
.kit-group > summary::after { content: "+"; font-size: 18px; font-weight: 400; color: #78716c; }
.kit-group[open] > summary { border-bottom: 1px solid #f0efed; }
.kit-group[open] > summary::after { content: "–"; }
.kit-group-body { padding: 4px 10px 10px; }
.kit-group-body .ext-section { padding: 0.5rem 0.25rem; }
.kit-flash { animation: studio-flash 0.9s ease-out 1; }

/* Loader preview dialog */
#ldPreview { border: 0; border-radius: 16px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }

/* ==========================================================================
   Questionnaires (admin): the flow list, the diagram, the step rows and their editor
   ========================================================================== */
.fo-card, .fo-tcard { border: 1px solid #e7e5e4; border-radius: 14px; padding: 12px; background: #ffffff; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.fo-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 8px; }
.fo-card.is-draft { border-style: dashed; }
.fo-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.fo-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #15803d; }
.fo-status.is-draft { color: #78716c; }
.fo-diagram { border: 1px solid #e7e5e4; border-radius: 12px; padding: 8px; background: #fafaf9; overflow-x: auto; }
.flow-diagram { width: 100%; min-width: 360px; height: auto; display: block; }
.flow-diagram .fd-node rect { fill: #ffffff; stroke: #d6d3d1; stroke-width: 1.2; }
.flow-diagram .fd-choice rect, .flow-diagram .fd-multi rect, .flow-diagram .fd-yesno rect { stroke: #1c1917; }
.flow-diagram .fd-end rect { fill: #1c1917; stroke: #1c1917; }
.flow-diagram .fd-end .fd-type, .flow-diagram .fd-end .fd-title { fill: #ffffff; }
.flow-diagram .fd-type { font: 700 9px ui-monospace, monospace; fill: #78716c; letter-spacing: 0.06em; }
.flow-diagram .fd-title { font: 600 12px system-ui, sans-serif; fill: #1c1917; }
.flow-diagram .fd-start { font: 700 9px ui-monospace, monospace; fill: #15803d; }
.flow-diagram .fd-arrow { stroke: #57534e; stroke-width: 1.3; fill: none; }
.flow-diagram .fd-branch { stroke: #a8a29e; stroke-width: 1.2; fill: none; stroke-dasharray: 4 3; }
.flow-diagram .fd-label { font: 600 10px system-ui, sans-serif; fill: #57534e; }
.fo-node { border: 1px solid #e7e5e4; border-radius: 12px; padding: 10px; margin-bottom: 8px; background: #ffffff; display: flex; flex-direction: column; gap: 8px; }
.fo-node.is-draft { border-style: dashed; opacity: 0.85; }
.fo-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fo-num { width: 22px; height: 22px; border-radius: 50%; background: #1c1917; color: #ffffff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.fo-type { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #78716c; }
.fo-title { font-weight: 600; color: #1c1917; font-size: 13px; }
.fo-chip { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #78716c; border: 1px dashed #a8a29e; border-radius: 999px; padding: 2px 8px; }
.fo-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.fo-edit { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #f0efed; padding-top: 8px; }
.fo-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.fo-row > span { font-size: 12px; color: #57534e; }
.fo-row label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.fo-row input[type="number"] { width: 70px; }

/* Audio editor: look and caption pickers, timed lines */
.au-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.au-pick { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; padding: 10px; border: 1.5px solid #e7e5e4; border-radius: 12px; background: #fff; cursor: pointer; font: inherit; }
.au-pick.is-on { border-color: #1c1917; box-shadow: inset 0 0 0 1px #1c1917; }
.au-pick b { font-size: 12.5px; color: #1c1917; } .au-pick small { font-size: 11px; color: #78716c; line-height: 1.35; }
.au-pick-prev { display: block; width: 100%; height: 40px; border-radius: 8px; background: #f5f5f4; position: relative; overflow: hidden; margin-bottom: 4px; }
.au-pick-prev i { position: absolute; display: block; height: 5px; border-radius: 3px; background: #a8a29e; left: 10px; right: 10px; }
.au-pick-prev i:nth-child(1) { top: 8px; } .au-pick-prev i:nth-child(2) { top: 17px; right: 40px; } .au-pick-prev i:nth-child(3) { top: 26px; left: 30px; }
.au-prev-player-pill { background: #1f1d1a; } .au-prev-player-pill i { background: #f5f4f0; }
.au-prev-player-card { background: #fff; box-shadow: inset 0 0 0 1px #d6d3d1; } .au-prev-player-card i { background: #78716c; }
.au-prev-player-bar { background: #0f0d0a; } .au-prev-player-bar i { background: #fff; }
.au-prev-player-voice { background: #f2f2f2; } .au-prev-player-voice i { background: #e5484d; }
.au-prev-caption-off { background: #fff; } .au-prev-caption-off i { background: #d6d3d1; }
.au-prev-caption-line { background: #fff; } .au-prev-caption-line i:nth-child(2) { background: #1c1917; }
.au-prev-caption-karaoke { background: #fff; } .au-prev-caption-karaoke i { background: #d6d3d1; } .au-prev-caption-karaoke i:nth-child(2) { background: #1c1917; }
.au-prev-caption-letters { background: #fff; } .au-prev-caption-letters i:nth-child(2) { background: #1c1917; right: 60px; }
.au-prev-caption-lyrics { background: #fff; } .au-prev-caption-lyrics i:nth-child(2) { background: #1c1917; height: 8px; }
.au-line-row { display: grid; grid-template-columns: 78px 78px minmax(0, 1fr) auto; gap: 4px; align-items: center; margin-bottom: 4px; }
.au-lines { max-height: 260px; overflow: auto; border: 1px solid #e7e5e4; border-radius: 10px; padding: 6px; margin: 6px 0; }

/* Audio editor: waveform looks, caption text options, key marks */
.au-prev-wave-bars { background: #fff; } .au-prev-wave-bars i { background: #78716c; height: 14px !important; left: 12px; right: 12px; top: 13px; }
.au-prev-wave-pill { background: #fff; } .au-prev-wave-pill i { background: #1c1917; height: 10px !important; border-radius: 99px; top: 15px; }
.au-prev-wave-mirror { background: #fff; } .au-prev-wave-mirror i { background: #1c1917; height: 4px !important; top: 18px; }
.au-prev-wave-dots { background: #fff; } .au-prev-wave-dots i { background: #1c1917; height: 5px !important; width: 5px !important; border-radius: 50%; top: 17px; }
.au-prev-wave-thin { background: #fff; } .au-prev-wave-thin i { background: #1c1917; height: 1px !important; top: 19px; }
.au-text { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0 10px; }
.au-text label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.au-key-mark { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: #57534e; }

/* ==========================================================================
   Site Kit path: area > section > part, one level at a time
   ========================================================================== */
.kit-path { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.kit-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; font-size: 12px; min-width: 0; }
.kit-crumbs li + li::before { content: "›"; margin: 0 6px; color: #a8a29e; }
.kit-crumbs li[aria-current] { font-weight: 700; color: #1c1917; }
.kit-crumbs button { background: none; border: 0; padding: 2px 0; color: #57534e; cursor: pointer; font: inherit; }
.kit-crumbs button:hover { color: #1c1917; text-decoration: underline; }
.kit-back { border: 1px solid #d6d3d1; background: #fff; border-radius: 999px; padding: 4px 10px; font: 600 12px/1 system-ui, sans-serif; cursor: pointer; }
.kit-level { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; min-width: 0; }
.kit-level[hidden] { display: none; }
.kit-chip-sub { font-weight: 500; }
.kit-hint { font-size: 12px; color: #78716c; margin: 4px 0; }
.kit-group[hidden], .ext-section[hidden] { display: none !important; }

/* ==========================================================================
   Fit the screen: nothing is wider than the screen; drawers, inspectors and pop-up
   dialogs stay inside it and scroll within themselves (phones, tablets, split screens)
   ========================================================================== */
html, body { max-width: 100%; overflow-x: hidden; }
.studio-left-drawer, .studio-right-inspector { max-width: 100vw; box-sizing: border-box; }
dialog { max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow: auto; box-sizing: border-box; }
.ext-group, .ext-section, .pt-item, .fo-node, .fo-card, .au-editor, .res-group, .kit-group-body, .drawer-body { min-width: 0; max-width: 100%; box-sizing: border-box; }
.ext-input, input, select, textarea { max-width: 100%; min-width: 0; box-sizing: border-box; }
img, video, canvas, svg { max-width: 100%; height: auto; }
.res-scroll, .au-lines, .fo-diagram { max-width: 100%; }
@media (max-width: 640px) {
  .studio-left-drawer, .studio-right-inspector { width: 100vw !important; }
  .fo-row, .fo-row2, .au-text, .au-line-row, .au-picks, .tpl-grid, .fo-templates, .fo-styles { grid-template-columns: minmax(0, 1fr) !important; }
  .kit-level { flex-wrap: wrap; }
  dialog { width: calc(100vw - 16px); }
}
@media (max-width: 380px) { .studio-topbar { flex-wrap: wrap; } }

/* Media library */
.ml-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.ml-kinds small { color: #78716c; font-weight: 500; }
.ml-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.ml-filters input[type="search"] { grid-column: 1 / -1; }
.ml-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.ml-card { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid #e7e5e4; border-radius: 12px; background: #fff; cursor: pointer; text-align: left; font: inherit; min-width: 0; }
.ml-card.is-on { border-color: #1c1917; box-shadow: inset 0 0 0 1px #1c1917; }
.ml-thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #f5f5f4; display: block; }
.ml-ph { display: grid; place-items: center; font-weight: 700; color: #57534e; font-size: 13px; }
.ml-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-meta { font-size: 11px; color: #78716c; }
.ml-detail { margin-top: 10px; border-top: 1px solid #e7e5e4; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ml-preview .ml-thumb { max-height: 200px; }
.ml-title { margin: 0; font-weight: 700; }
.ml-uses { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.ml-uses li { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 1px solid #f0efed; border-radius: 8px; padding: 6px 8px; }
.ml-uses li span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .ml-filters { grid-template-columns: 1fr; } .ml-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Top bar: the buttons wrap and scroll inside the screen; nothing pushes past its edge */
.studio-topbar { max-width: 100vw; box-sizing: border-box; flex-wrap: wrap; min-width: 0; overflow-x: auto; }
.studio-topbar > * { min-width: 0; max-width: 100%; }
.studio-topbar .btn, .studio-topbar button, .studio-topbar a { white-space: nowrap; }
.lib-dialog { width: min(640px, calc(100vw - 16px)); }
.lib-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.lib-status { font-size: 12px; color: #78716c; margin: 6px 0; }
.lib-foot { margin-top: 8px; }
.lib-pick { margin-top: 4px; }

/* Positioning */
#canvasViewport { position: relative; }
.pos-grid { position: absolute; inset: 0; pointer-events: none; display: none; grid-template-columns: repeat(var(--cols, 12), 1fr); column-gap: var(--gut, 20px); padding: 0 var(--mar, 32px); z-index: 5; }
body.pos-grid-on .pos-grid { display: grid; }
.pos-grid i { background: rgba(236, 72, 153, 0.10); border-left: 1px solid rgba(236, 72, 153, 0.25); border-right: 1px solid rgba(236, 72, 153, 0.25); }
.pos-view { display: flex; flex-direction: column; gap: 10px; }
.pos-bp, .pos-actions, .pos-seg, .pos-nudge, .pos-pads { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pos-sec { border: 1px solid #e7e5e4; border-radius: 12px; padding: 8px 10px; background: #fff; }
.pos-sec > summary { font-weight: 700; cursor: pointer; padding: 6px 0; min-height: 40px; display: flex; align-items: center; }
.pos-range { width: 100%; min-width: 0; }
.pos-nudge .pos-range { flex: 1 1 120px; }
.pos-pads label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; flex: 1 1 140px; min-width: 0; }
.pos-pads input { width: 100%; }
.pos-name { font-weight: 700; margin: 4px 0; }
.pos-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.pos-tpl { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid #e7e5e4; border-radius: 10px; background: #fff; font: 600 12px/1.2 system-ui, sans-serif; cursor: pointer; min-height: 44px; }
.pos-tpl:disabled { opacity: 0.45; cursor: default; }
.pos-ghost { display: grid; gap: 2px; height: 22px; }
.pos-ghost i { background: #e7e5e4; border-radius: 2px; }
.pos-ghost i.on { background: #1c1917; }
.pos-full-exit { position: fixed; right: 12px; bottom: 12px; z-index: 900; display: none; min-height: 44px; padding: 10px 14px; border-radius: 999px; border: 0; background: #1c1917; color: #fff; font: 600 13px/1 system-ui, sans-serif; cursor: pointer; }
body.full-preview .pos-full-exit { display: block; }
body.full-preview .studio-left-drawer, body.full-preview .studio-right-inspector { display: none !important; }
body.full-preview .studio-canvas-viewport { width: 100% !important; max-width: 100vw; }
.pos-view button, .pos-view select, .pos-view input { min-height: 40px; }
@media (max-width: 640px) { .pos-tpls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Undo, redo, history */
.hist-bar { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hist-btn { min-height: 40px; padding: 8px 12px; border-radius: 999px; border: 1px solid #d6d3d1; background: #fff; font: 600 12px/1 system-ui, sans-serif; cursor: pointer; white-space: nowrap; }
.hist-btn:disabled { opacity: 0.4; cursor: default; }
.hist-dialog { width: min(520px, calc(100vw - 16px)); }
.hist-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hist-sec { font-weight: 700; font-size: 12px; margin: 10px 0 4px; color: #57534e; }
.hist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.hist-row { width: 100%; text-align: left; min-height: 40px; padding: 8px 10px; border: 1px solid #e7e5e4; border-radius: 8px; background: #fff; font: 13px/1.3 system-ui, sans-serif; cursor: pointer; overflow-wrap: anywhere; }
.hist-row:hover { border-color: #1c1917; }

/* Site versions: one tidy layout at every width */
.sv-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sv-bar .hist-btn { min-height: 40px; }
.sv-publish { background: #1c1917; color: #fff; border-color: #1c1917; }
.sv-dialog { width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-sizing: border-box; padding: 16px; border-radius: 16px; }
.sv-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.sv-head strong { font-size: 16px; }
.sv-dialog .kit-hint { margin: 6px 0 12px; line-height: 1.5; }
.sv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 170px); overflow: auto; }
.sv-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title acts" "meta acts"; gap: 6px 14px; align-items: center; padding: 12px 14px; border: 1px solid #e7e5e4; border-radius: 12px; background: #fff; min-width: 0; box-sizing: border-box; }
.sv-title { grid-area: title; display: flex; align-items: center; gap: 8px; min-width: 0; }
.sv-name { font-size: 14px; font-weight: 700; color: #1c1917; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sv-meta { grid-area: meta; display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.sv-date { font-size: 12px; color: #78716c; white-space: nowrap; }
.sv-link { font-size: 12px; color: #1d4ed8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; min-width: 0; }
.sv-acts { grid-area: acts; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.sv-btn { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid #d6d3d1; background: #fff; font: 600 12px/1 system-ui, sans-serif; color: #1c1917; cursor: pointer; white-space: nowrap; }
.sv-btn:hover { border-color: #1c1917; }
.sv-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.sv-danger { color: #b42318; border-color: #fecaca; }
.sv-pill { flex: none; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #f5f5f4; color: #57534e; }
.sv-published { background: #dcfce7; color: #166534; }
.sv-draft { background: #fef3c7; color: #92400e; }
.sv-empty { font-size: 13px; color: #78716c; padding: 12px 4px; }
@media (max-width: 560px) {
  .sv-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "meta" "acts"; }
  .sv-acts { justify-content: stretch; }
  .sv-acts .sv-btn { flex: 1 1 0; }
  .sv-bar .hist-btn { flex: 1 1 auto; }
}
/* Dialogs sit in the middle of the screen at every size */
.sv-dialog, .hist-dialog, .lib-dialog { position: fixed; inset: 0; margin: auto; height: max-content; }

/* Choice dialog */
.choose-dialog { position: fixed; inset: 0; margin: auto; height: max-content; width: min(440px, calc(100vw - 24px)); border-radius: 16px; padding: 18px; box-sizing: border-box; }
.choose-title { font-size: 16px; }
.choose-opts { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.choose-btn { text-align: left; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid #d6d3d1; background: #fff; font: 600 14px/1.2 system-ui, sans-serif; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.choose-btn small { font-weight: 400; color: #78716c; font-size: 12px; }
.choose-btn.is-primary { background: #1c1917; color: #fff; border-color: #1c1917; }
.choose-btn.is-primary small { color: #d6d3d1; }
.choose-cancel { min-height: 40px; background: none; border: 0; font: 600 13px/1 system-ui, sans-serif; color: #57534e; cursor: pointer; }

/* Versions panel: groups, selection and bulk bar */
.sv-bulk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 10px; }
.sv-bulk-count { font-size: 12px; color: #57534e; margin-right: 4px; }
.sv-groups { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 230px); overflow: auto; }
.sv-group { border: 1px solid #e7e5e4; border-radius: 14px; background: #fafaf9; padding: 8px; }
.sv-ghead { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.sv-gtoggle { flex: 1 1 160px; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 6px 4px; font: inherit; color: #1c1917; cursor: pointer; text-align: left; }
.sv-gtoggle b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-count { font-size: 12px; color: #78716c; white-space: nowrap; }
.sv-gtag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #e7e5e4; color: #44403c; }
.sv-group .sv-list { margin-top: 8px; }
.sv-row { position: relative; padding-left: 44px; }
.sv-check { position: absolute; left: 12px; top: 14px; min-height: 24px; display: flex; align-items: center; }
.sv-check input { width: 18px; height: 18px; }
.sv-row.is-picked { border-color: #1c1917; box-shadow: inset 0 0 0 1px #1c1917; }
@media (max-width: 560px) { .sv-row { padding-left: 14px; padding-top: 40px; } .sv-check { top: 12px; left: 12px; } }
/* Versions: sites and templates in separate columns (stacked on phones) */
.sv-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.sv-col { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sv-colhead { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #78716c; padding: 0 4px; }
.sv-cols .sv-groups { max-height: calc(100vh - 270px); }
@media (max-width: 720px) { .sv-cols { grid-template-columns: minmax(0, 1fr); } .sv-cols .sv-groups { max-height: none; } }

/* Comms: a full-screen panel, separate from the site editor */
.cm-view { position: fixed; inset: 0; z-index: 1500; background: #fafaf9; display: flex; flex-direction: column; font: 14px/1.5 system-ui, sans-serif; color: #1c1917; }
.cm-view[hidden] { display: none; }
.cm-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e7e5e4; background: #fff; }
.cm-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 180px minmax(0, 1fr); }
.cm-nav { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-right: 1px solid #e7e5e4; background: #fff; }
.cm-navbtn { min-height: 40px; text-align: left; padding: 8px 12px; border-radius: 10px; border: 0; background: none; font: 600 13px/1 system-ui, sans-serif; color: #44403c; cursor: pointer; }
.cm-navbtn.is-on { background: #1c1917; color: #fff; }
.cm-main { min-width: 0; min-height: 0; overflow: auto; padding: 14px; }
.cm-split { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 14px; height: 100%; min-height: 0; }
.cm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.cm-item { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1px solid #e7e5e4; background: #fff; cursor: pointer; font: inherit; }
.cm-item b { font-size: 13px; }
.cm-item span, .cm-item small { color: #78716c; font-size: 12px; overflow-wrap: anywhere; }
.cm-item.is-on { border-color: #1c1917; box-shadow: inset 0 0 0 1px #1c1917; }
.cm-thread { min-width: 0; display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid #e7e5e4; border-radius: 14px; padding: 14px; }
.cm-thead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cm-thead span { color: #78716c; font-size: 12px; }
.cm-tag { background: #fef3c7; color: #92400e; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.cm-msgs { display: flex; flex-direction: column; gap: 8px; overflow: auto; max-height: 50vh; }
.cm-msg { max-width: 80%; padding: 9px 12px; border-radius: 12px; }
.cm-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-msg small { color: #78716c; font-size: 11px; }
.cm-in { background: #f5f5f4; align-self: flex-start; }
.cm-out { background: #1c1917; color: #fff; align-self: flex-end; }
.cm-out small { color: #d6d3d1; }
.cm-reply { display: flex; flex-direction: column; gap: 6px; }
.cm-reply textarea { width: 100%; box-sizing: border-box; border-radius: 10px; border: 1px solid #d6d3d1; padding: 8px 10px; font: inherit; resize: vertical; }
.cm-reply button { align-self: flex-end; }
.cm-hint, .cm-empty { color: #78716c; font-size: 12px; margin: 0; }
@media (max-width: 720px) {
  .cm-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .cm-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid #e7e5e4; }
  .cm-navbtn { white-space: nowrap; }
  .cm-split { grid-template-columns: 1fr; }
}
.cm-win { font-size: 12px; color: #78716c; padding: 3px 9px; border-radius: 999px; background: #f5f5f4; }
.cm-win.is-open { background: #dcfce7; color: #166534; font-weight: 700; }
.cm-spacer { flex: 1; }
/* Comms: templates, the WhatsApp switch, and screen sizes */
.cm-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.cm-tabs button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #d6d3d1; background: #fff; font: 600 13px/1 system-ui, sans-serif; cursor: pointer; }
.cm-tabs button.is-on { background: #1c1917; color: #fff; border-color: #1c1917; }
.cm-kill { margin-bottom: 12px; background: #fff; border: 1px solid #e7e5e4; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cm-killrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.cm-killrow.is-on { color: #991b1b; }
.cm-killrow.is-on b { color: #991b1b; }
.cm-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #44403c; }
.cm-field input, .cm-field textarea, .cm-field select, .cm-optrow input, .cm-tplsend select { min-height: 40px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 8px 10px; font: inherit; box-sizing: border-box; width: 100%; }
.cm-opts { border: 1px solid #e7e5e4; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.cm-optrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 6px; margin-bottom: 6px; }
.cm-tplform { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.cm-tplbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-tplsend { border: 1px solid #e7e5e4; border-radius: 12px; padding: 8px 10px; background: #fafaf9; }
.cm-tplsend form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.cm-fields { display: flex; flex-direction: column; gap: 8px; }
.cm-spacer { flex: 1; }
.cm-tpl { list-style: none; }
@media (max-width: 720px) {
  .cm-optrow { grid-template-columns: 1fr; }
  .cm-killrow { flex-direction: column; align-items: stretch; }
  .cm-killrow .pt-btn, .cm-thread .pt-btn, .cm-tplbtns .pt-btn { width: 100%; }
  .cm-split { gap: 10px; }
  .cm-msg { max-width: 92%; }
}
@media (min-width: 721px) and (max-width: 1100px) {
  .cm-body { grid-template-columns: 150px minmax(0, 1fr); }
  .cm-split { grid-template-columns: minmax(200px, 240px) minmax(0, 1fr); }
}
@media (min-width: 1600px) {
  .cm-split { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .cm-msgs { max-height: 62vh; }
}
/* WhatsApp panel (lean): two panes, phone to wide */
.wa { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.wa-health-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.wa-health { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f5f5f4; color: #44403c; }
.wa-health.ok { background: #dcfce7; color: #166534; font-weight: 700; }
.wa-health.warn { background: #fef9c3; color: #854d0e; font-weight: 700; }
.wa-health.bad { background: #fee2e2; color: #991b1b; font-weight: 700; }
.wa-split { display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 12px; min-height: 60vh; }
.wa-list { overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.wa-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px; border-radius: 12px; border: 1px solid #e7e5e4; background: #fff; cursor: pointer; font: inherit; min-height: 52px; box-sizing: border-box; }
.wa-row.is-on { border-color: #1c1917; box-shadow: inset 0 0 0 1px #1c1917; }
.wa-av { width: 34px; height: 34px; border-radius: 999px; background: #1c1917; color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.wa-rowtxt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.wa-rowtxt b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-rowtxt small { color: #78716c; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-unread { background: #16a34a; color: #fff; border-radius: 999px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: 11px; font-weight: 700; padding: 0 6px; }
.wa-chat { display: flex; flex-direction: column; gap: 8px; min-width: 0; background: #fff; border: 1px solid #e7e5e4; border-radius: 14px; padding: 12px; }
.wa-head { display: flex; flex-direction: column; gap: 8px; }
.wa-headrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wa-pill { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; }
.wa-pill.is-open { background: #dcfce7; color: #166534; }
.wa-pill.is-locked { background: #fee2e2; color: #991b1b; }
.wa-assign { font-size: 12px; display: flex; gap: 6px; align-items: center; }
.wa-assign input { min-height: 36px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 4px 8px; font: inherit; width: 140px; }
.wa-banner { margin: 0; padding: 8px 10px; border-radius: 10px; background: #fef9c3; font-size: 12px; }
.wa-banner.is-bad { background: #fee2e2; }
.wa-msgs { display: flex; flex-direction: column; gap: 8px; overflow: auto; min-height: 220px; max-height: 52vh; padding: 4px; }
.wa-bub { max-width: 80%; padding: 9px 12px; border-radius: 14px; }
.wa-bub p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-bub small { color: #78716c; font-size: 11px; display: block; margin-top: 3px; }
.wa-in { background: #f5f5f4; align-self: flex-start; border-bottom-left-radius: 4px; }
.wa-out { background: #dcf8c6; align-self: flex-end; border-bottom-right-radius: 4px; }
.wa-tick { font-weight: 700; margin-left: 4px; }
.wa-tick.wa-read { color: #2563eb; }
.wa-tick.wa-failed { color: #b91c1c; }
.wa-flag { color: #b45309; font-weight: 700; }
.wa-img { display: block; max-width: 100%; border-radius: 10px; margin-bottom: 6px; }
.wa-file { display: inline-block; margin-bottom: 6px; font-weight: 700; }
.wa-note { align-self: stretch; background: #fef08a; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.wa-note small { color: #713f12; font-size: 11px; }
.wa-composer { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.wa-composer textarea { flex: 1 1 240px; min-height: 44px; border-radius: 12px; border: 1px solid #d6d3d1; padding: 10px; font: inherit; resize: vertical; box-sizing: border-box; }
.wa-locked { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.wa-locked p { margin: 0; font-size: 12px; color: #78716c; }
.wa-locked select { min-height: 44px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 8px; font: inherit; }
.wa-note-form { display: flex; gap: 8px; }
.wa-note-form input { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid #fde047; background: #fefce8; padding: 8px 10px; font: inherit; }
.wa-empty { color: #78716c; font-size: 13px; margin: 0; }
@media (max-width: 720px) {
  .wa-split { grid-template-columns: 1fr; min-height: 0; }
  .wa-list { max-height: 30vh; }
  .wa-bub { max-width: 92%; }
  .wa-assign input { width: 110px; }
}

.wa-kill { background: #fff; border: 1px solid #e7e5e4; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.wa-killrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.wa-killrow.is-on, .wa-killrow.is-on b { color: #991b1b; }
.wa-killrow.is-on { background: #fee2e2; border-radius: 10px; padding: 8px 10px; }
.wa-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #44403c; }
.wa-field textarea { border-radius: 10px; border: 1px solid #d6d3d1; padding: 8px 10px; font: inherit; }
@media (max-width: 720px) { .wa-killrow .pt-btn { width: 100%; } }
/* Email panel (lean): metrics, two panes, badges, composer; phone to wide */
.em { display: flex; flex-direction: column; gap: 10px; min-height: 0; position: relative; }
.em-metrics { display: flex; flex-wrap: wrap; gap: 8px; }
.em-kpi { flex: 1 1 120px; background: #fff; border: 1px solid #e7e5e4; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.em-kpi b { font-size: 20px; }
.em-kpi span { font-size: 11px; color: #78716c; text-transform: uppercase; letter-spacing: 0.05em; }
.em-bar { display: flex; gap: 8px; }
.em-bar input { flex: 1; min-height: 42px; border-radius: 12px; border: 1px solid #d6d3d1; padding: 8px 12px; font: inherit; box-sizing: border-box; min-width: 0; }
.em-split { display: grid; grid-template-columns: minmax(230px, 320px) minmax(0, 1fr); gap: 12px; min-height: 60vh; }
.em-list { list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.em-row { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 10px; border-radius: 12px; border: 1px solid #e7e5e4; background: #fff; cursor: pointer; font: inherit; box-sizing: border-box; min-height: 56px; }
.em-row.is-on { border-color: #1c1917; box-shadow: inset 0 0 0 1px #1c1917; }
.em-rowtop { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.em-rowtop b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-rowtop small, .em-rowsub { color: #78716c; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.em-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: #f5f5f4; color: #44403c; }
.em-badge.is-unread { background: #dbeafe; color: #1e40af; }
.em-badge.is-replied { background: #dcfce7; color: #166534; }
.em-badge.is-sched { background: #ede9fe; color: #5b21b6; }
.em-badge.is-failed { background: #fee2e2; color: #991b1b; }
.em-thread { min-width: 0; display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid #e7e5e4; border-radius: 14px; padding: 12px; }
.em-head { display: flex; flex-direction: column; gap: 6px; }
.em-headtop, .em-headrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.em-headtop span { color: #78716c; font-size: 12px; }
.em-inuse { background: #fef9c3; color: #854d0e; padding: 3px 9px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.em-assign { font-size: 12px; display: flex; gap: 6px; align-items: center; }
.em-assign input { min-height: 36px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 4px 8px; font: inherit; width: 130px; }
.em-msgs { display: flex; flex-direction: column; gap: 8px; overflow: auto; max-height: 48vh; min-height: 200px; }
.em-msg { border-radius: 12px; padding: 10px 12px; max-width: 85%; }
.em-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.em-msg small { color: #78716c; font-size: 11px; display: block; margin-top: 4px; }
.em-msg.is-in { background: #f5f5f4; align-self: flex-start; }
.em-msg.is-out { background: #eef2ff; align-self: flex-end; }
.em-subj { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.em-del { font-weight: 700; }
.em-failed, .em-bounced { color: #b91c1c; }
.em-delivered { color: #166534; }
.em-flag { color: #b45309; font-weight: 700; }
.em-note { background: #fef08a; border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.em-composer { display: flex; flex-direction: column; gap: 8px; }
.em-composer input[name=subject] { min-height: 40px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 8px 10px; font: inherit; }
.em-composer textarea { border-radius: 12px; border: 1px solid #d6d3d1; padding: 10px; font: inherit; resize: vertical; box-sizing: border-box; width: 100%; }
.em-tools, .em-send { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.em-tools select { min-height: 40px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 6px; font: inherit; }
.em-when { font-size: 12px; display: flex; gap: 6px; align-items: center; }
.em-when input { min-height: 40px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 4px 8px; font: inherit; }
.em-send { margin-left: auto; }
.em-hint, .em-empty { color: #78716c; font-size: 12px; margin: 0; }
.em-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1c1917; color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; z-index: 1600; }
.em-toast[hidden] { display: none; }
.em-toast .pt-btn { background: #fff; color: #1c1917; }
@media (max-width: 720px) {
  .em-split { grid-template-columns: 1fr; min-height: 0; }
  .em-list { max-height: 30vh; }
  .em-msg { max-width: 95%; }
  .em-send .pt-btn { flex: 1 1 auto; }
  .em-assign input { width: 110px; }
}

.em-tplsend { border: 1px solid #e7e5e4; border-radius: 12px; padding: 8px 10px; background: #fafaf9; }
.em-tplsend form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.em-tplsend select { min-height: 40px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 6px; font: inherit; }
.em-fields { display: flex; flex-direction: column; gap: 6px; }
.em-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #44403c; }
.em-field input { min-height: 40px; border-radius: 10px; border: 1px solid #d6d3d1; padding: 6px 10px; font: inherit; }
.em-files { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: #44403c; }
.em-files input { font: inherit; font-size: 12px; max-width: 220px; }
/* The security check box while it runs (Non-Interactive mode: a loading bar shows) */
.ts-host { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2000; width: min(300px, calc(100vw - 32px)); background: #fff; color: #1c1917; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.18); padding: 8px; box-sizing: border-box; }

.ts-label { display: block; font-size: 12px; color: #44403c; padding: 2px 6px 6px; }
