/* === SproutPress Admin — v2.1 === */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600;9..40,700;9..40,800&display=swap');

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

:root {
  --bg:           #ebebeb;
  --surface:      #f5f5f5;
  --card:         rgba(255,255,255,.5);
  --dark:         #1c1c1c;
  --dark2:        #242424;
  --dark3:        #2e2e2e;
  --text:         #1c1c1c;
  --text-inv:     #ebebeb;
  --muted:        rgba(28,28,28,.42);
  --muted-inv:    rgba(235,235,235,.52);
  --border:       rgba(28,28,28,.1);
  --border-inv:   rgba(255,255,255,.07);
  --primary:      #22c55e;
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,.15);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,.12);
  --yellow:       #f59e0b;
  --radius-xl:    22px;
  --radius-lg:    16px;
  --radius-md:    10px;
  --radius-sm:    7px;
  --radius:       var(--radius-sm);
  --font:         'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:         'JetBrains Mono', 'Fira Code', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── HUB (DASHBOARD) ─────────────────────────────────────── */

.sp-hub-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px 100px;
}

.sp-hub {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

/* Brand */
.sp-hub-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.sp-hub-logo {
  width: 200px;
  max-height: 80px;
  object-fit: contain;
}

.sp-hub-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
}

.sp-hub-site {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

/* Cards grid */
.sp-hub-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}

.sp-hub-card {
  background: var(--dark);
  border: 1px solid var(--border-inv);
  border-radius: var(--radius-xl);
  padding: 26px 22px 22px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text-inv);
  transition: background .18s, transform .18s;
  min-height: 170px;
}

.sp-hub-card:hover {
  background: var(--dark2);
  transform: translateY(-3px);
}

.sp-hub-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: auto;
}

.sp-hub-card-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-top: 20px;
  margin-bottom: 3px;
}

.sp-hub-card-meta {
  font-size: 12px;
  color: var(--muted-inv);
  font-weight: 400;
}

/* Coming soon card style */
.sp-hub-card--dim {
  background: rgba(28,28,28,.45);
  pointer-events: none;
}

.sp-hub-card--dim:hover {
  background: rgba(28,28,28,.45);
  transform: none;
}

.sp-hub-card-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: rgba(235,235,235,.35);
  margin-top: 4px;
}

/* Hub user bar */
.sp-hub-user {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 8px 8px 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
  white-space: nowrap;
}

.sp-hub-user-info {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sp-hub-user-name {
  font-weight: 600;
  color: var(--text);
}

.sp-hub-logout {
  background: var(--dark);
  color: var(--text-inv);
  border: none;
  border-radius: 40px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-hub-logout:hover { background: var(--dark3); }

/* ── FLOATING NAV (inner pages) ──────────────────────────── */

.sp-floatnav {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--dark);
  border: 1px solid var(--border-inv);
  border-radius: 50px;
  display: flex;
  align-items: center;
  padding: 5px;
  gap: 2px;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  max-width: calc(100vw - 32px);
}

.sp-floatnav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted-inv);
  transition: background .15s, color .15s;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
}

.sp-floatnav-btn:hover {
  background: rgba(255,255,255,.08);
  color: var(--text-inv);
}

.sp-floatnav-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-inv);
  padding: 0 10px;
  flex: 1;
  text-align: center;
}

.sp-floatnav-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: filter .15s;
}

.sp-floatnav-action:hover { filter: brightness(0.85); }

.sp-floatnav-btn--primary {
  background: var(--primary);
  color: var(--primary-text);
}

.sp-floatnav-btn--primary:hover {
  background: var(--primary);
  color: var(--primary-text);
  filter: brightness(0.9);
}

/* ── INNER PAGE ──────────────────────────────────────────── */

.sp-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 90px 28px 80px;
}

.sp-inner-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
}

.sp-inner-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.sp-inner-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── ALERTS ──────────────────────────────────────────────── */

.sp-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  margin-bottom: 20px;
  font-weight: 500;
}

.sp-alert--success {
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,.2);
  color: #15803d;
}

