/* =====================================================
   PROMOTE.™ — All admin/builder styles
   Light theme inspired by the dotted-canvas mockup.
   ===================================================== */

:root {
  --promote-bg:           #fafafa;
  --promote-surface:      #ffffff;
  --promote-surface-2:    #f5f5f7;
  --promote-border:       #e5e5ea;
  --promote-border-strong:#d4d4d8;
  --promote-text:         #1c1c1e;
  --promote-text-2:       #6b6b70;
  --promote-text-3:       #a1a1a6;
  --promote-accent:       #2563eb;
  --promote-accent-soft:  #eff5ff;
  --promote-success:      #16a34a;
  --promote-danger:       #dc2626;
  --promote-shadow-sm:    0 1px 2px rgba(0,0,0,.04);
  --promote-shadow-md:    0 4px 12px rgba(0,0,0,.06);
  --promote-shadow-lg:    0 12px 32px rgba(0,0,0,.10);
  --promote-radius:       10px;
  --promote-radius-sm:    6px;
  --promote-font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--promote-font);
  color: var(--promote-text);
  background: var(--promote-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--promote-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------ Logo ------------ */
.promote-logo {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 18px;
  color: var(--promote-text);
}
.promote-logo span {
  color: var(--promote-text-3);
  font-weight: 500;
}

/* ------------ Buttons ------------ */
.promote-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--promote-radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  text-decoration: none;
  white-space: nowrap;
}
.promote-btn:active { transform: translateY(1px); }
.promote-btn:disabled { opacity: .5; cursor: not-allowed; }

.promote-btn-primary {
  background: var(--promote-accent);
  color: #fff;
}
.promote-btn-primary:hover { background: #1d4ed8; }

.promote-btn-ghost {
  background: var(--promote-surface);
  border-color: var(--promote-border);
  color: var(--promote-text);
}
.promote-btn-ghost:hover { background: var(--promote-surface-2); }

.promote-btn-danger {
  background: var(--promote-surface);
  border-color: var(--promote-border);
  color: var(--promote-danger);
}
.promote-btn-danger:hover { background: #fef2f2; border-color: #fecaca; }

.promote-btn-add {
  width: 100%;
  background: var(--promote-surface);
  border: 1px dashed var(--promote-border-strong);
  color: var(--promote-accent);
  padding: 12px;
  margin-top: 8px;
}
.promote-btn-add:hover { background: var(--promote-accent-soft); }

/* ------------ Login ------------ */
.promote-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.promote-login-card {
  width: 100%;
  max-width: 380px;
  background: var(--promote-surface);
  border: 1px solid var(--promote-border);
  border-radius: var(--promote-radius);
  padding: 32px;
  box-shadow: var(--promote-shadow-md);
}
.promote-login-card .promote-logo { font-size: 24px; margin-bottom: 4px; }
.promote-login-sub { color: var(--promote-text-2); margin: 0 0 20px; }
.promote-login-card form label,
#promote-pw-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--promote-text-2);
}
.promote-login-card input[type=text],
.promote-login-card input[type=password],
#promote-pw-form input[type=password] {
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  border: 1px solid var(--promote-border-strong);
  border-radius: var(--promote-radius-sm);
  font: inherit;
  background: var(--promote-surface);
}
.promote-login-card input:focus,
#promote-pw-form input:focus {
  outline: none;
  border-color: var(--promote-accent);
  box-shadow: 0 0 0 3px var(--promote-accent-soft);
}
.promote-login-card .promote-btn,
#promote-pw-form .promote-btn { width: 100%; margin-top: 8px; padding: 10px; }

.promote-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--promote-danger);
  padding: 8px 12px;
  border-radius: var(--promote-radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.promote-hint {
  font-size: 12px;
  color: var(--promote-text-3);
  margin-top: 16px;
  text-align: center;
}
.promote-hint code {
  background: var(--promote-surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* ------------ Topbar ------------ */
.promote-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--promote-surface);
  border-bottom: 1px solid var(--promote-border);
}
.promote-topbar-actions { display: flex; gap: 8px; }

/* ------------ Dashboard ------------ */
.promote-dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}
.promote-dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.promote-dashboard h1 { margin: 0; font-size: 22px; font-weight: 600; }

.promote-empty {
  background: var(--promote-surface);
  border: 1px dashed var(--promote-border-strong);
  border-radius: var(--promote-radius);
  padding: 48px;
  text-align: center;
  color: var(--promote-text-2);
}

.promote-widget-list { display: grid; gap: 12px; }
.promote-widget-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--promote-surface);
  border: 1px solid var(--promote-border);
  border-radius: var(--promote-radius);
  padding: 16px 20px;
  transition: box-shadow .15s, border-color .15s;
}
.promote-widget-card:hover {
  border-color: var(--promote-border-strong);
  box-shadow: var(--promote-shadow-sm);
}
.promote-widget-name { font-weight: 600; margin-bottom: 4px; }
.promote-widget-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--promote-text-2);
}
.promote-widget-card-actions { display: flex; gap: 8px; }

