/* ==========================================================================
   WP Social Proof — Admin CSS
   tokens.css is enqueued as a PHP dependency (class.core.php loadAdminStyles),
   so CSS custom properties from tokens.css are already in scope here.
   This file defines the full settings-page shell and all component primitives.
   Replaces the old admin.css entirely.
   ========================================================================== */

/* ---------- Reset inside our container ---------- */
.wpsp-page *,
.wpsp-page *::before,
.wpsp-page *::after {
  box-sizing: border-box;
}

/* ---------- Page shell ----------
   Fixed-height viewport layout: the three columns scroll independently;
   the global WP page never scrolls. 32px = WP admin bar height.      */
.wpsp-page {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--fg1);
  background: var(--bg-sunken);
  -webkit-font-smoothing: antialiased;
  /* Pull edge-to-edge within WP's .wrap margins */
  margin: 0 0px 0 -20px;
  /* Fill exactly the viewport below the WP admin bar */
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: fixed;
  z-index: 1;
  width: stretch;
}

/* ---------- Plugin header bar ---------- */
.wpsp-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  flex-shrink: 0;
  z-index: 50;
}

.wpsp-header-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-ink), oklch(35% 0.09 280));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.wpsp-header-title {
  display: flex;
  flex-direction: column;
}

.wpsp-header-name {
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg1);
  line-height: 1.2;
}

.wpsp-header-meta {
  font-size: var(--text-xs);
  color: var(--fg3);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.wpsp-header-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.wpsp-header-tab-label {
  font-size: 14px;
  color: var(--fg2);
  font-weight: 500;
}

.wpsp-header-spacer {
  flex: 1;
}

.wpsp-save-feedback {
  font-size: var(--text-xs);
  color: var(--fg3);
  opacity: 0;
  transition: opacity var(--dur-base);
  white-space: nowrap;
}

.wpsp-save-feedback.visible {
  opacity: 1;
}

/* ---------- 3-column layout ---------- */
.wpsp-layout {
  display: flex;
  flex: 1;
  height: calc(100% - 90px);
  overflow: hidden;
}

/* ---------- Internal sidebar ---------- */
.wpsp-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.wpsp-sidebar-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg3);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 6px 12px 8px;
}

.wpsp-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  color: var(--fg2);
  font-weight: 500;
  border: 0;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  font-family: var(--font-sans);
  transition: background var(--dur-fast), color var(--dur-fast);
}

.wpsp-nav-item:hover {
  background: var(--bg-hover);
  color: var(--fg1);
}

.wpsp-nav-item.active {
  background: var(--bg-active);
  color: var(--fg1);
  font-weight: 600;
}

.wpsp-nav-item svg {
  flex-shrink: 0;
}

.wpsp-nav-item .nav-spacer {
  flex: 1;
}

.wpsp-sidebar-spacer {
  flex: 1;
}

/* Pro upsell card in sidebar */
.wpsp-sidebar-upsell {
  background: linear-gradient(135deg, var(--brand-ink), oklch(33% 0.08 280));
  color: white;
  padding: 14px;
  border-radius: 12px;
  font-size: var(--text-xs);
  line-height: 1.4;
  margin-top: 4px;
}

.wpsp-sidebar-upsell-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 4px;
}

.wpsp-sidebar-upsell-body {
  color: oklch(85% 0.02 260);
  margin-bottom: 10px;
}

.wpsp-sidebar-upsell .btn {
  background: white;
  color: var(--brand-ink);
  border: 0;
  width: 100%;
  justify-content: center;
}

.wpsp-sidebar-upsell .btn:hover {
  background: var(--bg-active);
}

/* ---------- Main content ---------- */
.wpsp-main {
  flex: 1;
  min-width: 0;
  padding: 24px 32px 40px;
  height: 100%;
  overflow-y: auto;
}

/* ---------- Live preview rail ---------- */
.wpsp-preview-rail {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow-y: auto;
  transition: width var(--dur-base) var(--ease-out),
              padding var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.wpsp-preview-rail.wpsp-rail-collapsed {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-left-color: transparent;
  overflow: hidden;
}

.wpsp-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wpsp-rail-title {
  font-size: var(--text-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wpsp-rail-hint {
  font-size: var(--text-xs);
  color: var(--fg3);
  margin-top: 2px;
}

.wpsp-rail-eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg3);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.wpsp-rail-footer {
  padding: 12px;
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--fg2);
  line-height: 1.5;
  display: flex;
  gap: 8px;
}

/* Faux-site stage in rail */
.wpsp-blip-stage {
  position: relative;
  background:
    radial-gradient(ellipse at 30% 20%, oklch(96% 0.02 260) 0%, transparent 50%),
    linear-gradient(180deg, oklch(98% 0.005 85), oklch(95% 0.008 85));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex-shrink: 0;
}

.wpsp-blip-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), oklch(90% 0.01 260 / 0.35) 100%),
    linear-gradient(0deg,  transparent 0, transparent calc(100% - 1px), oklch(90% 0.01 260 / 0.35) 100%);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