.sp-alert--error {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,.2);
  color: #b91c1c;
}

.sp-alert-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: .5;
  padding: 0;
}
.sp-alert-close:hover { opacity: 1; }

/* ── BUTTONS ─────────────────────────────────────────────── */

.sp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
  font-family: var(--font);
  min-height: 34px;
}

.sp-btn--primary {
  background: var(--dark);
  color: var(--text-inv);
}
.sp-btn--primary:hover { background: var(--dark2); }

.sp-btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.sp-btn--ghost:hover {
  border-color: rgba(28,28,28,.25);
  color: var(--text);
}

.sp-btn--danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(239,68,68,.2);
}
.sp-btn--danger:hover { background: var(--red); color: #fff; }

.sp-btn--sm { padding: 5px 12px; font-size: 12.5px; }
.sp-btn--full { width: 100%; justify-content: center; }

/* ── FILTER TABS ─────────────────────────────────────────── */

.sp-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.sp-filter-tabs {
  display: flex;
  background: rgba(28,28,28,.07);
  border-radius: 50px;
  padding: 4px;
  gap: 2px;
}

.sp-filter-tab {
  padding: 6px 14px;
  border-radius: 40px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.sp-filter-tab:hover { color: var(--text); }
.sp-filter-tab.active {
  background: var(--dark);
  color: var(--text-inv);
}

/* ── TABLE ───────────────────────────────────────────────── */

.sp-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255,255,255,.4);
  overflow-x: auto;
}

.sp-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.sp-table th,
.sp-table td {
  padding: 13px 18px;
  text-align: left;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}

.sp-table th {
  background: rgba(28,28,28,.04);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.sp-table tbody tr:last-child td { border-bottom: none; }
.sp-table tbody tr:hover { background: rgba(255,255,255,.5); }

.sp-table-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.sp-table-link:hover { color: #444; text-decoration: underline; }

.sp-table-date { color: var(--muted); font-size: 12.5px; }

.sp-table-actions { display: flex; gap: 6px; align-items: center; }

/* ── BADGES ──────────────────────────────────────────────── */

.sp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}

.sp-badge--published {
  background: rgba(34,197,94,.12);
  color: #15803d;
}

.sp-badge--draft {
  background: rgba(28,28,28,.07);
  color: var(--muted);
}

.sp-badge--dot::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  display: block;
  flex-shrink: 0;
}

.sp-badge--admin {
  background: rgba(99,102,241,.12);
  color: #4338ca;
}

.sp-badge--editor {
  background: rgba(28,28,28,.07);
  color: var(--muted);
}

/* ── CODE ────────────────────────────────────────────────── */

.sp-code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: rgba(28,28,28,.07);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  color: var(--muted);
}

/* ── EMPTY STATE ─────────────────────────────────────────── */

.sp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 80px 32px;
  text-align: center;
}

.sp-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(28,28,28,.07);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.sp-empty h3 { font-size: 16px; font-weight: 700; }
.sp-empty p { font-size: 13.5px; color: var(--muted); max-width: 300px; }

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

.sp-form-layout {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 20px;
  align-items: start;
}

.sp-form-main { display: flex; flex-direction: column; gap: 14px; }

.sp-form-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 86px;
}

.sp-panel {
  background: rgba(255,255,255,.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sp-panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.sp-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-label-hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.sp-required { color: var(--red); }

.sp-input {
  width: 100%;
  background: rgba(255,255,255,.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font);
  transition: border-color .15s, background .15s;
  outline: none;
}

.sp-input:focus {
  border-color: var(--dark);
  background: rgba(255,255,255,.8);
}

.sp-input::placeholder { color: var(--muted); }

.sp-textarea-code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  resize: vertical;
}

.sp-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.sp-input-prefix {
  display: flex;
  align-items: stretch;
  background: rgba(255,255,255,.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .15s;
}
.sp-input-prefix:focus-within { border-color: var(--dark); }

.sp-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: rgba(28,28,28,.06);
  color: var(--muted);
  font-size: 13px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.sp-input-prefix .sp-input { border: none; background: transparent; border-radius: 0; }
.sp-input-prefix .sp-input:focus { background: transparent; }

.sp-color-picker {
  width: 42px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.6);
  cursor: pointer;
}

.sp-form-actions { display: flex; flex-direction: column; gap: 8px; }

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

.sp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,28,28,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
}

