/* Full-height split editor — only used by the code preview tool. */

:root {
  --editor-font: 'JetBrains Mono', Consolas, 'SF Mono', Menlo, Monaco, monospace;
  --editor-font-size: 13px;
}

.editor-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* The templates rail is the first column and collapses to nothing when signed
   out, so the split stays a plain two-pane grid for everyone else.

   Every child names its column explicitly: the rail is `display: none` while
   signed out, and auto-placement would otherwise slide the code pane into the
   0px first column. */
.editor {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  display: grid;
  grid-template-columns: var(--side, 0px) var(--split, 1fr) 5px 1fr;
  background: var(--bg-soft);
}
.editor--with-side { --side: 250px; }
.editor--with-side.editor--side-collapsed { --side: 46px; }

.side { grid-column: 1; }
.editor__pane--code { grid-column: 2; }
.editor__grip { grid-column: 3; }
.editor__pane--preview { grid-column: 4; }

.editor__pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}
.editor__pane--preview { border-left: 1px solid var(--border); }

.editor__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  flex: 0 0 auto;
}

.editor__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  flex: 0 0 auto;
}

/* Which template the editors currently hold. The dot marks unsaved edits. */
.editor__doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  font-size: 12.5px !important;
  line-height: 1.4 !important;
  font-weight: 600;
  color: var(--text);
}
.editor__doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor__doc--untitled { color: var(--text-faint); font-weight: 500; }
.editor__doc-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.editor__doc-dot[hidden] { display: none; }

.editor__stack { flex: 1 1 auto; min-height: 0; position: relative; }

.editor__code {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 14px 16px;
  border: 0;
  resize: none;
  background: var(--surface);
  color: var(--text);
  font-family: var(--editor-font, 'JetBrains Mono', Consolas, monospace);
  font-size: var(--editor-font-size, 13px);
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.editor__code:focus { outline: none; }
.editor__code::placeholder { color: var(--text-faint); }

.editor__grip {
  background: var(--border);
  cursor: col-resize;
  transition: background .12s;
}
.editor__grip:hover, .editor__grip:focus-visible { background: var(--accent); outline: none; }

.editor__preview {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface);
  position: relative;
}
.editor__preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #ffffff;
}