.wpsp-faux-site,
.wpsp-blip-stage > * {
  position: relative;
  z-index: 1;
}

.wpsp-faux-site {
  position: absolute;
  inset: 0;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wpsp-faux-bar {
  height: 6px;
  background: oklch(88% 0.01 260);
  border-radius: 4px;
}

.wpsp-faux-bar.w70 { width: 70%; }
.wpsp-faux-bar.w90 { width: 90%; }
.wpsp-faux-bar.w50 { width: 50%; }
.wpsp-faux-bar.w40 { width: 40%; }
.wpsp-faux-bar.tall { height: 80px; background: oklch(92% 0.008 260); border-radius: 6px; margin-top: 6px; }

/* ---------- Live preview blip ---------- */
.wpsp-preview-blip {
  position: absolute !important;
  z-index: 2;
  width: 220px;
  background: white;
  border-radius: 10px;
  padding: 9px 11px;
  box-shadow: 0 2px 8px oklch(20% 0.02 260 / 0.14), 0 1px 2px oklch(20% 0.02 260 / 0.06);
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: none;
  font-family: var(--font-sans);
}

.wpsp-preview-blip.pos-bl { bottom: 10px; left: 10px; }
.wpsp-preview-blip.pos-br { bottom: 10px; right: 10px; }
.wpsp-preview-blip.pos-tl { top: 10px;    left: 10px; }
.wpsp-preview-blip.pos-tr { top: 10px;    right: 10px; }

.wpsp-preview-blip-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wpsp-preview-blip-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wpsp-preview-blip-body {
  flex: 1;
  min-width: 0;
  /* Standard + Rounded: name and detail flow inline as a sentence */
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px;
}

.wpsp-preview-blip-name {
  font-size: 12px;
  font-weight: 600;
  color: oklch(22% 0.015 260);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wpsp-preview-blip-detail {
  font-size: 11px;
  color: oklch(55% 0.01 260);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Split template: name stacked above detail */
.wpsp-blip-tpl-split .wpsp-preview-blip-body {
  flex-direction: column;
  gap: 2px;
}

@keyframes wpspPreviewFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes wpspPreviewSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes wpspPreviewFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.wpsp-preview-blip.anim-in-fade     { animation: wpspPreviewFadeIn  500ms var(--ease-out) forwards; }
.wpsp-preview-blip.anim-in-slide_up { animation: wpspPreviewSlideIn 380ms var(--ease-out) forwards; }
.wpsp-preview-blip.anim-out         { animation: wpspPreviewFadeOut 300ms var(--ease-out) forwards; }

/* ---------- Buttons ---------- */
.wpsp-page .btn,
.wpsp-page button.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--fg1);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  line-height: 1;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.wpsp-page .btn:hover {
  background: var(--bg-hover);
}

.wpsp-page .btn.primary {
  background: var(--brand-ink);
  color: white;
  border-color: var(--brand-ink);
}

.wpsp-page .btn.primary:hover {
  background: var(--brand-ink-hover);
  border-color: var(--brand-ink-hover);
}

.wpsp-page .btn.ghost {
  border-color: transparent;
  background: transparent;
}

.wpsp-page .btn.ghost:hover {
  background: var(--bg-hover);
}

.wpsp-page .btn.ghost.active {
  background: var(--bg-active);
  border-color: var(--border);
}

.wpsp-page .btn.sm {
  padding: 5px 10px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.wpsp-page .btn.icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}


/* ---------- Chips ---------- */
.wpsp-page .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-active);
  color: var(--fg2);
  white-space: nowrap;
}

.wpsp-page .chip.pro {
  background: var(--brand-coral-soft);
  color: oklch(45% 0.15 30);
}

.wpsp-page .chip.live {
  background: var(--success-soft);
  color: oklch(35% 0.14 155);
}

.wpsp-page .chip.live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--success);
  flex-shrink: 0;
}