.sp-modal {
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0,0,0,.15);
}

.sp-modal-title { font-size: 16px; font-weight: 800; margin-bottom: 10px; letter-spacing: -.02em; }
.sp-modal-body { font-size: 13.5px; color: var(--muted); margin-bottom: 24px; line-height: 1.6; }
.sp-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── LOGIN ───────────────────────────────────────────────── */

.sp-login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.sp-login-card {
  width: 100%;
  max-width: 360px;
  background: var(--dark);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
}

.sp-login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
  width: 100%;
}

.sp-login-logo {
  width: 200px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.sp-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sp-login-form .sp-label { color: rgba(235,235,235,.6); }

.sp-login-form .sp-input {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.1);
  color: var(--text-inv);
}

.sp-login-form .sp-input:focus {
  border-color: rgba(255,255,255,.3);
  background: rgba(255,255,255,.1);
}

.sp-login-form .sp-input::placeholder { color: rgba(235,235,235,.25); }

.sp-login-submit {
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-text);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  margin-top: 4px;
  transition: filter .15s;
}
.sp-login-submit:hover { filter: brightness(0.85); }

.sp-login-alert {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.25);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 4px;
}

/* ── FIELD TYPE BADGES ───────────────────────────────────── */

.sp-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  background: rgba(28,28,28,.07);
  color: var(--muted);
  border: 1px solid var(--border);
}