.promote-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.promote-badge-published { background: #ecfdf5; color: #047857; }
.promote-badge-draft { background: var(--promote-surface-2); color: var(--promote-text-2); }

/* ------------ Modal ------------ */
.promote-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.promote-modal-backdrop[hidden] { display: none; }
.promote-modal {
  background: var(--promote-surface);
  border-radius: var(--promote-radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--promote-shadow-lg);
  overflow: hidden;
}
.promote-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--promote-border);
}
.promote-modal-head h2 { margin: 0; font-size: 16px; }
.promote-modal-close {
  background: none; border: none;
  font-size: 24px; line-height: 1;
  color: var(--promote-text-2);
  cursor: pointer;
  padding: 0; width: 32px; height: 32px;
  border-radius: var(--promote-radius-sm);
}
.promote-modal-close:hover { background: var(--promote-surface-2); }
.promote-modal-body { padding: 20px; }
.promote-modal-body textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 12px;
  border: 1px solid var(--promote-border-strong);
  border-radius: var(--promote-radius-sm);
  background: var(--promote-surface-2);
  resize: vertical;
  margin-bottom: 12px;
}

/* ===========================================================
   BUILDER
   =========================================================== */
.promote-builder-app { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

.promote-builder-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--promote-surface);
  border-bottom: 1px solid var(--promote-border);
  flex-shrink: 0;
}
.promote-builder-title { display: flex; align-items: center; gap: 12px; }
.promote-back {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--promote-radius-sm);
  color: var(--promote-text);
  font-size: 18px;
}
.promote-back:hover { background: var(--promote-surface-2); text-decoration: none; }
.promote-name-input {
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 10px;
  border-radius: var(--promote-radius-sm);
  min-width: 240px;
  font-family: inherit;
  color: var(--promote-text);
}
.promote-name-input:hover { background: var(--promote-surface-2); }
.promote-name-input:focus {
  outline: none;
  background: var(--promote-surface);
  border-color: var(--promote-border-strong);
}
.promote-save-status { font-size: 12px; color: var(--promote-text-3); }
.promote-builder-actions { display: flex; gap: 8px; }

.promote-builder-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 64px 320px 1fr;
  min-height: 0;
}

/* ----- Left rail ----- */
.promote-rail {
  background: var(--promote-surface);
  border-right: 1px solid var(--promote-border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 12px 0;
}
.promote-rail-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  font: inherit;
  font-size: 11px;
  color: var(--promote-text-2);
  cursor: pointer;
  position: relative;
}
.promote-rail-btn:hover { color: var(--promote-text); }
.promote-rail-btn.is-active { color: var(--promote-accent); }
.promote-rail-btn.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--promote-accent);
  border-radius: 0 2px 2px 0;
}

/* ----- Sidebar ----- */
.promote-sidebar {
  background: var(--promote-surface);
  border-right: 1px solid var(--promote-border);
  overflow-y: auto;
}
.promote-panel { display: none; padding: 20px; }
.promote-panel.is-active { display: block; }
.promote-panel-title {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
}

.promote-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--promote-text-3);
  margin: 20px 0 10px;
}

.promote-field-group { margin-bottom: 18px; }
.promote-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--promote-text);
  margin-bottom: 6px;
}
.promote-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.promote-label-row .promote-label { margin-bottom: 0; }
.promote-label-row span {
  font-size: 12px;
  color: var(--promote-accent);
}

.promote-panel select,
.promote-panel textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--promote-border-strong);
  border-radius: var(--promote-radius-sm);
  background: var(--promote-surface);
  font: inherit;
}
.promote-panel select:focus,
.promote-panel textarea:focus {
  outline: none;
  border-color: var(--promote-accent);
  box-shadow: 0 0 0 3px var(--promote-accent-soft);
}
.promote-panel textarea { resize: vertical; min-height: 60px; font-size: 12px; font-family: ui-monospace, monospace; }

.promote-panel input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  background: transparent;
}
.promote-panel input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--promote-border);
  border-radius: 2px;
}
.promote-panel input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--promote-accent);
  border-radius: 50%;
  margin-top: -6px;
  cursor: pointer;
}
.promote-panel input[type=range]::-moz-range-track {
  height: 4px;
  background: var(--promote-border);
  border-radius: 2px;
}
.promote-panel input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--promote-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.promote-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.promote-color-row input[type=color] {
  width: 36px; height: 36px;
  border: 1px solid var(--promote-border-strong);
  border-radius: var(--promote-radius-sm);
  background: var(--promote-surface);
  cursor: pointer;
}
.promote-color-row span {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--promote-text-2);
}