.wpsp-page button.wpsp-shortcode-chip,
.wpsp-page .wpsp-shortcode-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--fg2);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  line-height: 1.6;
  letter-spacing: 0;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.wpsp-page button.wpsp-shortcode-chip:hover,
.wpsp-page .wpsp-shortcode-chip:hover {
  background: var(--bg-active);
  border-color: var(--border-strong);
  color: var(--fg1);
}

/* ---------- String Editor card layout ---------- */
.wpsp-str-card + .wpsp-str-card { margin-top: 12px; }

.wpsp-str-group-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg1);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wpsp-str-item {
  margin-bottom: 14px;
}

.wpsp-str-item:last-child {
  margin-bottom: 0;
}

.wpsp-str-item-label {
  font-size: 12px;
  color: var(--fg2);
  font-weight: 500;
  margin-bottom: 5px;
}

.wpsp-str-item-desc {
  font-size: 11px;
  color: var(--fg3);
  font-weight: 400;
  margin-top: 2px;
}

.wpsp-str-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--fg1);
  background: var(--bg-raised);
  box-sizing: border-box;
}

.wpsp-str-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.wpsp-str-chips {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ---------- Cards ---------- */
.wpsp-page .card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

/* ---------- Toggle switch ---------- */
.wpsp-page .toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-fast);
  border: 0;
  outline: 0;
}

.wpsp-page .toggle::before {
  position: relative;
  top: 2px;
  left: 2px;
}

.wpsp-page .toggle::before {
  display: none;
}

.wpsp-page .toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: white;
  transition: transform var(--dur-base) var(--ease-out);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  background-image: none;
}

.wpsp-page .toggle:checked {
  background: var(--brand-ink);
}

.wpsp-page .toggle:checked::after {
  transform: translateX(16px);
}

.wpsp-page .toggle:focus-visible {
  box-shadow: var(--shadow-focus);
}

/* ---------- Text inputs ---------- */
.wpsp-page input[type="text"],
.wpsp-page input[type="number"],
.wpsp-page input[type="url"],
.wpsp-page select,
.wpsp-page textarea {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  color: var(--fg1);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: 0;
  transition: box-shadow var(--dur-fast), border-color var(--dur-fast);
  appearance: none;
  -webkit-appearance: none;
}

.wpsp-page select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2362697a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.wpsp-page input[type="text"]:focus,
.wpsp-page input[type="number"]:focus,
.wpsp-page select:focus,
.wpsp-page textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* ---------- Section heading ---------- */
.wpsp-section-heading {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg3);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 24px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.wpsp-section-heading:first-child {
  padding-top: 0;
}

/* ---------- Setting row ---------- */
form#wpsp-settings-form {
  height: 100%;
}

.wpsp-setting-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.wpsp-setting-row.locked {
  opacity: 0.55;
  pointer-events: none;
}

.wpsp-setting-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.wpsp-setting-hint {
  font-size: var(--text-xs);
  color: var(--fg3);
  margin-top: 3px;
  line-height: 1.4;
}

.wpsp-setting-control {
  display: flex;
  align-items: flex-start;
}

/* ---------- Appearance tab — template cards ---------- */
.wpsp-template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.wpsp-template-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 12px;
  cursor: pointer;
  text-align: left;
  position: relative;
  width: 100%;
  box-shadow: none;
  font-family: var(--font-sans);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.wpsp-template-card:hover {
  border-color: var(--border-strong);
}

.wpsp-template-card.active {
  border: 2px solid var(--brand-ink);
  box-shadow: var(--shadow-sm);
}

.wpsp-template-card.locked-pro {
  opacity: 0.6;
  cursor: default;
}

.wpsp-template-card.locked-pro:hover {
  border-color: var(--border);
}

.wpsp-template-thumb {
  height: 80px;
  margin-bottom: 10px;
  background: oklch(96% 0.005 85);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.wpsp-template-thumb-blip {
  /* Mini blip preview inside the card */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: white;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  max-width: 180px;
  font-size: 11px;
  transform: scale(0.82);
}

.wpsp-template-thumb-blip.rounded-preview {
  border-radius: var(--radius-full);
  padding: 6px 12px 6px 6px;
}

.wpsp-template-thumb-blip.split-preview {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border-radius: 10px;
  max-width: 140px;
  gap: 0;
}

.wpsp-template-thumb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand-ink), oklch(40% 0.10 280));
  flex-shrink: 0;
}