/* ---- Preview Loading Overlay -------------------------------------------- */
.preview-loader {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(15, 17, 26, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.22s ease;
}
.preview-loader[hidden] {
  display: none;
}
.preview-loader.preview-loader--fade {
  opacity: 0;
}
.preview-loader__spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(59, 130, 246, 0.22);
  border-top-color: #60a5fa;
  border-right-color: #93c5fd;
  animation: preview-spin 0.75s cubic-bezier(0.6, 0.05, 0.4, 0.95) infinite;
  box-shadow: 0 0 18px rgba(96, 165, 250, 0.35);
}
.preview-loader__label {
  font-size: 12px;
  font-weight: 500;
  color: #8b95a7;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
@keyframes preview-spin {
  to { transform: rotate(360deg); }
}

[data-theme="light"] .preview-loader {
  background: rgba(248, 250, 252, 0.80);
}
[data-theme="light"] .preview-loader__spinner {
  border-color: rgba(59, 130, 246, 0.18);
  border-top-color: #3b82f6;
  border-right-color: #3b82f6;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.25);
}
[data-theme="light"] .preview-loader__label {
  color: #64748b;
}

.editor__console {
  flex: 0 0 auto;
  height: 200px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.editor__console-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
/* Console action buttons: reddish tone normally, vivid colored hover */
#console-clear,
#console-close {
  color: var(--danger, #f43f5e) !important;
  border: 1px solid color-mix(in srgb, var(--danger, #f43f5e) 35%, var(--border)) !important;
  background: color-mix(in srgb, var(--danger, #f43f5e) 10%, transparent) !important;
  transition: all 0.15s ease;
}

#console-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-weight: 550;
  cursor: pointer;
}

#console-clear svg {
  display: block;
  flex: 0 0 auto;
}

#console-close {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  border-radius: var(--radius-sm, 6px);
}

#console-clear:hover,
#console-close:hover {
  color: #ffffff !important;
  background: var(--danger, #f43f5e) !important;
  border-color: var(--danger, #f43f5e) !important;
  box-shadow: 0 2px 8px -1px color-mix(in srgb, var(--danger, #f43f5e) 50%, transparent);
}

#console-clear:active,
#console-close:active {
  transform: translateY(1px);
  filter: brightness(0.9);
}

[data-theme="dark"] #console-clear,
[data-theme="dark"] #console-close {
  color: #fb7185 !important;
  background: rgba(244, 63, 94, 0.12) !important;
  border-color: rgba(244, 63, 94, 0.35) !important;
}

[data-theme="dark"] #console-clear:hover,
[data-theme="dark"] #console-close:hover {
  color: #ffffff !important;
  background: #f43f5e !important;
  border-color: #f43f5e !important;
  box-shadow: 0 2px 10px rgba(244, 63, 94, 0.45);
}
.editor__console-log {
  flex: 1 1 auto;
  overflow: auto;
  padding: 6px 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

.log-line {
  display: flex;
  gap: 8px;
  padding: 3px 12px;
  border-bottom: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
.log-line:last-child { border-bottom: 0; }
.log-line__tag {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding-top: 2px;
  min-width: 38px;
}
.log-line--error { background: var(--danger-soft); color: var(--danger); }
.log-line--error .log-line__tag { color: var(--danger); }
.log-line--warn { background: var(--warn-soft); color: var(--warn); }
.log-line--warn .log-line__tag { color: var(--warn); }

.editor__console-log .empty { padding: 22px; }

/* --- saved templates rail ------------------------------------------------- */

.side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
}
.side[hidden] { display: none; }

.side__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.side__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-faint);
  overflow: hidden;
  white-space: nowrap;
}

/* Collapsed: only the rail of icons survives, stacked so they still fit. */
.editor--side-collapsed .side__bar { flex-direction: column; padding: 8px 6px; }
.editor--side-collapsed .side__title,
.editor--side-collapsed .side__body { display: none; }

.side__body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.side__search {
  height: 28px;
  margin: 8px;
  font-size: 12.5px;
  flex: 0 0 auto;
}

.side__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px 6px;
}
.side__list .empty { padding: 26px 14px; font-size: 12.5px; }

.tpl {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  padding-right: 4px;
}
.tpl:hover { background: var(--surface); }
.tpl--active { background: var(--accent-soft); }

.tpl__open {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  padding: 7px 8px;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.tpl__name {
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl--active .tpl__name { color: var(--accent); }
.tpl__meta { font-size: 11px; color: var(--text-faint); }

/* Row actions stay out of the way until the row is hovered or focused, but
   remain reachable by keyboard and always visible on touch. */
.tpl__actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.tpl:hover .tpl__actions,
.tpl:focus-within .tpl__actions { opacity: 1; }
@media (hover: none) { .tpl__actions { opacity: 1; } }

/* .icon-btn--xs now lives in app.css — the Bug Sheet's column list needs it
   too, and that page does not load this stylesheet. */

/* --- folder groups --------------------------------------------------------- */

.tpl-folder + .tpl-folder { margin-top: 2px; }
.tpl-folder--unfiled { margin-top: 6px; }

.tpl-folder__head {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--radius-sm);
}
.tpl-folder__head:hover { background: var(--surface); }

.tpl-folder__toggle {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.tpl-folder__toggle svg { flex: 0 0 auto; transition: transform .12s; }
.tpl-folder--collapsed .tpl-folder__toggle svg { transform: rotate(-90deg); }

.tpl-folder__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-folder__name--static { padding: 7px 8px; color: var(--text-faint); }

.tpl-folder__count { flex: 0 0 auto; font-size: 11px; color: var(--text-faint); }

.tpl-folder__head:hover .tpl__actions,
.tpl-folder__head:focus-within .tpl__actions { opacity: 1; }
@media (hover: none) { .tpl-folder .tpl__actions { opacity: 1; } }

.tpl-folder__body { padding-left: 10px; }
.tpl-folder--collapsed .tpl-folder__body { display: none; }

.tpl-folder__empty {
  padding: 6px 8px 6px 16px;
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

/* --- move-to-folder dialog -------------------------------------------------- */

.move-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
}
.move-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.move-opt:hover { background: var(--bg-soft); }
.move-opt--active { border-color: var(--accent); color: var(--accent); }
.move-opt__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .editor-body { height: auto; overflow: auto; }
  /* The rail becomes a strip above the editor instead of a column beside it. */
  .editor { grid-template-columns: 1fr; }
  .side, .editor__pane--code, .editor__grip, .editor__pane--preview { grid-column: 1; }
  .editor__grip { display: none; }
  .editor__stack { height: 46vh; }
  .editor__pane--preview { border-left: 0; border-top: 1px solid var(--border); height: 60vh; }

  .side { border-right: 0; border-bottom: 1px solid var(--border); }
  .side__list { max-height: 40vh; }
  .editor--side-collapsed .side__bar { flex-direction: row; }
}

/* --- Live Code Preview: icon-only left rail -----------------------------------
   Only this page (body.editor-body) turns the top bar into a ~62px fixed icon
   strip, freeing maximum width for code + preview. Each tool link shows just
   its icon (injected from the shared TOOLS registry by code-preview.js); the
   full name flies out on hover. More Tools keeps its grid icon and flies its
   whole menu out to the right. Theme + account stack vertically at the bottom.
   Small screens fall back to the normal top bar + hamburger via the reset
   below, so every rule here lives inside the desktop media query. */

@media (min-width: 721px) {
body.editor-body { padding-left: 52px !important; }
body.editor-body .nav {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  width: 52px !important;
  height: 100vh !important;
  max-height: 100vh !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 10px 6px !important;
  border-bottom: 0 !important;
  border-right: 1px solid var(--border) !important;
  overflow: visible !important;
  z-index: 900 !important;
}
/* The wide wordmark cannot fit a 62px strip: hide it and show the square
   favicon tile instead — the same artwork as the browser tab. */
body.editor-body .nav__mark { display: none; }
body.editor-body .nav__brand {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #fff url('../images/favicon.svg?v=6') center / 22px no-repeat;
  box-shadow: 0 0 0 1px rgba(10, 40, 80, 0.28);
}
body.editor-body .nav__center {
  flex: 0 0 auto;
  justify-content: stretch;
  width: 100%;
  margin-top: 6px;
}
body.editor-body .nav__links {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
}
body.editor-body .nav__link,
body.editor-body .nav__link[aria-current="page"] {
  position: relative !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  max-width: 34px !important;
  max-height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border-radius: 9px !important;
  overflow: visible !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-decoration: none !important;
}
body.editor-body .nav__link svg,
body.editor-body .nav__dropdown-btn svg {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
  margin: auto !important;
  flex-shrink: 0 !important;
}
/* --- High-End Redesigned Rail Tooltip --- */
body.editor-body .rail-tip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  padding: 6px 12px;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.94) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  color: #f8fafc !important;
  font-family: var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.15s;
  z-index: 99999 !important;
  box-shadow: 
    0 10px 25px -4px rgba(0, 0, 0, 0.65),
    0 4px 10px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* Tooltip Left-Pointing Arrow / Caret */
body.editor-body .rail-tip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

body.editor-body .rail-tip::after {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-right-color: rgba(15, 23, 42, 0.94);
  pointer-events: none;
}

[data-theme="light"] body.editor-body .rail-tip {
  background: rgba(15, 23, 42, 0.92) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
  box-shadow: 
    0 10px 25px -4px rgba(0, 0, 0, 0.3),
    0 4px 10px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] body.editor-body .rail-tip::after {
  border-right-color: rgba(15, 23, 42, 0.92);
}

body.editor-body .nav__link:hover .rail-tip,
body.editor-body .nav__link:focus-visible .rail-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}
/* More Tools: grid icon only — the label and chevron stay hidden while the
   whole menu flies out to the right (opened on hover via JS, because the
   global [hidden] rule cannot be beaten by :hover CSS alone). */
body.editor-body .nav__dropdown {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
body.editor-body .nav__dropdown-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 9px;
}
body.editor-body .nav__dropdown-btn > span,
body.editor-body .nav__dropdown-chev { display: none; }
body.editor-body .nav__dropdown-menu {
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 240px;
  width: max-content;
  max-width: min(300px, calc(100vw - 90px));
  margin-top: 0;
  padding: 6px;
  padding-left: 16px; /* 10px visual gap + 6px original padding — bridge so hover zone is continuous */
  z-index: 80;
  box-sizing: border-box;
}
/* Theme + account stack vertically, pinned to the bottom of the strip. */
body.editor-body .nav__end {
  margin-left: 0;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
body.editor-body .nav__toggle { display: none; }
}

@media (max-width: 720px) {
  body.editor-body { padding-left: 0; }
  body.editor-body .nav {
    position: sticky;
    top: 0;
    bottom: auto;
    width: auto;
    height: var(--nav-h);
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  body.editor-body .nav__brand { justify-content: flex-start; }
  body.editor-body .nav__mark { height: 35px; }
  /* Hand the menu back to the hamburger dropdown from app.css. */
  body.editor-body .nav__center {
    flex: 1 1 auto;
    justify-content: center;
    position: absolute;
    top: calc(100% + 8px);
    right: 12px;
    left: auto;
    width: min(260px, calc(100vw - 24px));
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(.97);
    transform-origin: top right;
  }
  body.editor-body .nav__center--open {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  body.editor-body .nav__links {
    width: 100%;
    padding: 8px;
    border-radius: var(--radius);
  }
  body.editor-body .nav__link { padding: 10px 14px; }
  body.editor-body .nav__link[aria-current="page"] { padding: 10px 14px; }
  body.editor-body .nav__dropdown-btn { padding: 10px 14px; }
  body.editor-body .nav__end { margin-top: 0; margin-left: auto; padding-top: 0; border-top: 0; justify-content: flex-end; }
  body.editor-body .nav__toggle { display: grid; }
}

/* --- Slim toolbars: narrower bars, more room for code + preview ------------- */
/* Both top bars share one height so code + preview stay aligned. */
.editor__bar { padding: 3px 10px; gap: 8px; min-height: 34px; }
.editor__foot { padding: 5px 10px; gap: 6px; }
.editor__console-bar { padding: 4px 10px; }
.side__bar { padding: 5px 8px 5px 10px; }

/* Compact language tabs: almost no padding, so the code bar matches the
   Preview bar height. The error dot tucks into the smaller corner. */
.editor__pane--code .seg { padding: 1px; gap: 1px; }
.editor__pane--code .seg button { padding: 2px 7px; font-size: 12px; }
body.editor-body .seg-dot { top: 2px; right: 2px; }
/* Run is an icon button (play glyph injected by code-preview.js): square it. */
#run-btn { padding: 0 7px; }
#run-btn svg { display: block; }

/* Editor action buttons hover styling */
#save-btn:hover,
#saveas-btn:hover,
#run-btn:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  color: #f1f5f9 !important;
}

#sample-btn:hover,
#export-btn:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent) !important;
  border-color: var(--accent) !important;
  color: var(--text) !important;
}

[data-theme="dark"] #sample-btn:hover,
[data-theme="dark"] #export-btn:hover {
  background: color-mix(in srgb, var(--accent) 24%, #252526) !important;
  border-color: var(--accent) !important;
  color: #e2e8f0 !important;
}

/* Line wrap toggle button */
#wrap-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm, 6px);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

#inspect-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm, 6px);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 6px;
  flex-shrink: 0;
}
#inspect-btn:hover {
  color: var(--text-strong, #e2e8f0);
  border-color: var(--border-strong);
  background: var(--surface-2, rgba(255, 255, 255, 0.06));
}
#inspect-btn.is-active,
#inspect-btn[aria-pressed="true"] {
  color: #60a5fa !important;
  background: rgba(59, 130, 246, 0.18) !important;
  border-color: rgba(59, 130, 246, 0.5) !important;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3) !important;
}
#inspect-btn.is-active:hover {
  color: #93c5fd !important;
  background: rgba(59, 130, 246, 0.28) !important;
  border-color: rgba(59, 130, 246, 0.7) !important;
}

#wrap-btn:hover {
  color: var(--text-strong, #e2e8f0);
  border-color: var(--border-strong);
  background: var(--surface-2, rgba(255, 255, 255, 0.06));
}
#wrap-btn.is-active,
#wrap-btn[aria-pressed="true"] {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.45);
}
#wrap-btn.is-active:hover {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.24);
  border-color: rgba(59, 130, 246, 0.65);
}

