*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1e1e1e;
  color: #cccccc;
  overflow: hidden;
}

/* ─── TOPBAR ───────────────────────────────────────────── */

#topbar {
  height: 48px;
  background: #2d2d30;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  user-select: none;
  flex-shrink: 0;
}

#topbar-brand {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
  padding: 0 6px;
  white-space: nowrap;
}

.tb-sep {
  width: 1px;
  height: 22px;
  background: #3e3e42;
  margin: 0 5px;
  flex-shrink: 0;
}

.tb-spacer { flex: 1; }

.tb-btn {
  background: transparent;
  border: none;
  color: #cccccc;
  padding: 5px 9px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.tb-btn:hover  { background: #3e3e42; color: #fff; }
.tb-btn.active { background: #094771; color: #fff; }
.tb-btn.primary { background: #0e639c; color: #fff; }
.tb-btn.primary:hover { background: #1177bb; }
.tb-btn.success { background: #2d7d27; color: #fff; }
.tb-btn.success:hover { background: #388a31; }
.tb-btn:disabled { opacity: 0.38; cursor: default; }

.device-group {
  display: flex;
  background: #1e1e1e;
  border-radius: 5px;
  padding: 2px;
  gap: 1px;
}
.device-btn {
  background: transparent;
  border: none;
  color: #777;
  padding: 4px 9px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  align-items: center;
}
.device-btn:hover { color: #ccc; }
.device-btn.active { background: #3e3e42; color: #fff; }

#pageSelect {
  background: #3c3c3c;
  border: 1px solid #555;
  color: #ccc;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  max-width: 130px;
}
#pageSelect:focus { outline: 1px solid #007acc; }

/* ─── WORKSPACE ─────────────────────────────────────────── */

#workspace {
  display: flex;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* ─── LEFT PANEL ─────────────────────────────────────────── */

#left {
  width: 220px;
  min-width: 220px;
  background: #252526;
  border-right: 1px solid #3e3e42;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#left-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#left-scroll::-webkit-scrollbar { width: 5px; }
#left-scroll::-webkit-scrollbar-track { background: transparent; }
#left-scroll::-webkit-scrollbar-thumb { background: #3e3e42; border-radius: 3px; }
#left-scroll::-webkit-scrollbar-thumb:hover { background: #555; }
#left-scroll > .panel-section { flex-shrink: 0; }

/* ─── CENTER CANVAS ──────────────────────────────────────── */

#gjs {
  flex: 1;
  min-width: 0;
  background: #1e1e1e;
}

/* ─── RIGHT PANEL ────────────────────────────────────────── */

#right {
  width: 260px;
  min-width: 260px;
  background: #252526;
  border-left: 1px solid #3e3e42;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.selection-helper {
  margin: 12px 12px 10px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid #3e3e42;
  background: linear-gradient(180deg, #2a2a2d 0%, #222326 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.selection-helper.has-selection {
  border-color: #0e639c;
  box-shadow: 0 0 0 1px rgba(14,99,156,0.2), inset 0 1px 0 rgba(255,255,255,0.03);
}
.selection-helper-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #7ec8f4;
}
.selection-helper-name {
  margin-top: 7px;
  font-size: 15px;
  line-height: 1.35;
  color: #fff;
  font-weight: 700;
}
.selection-helper-copy {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: #b9bcc2;
}
.selection-helper-copy strong { color: #fff; }

.dynamic-inline-panel {
  margin: 10px 10px 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #3e3e42;
  background: linear-gradient(180deg, #2a2a2d 0%, #232427 100%);
}
.dynamic-inline-panel.has-selection {
  border-color: #0e639c;
  box-shadow: 0 0 0 1px rgba(14,99,156,0.22);
}
.dynamic-inline-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7ec8f4;
}
.dynamic-inline-copy {
  margin-top: 8px;
  color: #b9bcc2;
  font-size: 12px;
  line-height: 1.55;
}
.dynamic-inline-panel .tb-btn {
  margin-top: 10px;
  width: 100%;
  justify-content: center;
}

/* ─── PANEL SECTIONS ─────────────────────────────────────── */

.panel-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.panel-section.grow { flex: 1; }
.panel-section.is-collapsed { flex: 0 0 auto !important; max-height: none !important; }
.panel-section.is-collapsed .panel-body { display: none; }
.panel-section + .panel-section { border-top: 2px solid #141416; }

.panel-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: #858585;
  padding: 10px 12px;
  background: #2d2d30;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  user-select: none;
  cursor: pointer;
}
.panel-header:hover { color: #bbb; }
.panel-section--active .panel-header {
  color: #d8f0ff;
  background: linear-gradient(180deg, #12476a 0%, #0f3f5f 100%);
  border-bottom-color: #0e639c;
}
.panel-header::after {
  content: '▾';
  font-size: 16px;
  color: #888;
  margin-left: auto;
  padding-left: 8px;
  line-height: 1;
}
.panel-section.is-collapsed .panel-header::after { content: '▸'; }
.panel-header > .ph-icon-btn { margin-left: auto; }
.panel-header > :first-child:last-child { margin-right: 0; }

.panel-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.panel-body::-webkit-scrollbar { width: 5px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: #3e3e42; border-radius: 3px; }
.panel-body::-webkit-scrollbar-thumb:hover { background: #555; }

/* ─── COMPONENT ITEMS ────────────────────────────────────── */

#components { padding: 8px; display: flex; flex-direction: column; gap: 3px; }

.comp-item {
  padding: 9px 11px;
  background: #2d2d30;
  border: 1px solid #3e3e42;
  border-radius: 5px;
  cursor: grab;
  font-size: 13px;
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.12s;
}
.comp-item:hover { background: #3e3e42; border-color: #007acc; color: #fff; }
.comp-item:active { cursor: grabbing; }
.comp-icon { font-size: 16px; opacity: 0.9; flex-shrink: 0; }
.comp-meta { margin-left:auto; font-size:11px; color:#888; text-transform:uppercase; letter-spacing:.08em; }

#globals-panel,
#assets-panel {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.global-card,
.asset-mini {
  background: #2d2d30;
  border: 1px solid #3e3e42;
  border-radius: 8px;
  padding: 10px;
}

.global-card-title,
.asset-mini-name {
  font-size: 13px;
  color: #fff;
  font-weight: 700;
}

.global-card-desc,
.asset-mini-meta {
  font-size: 12px;
  color: #888;
  line-height: 1.5;
  margin-top: 4px;
}

.global-card-actions,
.asset-mini-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.panel-chip-btn {
  background: #1e1e1e;
  color: #ccc;
  border: 1px solid #3e3e42;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}

.panel-chip-btn:hover {
  border-color: #007acc;
  color: #fff;
}

.asset-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-mini-thumb {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  font-size: 11px;
  flex-shrink: 0;
}

.asset-mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-mini-main {
  min-width: 0;
  flex: 1;
}

/* ─── GRAPESJS BLOCK MANAGER OVERRIDES ───────────────────── */

.gjs-blocks-c { padding: 6px !important; }
.gjs-block-categories { padding: 0 !important; }

.gjs-block-category { margin-bottom: 0 !important; border-top: 2px solid #141416 !important; }
.gjs-block-category:first-child { border-top: none !important; }

/* Cover both GrapesJS rendering variants (Backbone: .gjs-title / Svelte: __title) */
.gjs-block-category .gjs-title,
.gjs-block-category__title {
  background: #2d2d30 !important;
  color: #858585 !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.9px !important;
  text-transform: uppercase !important;
  padding: 10px 12px 10px 32px !important;
  border-bottom: 1px solid #3e3e42 !important;
  border-top: none !important;
  cursor: pointer !important;
  user-select: none !important;
}
.gjs-block-category .gjs-title:hover,
.gjs-block-category__title:hover { color: #bbb !important; }

/* Make GrapesJS's Font Awesome caret bigger and brighter */
.gjs-block-category .gjs-caret-icon,
.gjs-block-category__title .gjs-caret-icon {
  font-size: 14px !important;
  color: #888 !important;
  margin-right: 8px !important;
  width: 14px !important;
  display: inline-block !important;
  text-align: center !important;
}

.gjs-block {
  background: #2d2d30 !important;
  border: 1px solid #3e3e42 !important;
  border-radius: 6px !important;
  color: #ccc !important;
  padding: 10px 6px !important;
  width: calc(50% - 8px) !important;
  margin: 3px 3px !important;
  transition: all 0.12s !important;
  cursor: grab !important;
}
.gjs-block:hover {
  background: #3e3e42 !important;
  border-color: #007acc !important;
  color: #fff !important;
  box-shadow: none !important;
}
.gjs-block:active { cursor: grabbing !important; }

.gjs-block-label { font-size: 12px !important; color: inherit !important; font-weight: 600 !important; }

.gjs-block__media {
  color: #888 !important;
  margin-bottom: 5px !important;
  display: flex !important;
  justify-content: center !important;
}
.gjs-block__media svg { width: 24px; height: 24px; }
.gjs-block:hover .gjs-block__media { color: #aaa !important; }

/* ─── GRAPESJS LAYER MANAGER ─────────────────────────────── */

.gjs-layer-name { color: #ccc !important; font-size: 13px !important; }
.gjs-layer { border-color: #3e3e42 !important; }
.gjs-layer.gjs-hovered { background: #2d2d30 !important; }
.gjs-layer.gjs-selected > .gjs-layer-title { background: #094771 !important; }
.gjs-layer-title { background: transparent !important; }
.gjs-layer-title:hover { background: #2d2d30 !important; }
.gjs-layer-count { background: #3e3e42 !important; color: #aaa !important; font-size: 11px !important; }
.gjs-layer-vis { color: #555 !important; }

/* ─── GRAPESJS STYLE MANAGER ─────────────────────────────── */

.gjs-sm-sector-title {
  background: #2d2d30 !important;
  color: #888 !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.8px !important;
  text-transform: uppercase !important;
  padding: 9px 10px !important;
  border-bottom: 1px solid #3e3e42 !important;
  border-top: 1px solid #3e3e42 !important;
}
.gjs-sm-sector-title:hover { color: #bbb !important; }
.gjs-sm-sector { border: none !important; }
.gjs-sm-label { color: #c2c5ca !important; font-size: 12px !important; font-weight: 600 !important; }
.gjs-sm-property { padding: 8px 10px !important; border-bottom: 1px solid #2a2a2a !important; }
.gjs-field { background: #3c3c3c !important; border: 1px solid #555 !important; color: #ccc !important; border-radius: 4px !important; font-size: 13px !important; min-height: 34px !important; }
.gjs-field:focus { outline: 1px solid #007acc !important; }
.gjs-field-color-picker { cursor: pointer !important; pointer-events: auto !important; }
.sp-container.gjs-editor-sp,
.sp-container.gjs-one-bg.gjs-two-color {
  z-index: 10000000 !important;
}
.gjs-input-holder { background: #3c3c3c !important; border-color: #555 !important; }
.gjs-field input,
.gjs-field select,
.gjs-field textarea { font-size: 13px !important; }

/* ─── GRAPESJS TRAIT MANAGER ─────────────────────────────── */

.gjs-trt-trait { border-bottom: 1px solid #2a2a2a !important; padding: 8px 10px !important; }
.gjs-label { color: #c2c5ca !important; font-size: 12px !important; font-weight: 600 !important; }

/* ─── GRAPESJS CANVAS ────────────────────────────────────── */

.gjs-cv-canvas { background: #2a2a2a !important; top: 0 !important; }
.gjs-frame-wrapper { box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important; }
.gjs-toolbar {
  border-radius: 10px !important;
  overflow: hidden !important;
  box-shadow: 0 8px 20px rgba(0,0,0,0.22) !important;
}
.gjs-toolbar-item {
  min-width: 34px !important;
  min-height: 32px !important;
  font-size: 15px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.gjs-toolbar-item .fa,
.gjs-toolbar-item svg {
  font-size: 15px !important;
  width: 15px !important;
  height: 15px !important;
}

/* ─── TOAST NOTIFICATIONS ────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: #323233;
  border: 1px solid #4a4a4e;
  border-left: 3px solid #007acc;
  color: #ccc;
  padding: 9px 14px;
  border-radius: 4px;
  font-size: 12px;
  min-width: 180px;
  pointer-events: auto;
  animation: toastIn 0.18s ease, toastOut 0.3s ease 2.2s forwards;
}
.toast.success { border-left-color: #388a34; }
.toast.error   { border-left-color: #f44747; }
.toast.info    { border-left-color: #007acc; }

@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; pointer-events: none; } }

/* ─── ACCENT BUTTON (Templates) ─────────────────────────────── */

.tb-btn.accent { background: #3b2d6e; color: #c4b5fd; }
.tb-btn.accent:hover { background: #4c3a8a; color: #ddd6fe; }

/* ─── MODAL SYSTEM ───────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: #252526;
  border: 1px solid #3e3e42;
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  animation: modalIn 0.18s ease;
}
.modal.modal-xl { max-width: 920px; }

@keyframes modalIn { from { transform: scale(0.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #3e3e42;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: #3e3e42; color: #ccc; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: #3e3e42; border-radius: 3px; }

.modal-hint {
  font-size: 12px;
  color: #777;
  margin: 0 0 18px;
  line-height: 1.5;
}

/* ─── TEMPLATE GRID ──────────────────────────────────────────── */

#template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.tpl-card {
  background: #2d2d30;
  border: 1px solid #3e3e42;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.tpl-card:hover {
  border-color: #007acc;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.tpl-preview {
  height: 120px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}
.tpl-preview-bar  { border-radius: 3px; background: rgba(255,255,255,0.25); height: 8px; }
.tpl-preview-hero { border-radius: 4px; background: rgba(255,255,255,0.18); flex: 1; }
.tpl-preview-cols { display: flex; gap: 5px; height: 28px; }
.tpl-preview-col  { border-radius: 3px; background: rgba(255,255,255,0.15); flex: 1; }
.tpl-preview-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  font-size: 2rem;
  opacity: 0.7;
}

.tpl-info { padding: 12px 14px; }
.tpl-info h4 { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: #fff; }
.tpl-info p  { margin: 0 0 12px; font-size: 11px; color: #888; line-height: 1.5; }

.tpl-use-btn {
  width: 100%;
  padding: 7px;
  background: #0e639c;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.tpl-use-btn:hover { background: #1177bb; }

/* ─── MODAL FORMS ────────────────────────────────────────────── */

.mform { display: flex; flex-direction: column; gap: 4px; }

.mform-label {
  font-size: 11px;
  font-weight: 700;
  color: #aaa;
  margin-top: 12px;
  margin-bottom: 2px;
}
.mform-label:first-child { margin-top: 0; }

.mform-hint-inline { font-weight: 400; color: #666; font-size: 10px; }

.mform-input {
  background: #3c3c3c;
  border: 1px solid #555;
  color: #ccc;
  padding: 8px 11px;
  border-radius: 5px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s;
  width: 100%;
}
.mform-input:focus { border-color: #007acc; }

.mform-textarea { resize: vertical; min-height: 70px; }

.mform-hint { font-size: 10px; color: #666; margin-top: 3px; }
.mform-hint code { background: #1e1e1e; padding: 1px 4px; border-radius: 3px; }

.mform-hint-link {
  font-size: 11px;
  color: #007acc;
  text-decoration: none;
  margin-top: 3px;
  display: inline-block;
}
.mform-hint-link:hover { text-decoration: underline; }
.mform-hint-link code { background: #1e1e1e; padding: 1px 4px; border-radius: 3px; font-size: 10px; }

.mform-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #3e3e42;
}

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

.theme-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.theme-field span {
  font-size: 11px;
  color: #aaa;
  font-weight: 700;
}

.theme-field input[type="color"] {
  padding: 4px;
  min-height: 38px;
}

.theme-preview {
  margin-top: 18px;
  padding: 16px;
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  border-radius: 10px;
}

.theme-preview-card {
  border-radius: 16px;
  padding: 18px;
  background: linear-gradient(135deg, #0e639c, #3b82f6);
  color: white;
}

.theme-preview-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.theme-preview-card h4 {
  margin: 14px 0 8px;
  font-size: 20px;
}

.theme-preview-card p {
  margin: 0;
  color: rgba(255,255,255,0.84);
  line-height: 1.6;
  font-size: 13px;
}

.theme-preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.theme-preview-actions button {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
}

.theme-preview-actions button:first-child {
  background: white;
  color: #0f172a;
}

.theme-preview-actions button:last-child {
  background: rgba(255,255,255,0.14);
  color: white;
  border: 1px solid rgba(255,255,255,0.24);
}

.asset-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.asset-card {
  background: #2d2d30;
  border: 1px solid #3e3e42;
  border-radius: 10px;
  overflow: hidden;
}

.asset-card-media {
  aspect-ratio: 16 / 10;
  background: #1e1e1e;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #777;
  font-size: 12px;
  overflow: hidden;
}

.asset-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-card-body {
  padding: 12px;
}

.asset-card-title {
  font-size: 12px;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-card-meta {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.asset-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.audit-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audit-item {
  background: #252526;
  border: 1px solid #3e3e42;
  border-radius: 8px;
  padding: 10px 12px;
}

.audit-item strong {
  display: block;
  color: #fff;
  font-size: 12px;
}

.audit-item span {
  display: block;
  color: #9ca3af;
  font-size: 11px;
  line-height: 1.5;
  margin-top: 4px;
}

.dynamic-current {
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.6;
}

.dynamic-form-section code {
  background: #1e1e1e;
  padding: 1px 4px;
  border-radius: 4px;
}

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

.code-editor-pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.code-editor-pane span {
  font-size: 11px;
  color: #aaa;
  font-weight: 700;
}

.code-editor-pane-wide {
  grid-column: 1 / -1;
}

.code-editor-textarea {
  min-height: 240px;
  width: 100%;
  resize: vertical;
  background: #1e1e1e;
  color: #d4d4d4;
  border: 1px solid #3e3e42;
  border-radius: 8px;
  padding: 12px;
  font: 12px/1.6 'SF Mono', 'Fira Code', Consolas, monospace;
  outline: none;
}

.code-editor-textarea:focus {
  border-color: #007acc;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audit-item {
  border: 1px solid #3e3e42;
  border-radius: 8px;
  padding: 12px 14px;
  background: #1e1e1e;
}

.audit-item strong {
  display: block;
  font-size: 12px;
  color: #fff;
  margin-bottom: 4px;
}

.audit-item span {
  display: block;
  font-size: 11px;
  color: #8b949e;
  line-height: 1.6;
}

.audit-item.audit-pass {
  border-color: #2d7d27;
}

.audit-item.audit-warn {
  border-color: #a16207;
}

.history-meta {
  display: block;
  font-size: 11px;
  color: #8b949e;
  margin-top: 6px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

#ai-output {
  white-space: pre-wrap;
}

/* ─── DEPLOY STATUS ──────────────────────────────────────────── */

.deploy-status {
  margin-top: 12px;
  padding: 10px 14px;
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  border-radius: 5px;
  font-size: 12px;
  color: #aaa;
  line-height: 1.6;
}
.deploy-status.ok    { border-color: #388a34; color: #81c784; }
.deploy-status.error { border-color: #f44747; color: #e57373; }

.deploy-status a {
  color: #4fc3f7;
  text-decoration: underline;
  word-break: break-all;
}

/* ─── PANEL HEADER ICON BUTTON ───────────────────────────────────────────────── */

.ph-icon-btn {
  background: transparent;
  border: none;
  color: #666;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s, color 0.12s;
}
.ph-icon-btn:hover { background: #3e3e42; color: #fff; }

/* ─── PAGE LIST (SIDEBAR) ────────────────────────────────────────────────────── */

#page-list { padding: 4px 6px; display: flex; flex-direction: column; gap: 1px; }

.page-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s;
  gap: 6px;
  min-height: 30px;
}
.page-item:hover { background: #2d2d30; }
.page-item:hover .page-item-actions { opacity: 1; }
.page-item.pg-active { background: #094771; }
.page-item.pg-active .page-name { color: #fff; font-weight: 600; }

.page-name {
  flex: 1;
  font-size: 12px;
  color: #ccc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}

.page-item-actions {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.1s;
  flex-shrink: 0;
}
.page-item.pg-active .page-item-actions { opacity: 1; }

.page-action-btn {
  background: transparent;
  border: none;
  color: #777;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.page-action-btn:hover { background: #3e3e42; color: #ccc; }
.page-action-btn.danger:hover { background: #5a1d1d; color: #f44747; }

/* ─── IMAGE EDITOR MODAL ─────────────────────────────────────────────────────── */

#img-editor-hint {
  font-size: 11px;
  color: #888;
  margin-bottom: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  background: #1e1e1e;
  border-radius: 4px;
  border: 1px solid #3e3e42;
}
#img-editor-hint strong { color: #ccc; }

#img-edit-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  cursor: crosshair;
  max-width: 100%;
  border-radius: 4px;
  overflow: hidden;
  background: #111;
}

#img-main-canvas {
  display: block;
  max-width: 100%;
}

#img-sel-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  display: block;
}

/* ─── IMAGE ADJUSTMENT TOOLBAR ───────────────────────────────────────────────── */

#img-adj-toolbar {
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 8px;
}

.img-adj-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.img-resize-row {
  flex-wrap: wrap;
}

.img-adj-lbl {
  font-size: 10px;
  color: #888;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  width: 72px;
  flex-shrink: 0;
}

.img-adj-slider {
  flex: 1;
  height: 3px;
  accent-color: #007acc;
  cursor: pointer;
}

.img-adj-val {
  font-size: 10px;
  color: #666;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.img-size-input {
  width: 92px;
  min-width: 92px;
}

.img-size-sep {
  font-size: 12px;
  color: #777;
}

.img-adj-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid #3e3e42;
  margin-top: 2px;
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.welcome-card {
  appearance: none;
  border: 1px solid #3e3e42;
  background: #252526;
  color: #ccc;
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .12s, transform .12s, background .12s;
}

.welcome-card:hover {
  border-color: #007acc;
  background: #2d2d30;
  transform: translateY(-1px);
}

.welcome-card strong {
  font-size: 14px;
  color: #fff;
}

.welcome-card span {
  font-size: 12px;
  line-height: 1.5;
  color: #9ca3af;
}

/* ─── CONTEXT MENU ────────────────────────────────────────────────────────────── */

#ctx-menu {
  display: none;
  position: fixed;
  z-index: 9998;
  background: #252526;
  border: 1px solid #3e3e42;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 178px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  font-size: 12px;
}

.ctx-item {
  padding: 7px 14px;
  color: #ccc;
  cursor: pointer;
  user-select: none;
  transition: background 0.08s, color 0.08s;
}
.ctx-item:hover { background: #094771; color: #fff; }
.ctx-item.ctx-danger { color: #f47d7d; }
.ctx-item.ctx-danger:hover { background: #5a1d1d; color: #f44747; }
.ctx-item.ctx-link-item { color: #7dd3fc; }
.ctx-item.ctx-link-item:hover { background: #0c3a5a; color: #bae6fd; }

.ctx-sep {
  height: 1px;
  background: #3e3e42;
  margin: 3px 0;
}

/* ─── AUTOSAVE LABEL ──────────────────────────────────────────────────────────── */

#autosave-label {
  font-size: 10px;
  color: #555;
  padding: 0 5px;
  white-space: nowrap;
  flex-shrink: 0;
  font-style: italic;
}

/* ─── NEW PAGE MODAL: TEMPLATE RADIO LIST ─────────────────────────────────────── */

.np-radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  color: #ccc;
  transition: background 0.1s;
}
.np-radio-row:hover { background: #2d2d30; }
.np-radio-row input[type="radio"] { accent-color: #007acc; flex-shrink: 0; }

/* ─── LINK-TO MODAL ────────────────────────────────────────────────────────── */

.lto-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 10px 6px 4px;
  border-top: 1px solid #3e3e42;
  margin-top: 2px;
}
.lto-section-label:first-child { border-top: none; margin-top: 0; padding-top: 2px; }

.lto-item {
  padding: 7px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.875rem;
  color: #cbd5e1;
  display: flex;
  align-items: baseline;
  gap: 7px;
  transition: background 0.1s;
}
.lto-item:hover { background: #2d2d30; color: #f0f0f0; }
.lto-item-icon { font-size: 0.78rem; color: #64748b; flex-shrink: 0; }
.lto-item-sub { color: #475569; font-size: 0.78rem; margin-left: 2px; }

/* ─── LINK-TO: CUSTOM URL ROW ────────────────────────────────────────────────── */

.lto-url-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #3e3e42;
  align-items: center;
}

.lto-url-input {
  flex: 1;
  box-sizing: border-box;
  padding: 7px 11px;
  border: 1px solid #3e3e42;
  border-radius: 6px;
  font-size: 0.825rem;
  background: #2d2d30;
  color: #ccc;
  outline: none;
  font-family: inherit;
  transition: border-color 0.12s;
}
.lto-url-input:focus { border-color: #007acc; }
.lto-url-input::placeholder { color: #555; }

/* ─── CHANGE TYPE MODAL ──────────────────────────────────────────────────────── */

.ctype-group-label {
  font-size: 10px;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 12px 0 5px;
}
.ctype-group-label:first-child { margin-top: 0; }

.ctype-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 2px;
}

.ctype-btn {
  padding: 5px 11px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  background: #2d2d30;
  color: #aaa;
  border: 1px solid #3e3e42;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.ctype-btn:hover { background: #3e3e42; color: #fff; border-color: #555; }
.ctype-btn.ctype-current { background: #094771; color: #7ec8f4; border-color: #007acc; }

/* ─── PANEL RESIZE HANDLE ────────────────────────────────────────────────────── */

.panel-resize-handle {
  height: 5px;
  flex-shrink: 0;
  background: transparent;
  cursor: row-resize;
  position: relative;
  z-index: 1;
  transition: background 0.12s;
}
.panel-resize-handle:hover,
.panel-resize-handle.is-resizing {
  background: #007acc;
}

/* ─── PANEL DRAG HANDLE (reorder grip in header) ─────────────────────────────── */

.ph-drag-handle {
  color: #444;
  font-size: 13px;
  cursor: grab;
  padding: 0 4px 0 0;
  margin-right: 2px;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}
.panel-header:hover .ph-drag-handle { opacity: 1; color: #666; }
.ph-drag-handle:active { cursor: grabbing; }

/* ─── PANEL DRAG STATES ──────────────────────────────────────────────────────── */

.ps-dragging { opacity: 0.35; }
.ps-drag-over {
  outline: 1px solid #007acc;
  outline-offset: -1px;
  border-radius: 4px;
}

/* ─── MORE DROPDOWN ──────────────────────────────────────────────────────────── */

.tb-more-wrap {
  position: relative;
  flex-shrink: 0;
}

.tb-more-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #252526;
  border: 1px solid #3e3e42;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 178px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  z-index: 9999;
}
.tb-more-menu.open { display: block; }

.tb-more-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #ccc;
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.08s, color 0.08s;
  white-space: nowrap;
}
.tb-more-item:hover  { background: #094771; color: #fff; }
.tb-more-item:disabled { opacity: 0.38; cursor: default; }

.tb-more-sep {
  height: 1px;
  background: #3e3e42;
  margin: 3px 0;
}

/* ─── BLOCK SEARCH ───────────────────────────────────────────────────────────── */

.block-search-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 6px 0 8px;
  padding: 5px 9px;
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  border-radius: 4px;
  color: #ccc;
  font-size: 11px;
  outline: none;
  transition: border-color 0.15s;
}
.block-search-input:focus { border-color: #007acc; }
.block-search-input::placeholder { color: #555; }

/* ─── CONTEXT MENU SHORTCUT HINTS ────────────────────────────────────────────── */

.ctx-item { display: flex; align-items: center; }
.ctx-label { flex: 1; }
.ctx-kbd {
  font-size: 10px;
  color: #555;
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  border-radius: 3px;
  padding: 1px 4px;
  font-family: inherit;
  margin-left: 8px;
  flex-shrink: 0;
  pointer-events: none;
}
.ctx-item:hover .ctx-kbd { color: rgba(255,255,255,0.5); border-color: rgba(255,255,255,0.2); background: transparent; }

/* ─── PAGE DRAG HANDLE ───────────────────────────────────────────────────────── */

.page-drag-handle {
  color: #444;
  font-size: 13px;
  cursor: grab;
  padding: 0 2px;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}
.page-item:hover .page-drag-handle { color: #666; }
.page-item.pg-dragging { opacity: 0.4; }
.page-item.pg-drag-over { outline: 1px solid #007acc; border-radius: 5px; }

/* ─── FOLLOW LINK BUTTON ─────────────────────────────────────────────────────── */

.sel-follow-link-btn {
  margin-top: 8px;
  width: 100%;
  font-size: 11px;
  background: rgba(14,99,156,0.12);
  color: #4fc3f7;
  border-color: rgba(14,99,156,0.35);
}
.sel-follow-link-btn:hover {
  background: rgba(14,99,156,0.24);
  border-color: rgba(14,99,156,0.6);
}

/* ─── SELECTION HELPER SIZE ROW ──────────────────────────────────────────────── */

.sel-size-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.sel-size-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.sel-size-field span {
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sel-size-input {
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  border-radius: 5px;
  color: #ccc;
  font-size: 12px;
  padding: 4px 6px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
}

.sel-size-input:focus {
  border-color: #007acc;
  color: #fff;
}

/* ─── SELECTION HELPER ALIGN ROW ─────────────────────────────────────────────── */

.sel-align-row {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.sel-align-btn {
  flex: 1;
  background: #1e1e1e;
  border: 1px solid #3e3e42;
  border-radius: 5px;
  color: #888;
  padding: 5px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sel-align-btn:hover { background: #2d2d30; color: #ccc; border-color: #555; }
.sel-align-btn.is-active { background: rgba(14,99,156,0.2); color: #4fc3f7; border-color: rgba(14,99,156,0.5); }