.wpsp-template-thumb-avatar.circle {
  border-radius: var(--radius-full);
}

.wpsp-template-thumb-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.wpsp-template-thumb-line {
  height: 6px;
  background: oklch(88% 0.01 260);
  border-radius: 3px;
}

.wpsp-template-thumb-line.short { width: 55%; }
.wpsp-template-thumb-line.long  { width: 85%; }
.wpsp-template-thumb-line.med   { width: 70%; }

.wpsp-template-thumb-split-top {
  background: linear-gradient(135deg, var(--brand-ink), oklch(30% 0.08 280));
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  border-radius: 10px 10px 0 0;
}

.wpsp-template-thumb-split-dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--brand-coral);
  flex-shrink: 0;
}

.wpsp-template-thumb-split-eyebrow {
  height: 5px;
  width: 60px;
  background: oklch(70% 0.02 260);
  border-radius: 3px;
}

.wpsp-template-thumb-split-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
}

.wpsp-template-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wpsp-template-card-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg1);
}

.wpsp-template-card-check {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--brand-ink);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Appearance tab — position picker ---------- */
.wpsp-position-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}

.wpsp-position-picker {
  width: 140px;
  height: 92px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  flex-shrink: 0;
}

.wpsp-position-picker::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-xs);
  pointer-events: none;
}

.wpsp-corner-btn {
  position: absolute;
  width: 28px;
  height: 18px;
  cursor: pointer;
}

.wpsp-corner-btn input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
  margin: 0;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.wpsp-corner-btn input[type="radio"]:checked {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
}

.wpsp-corner-btn input[type="radio"]:hover:not(:checked) {
  border-color: var(--brand-ink);
}

.wpsp-corner-btn.tl { top: 6px;    left: 6px;   }
.wpsp-corner-btn.tr { top: 6px;    right: 6px;  }
.wpsp-corner-btn.bl { bottom: 6px; left: 6px;   }
.wpsp-corner-btn.br { bottom: 6px; right: 6px;  }

.wpsp-position-label {
  font-size: var(--text-xs);
  color: var(--fg2);
  min-width: 80px;
}

/* ---------- Appearance tab — animation segmented control ---------- */
.wpsp-animation-group {
  display: flex;
  gap: 8px;
}

.wpsp-anim-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--fg1);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}

.wpsp-anim-btn.active,
.wpsp-anim-btn:has(+ input:checked) {
  background: var(--brand-ink);
  color: white;
  border-color: var(--brand-ink);
}

/* ---------- Appearance tab — icon swatches ---------- */
.wpsp-icon-swatches {
  display: flex;
  gap: 10px;
  align-items: center;
}

.wpsp-icon-swatch {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  outline: none;
  cursor: pointer;
  overflow: hidden;
  background: var(--bg-surface);
  transition: outline-color var(--dur-fast), border-color var(--dur-fast);
  padding: 0;
  position: relative;
}

.wpsp-icon-swatch.active,
.wpsp-icon-swatch:focus-visible {
  outline: 2px solid var(--brand-ink);
  outline-offset: 2px;
}

.wpsp-icon-swatch-pro {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
  border: 2px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg3);
  cursor: default;
}

/* ---------- Info banner ---------- */
.wpsp-info-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--info-soft);
  border: 1px solid oklch(88% 0.05 240);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: oklch(35% 0.14 240);
  margin-bottom: 14px;
}

/* ---------- Upsell inline card (Behavior tab, etc.) ---------- */
.wpsp-upsell-card {
  margin-top: 24px;
  padding: 18px;
  background: linear-gradient(135deg, oklch(98% 0.02 30), oklch(96% 0.05 30));
  border: 1px solid oklch(90% 0.06 30);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.wpsp-upsell-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-coral), oklch(60% 0.18 25));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wpsp-upsell-body {
  flex: 1;
}

.wpsp-upsell-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.wpsp-upsell-hint {
  font-size: var(--text-xs);
  color: var(--fg2);
}

/* ---------- Help tab upsell banner ---------- */
.wpsp-help-upsell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--brand-ink), oklch(33% 0.08 280));
  border-radius: var(--radius-lg);
  color: white;
}

.wpsp-help-upsell-inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