/* Sample menu: 3-option popup above the Sample button. */
.sample-menu-wrap { position: relative; display: inline-flex; }
.sample-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 80;
}
.sample-opt {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.sample-opt:hover { background: var(--bg-soft); }
.sample-opt__label { font-size: 13px; font-weight: 600; }
.sample-opt__desc { font-size: 11.5px; color: var(--text-muted); }

/* --- Overlay code editor: line numbers + indent block guides ----------------
   Same technique as the JSON formatter: the real textarea sits transparent
   over a highlighted <pre>, so typing, Tab, shortcuts and scrolling behave
   natively while numbers, colours and block guides paint underneath. */

.editor__stack { overflow: hidden; }

.cpe { position: absolute; inset: 0; display: flex; min-height: 0; }
.cpe[hidden] { display: none; }

.cpe__gutter {
  flex: 0 0 auto;
  width: 66px;
  overflow: hidden;
  overflow: clip;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 14px 0;
  user-select: none;
}
.cpe__nums {
  font-family: var(--editor-font, 'JetBrains Mono', Consolas, monospace);
  font-size: var(--editor-font-size, 13px);
  line-height: 1.65;
  text-align: right;
  /* Daylight between the numbers and fold chevrons */
  padding-left: 4px;
  padding-right: 5px;
  color: var(--text-faint);
  white-space: pre;
  will-change: transform;
  flex: 1 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.cpe__nums .ln-err { color: var(--danger); font-weight: 700; }
.cpe__ln {
  min-height: 1.65em;
  line-height: 1.65;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 3px;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
}
.cpe__ln.ln-err { color: var(--danger); font-weight: 700; }

.cpe__ln-num {
  flex: 1 1 auto;
  text-align: right;
  line-height: 1.65;
  display: inline-block;
}

.cpe__fold-btn {
  flex: 0 0 18px;
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
  margin: 1px 0 0 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 3px;
  opacity: 0.42;
  appearance: none;
  -webkit-appearance: none;
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.cpe__fold-btn svg {
  display: block;
  pointer-events: none;
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
}
.cpe__ln:hover .cpe__fold-btn {
  opacity: 0.8;
  color: var(--text-muted);
}
.cpe__fold-btn:hover {
  opacity: 1;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}
.cpe__fold-btn--collapsed,
.cpe__ln--collapsed .cpe__fold-btn {
  opacity: 1;
  color: var(--accent);
  font-weight: 700;
}
.cpe__fold-spacer {
  flex: 0 0 18px;
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin: 1px 0 0 0;
  display: inline-block;
  pointer-events: none;
}

.cpe__ln--collapsed {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--accent);
}
.cpe__ln--collapsed + .cpe__ln--collapsed {
  border-top: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.cpe__ln--collapsed .cpe__ln-num {
  color: var(--accent);
  font-weight: 650;
}

.cpe__gutter-fill {
  flex: 1 1 auto;
  min-height: 8px;
}

.cpe__fold-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  user-select: none;
  pointer-events: auto;
  transition: all 0.12s ease;
}
.cpe__fold-badge:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.cpe__wrap { position: relative; flex: 1 1 auto; min-width: 0; }
.cpe__hi {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.cpe__pre {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--editor-font, 'JetBrains Mono', Consolas, monospace);
  font-size: var(--editor-font-size, 13px);
  line-height: 1.65;
  tab-size: 2;
  will-change: transform;
  box-sizing: border-box;
}
.cpe__line {
  white-space: pre;
  padding-right: 24px;
  box-sizing: border-box;
  /* Indent block guides: 1px rules every --istep, drawn only --d deep. */
  background-image: repeating-linear-gradient(to right, var(--guide, transparent) 0 1px, transparent 1px var(--istep, 2ch));
  background-size: calc(max(0px, (var(--d, 0) - 1) * var(--istep, 2ch) + 1px)) 100%;
  background-repeat: no-repeat;
}
[data-theme="dark"] .cpe__line { --guide: rgba(255, 255, 255, .09); }
:root:not([data-theme="dark"]) .cpe__line { --guide: rgba(15, 23, 42, .10); }
.cpe__line:empty::before { content: '\200b'; }

.cpe--wrap .cpe__line {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
}
.cpe--wrap .cpe__code {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  overflow-x: hidden !important;
  overflow-y: scroll !important;
}

.cpe__line--collapsed {
  background-color: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
  border-radius: 2px;
}

.cpe__code {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 14px 16px;
  padding-right: 40px;
  border: 0;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  font-family: var(--editor-font, 'JetBrains Mono', Consolas, monospace);
  font-size: var(--editor-font-size, 13px);
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
  overflow-y: scroll;
}
.cpe__code:focus { outline: none; }
.cpe__code::placeholder { color: var(--text-faint); }
.cpe__code::selection { background: var(--accent); color: #ffffff; text-shadow: none; }

/* Key-repeat (held Backspace / typing burst): show the real textarea so
   characters delete at native speed while the highlight layer catches up. */
.cpe--live .cpe__code { color: var(--text); }
.cpe--live .cpe__hi { visibility: hidden; }

/* Token colours (both themes below). */
.hl-com { color: var(--text-faint); font-style: italic; }
.hl-str { color: #0e9f6e; }
.hl-num { color: #c27803; }
.hl-kw { color: #2563eb; }
.hl-punc { color: var(--text-muted); }
.hl-tag { color: #dc2626; }
.hl-attr { color: #2563eb; }
.hl-sel { color: #2563eb; }
.hl-prop { color: #2563eb; }
.hl-at { color: #c27803; }
[data-theme="dark"] .hl-str { color: #6ede9c; }
[data-theme="dark"] .hl-num { color: #f5b14c; }
[data-theme="dark"] .hl-kw { color: #93c5fd; }
[data-theme="dark"] .hl-punc { color: #8b95a7; }
[data-theme="dark"] .hl-tag { color: #f87171; }
[data-theme="dark"] .hl-attr { color: #93c5fd; }
[data-theme="dark"] .hl-sel { color: #93c5fd; }
[data-theme="dark"] .hl-prop { color: #93c5fd; }
[data-theme="dark"] .hl-at { color: #f5b14c; }

/* Error dot on the HTML/CSS/JS tab + red line number in the gutter. */
.seg button { position: relative; }
.seg-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
}
.seg-dot[hidden] { display: none; }

/* Language icons before the HTML/CSS/JS tab labels. */
.editor__pane--code .seg button[data-lang]::before {
  content: none !important;
  display: none !important;
}

.editor__pane--code .seg {
  padding: 2px;
  gap: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.editor__pane--code .seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

/* Inactive tabs hover */
.editor__pane--code .seg button[data-lang="html"]:hover:not([aria-selected="true"]) {
  background: rgba(228, 77, 38, 0.08);
  color: var(--text);
}
.editor__pane--code .seg button[data-lang="css"]:hover:not([aria-selected="true"]) {
  background: rgba(37, 99, 235, 0.08);
  color: var(--text);
}
.editor__pane--code .seg button[data-lang="js"]:hover:not([aria-selected="true"]) {
  background: rgba(234, 179, 8, 0.08);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Active Language Tab Highlight (HTML / CSS / JS) - Dark Theme
   -------------------------------------------------------------------------- */
[data-theme="dark"] .editor__pane--code .seg button[data-lang="html"][aria-selected="true"],
:root[data-theme="dark"] .editor__pane--code .seg button[data-lang="html"][aria-selected="true"],
html[data-theme="dark"] .editor__pane--code .seg button[data-lang="html"][aria-selected="true"] {
  background: rgba(228, 77, 38, 0.20) !important;
  color: #ff8a65 !important;
  border-color: rgba(228, 77, 38, 0.55) !important;
  box-shadow: 0 1px 6px rgba(228, 77, 38, 0.28) !important;
}

[data-theme="dark"] .editor__pane--code .seg button[data-lang="css"][aria-selected="true"],
:root[data-theme="dark"] .editor__pane--code .seg button[data-lang="css"][aria-selected="true"],
html[data-theme="dark"] .editor__pane--code .seg button[data-lang="css"][aria-selected="true"] {
  background: rgba(37, 99, 235, 0.24) !important;
  color: #70b5ff !important;
  border-color: rgba(59, 130, 246, 0.55) !important;
  box-shadow: 0 1px 6px rgba(37, 99, 235, 0.30) !important;
}

[data-theme="dark"] .editor__pane--code .seg button[data-lang="js"][aria-selected="true"],
:root[data-theme="dark"] .editor__pane--code .seg button[data-lang="js"][aria-selected="true"],
html[data-theme="dark"] .editor__pane--code .seg button[data-lang="js"][aria-selected="true"] {
  background: rgba(234, 179, 8, 0.20) !important;
  color: #ffd84d !important;
  border-color: rgba(234, 179, 8, 0.52) !important;
  box-shadow: 0 1px 6px rgba(234, 179, 8, 0.25) !important;
}

/* --------------------------------------------------------------------------
   Active Language Tab Highlight (HTML / CSS / JS) - Light Theme
   -------------------------------------------------------------------------- */
:root:not([data-theme="dark"]) .editor__pane--code .seg button[data-lang="html"][aria-selected="true"],
html[data-theme="light"] .editor__pane--code .seg button[data-lang="html"][aria-selected="true"],
body[data-theme="light"] .editor__pane--code .seg button[data-lang="html"][aria-selected="true"] {
  background: #fff3ec !important;
  color: #c2410c !important;
  border-color: #fdba74 !important;
  box-shadow: 0 1px 3px rgba(228, 77, 38, 0.22) !important;
}

:root:not([data-theme="dark"]) .editor__pane--code .seg button[data-lang="css"][aria-selected="true"],
html[data-theme="light"] .editor__pane--code .seg button[data-lang="css"][aria-selected="true"],
body[data-theme="light"] .editor__pane--code .seg button[data-lang="css"][aria-selected="true"] {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border-color: #93c5fd !important;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.22) !important;
}

:root:not([data-theme="dark"]) .editor__pane--code .seg button[data-lang="js"][aria-selected="true"],
html[data-theme="light"] .editor__pane--code .seg button[data-lang="js"][aria-selected="true"],
body[data-theme="light"] .editor__pane--code .seg button[data-lang="js"][aria-selected="true"] {
  background: #fefce8 !important;
  color: #a16207 !important;
  border-color: #fde047 !important;
  box-shadow: 0 1px 3px rgba(202, 138, 4, 0.22) !important;
}

/* Active Dropdown items for narrow pane */
.seg-dropdown__item[data-lang="html"].is-active {
  background: rgba(228, 77, 38, 0.16) !important;
  color: #ff8a65 !important;
}
:root:not([data-theme="dark"]) .seg-dropdown__item[data-lang="html"].is-active,
html[data-theme="light"] .seg-dropdown__item[data-lang="html"].is-active {
  background: #fff3ec !important;
  color: #c2410c !important;
}

.seg-dropdown__item[data-lang="css"].is-active {
  background: rgba(37, 99, 235, 0.20) !important;
  color: #70b5ff !important;
}
:root:not([data-theme="dark"]) .seg-dropdown__item[data-lang="css"].is-active,
html[data-theme="light"] .seg-dropdown__item[data-lang="css"].is-active {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
}

.seg-dropdown__item[data-lang="js"].is-active {
  background: rgba(234, 179, 8, 0.18) !important;
  color: #ffd84d !important;
}
:root:not([data-theme="dark"]) .seg-dropdown__item[data-lang="js"].is-active,
html[data-theme="light"] .seg-dropdown__item[data-lang="js"].is-active {
  background: #fefce8 !important;
  color: #a16207 !important;
}

.seg-lang-icon {
  display: block;
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  transition: transform 0.12s ease;
}

.editor__pane--code .seg button:hover .seg-lang-icon {
  transform: scale(1.1);
}

/* --- Active line highlight (Go to line / Error / Warning) ---------------- */

.cpe__line.cpe__line--highlight-warn {
  background-color: rgba(245, 158, 11, 0.22) !important;
  box-shadow: inset 4px 0 0 #f59e0b, 0 0 16px rgba(245, 158, 11, 0.18) !important;
  border-radius: 2px;
  animation: cpe-line-pulse-warn 1.8s ease-in-out infinite alternate;
}

.cpe__line.cpe__line--highlight {
  background-color: rgba(239, 68, 68, 0.22) !important;
  box-shadow: inset 4px 0 0 #ef4444, 0 0 16px rgba(239, 68, 68, 0.18) !important;
  border-radius: 2px;
  animation: cpe-line-pulse-err 1.8s ease-in-out infinite alternate;
}

@keyframes cpe-line-pulse-warn {
  0% { background-color: rgba(245, 158, 11, 0.18); }
  100% { background-color: rgba(245, 158, 11, 0.32); }
}

@keyframes cpe-line-pulse-err {
  0% { background-color: rgba(239, 68, 68, 0.18); }
  100% { background-color: rgba(239, 68, 68, 0.32); }
}

.cpe__ln.cpe__ln--highlight-warn {
  background-color: rgba(245, 158, 11, 0.22) !important;
  color: #f59e0b !important;
  font-weight: 700 !important;
}


/* Inspect line highlight in code editor */
.cpe__line.cpe__line--inspect {
  box-shadow: inset 3px 0 0 #2563eb !important;
  border-radius: 2px;
}
.cpe__ln.cpe__ln--inspect {
  background-color: rgba(59, 130, 246, 0.35) !important;
  color: #60a5fa !important;
  font-weight: 800 !important;
  box-shadow: inset 4px 0 0 #2563eb !important;
}
[data-theme="dark"] .cpe__line.cpe__line--inspect {
  box-shadow: inset 3px 0 0 #60a5fa !important;
}
[data-theme="dark"] .cpe__ln.cpe__ln--inspect {
  background-color: rgba(59, 130, 246, 0.38) !important;
  color: #93c5fd !important;
  box-shadow: inset 4px 0 0 #60a5fa !important;
}
@keyframes cpe-line-pulse-inspect {
  0% { background-color: rgba(59, 130, 246, 0.18); }
  100% { background-color: rgba(59, 130, 246, 0.34); }
}

/* Matching HTML start / end tag highlight */
.cpe__tag-wrap {
  display: inline;
  border-radius: 3px;
  position: relative;
  transition: background-color 0.12s ease, outline 0.12s ease, box-shadow 0.12s ease;
}
.cpe__tag-wrap.cpe__tag-match {
  background-color: rgba(6, 182, 212, 0.18) !important;
  outline: 1.5px solid #0891b2 !important;
  outline-offset: 1px !important;
  border-radius: 3px !important;
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.35) !important;
}
[data-theme="dark"] .cpe__tag-wrap.cpe__tag-match {
  background-color: rgba(34, 211, 238, 0.22) !important;
  outline: 1.5px solid #22d3ee !important;
  outline-offset: 1px !important;
  border-radius: 3px !important;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.45) !important;
}
.cpe__tag-wrap.cpe__tag-match.cpe__tag-match--partner {
  background-color: rgba(6, 182, 212, 0.26) !important;
  outline: 1.5px solid #06b6d4 !important;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5) !important;
}
[data-theme="dark"] .cpe__tag-wrap.cpe__tag-match.cpe__tag-match--partner {
  background-color: rgba(34, 211, 238, 0.28) !important;
  outline: 1.5px solid #38bdf8 !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6) !important;
}

.cpe__ln.cpe__ln--highlight {
  background-color: rgba(239, 68, 68, 0.22) !important;
  color: #ef4444 !important;
  font-weight: 700 !important;
}

.preview-error__line {
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.preview-error__line:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

/* --- Floating toolbar for selected text (Copy / Replace / Remove) -------- */

.sel-copy-widget {
  position: fixed;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 8px;
  font-family: var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  line-height: 1;
  user-select: none;
  transform: translate(-50%, -100%) translateY(-8px);
  transition: opacity 0.12s ease, transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  pointer-events: auto;
  opacity: 1;
}

.sel-copy-widget[hidden] {
  display: none !important;
}

.sel-copy-widget::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px 5px 0 5px;
  border-style: solid;
}

.sel-widget__actions,
.sel-widget__replace {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.sel-widget__actions[hidden],
.sel-widget__replace[hidden] {
  display: none !important;
}

.sel-widget__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: all 0.12s ease;
}

.sel-widget__btn svg {
  display: block;
  flex: 0 0 auto;
}

.sel-widget__btn:active {
  transform: scale(0.92);
}

.sel-widget__divider {
  display: inline-block;
  width: 1px;
  height: 14px;
  margin: 0 1px;
  opacity: 0.25;
}

.sel-widget__input {
  height: 24px;
  width: 140px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 12px;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.sel-widget__btn--danger {
  color: #ef4444 !important;
}

.sel-widget__btn--apply {
  background: #10b981 !important;
  color: #ffffff !important;
}
.sel-widget__btn--apply:hover {
  background: #059669 !important;
}

.sel-widget__btn--cancel:hover {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #ef4444 !important;
}

/* Persistent selection highlight overlay during replace mode */
.sel-replace-highlight {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
}

.sel-replace-highlight__box {
  position: fixed;
  pointer-events: none;
  background: rgba(59, 130, 246, 0.45);
  border: 1.5px solid #60a5fa;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  box-sizing: border-box;
  animation: selPulse 1.8s ease-in-out infinite alternate;
}

@keyframes selPulse {
  from {
    background: rgba(59, 130, 246, 0.40);
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
  }
  to {
    background: rgba(59, 130, 246, 0.55);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.7);
  }
}

:root:not([data-theme="dark"]) .sel-replace-highlight__box,
html[data-theme="light"] .sel-replace-highlight__box {
  background: rgba(37, 99, 235, 0.32);
  border: 1.5px solid #2563eb;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.4);
}

/* Light editor */
:root:not([data-theme="dark"]) .sel-copy-widget,
html[data-theme="light"] .sel-copy-widget {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #0f172a;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.32), 0 1px 4px rgba(15, 23, 42, 0.2);
}
:root:not([data-theme="dark"]) .sel-copy-widget::after,
html[data-theme="light"] .sel-copy-widget::after {
  border-color: #1e293b transparent transparent transparent;
}
:root:not([data-theme="dark"]) .sel-widget__btn:hover,
html[data-theme="light"] .sel-widget__btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}
:root:not([data-theme="dark"]) .sel-widget__btn--danger,
html[data-theme="light"] .sel-widget__btn--danger {
  color: #f87171 !important;
}
:root:not([data-theme="dark"]) .sel-widget__btn--danger:hover,
html[data-theme="light"] .sel-widget__btn--danger:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  color: #fca5a5 !important;
}
:root:not([data-theme="dark"]) .sel-widget__divider,
html[data-theme="light"] .sel-widget__divider {
  background: rgba(255, 255, 255, 0.3);
}
:root:not([data-theme="dark"]) .sel-widget__input,
html[data-theme="light"] .sel-widget__input {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
:root:not([data-theme="dark"]) .sel-widget__input:focus,
html[data-theme="light"] .sel-widget__input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa;
}

/* Dark editor (crisp chip matching screenshot) */
[data-theme="dark"] .sel-copy-widget {
  background: #dbeafe;
  color: #1e293b;
  border: 1px solid #bfdbfe;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.55), 0 1px 4px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .sel-copy-widget::after {
  border-color: #dbeafe transparent transparent transparent;
}
[data-theme="dark"] .sel-widget__btn:hover {
  background: rgba(30, 41, 59, 0.14);
  color: #0f172a;
}
[data-theme="dark"] .sel-widget__btn--danger {
  color: #ef4444 !important;
}
[data-theme="dark"] .sel-widget__btn--danger:hover {
  background: rgba(239, 68, 68, 0.16) !important;
  color: #dc2626 !important;
}
[data-theme="dark"] .sel-widget__divider {
  background: rgba(30, 41, 59, 0.25);
}
[data-theme="dark"] .sel-widget__input {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #94a3b8;
}
[data-theme="dark"] .sel-widget__input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

.sel-widget__btn--copied {
  color: #10b981 !important;
}

/* --- Preview error banner ----------------------------------------------------
   Sits on top of the preview: what broke + the exact line + a jump button. */

.editor__preview {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.editor__preview iframe {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  background: #ffffff;
}

.preview-error {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  background: color-mix(in srgb, var(--danger, #ef4444) 14%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--danger, #ef4444) 30%, var(--border));
  border-left: 4px solid var(--danger, #ef4444);
  color: var(--text);
  position: relative;
  z-index: 5;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.preview-error[hidden] { display: none; }

.preview-error--warn {
  background: color-mix(in srgb, var(--warn, #f59e0b) 14%, var(--surface));
  border-bottom-color: color-mix(in srgb, var(--warn, #f59e0b) 30%, var(--border));
  border-left-color: var(--warn, #f59e0b);
}

.preview-error__badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--danger, #ef4444);
  color: #ffffff;
  line-height: 1.2;
}
.preview-error--warn .preview-error__badge {
  background: var(--warn, #f59e0b);
  color: #111827;
}

.preview-error__msg {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.preview-error__line {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger, #ef4444) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #ef4444) 40%, transparent);
  color: var(--danger, #ef4444);
  white-space: nowrap;
}
.preview-error--warn .preview-error__line {
  background: color-mix(in srgb, var(--warn, #f59e0b) 20%, transparent);
  border-color: color-mix(in srgb, var(--warn, #f59e0b) 40%, transparent);
  color: var(--warn, #f59e0b);
}
.preview-error__line[hidden] { display: none; }

#preview-error-go {
  flex: 0 0 auto;
  height: 24px;
  padding: 0 8px;
  font-size: 11.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  transition: all 0.15s ease;
}
#preview-error-go:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong, var(--border));
  color: var(--text-strong, var(--text));
}
#preview-error-go[hidden] { display: none; }

.preview-error__close {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm, 6px);
  transition: all 0.15s ease;
}
.preview-error__close:hover {
  color: var(--text);
  background: var(--bg-soft);
}

/* Code editor styling for Blue (Default) and Luna Blue (XP) themes */
:root[data-theme="dark"]:not([data-theme-preset]) .editor__pane--code,
html[data-theme="dark"][data-theme-preset="default"] .editor__pane--code,
html[data-theme="dark"][data-theme-preset="xp"] .editor__pane--code {
  background: #1d2130 !important;
}

:root[data-theme="dark"]:not([data-theme-preset]) .editor__pane--code .editor__bar,
html[data-theme="dark"][data-theme-preset="default"] .editor__pane--code .editor__bar,
html[data-theme="dark"][data-theme-preset="xp"] .editor__pane--code .editor__bar,
:root[data-theme="dark"]:not([data-theme-preset]) .editor__pane--code .editor__foot,
html[data-theme="dark"][data-theme-preset="default"] .editor__pane--code .editor__foot,
html[data-theme="dark"][data-theme-preset="xp"] .editor__pane--code .editor__foot {
  background: #171a26 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"]:not([data-theme-preset]) .cpe,
html[data-theme="dark"][data-theme-preset="default"] .cpe,
html[data-theme="dark"][data-theme-preset="xp"] .cpe {
  background: #1d2130 !important;
}

:root[data-theme="dark"]:not([data-theme-preset]) .cpe__gutter,
html[data-theme="dark"][data-theme-preset="default"] .cpe__gutter,
html[data-theme="dark"][data-theme-preset="xp"] .cpe__gutter {
  background: #1d2130 !important;
  border-right-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"]:not([data-theme-preset]) .cpe__nums,
html[data-theme="dark"][data-theme-preset="default"] .cpe__nums,
html[data-theme="dark"][data-theme-preset="xp"] .cpe__nums {
  color: #7e89a6 !important;
}

:root[data-theme="dark"]:not([data-theme-preset]) .editor__grip,
html[data-theme="dark"][data-theme-preset="default"] .editor__grip,
html[data-theme="dark"][data-theme-preset="xp"] .editor__grip {
  background: rgba(255, 255, 255, 0.08) !important;
}
:root[data-theme="dark"]:not([data-theme-preset]) .editor__grip:hover,
html[data-theme="dark"][data-theme-preset="default"] .editor__grip:hover,
html[data-theme="dark"][data-theme-preset="xp"] .editor__grip:hover {
  background: var(--accent) !important;
}

/* Eye-comfort soft text styling for dark mode in Live Code Preview */
[data-theme="dark"] body.editor-body,
:root[data-theme="dark"] body.editor-body,
html[data-theme="dark"] body.editor-body {
  --text: #cbd5e1;
  --text-strong: #e2e8f0;
  --text-muted: #8b95a7;
  --text-faint: #64748b;
}

[data-theme="dark"] body.editor-body .card__title,
:root[data-theme="dark"] body.editor-body .card__title {
  color: #e2e8f0;
}

[data-theme="dark"] body.editor-body .editor__doc-name,
:root[data-theme="dark"] body.editor-body .editor__doc-name {
  color: #e2e8f0;
}



[data-theme="dark"] body.editor-body .check,
:root[data-theme="dark"] body.editor-body .check {
  color: #8b95a7;
}
[data-theme="dark"] body.editor-body .check:hover,
:root[data-theme="dark"] body.editor-body .check:hover {
  color: #cbd5e1;
}

[data-theme="dark"] body.editor-body .btn:not(.btn--primary):not(.btn--danger),
:root[data-theme="dark"] body.editor-body .btn:not(.btn--primary):not(.btn--danger) {
  color: #cbd5e1;
}
[data-theme="dark"] body.editor-body .btn:not(.btn--primary):not(.btn--danger):hover,
:root[data-theme="dark"] body.editor-body .btn:not(.btn--primary):not(.btn--danger):hover {
  color: #e2e8f0;
}

[data-theme="dark"] body.editor-body .btn--primary,
:root[data-theme="dark"] body.editor-body .btn--primary {
  color: #f1f5f9;
}

[data-theme="dark"] body.editor-body .editor__console-bar .card__title,
:root[data-theme="dark"] body.editor-body .editor__console-bar .card__title {
  color: #e2e8f0;
}

[data-theme="dark"] body.editor-body .side__title,
:root[data-theme="dark"] body.editor-body .side__title {
  color: #8b95a7;
}

[data-theme="dark"] body.editor-body #editor-status,
:root[data-theme="dark"] body.editor-body #editor-status {
  color: #7e89a6;
}

/* --- Redesigned Confirm Dialog Modal -------------------------------------- */
.confirm-dialog {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 0;
  overflow: hidden;
  width: min(440px, calc(100vw - 32px));
  position: relative;
}

[data-theme="dark"] .confirm-dialog {
  background: #171a26;
  border-color: rgba(255, 255, 255, 0.14);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.confirm-dialog__card {
  position: relative;
  padding: 24px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.confirm-dialog__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.confirm-dialog__close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.confirm-dialog__header-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.confirm-dialog__icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(244, 63, 94, 0.16);
  color: #f43f5e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.confirm-dialog.is-primary .confirm-dialog__icon-wrap {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
}

.confirm-dialog__title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.3;
}

.confirm-dialog__badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f43f5e;
  margin-top: 2px;
}

.confirm-dialog.is-primary .confirm-dialog__badge {
  color: var(--accent);
}

.confirm-dialog__content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.confirm-dialog__msg {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.confirm-dialog__msg strong {
  color: var(--text);
}

.confirm-dialog__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

[data-theme="dark"] .confirm-dialog__actions {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.confirm-dialog__btn-cancel {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

[data-theme="dark"] .confirm-dialog__btn-cancel {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

.confirm-dialog__btn-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.confirm-dialog__btn-ok {
  height: 36px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* --- Reset All Modal with Template Selection ------------------------------ */
.reset-modal {
  width: min(460px, calc(100vw - 32px));
}

.reset-tpl-options {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reset-tpl-label {
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.reset-tpl-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reset-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  transition: all 0.16s ease;
  user-select: none;
  text-align: left;
}

[data-theme="dark"] .reset-chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

.reset-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

/* Active Highlight Color when selected */
.reset-chip.is-active {
  background: color-mix(in srgb, var(--accent) 16%, rgba(255, 255, 255, 0.05)) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent), 0 4px 14px color-mix(in srgb, var(--accent) 22%, transparent);
}

.reset-chip__radio {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.16s ease;
}

.reset-chip.is-active .reset-chip__radio {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 2.5px #171a26;
}

[data-theme="light"] .reset-chip.is-active .reset-chip__radio {
  box-shadow: inset 0 0 0 2.5px #ffffff;
}

.reset-chip__title {
  font-weight: 650;
  color: var(--text);
}

.reset-chip__tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  margin-left: auto;
}

.reset-chip.is-active .reset-chip__tag {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
}

.reset-tpl-desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  padding: 9px 13px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 36px;
  display: flex;
  align-items: center;
}




/* --- Code Preview SEO & Guide Styles --- */
html.is-guide-open,
html:has(body.is-guide-open) {
  height: auto !important;
  min-height: 100vh !important;
  overflow-y: auto !important;
  scroll-behavior: smooth !important;
}

/* By default, Live Code Preview is a full-height locked IDE */
body.editor-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.editor-body:not(.is-guide-open) .cp-seo-container {
  display: none !important;
}

body.editor-body.is-guide-open {
  height: auto !important;
  min-height: 100vh !important;
  overflow: visible !important;
  overflow-y: visible !important;
}

body.editor-body.is-guide-open .editor {
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  flex: 0 0 100vh !important;
}

.cp-seo-container {
  width: 100%;
  max-width: 1200px;
  margin: 48px auto;
  padding: 0 24px 64px;
}

/* --- Preview Device Switcher Toolbar ------------------------------------- */
.device-toolbar {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  gap: 4px !important;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  height: 28px !important;
  max-height: 28px !important;
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
}

.device-toolbar > * {
  display: inline-flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
}

.device-toolbar {
  overflow: visible !important;
}

.device-select-wrapper {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
  overflow: visible !important;
}

.device-select-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  height: 22px !important;
  background: transparent !important;
  border: 0 !important;
  outline: none !important;
  font-family: inherit !important;
  font-size: 11.5px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  cursor: pointer !important;
  padding: 0 4px 0 2px !important;
  border-radius: 4px !important;
  transition: background 0.15s ease, color 0.15s ease !important;
  max-width: 140px !important;
}

.device-select-btn:hover,
.device-select-wrapper.is-open .device-select-btn {
  background: var(--bg-hover) !important;
  color: var(--text) !important;
}

.device-icon {
  color: var(--text-muted);
  flex-shrink: 0 !important;
  display: block !important;
}

.device-select-label {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.device-select-chevron {
  color: var(--text-muted) !important;
  flex-shrink: 0 !important;
  transition: transform 0.15s ease;
}

.device-select-wrapper.is-open .device-select-chevron {
  transform: rotate(180deg);
}

/* Custom Sleek Dark-Theme Device Menu */
.device-menu {
  position: absolute !important;
  top: calc(100% + 5px) !important;
  right: 0 !important;
  min-width: 275px !important;
  max-width: 320px !important;
  max-height: 380px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  padding: 6px !important;
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.25) !important;
  z-index: 1000 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  /* Dark-theme friendly scrollbar */
  scrollbar-width: thin !important;
  scrollbar-color: var(--border-hover, #333a4d) transparent !important;
}

.device-menu[hidden] {
  display: none !important;
}

.device-menu::-webkit-scrollbar {
  width: 6px !important;
}
.device-menu::-webkit-scrollbar-track {
  background: transparent !important;
}
.device-menu::-webkit-scrollbar-thumb {
  background: var(--border-hover, #333a4d) !important;
  border-radius: 9999px !important;
}
.device-menu::-webkit-scrollbar-thumb:hover {
  background: var(--accent) !important;
}

.device-menu__header {
  font-size: 10.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  color: var(--text-muted) !important;
  padding: 8px 10px 4px 10px !important;
  margin-top: 4px !important;
  border-top: 1px solid var(--border-soft, rgba(255, 255, 255, 0.06)) !important;
  user-select: none !important;
  pointer-events: none !important;
}
.device-menu__header:first-of-type {
  border-top: 0 !important;
  margin-top: 0 !important;
}

.device-menu__item {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  padding: 6px 10px !important;
  border-radius: 6px !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--text) !important;
  font-family: inherit !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  text-align: left !important;
  transition: background 0.12s ease, color 0.12s ease !important;
  gap: 8px !important;
  box-sizing: border-box !important;
}

.device-menu__item:hover {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
}

.device-menu__item.is-active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  font-weight: 600 !important;
}

.device-menu__item-left {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

.device-menu__item-icon {
  color: var(--text-muted) !important;
  flex-shrink: 0 !important;
  display: block !important;
}
.device-menu__item:hover .device-menu__item-icon,
.device-menu__item.is-active .device-menu__item-icon {
  color: var(--accent) !important;
}

.device-menu__item-name {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.device-menu__item-right {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
}

.device-menu__item-dim {
  font-size: 11px !important;
  color: var(--text-muted) !important;
  font-variant-numeric: tabular-nums !important;
}
.device-menu__item:hover .device-menu__item-dim,
.device-menu__item.is-active .device-menu__item-dim {
  color: var(--accent) !important;
  opacity: 0.85 !important;
}

.device-menu__item-check {
  color: var(--accent) !important;
  opacity: 0 !important;
  flex-shrink: 0 !important;
  transition: opacity 0.1s ease !important;
}
.device-menu__item.is-active .device-menu__item-check {
  opacity: 1 !important;
}

.device-btn {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0 !important;
}

.device-btn svg {
  display: block;
}

.device-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--text);
}

.device-btn.is-active:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

.device-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.device-dim-badge {
  font-family: var(--mono) !important;
  font-size: 10px !important;
  padding: 1px 5px !important;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap !important;
  letter-spacing: -0.2px;
  flex-shrink: 0 !important;
  line-height: 1.4 !important;
}

/* --- Preview Device Stage & Frame Mockup --------------------------------- */
.preview-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: block;
}

.preview-stage:not(.is-device-mode) {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  background: #ffffff !important;
}

.preview-stage:not(.is-device-mode) .preview-frame-scaler {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  position: static !important;
  margin: 0 !important;
}

.preview-stage:not(.is-device-mode) .preview-frame-wrapper {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  position: static !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  transform: none !important;
  background: #ffffff !important;
}

.preview-stage:not(.is-device-mode) iframe {
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  display: block !important;
  border: 0 !important;
  background: #ffffff !important;
}

.preview-stage.is-device-mode {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important; /* Strictly no scrollbars in fit mode; frame stays perfectly centered */
  padding: 24px !important;
  box-sizing: border-box !important;
  background-color: var(--bg-soft, #0e121a);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: center center;
}

.preview-stage.is-device-mode.is-unfit {
  overflow: auto !important;
}

.preview-stage.is-device-mode .preview-frame-scaler {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  margin: auto !important;
}

.preview-stage.is-device-mode .preview-frame-wrapper {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  transform-origin: center center !important;
  display: flex !important;
  flex-direction: column;
  flex-shrink: 0 !important;
}

/* Default Phone Base */
.preview-frame-wrapper--phone {
  border-radius: 36px;
  box-shadow: 
    0 0 0 10px #1a1e2b,
    0 0 0 12px rgba(255, 255, 255, 0.12),
    0 25px 60px -12px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

/* 1. Apple iPhone Dynamic Island (14/15/16 Pro) */
.preview-frame-wrapper.device-brand--apple-island {
  border-radius: 46px;
  box-shadow: 
    0 0 0 10px #181c26,
    0 0 0 11.5px rgba(255, 255, 255, 0.14),
    0 25px 60px -12px rgba(0, 0, 0, 0.7);
}
.device-brand--apple-island .device-cutout {
  display: block !important;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 88px;
  height: 22px;
  background: #000000;
  border-radius: 14px;
  z-index: 5;
  pointer-events: none;
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.08);
}
.device-brand--apple-island.is-landscape .device-cutout {
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  width: 22px;
  height: 88px;
}

/* 2. Apple Classic Notch (iPhone 11/12/13/XR) */
.preview-frame-wrapper.device-brand--apple-notch {
  border-radius: 40px;
  box-shadow: 
    0 0 0 10px #181c26,
    0 0 0 11.5px rgba(255, 255, 255, 0.12),
    0 25px 60px -12px rgba(0, 0, 0, 0.7);
}
.device-brand--apple-notch .device-cutout {
  display: block !important;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 124px;
  height: 24px;
  background: #000000;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  z-index: 5;
  pointer-events: none;
}
.device-brand--apple-notch.is-landscape .device-cutout {
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 24px;
  height: 124px;
  border-bottom-left-radius: 0;
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
}

/* 3. Apple Classic SE */
.preview-frame-wrapper.device-brand--apple-classic,
.preview-frame-wrapper.device-brand--compact {
  border-radius: 28px;
  box-shadow: 
    0 0 0 11px #1a1e2a,
    0 0 0 12.5px rgba(255, 255, 255, 0.1),
    0 25px 50px rgba(0, 0, 0, 0.6);
}
.device-brand--apple-classic .device-cutout,
.device-brand--compact .device-cutout {
  display: block !important;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 4px;
  background: #232838;
  border-radius: 2px;
  z-index: 5;
  pointer-events: none;
}
.device-brand--apple-classic.is-landscape .device-cutout,
.device-brand--compact.is-landscape .device-cutout {
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  width: 4px;
  height: 44px;
}

/* 4. Samsung Galaxy S21-S24 (Slim Bezels + Punch Hole) */
.preview-frame-wrapper.device-brand--samsung,
.preview-frame-wrapper.device-brand--android-hole {
  border-radius: 36px;
  box-shadow: 
    0 0 0 7px #141720,
    0 0 0 8.5px rgba(255, 255, 255, 0.1),
    0 25px 60px -10px rgba(0, 0, 0, 0.7);
}
.device-brand--samsung .device-cutout,
.device-brand--android-hole .device-cutout {
  display: block !important;
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #080b12;
  border: 1.5px solid #1c2230;
  box-shadow: inset 0 0 2px #000000, 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 5;
  pointer-events: none;
}
.device-brand--samsung.is-landscape .device-cutout,
.device-brand--android-hole.is-landscape .device-cutout {
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
}

/* 5. Samsung Galaxy Ultra (Iconic Sharp Boxy Corners + Infinity-O Hole) */
.preview-frame-wrapper.device-brand--samsung-ultra {
  border-radius: 14px !important; /* Sharp signature rectangular aesthetic of Galaxy Ultra */
  box-shadow: 
    0 0 0 7.5px #191e2a,
    0 0 0 9px rgba(255, 255, 255, 0.14),
    0 25px 60px -10px rgba(0, 0, 0, 0.75);
}
.device-brand--samsung-ultra .device-cutout {
  display: block !important;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #06080e;
  border: 1.5px solid #202638;
  box-shadow: inset 0 0 2px #000000;
  z-index: 5;
  pointer-events: none;
}
.device-brand--samsung-ultra.is-landscape .device-cutout {
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
}

/* 6. Google Pixel (Signature Rounded Pebble Frame + Center Punch Hole) */
.preview-frame-wrapper.device-brand--pixel {
  border-radius: 38px;
  box-shadow: 
    0 0 0 8px #171b24,
    0 0 0 9.5px rgba(255, 255, 255, 0.12),
    0 25px 60px -10px rgba(0, 0, 0, 0.68);
}
.device-brand--pixel .device-cutout {
  display: block !important;
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #070910;
  border: 1.5px solid #1a202c;
  box-shadow: inset 0 0 2px #000000;
  z-index: 5;
  pointer-events: none;
}
.device-brand--pixel.is-landscape .device-cutout {
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
}

/* 7. Tablet Bezel (iPad Mini / Air / Pro) */
.preview-frame-wrapper--tablet {
  border-radius: 24px;
  box-shadow: 
    0 0 0 12px #181d28,
    0 0 0 13.5px rgba(255, 255, 255, 0.1),
    0 30px 70px -15px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.preview-frame-wrapper--tablet .device-cutout {
  display: block !important;
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0a0e16;
  border: 1px solid #202638;
  z-index: 5;
  pointer-events: none;
}
.preview-frame-wrapper--tablet.is-landscape .device-cutout {
  top: 50%;
  left: 4px;
  transform: translateY(-50%);
}

/* 8. Desktop / Laptop Frame */
.preview-frame-wrapper--desktop {
  overflow: hidden;
}
.preview-frame-wrapper.device-brand--laptop {
  border-radius: 10px;
  box-shadow: 
    0 0 0 8px #1c212e,
    0 0 0 9.5px rgba(255, 255, 255, 0.1),
    0 25px 60px -12px rgba(0, 0, 0, 0.65);
}
.preview-frame-wrapper.device-brand--desktop {
  border-radius: 8px;
  box-shadow: 
    0 0 0 6px #161a25,
    0 0 0 7.5px rgba(255, 255, 255, 0.08),
    0 25px 55px -10px rgba(0, 0, 0, 0.6);
}
.preview-frame-wrapper--desktop .device-cutout {
  display: none !important;
}

.preview-frame-wrapper iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0;
  display: block;
  background: #ffffff;
  flex: 1 1 auto;
}


/* --- Left Rail More Tools: strictly hide chevron arrow --- */
body.editor-body .nav__dropdown-btn .nav__dropdown-chev,
body.editor-body .nav__dropdown-chev {
  display: none !important;
}

/* --- Responsive Toolbars & Three-Dot Overflow Dropdowns --- */

/* Language Dropdown in Code Bar (shown when pane is narrow) */
.seg-dropdown {
  position: relative;
  display: none;
  align-items: center;
}

.seg-dropdown__btn {
  height: 26px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.seg-dropdown__btn:hover {
  background: var(--bg-soft);
  border-color: var(--accent);
}

.seg-dropdown__current {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.seg-dropdown__chev {
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.seg-dropdown.is-open .seg-dropdown__chev {
  transform: rotate(180deg);
}

.seg-dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 125px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.seg-dropdown__menu[hidden] {
  display: none !important;
}

.seg-dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.seg-dropdown__item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.seg-dropdown__item.is-active {
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Three-Dot Overflow Dropdown Menus for Both Bars */
.bar-more-dropdown {
  position: relative;
  display: none;
  align-items: center;
}

.bar-more-dropdown--code {
  display: inline-flex !important;
}

.bar-more-btn {
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  min-height: 26px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bar-more-btn:hover,
.bar-more-dropdown.is-open .bar-more-btn {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--text);
}

.bar-more-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
}

.bar-more-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 165px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bar-more-menu[hidden] {
  display: none !important;
}

.bar-more-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.bar-more-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.bar-more-item-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.bar-more-check {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  opacity: 0;
}

.bar-more-item.is-checked .bar-more-check {
  opacity: 1;
}

.bar-more-shortcut {
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: inherit;
  margin-left: 10px;
}

.bar-more-item:hover .bar-more-shortcut {
  color: var(--text);
}

.bar-more-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}

/* Help & Shortcuts Dialog */
.help-dialog {
  width: min(520px, calc(100vw - 32px)) !important;
}
.help-dialog__card {
  padding: 22px 24px 20px;
}
.help-shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}
.help-shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.help-shortcut-desc {
  color: var(--text);
  font-weight: 500;
}
.help-shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.help-shortcut-keys kbd {
  display: inline-block;
  padding: 2.5px 6.5px;
  font-family: var(--editor-font, monospace);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 1.5px 0 rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .help-shortcut-keys kbd {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 1.5px 0 rgba(0, 0, 0, 0.4);
}

/* Container Queries for Adaptive Toolbar Layout */
.editor__pane--code {
  container-type: inline-size;
  container-name: codePane;
}

.editor__pane--preview {
  container-type: inline-size;
  container-name: previewPane;
}

/* Code Pane Responsive Rules */
@container codePane (max-width: 440px) {
  .editor__pane--code .seg {
    display: none !important;
  }
  .editor__pane--code .seg-dropdown {
    display: inline-flex !important;
  }
}

@container codePane (max-width: 330px) {
  .editor__pane--code #opt-auto-label {
    display: none !important;
  }
  .editor__pane--code .bar-more-dropdown {
    display: inline-flex !important;
  }
}

/* Class-based fallback for Code Pane */
.editor__pane--code.pane--compact-lang .seg {
  display: none !important;
}
.editor__pane--code.pane--compact-lang .seg-dropdown {
  display: inline-flex !important;
}

.editor__pane--code.pane--ultra-compact #opt-auto-label {
  display: none !important;
}
.editor__pane--code.pane--ultra-compact .bar-more-dropdown {
  display: inline-flex !important;
}

/* Preview Pane Responsive Rules */
@container previewPane (max-width: 550px) {
  .editor__pane--preview #console-btn,
  .editor__pane--preview #reload-btn {
    display: none !important;
  }
  .editor__pane--preview .bar-more-dropdown {
    display: inline-flex !important;
  }
}

@container previewPane (max-width: 390px) {
  .editor__pane--preview .card__title,
  .editor__pane--preview #inspect-btn,
  .editor__pane--preview #console-badge,
  .editor__pane--preview #device-rotate-btn,
  .editor__pane--preview #device-fit-btn,
  .editor__pane--preview #device-dim-badge,
  .editor__pane--preview #console-btn,
  .editor__pane--preview #reload-btn {
    display: none !important;
  }
  .editor__pane--preview .device-toolbar {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    gap: 0 !important;
    margin-left: auto !important;
  }
  .editor__pane--preview .device-select-wrapper {
    position: relative !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  .editor__pane--preview .device-select-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: var(--radius-sm, 6px) !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    cursor: pointer !important;
  }
  .editor__pane--preview .device-select-btn:hover,
  .editor__pane--preview .device-select-wrapper.is-open .device-select-btn {
    background: var(--bg-hover) !important;
    border-color: var(--border-hover, var(--border)) !important;
    color: var(--accent) !important;
  }
  .editor__pane--preview .device-select-btn .device-icon {
    width: 14px !important;
    height: 14px !important;
    color: var(--text) !important;
    margin: 0 !important;
  }
  .editor__pane--preview .device-select-btn:hover .device-icon,
  .editor__pane--preview .device-select-wrapper.is-open .device-select-btn .device-icon {
    color: var(--accent) !important;
  }
  .editor__pane--preview .device-select-label,
  .editor__pane--preview .device-select-chevron {
    display: none !important;
  }
  .editor__pane--preview .bar-more-dropdown {
    display: inline-flex !important;
    margin-left: 2px !important;
  }
  .editor__pane--preview .menu-device-opt {
    display: flex !important;
  }
}

/* Class-based fallback for Preview Pane */
.editor__pane--preview.pane--compact-preview #console-btn,
.editor__pane--preview.pane--compact-preview #reload-btn {
  display: none !important;
}
.editor__pane--preview.pane--compact-preview .bar-more-dropdown {
  display: inline-flex !important;
}

.editor__pane--preview.pane--ultra-compact-preview .card__title,
.editor__pane--preview.pane--ultra-compact-preview #console-badge,
.editor__pane--preview.pane--ultra-compact-preview #device-rotate-btn,
.editor__pane--preview.pane--ultra-compact-preview #device-fit-btn,
.editor__pane--preview.pane--ultra-compact-preview #device-dim-badge,
.editor__pane--preview.pane--ultra-compact-preview #console-btn,
.editor__pane--preview.pane--ultra-compact-preview #reload-btn {
  display: none !important;
}
.editor__pane--preview.pane--ultra-compact-preview .device-toolbar {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  gap: 0 !important;
  margin-left: auto !important;
}
.editor__pane--preview.pane--ultra-compact-preview .device-select-wrapper {
  position: relative !important;
  margin: 0 !important;
  overflow: visible !important;
}
.editor__pane--preview.pane--ultra-compact-preview .device-select-btn {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  margin: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: var(--radius-sm, 6px) !important;
  border: 1px solid var(--border) !important;
  background: var(--surface) !important;
  cursor: pointer !important;
}
.editor__pane--preview.pane--ultra-compact-preview .device-select-btn:hover,
.editor__pane--preview.pane--ultra-compact-preview .device-select-wrapper.is-open .device-select-btn {
  background: var(--bg-hover) !important;
  border-color: var(--border-hover, var(--border)) !important;
  color: var(--accent) !important;
}
.editor__pane--preview.pane--ultra-compact-preview .device-select-btn .device-icon {
  width: 14px !important;
  height: 14px !important;
  color: var(--text) !important;
  margin: 0 !important;
}
.editor__pane--preview.pane--ultra-compact-preview .device-select-btn:hover .device-icon,
.editor__pane--preview.pane--ultra-compact-preview .device-select-wrapper.is-open .device-select-btn .device-icon {
  color: var(--accent) !important;
}
.editor__pane--preview.pane--ultra-compact-preview .device-select-label,
.editor__pane--preview.pane--ultra-compact-preview .device-select-chevron {
  display: none !important;
}
.editor__pane--preview.pane--ultra-compact-preview .bar-more-dropdown {
  display: inline-flex !important;
  margin-left: 2px !important;
}
.editor__pane--preview.pane--ultra-compact-preview .menu-device-opt {
  display: flex !important;
}

/* Upward-opening dropdown for bottom footer bar */
.bar-more-dropdown--up {
  position: relative;
}

.bar-more-dropdown--up .bar-more-menu--up {
  top: auto !important;
  bottom: calc(100% + 6px) !important;
}

.bar-more-item--danger {
  color: #ef4444 !important;
}

.bar-more-item--danger:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  color: #f87171 !important;
}

/* Ensure editor foot stays in a single row without wrapping and allows popup menu */
.editor__foot {
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  overflow: visible !important;
  position: relative;
  z-index: 10;
}
.editor__bar {
  overflow: visible !important;
  position: relative;
  z-index: 10;
}

/* Code Pane Footer Responsive Rules */
.editor__pane--code .editor__foot #doc-label {
  flex-shrink: 1;
  min-width: 0;
}
.editor__pane--code .editor__foot #doc-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor__pane--code .editor__foot .btn {
  flex-shrink: 0;
}

/* Hide status timestamp hint at <= 700px so all buttons fit neatly in 50-50 screen view */
@container codePane (max-width: 700px) {
  .editor__pane--code .editor__foot .hint {
    display: none !important;
  }
}

/* Collapse extra buttons into 3-dot menu at <= 580px */
@container codePane (max-width: 580px) {
  .editor__pane--code .editor__foot .sample-menu-wrap,
  .editor__pane--code .editor__foot #sample-btn,
  .editor__pane--code .editor__foot #export-btn,
  .editor__pane--code .editor__foot #reset-all-btn,
  .editor__pane--code .editor__foot #reset-btn,
  .editor__pane--code .editor__foot #saveas-btn {
    display: none !important;
  }
  .editor__pane--code .editor__foot .bar-more-dropdown {
    display: inline-flex !important;
  }
}

/* Class-based fallbacks for Code Pane Footer */
.editor__pane--code.pane--compact-status .editor__foot .hint {
  display: none !important;
}

.editor__pane--code.pane--compact-foot .sample-menu-wrap,
.editor__pane--code.pane--compact-foot #sample-btn,
.editor__pane--code.pane--compact-foot #export-btn,
.editor__pane--code.pane--compact-foot #reset-all-btn,
.editor__pane--code.pane--compact-foot #reset-btn,
.editor__pane--code.pane--compact-foot #saveas-btn {
  display: none !important;
}
.editor__pane--code.pane--compact-foot .editor__foot .bar-more-dropdown {
  display: inline-flex !important;
}

.editor__pane--code.pane--ultra-compact .editor__foot .hint {
  display: none !important;
}

/* Floating Guide Button: docked to right screen edge, default position in blue highlight area */
.guide-float-btn {
  bottom: 46px;
  right: 0 !important;
  left: auto !important;
  cursor: grab;
  touch-action: none;
}

.guide-float-btn:hover,
.guide-float-btn:active {
  transform: none !important;
}

.guide-float-btn.is-dragging {
  cursor: grabbing !important;
  transition: none !important;
}

/* Narrow, sleek scrollbars for preview pane & stages */
.editor__pane--preview,
.editor__preview,
.preview-stage,
.preview-frame-scaler,
.preview-frame-wrapper {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

.editor__pane--preview::-webkit-scrollbar,
.editor__preview::-webkit-scrollbar,
.preview-stage::-webkit-scrollbar,
.preview-frame-scaler::-webkit-scrollbar,
.preview-frame-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.editor__pane--preview::-webkit-scrollbar-track,
.editor__preview::-webkit-scrollbar-track,
.preview-stage::-webkit-scrollbar-track,
.preview-frame-scaler::-webkit-scrollbar-track,
.preview-frame-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.editor__pane--preview::-webkit-scrollbar-thumb,
.editor__preview::-webkit-scrollbar-thumb,
.preview-stage::-webkit-scrollbar-thumb,
.preview-frame-scaler::-webkit-scrollbar-thumb,
.preview-frame-wrapper::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
}

.editor__pane--preview::-webkit-scrollbar-thumb:hover,
.editor__preview::-webkit-scrollbar-thumb:hover,
.preview-stage::-webkit-scrollbar-thumb:hover,
.preview-frame-scaler::-webkit-scrollbar-thumb:hover,
.preview-frame-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.75);
}

.editor__pane--preview::-webkit-scrollbar-corner,
.editor__preview::-webkit-scrollbar-corner,
.preview-stage::-webkit-scrollbar-corner {
  background: transparent;
}