.promote-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}

/* ----- Layout grid ----- */
.promote-layout-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.promote-layout-option {
  background: var(--promote-surface);
  border: 1px solid var(--promote-border);
  border-radius: var(--promote-radius-sm);
  padding: 10px 6px 8px;
  font: inherit;
  font-size: 11px;
  color: var(--promote-text-2);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.promote-layout-option:hover:not(.is-disabled) {
  border-color: var(--promote-border-strong);
  color: var(--promote-text);
}
.promote-layout-option.is-active {
  border-color: var(--promote-accent);
  color: var(--promote-accent);
  background: var(--promote-accent-soft);
}
.promote-layout-option.is-disabled { opacity: .5; cursor: not-allowed; }

.promote-layout-icon {
  width: 56px;
  height: 36px;
  background: var(--promote-surface-2);
  border-radius: 4px;
  position: relative;
  border: 1px solid var(--promote-border);
}
.promote-layout-option.is-active .promote-layout-icon { border-color: var(--promote-accent); }

.promote-layout-icon-modal::after { content: ''; position: absolute; inset: 8px 14px; background: currentColor; opacity: .8; border-radius: 2px; }
.promote-layout-icon-leftpane::after { content: ''; position: absolute; left: 2px; top: 2px; bottom: 2px; width: 40%; background: currentColor; opacity: .6; border-radius: 2px; }
.promote-layout-icon-rightpane::after { content: ''; position: absolute; right: 2px; top: 2px; bottom: 2px; width: 40%; background: currentColor; opacity: .6; border-radius: 2px; }
.promote-layout-icon-leftslide::after { content: ''; position: absolute; left: 4px; bottom: 4px; width: 30%; height: 50%; background: currentColor; opacity: .6; border-radius: 2px; }
.promote-layout-icon-rightslide::after { content: ''; position: absolute; right: 4px; bottom: 4px; width: 30%; height: 50%; background: currentColor; opacity: .6; border-radius: 2px; }
.promote-layout-icon-topbar::after { content: ''; position: absolute; left: 2px; right: 2px; top: 2px; height: 30%; background: currentColor; opacity: .6; border-radius: 2px; }
.promote-layout-icon-bottombar::after { content: ''; position: absolute; left: 2px; right: 2px; bottom: 2px; height: 30%; background: currentColor; opacity: .6; border-radius: 2px; }

/* ----- Block list ----- */
.promote-blocks-list { display: flex; flex-direction: column; gap: 6px; }
.promote-block-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--promote-surface);
  border: 1px solid var(--promote-border);
  border-radius: var(--promote-radius-sm);
  transition: border-color .15s;
}
.promote-block-item:hover { border-color: var(--promote-border-strong); }
.promote-block-thumb {
  width: 32px; height: 32px;
  background: var(--promote-surface-2);
  border-radius: 4px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.promote-block-info { flex: 1; min-width: 0; font-size: 12px; }
.promote-block-info strong { display: block; font-weight: 500; color: var(--promote-text); }
.promote-block-info span {
  display: block;
  font-size: 11px;
  color: var(--promote-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.promote-block-link {
  width: 100%;
  margin-top: 6px;
  padding: 4px 6px;
  border: 1px solid var(--promote-border);
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  background: var(--promote-surface);
}
.promote-block-link:focus { outline: none; border-color: var(--promote-accent); }
.promote-block-remove {
  background: none; border: none;
  color: var(--promote-text-3);
  font-size: 18px;
  cursor: pointer;
  padding: 0; width: 24px; height: 24px;
  border-radius: 4px;
}
.promote-block-remove:hover { color: var(--promote-danger); background: #fef2f2; }

/* ----- Preview canvas ----- */
.promote-preview {
  background:
    radial-gradient(circle, var(--promote-border) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--promote-bg);
  position: relative;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 40px;
}
.promote-device-toggle {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--promote-surface);
  border: 1px solid var(--promote-border);
  border-radius: var(--promote-radius-sm);
  padding: 2px;
  display: flex;
  gap: 2px;
  box-shadow: var(--promote-shadow-sm);
}
.promote-device-toggle button {
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--promote-text-2);
  display: grid;
  place-items: center;
}
.promote-device-toggle button.is-active {
  background: var(--promote-accent-soft);
  color: var(--promote-accent);
}

.promote-preview-stage { position: relative; }

.promote-preview-popup {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--promote-shadow-lg);
  position: relative;
  overflow: hidden;
}
.promote-preview-popup-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--promote-border);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--promote-text-2);
  z-index: 2;
}
.promote-preview-popup-img { display: block; width: 100%; height: auto; }
.promote-preview-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--promote-text-3);
  font-size: 13px;
}
.promote-preview-stage.is-mobile .promote-preview-popup { max-width: 320px; }