.wpsp-help-upsell-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: oklch(100% 0 0 / 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wpsp-help-upsell-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.wpsp-help-upsell-hint {
  font-size: var(--text-xs);
  color: oklch(85% 0.02 260);
  line-height: 1.4;
}

.wpsp-help-upsell-btn {
  background: white !important;
  color: var(--brand-ink) !important;
  border: 0 !important;
  white-space: nowrap;
  flex-shrink: 0;
}

.wpsp-help-upsell-btn:hover {
  background: var(--bg-active) !important;
}

/* ---------- Per-tab preview rail visibility ---------- */
/* Help tab: rail is not rendered by PHP; hide the header toggle too */
.wpsp-page[data-tab="help"] #wpsp-preview-toggle {
  display: none;
}

/* ---------- Help tab grid ---------- */
.wpsp-help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* 3 columns when there's enough room (no rail on help tab) */
@media (min-width: 1100px) {
  .wpsp-page[data-tab="help"] .wpsp-help-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.wpsp-help-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-active);
  color: var(--fg1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.wpsp-help-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.wpsp-help-card-hint {
  font-size: var(--text-xs);
  color: var(--fg3);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* ---------- Stub tab placeholder ---------- */
.wpsp-tab-stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--fg3);
  gap: 8px;
  text-align: center;
}

.wpsp-tab-stub-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--fg2);
}

/* ---------- Legacy hook output wrapper ----------
   Old upsell HTML (<tr> elements) won't render visibly
   here but the hooks still fire for back-compat.        */
.wpsp-legacy-hook-output {
  display: none;
}


/* ==========================================================================
   Responsive — tablet & mobile
   ========================================================================== */

/* ── Tablet (≤ 960px): collapse rail, let page scroll ──────────────────── */
@media (max-width: 960px) {
  /* Switch from fixed viewport to natural scroll */
  .wpsp-page {
    height: auto;
    overflow: visible;
    margin: 0 0px 0 -10px;
    position: unset;
  }

  .wpsp-layout {
    height: auto;
    overflow: visible;
  }

  .wpsp-main {
    height: auto;
    overflow: visible;
    padding: 20px 24px 32px;
  }

  /* Hide rail and its toggle — not enough room */
  .wpsp-preview-rail,
  #wpsp-preview-toggle {
    display: none !important;
  }

  /* Narrower sidebar */
  .wpsp-sidebar {
    width: 180px;
  }
}

@media screen and (max-width: 782px) {
    .wpsp-page .toggle::before {
      position: relative;
      top: -1.5px !important;
      left: 0px;
      transform: scale(0.5);
    }
}

/* ── Mobile (≤ 640px): stack layout, sidebar becomes a top tab bar ──────── */
@media (max-width: 640px) {
  /* Header: single row, branding left — Live + Save right */
  .wpsp-header {
    flex-wrap: nowrap;
    padding: 10px 16px;
    gap: 10px;
  }

  /* Allow title to shrink so actions can sit on the right */
  .wpsp-header-title {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
  }

  .wpsp-header-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .wpsp-header-meta {
    white-space: nowrap;
    overflow: hidden;
  }

  /* Spacer stays — pushes Live + Save to the right edge */
  .wpsp-header-spacer {
    flex: 1;
  }

  /* Hide items that don't fit on mobile */
  .wpsp-header-divider,
  .wpsp-header-tab-label,
  .wpsp-save-feedback {
    display: none;
  }

  /* Layout stacks vertically */
  .wpsp-layout {
    flex-direction: column;
  }

  /* Sidebar becomes a horizontal scrollable nav strip */
  .wpsp-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .wpsp-sidebar::-webkit-scrollbar { display: none; }

  .wpsp-sidebar-label,
  .wpsp-sidebar-spacer,
  .wpsp-sidebar-upsell {
    display: none;
  }

  .wpsp-nav-item {
    width: auto;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: var(--text-xs);
  }

  /* Main content */
  .wpsp-main {
    padding: 16px;
  }

  /* Help grid: single column */
  .wpsp-help-grid {
    grid-template-columns: 1fr;
  }

  /* Help upsell: stack vertically */
  .wpsp-help-upsell {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  /* Template cards: two columns on mobile */
  .wpsp-template-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Setting rows: stack label above control */
  .wpsp-setting-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Control takes full width; toggles end up right-aligned via justify-content */
  .wpsp-setting-control {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  /* Range sliders: expand to fill available width */
  .wpsp-setting-control input[type="range"] {
    flex: 1;
    min-width: 0;
    max-width: none !important;
  }

  /* Text inputs: full width */
  .wpsp-setting-control input[type="text"],
  .wpsp-setting-control input[type="number"] {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
  }
}