.sp-type-badge--text     { background: rgba(59,130,246,.08);  color: #2563eb; border-color: rgba(59,130,246,.2); }
.sp-type-badge--textarea { background: rgba(99,102,241,.08);  color: #4338ca; border-color: rgba(99,102,241,.2); }
.sp-type-badge--richtext { background: rgba(139,92,246,.08);  color: #7c3aed; border-color: rgba(139,92,246,.2); }
.sp-type-badge--image    { background: rgba(236,72,153,.08);  color: #be185d; border-color: rgba(236,72,153,.2); }
.sp-type-badge--file     { background: rgba(245,158,11,.08);  color: #b45309; border-color: rgba(245,158,11,.2); }
.sp-type-badge--url      { background: rgba(20,184,166,.08);  color: #0f766e; border-color: rgba(20,184,166,.2); }
.sp-type-badge--email    { background: rgba(34,197,94,.08);   color: #15803d; border-color: rgba(34,197,94,.2);  }
.sp-type-badge--number   { background: rgba(249,115,22,.08);  color: #c2410c; border-color: rgba(249,115,22,.2); }
.sp-type-badge--date     { background: rgba(14,165,233,.08);  color: #0369a1; border-color: rgba(14,165,233,.2); }
.sp-type-badge--select   { background: rgba(168,85,247,.08);  color: #7e22ce; border-color: rgba(168,85,247,.2); }
.sp-type-badge--checkbox { background: rgba(28,28,28,.06);    color: var(--muted); }

/* ── CHECKBOX WRAP ───────────────────────────────────────── */

.sp-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.sp-checkbox-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--dark);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── REORDER BUTTONS ─────────────────────────────────────── */

.sp-reorder-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(255,255,255,.5);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.sp-reorder-btn:hover {
  background: var(--dark);
  color: var(--text-inv);
  border-color: var(--dark);
}

/* ── FILE INPUTS ─────────────────────────────────────────── */

.sp-input-file {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.4);
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color .15s;
}

.sp-input-file:hover { border-color: rgba(28,28,28,.25); }

/* ── IMAGE PREVIEW ───────────────────────────────────────── */

.sp-image-preview-wrap {
  position: relative;
  display: inline-block;
  margin-top: 6px;
}

.sp-image-clear-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity .15s;
}
.sp-image-preview-wrap:hover .sp-image-clear-btn { opacity: 1; }

.sp-image-preview {
  max-width: 240px;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.sp-image-preview-label {
  font-size: 11.5px;
  color: var(--muted);
}

/* ── FILE LINK ───────────────────────────────────────────── */

.sp-file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  background: rgba(255,255,255,.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  transition: color .15s;
}

.sp-file-link:hover { color: var(--text); }

/* ── RICHTEXT EDITOR (Quill) ─────────────────────────────── */

.sp-richtext-editor {
  background: rgba(255,255,255,.6);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  min-height: 200px;
  font-size: 14px;
}

.ql-toolbar {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
  background: rgba(255,255,255,.5) !important;
}

.ql-container {
  border: 1px solid var(--border) !important;
  border-top: none !important;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
  font-family: var(--font) !important;
}

/* ── TYPE LIST (field-form sidebar) ─────────────────────── */

.sp-type-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sp-type-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ── MEDIA LIBRARY ───────────────────────────────────────── */

.sp-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.sp-media-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sp-media-thumb {
  aspect-ratio: 4/3;
  background: rgba(28,28,28,.06);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sp-media-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.sp-media-ext {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
}

.sp-media-info {
  padding: 8px 10px 4px;
  flex: 1;
}

.sp-media-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-media-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.sp-media-actions {
  padding: 8px 10px;
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  align-items: stretch;
}

.sp-media-actions .sp-btn { align-self: stretch; }

/* ── RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 780px) {
  .sp-hub-cards { grid-template-columns: repeat(2, 1fr); }
  .sp-form-layout { grid-template-columns: 1fr; }
  .sp-form-side { position: static; }
  .sp-inner { padding: 84px 16px 60px; }
  .sp-floatnav { left: 16px; right: 16px; transform: none; overflow-x: auto; justify-content: flex-start; }
  .sp-floatnav-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .sp-toolbar { align-items: stretch; flex-direction: column; }
  .sp-filter-tabs { overflow-x: auto; }
  .sp-table-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .sp-hub { gap: 28px; }
  .sp-hub-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* ── REPEATER ────────────────────────────────────────────── */

.sp-repeater { display: flex; flex-direction: column; gap: 8px; }

.sp-repeater-rows { display: flex; flex-direction: column; gap: 6px; }

.sp-repeater-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 10px 10px 12px;
}

.sp-repeater-remove {
  align-self: stretch;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  flex-shrink: 0;
}

.sp-repeater-cells {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 10px;
}

.sp-repeater-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 140px;
}

.sp-label--sm {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.sp-type-badge--repeater { background: rgba(16,185,129,.08); color: #059669; border-color: rgba(16,185,129,.2); }
.sp-type-badge--color    { background: rgba(139,92,246,.08); color: #7c3aed; border-color: rgba(139,92,246,.2); }
.sp-type-badge--gallery  { background: rgba(236,72,153,.08);  color: #db2777; border-color: rgba(236,72,153,.2); }

.sp-color-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sp-input-color {
  width: 44px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.sp-color-value {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}

.sp-color-hex-input {
  width: 82px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}
.sp-color-hex-input:focus { border-color: var(--primary); }

/* Sub-fields editor (field-form.ejs) */
.sp-subfield-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sp-subfield-row:last-child { border-bottom: none; }

.sp-subfield-cell { display: flex; flex-direction: column; gap: 3px; }

.sp-subfield-remove {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  flex-shrink: 0;
}

/* ── MEDIA PICKER ─────────────────────────────────────────── */

.sp-media-picker-wrap { display: flex; flex-direction: column; gap: 10px; }

/* ── GALLERY FIELD ────────────────────────────────────────── */

.sp-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.sp-gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: grab;
  transition: opacity .15s;
}

.sp-gallery-item--dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.sp-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sp-gallery-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity .15s;
}

.sp-gallery-item:hover .sp-gallery-remove { opacity: 1; }

/* ── REPEATER IMAGE SUB-FIELD ─────────────────────────────── */

.sp-subfield-img-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 90px;
}

.sp-subfield-img-preview-wrap {
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  aspect-ratio: 1;
  width: 100%;
  max-width: 90px;
}

.sp-subfield-img-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sp-media-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-media-modal {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  width: min(900px, 95vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.sp-media-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sp-media-modal-title { font-size: 14px; font-weight: 600; }

.sp-media-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.sp-media-close:hover { color: var(--text); background: var(--bg); }

.sp-media-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  flex-shrink: 0;
}

.sp-media-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  margin-bottom: -1px;
  font-family: var(--font);
}
.sp-media-tab:hover { color: var(--text); }
.sp-media-tab--active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

.sp-media-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}

.sp-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.sp-media-item {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: border-color .15s;
  font-family: var(--font);
  position: relative;
}
.sp-media-item:hover { border-color: var(--primary); }
.sp-media-item.selected { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 1px; }
.sp-media-item.selected::after {
  content: '';
  position: absolute;
  top: 6px; left: 6px;
  width: 18px; height: 18px;
  background: var(--primary);
  border-radius: 50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20,6 9,17 4,12'/%3E%3C/svg%3E");
  background-size: 11px;
  background-repeat: no-repeat;
  background-position: center;
}

.sp-picker-item-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .15s;
}
.sp-media-item:hover .sp-picker-item-actions { opacity: 1; }

.sp-picker-item-btn {
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.sp-picker-item-btn:hover { background: rgba(0,0,0,.9); }
.sp-picker-item-btn--danger { background: rgba(220,38,38,.8); }
.sp-picker-item-btn--danger:hover { background: rgb(220,38,38); }

.sp-picker-rename-input {
  font-size: 10px;
  padding: 2px 4px;
  border: 1px solid var(--primary);
  border-radius: 3px;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.sp-media-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.sp-media-item-name {
  font-size: 10px;
  color: var(--muted);
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.sp-media-loading, .sp-media-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 48px;
}

.sp-media-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, color .15s;
  user-select: none;
}
.sp-media-dropzone:hover { border-color: var(--primary); color: var(--text); }
.sp-media-dropzone.dragover { border-color: var(--primary); background: rgba(34,197,94,.05); color: var(--text); }

.sp-media-footer {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
  flex-shrink: 0;
}

.sp-media-clear {
  background: none;
  border: none;
  color: var(--red);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
  text-decoration: underline;
}

/* ── Menu editor ─────────────────────────────────────────── */
.sp-menu-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sp-menu-item-row:last-child { border-bottom: none; }
.sp-menu-item-row--dragging { opacity: .4; }

.sp-menu-drag-handle {
  display: flex;
  align-items: center;
  color: var(--muted);
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
}
.sp-menu-drag-handle:active { cursor: grabbing; }

.sp-menu-label-input { flex: 1; min-width: 0; }
.sp-menu-url-input   { flex: 1.4; min-width: 0; }
.sp-menu-newab       { flex-shrink: 0; }

.sp-code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
  margin: 0;
  line-height: 1.6;
}

.sp-btn--danger-ghost {
  background: none;
  border: 1px solid transparent;
  color: var(--red);
}
.sp-btn--danger-ghost:hover {
  border-color: var(--red);
  background: rgba(239,68,68,.06);
}

/* ── Visual editor ───────────────────────────────────────── */
.sp-visual-wrap {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.sp-visual-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  z-index: 10;
}

.sp-visual-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sp-visual-sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-visual-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sp-visual-hint {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  padding: 32px 16px;
  line-height: 1.6;
}

.sp-visual-prop-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 5px;
}

.sp-visual-prop-group {
  margin-bottom: 14px;
}

.sp-visual-tag-badge {
  display: inline-block;
  font-size: 11px;
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--muted);
  margin-bottom: 12px;
}

.sp-visual-frame-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.sp-visual-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.sp-visual-saving {
  display: none;
  font-size: 12px;
  color: var(--muted);
}
