:root {
  --bg: #f5f6f8;
  --bg-grad: linear-gradient(rgba(0,0,0,0.2), rgba(0,0,0,0.2)),
              url("/bg2.jpg") center center/cover no-repeat fixed;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --panel-3: #f3f4f6;
  --border: rgba(15,23,42,0.08);
  --border-strong: rgba(15,23,42,0.16);
  --text: #0f172a;
  --text-2: #1f2937;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #6366f1;
  --accent-2: #ec4899;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --good: #10b981;
  --bad: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow: 0 4px 16px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg: 0 12px 40px rgba(15,23,42,0.1), 0 4px 12px rgba(15,23,42,0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-grad);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; }

.page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px 80px;
}

.container {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ============ HERO ============ */
.hero { display: flex; flex-direction: column; gap: 24px; }

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 40px; height: 40px;
  background: var(--accent-grad);
  border-radius: 11px;
  position: relative;
  box-shadow: 0 8px 24px rgba(99,102,241,0.3);
}
.brand-mark::after {
  content: "F";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-weight: 800; color: white; font-size: 20px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; color: #fff; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,0.75); letter-spacing: 0.05em; text-transform: uppercase; font-weight: 600; }

.status {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; color: var(--muted); font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.status-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
.status-dot.connected { background: var(--good); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.status-dot.error { background: var(--bad); box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }
.status-sep { color: var(--muted-2); }
.project-name { color: var(--text-2); font-weight: 600; }

.user-bar {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  color: var(--muted);
  backdrop-filter: blur(12px);
}
.user-email { color: var(--text-2); font-weight: 600; }

.site-tabs {
  display: inline-flex;
  margin: 4px auto 0;
  padding: 5px;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  gap: 4px;
  backdrop-filter: blur(8px);
  align-self: center;
}
.site-tab {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.site-tab:hover { color: var(--text-2); }
.site-tab.active {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.hero-content { text-align: center; padding: 8px 0 4px; }
.hero h1 {
  margin: 0; font-size: 38px; font-weight: 800; letter-spacing: -0.03em;
  color: #ffffff;
}
.hero-sub { margin: 8px 0 0; color: rgba(255,255,255,0.85); font-size: 15px; }
.hero-sub strong { color: #fff; font-weight: 600; }

/* ============ FORM ============ */
.form { display: flex; flex-direction: column; gap: 16px; }
#fields-container { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }

.card-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.card-title {
  margin: 0; font-size: 12px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.card-sub { margin: 4px 0 0; color: var(--muted-2); font-size: 12px; }

.section-card .card-head .card-title {
  font-size: 13px; letter-spacing: 0.08em;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 700;
}

.slug-card .card-title { color: var(--text); font-size: 14px; letter-spacing: 0; text-transform: none; font-weight: 700; }

.card-body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 16px; }

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

/* ============ INPUTS ============ */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: 4px;
}
.req { color: var(--bad); }
.field-type-tag {
  margin-left: auto;
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  background: var(--panel-3); color: var(--muted);
  letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600;
}

.input, .textarea, select.input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}
.input:hover, .textarea:hover, select.input:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, select.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}
.textarea { min-height: 90px; resize: vertical; font-family: inherit; }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2364748b' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px;
}
.input::placeholder { color: var(--muted-2); }

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

/* ============ BOOLEAN SWITCH ============ */
.bool-switch {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.bool-switch:hover { border-color: var(--border-strong); background: var(--panel-3); }
.bool-switch input { display: none; }
.bool-switch .toggle {
  width: 36px; height: 20px; background: rgba(15,23,42,0.15);
  border-radius: 999px; position: relative;
  transition: background 0.2s;
}
.bool-switch .toggle::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 999px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(15,23,42,0.2);
}
.bool-switch input:checked ~ .toggle { background: var(--accent); }
.bool-switch input:checked ~ .toggle::after { transform: translateX(16px); }
.bool-switch span:first-child { color: var(--text-2); font-weight: 500; }

/* ============ CHECKBOX LIST ============ */
.multi-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  max-height: 200px; overflow-y: auto;
}
.multi-select-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 13px;
}
.multi-select-item:hover { background: var(--panel); }
.multi-select-item input { accent-color: var(--accent); }
.multi-select-item .ms-slug { color: var(--muted-2); font-size: 11px; }

/* ============ IMAGE UPLOAD ============ */
.image-uploader {
  background: var(--panel-2);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  overflow: hidden;
}
.image-uploader:hover { border-color: var(--accent); background: rgba(99,102,241,0.04); }
.image-uploader.has-image { padding: 6px; border-style: solid; border-color: var(--border); align-items: flex-start; }
.image-uploader input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.image-uploader-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13px;
  padding: 18px 0;
}
.image-uploader-empty svg { width: 28px; height: 28px; opacity: 0.7; }
.image-uploader-empty .label { font-weight: 500; color: var(--text-2); }
.image-uploader-empty .hint { font-size: 11px; }
.image-uploader-preview {
  width: 120px; height: 80px;
  background: var(--panel-3);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.image-uploader-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-uploader-status {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(15,23,42,0.85); color: white;
  padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 500;
  display: flex; align-items: center; gap: 5px;
  backdrop-filter: blur(8px);
}
.image-uploader-status.uploading { background: rgba(99,102,241,0.95); }
.image-uploader-status.success { background: rgba(16,185,129,0.95); }
.image-uploader-status.error { background: rgba(239,68,68,0.95); }
.spinner {
  width: 10px; height: 10px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ RICH TEXT EDITOR ============ */
.rte {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99,102,241,0.12); }
.rte-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 6px 8px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.rte-btn {
  background: transparent; border: none; color: var(--muted);
  width: 30px; height: 28px;
  border-radius: 5px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.rte-btn:hover { background: var(--panel-3); color: var(--text); }
.rte-btn.active { background: var(--accent); color: white; }
.rte-btn select {
  background: transparent; border: none; color: inherit; font: inherit;
  outline: none; cursor: pointer; padding: 0 4px;
}
.rte-btn select option { background: var(--panel); color: var(--text); }
.rte-divider { width: 1px; height: 18px; background: var(--border); margin: 0 4px; align-self: center; }
.rte-content {
  min-height: 160px;
  padding: 14px 16px;
  font-size: 14px; line-height: 1.65;
  outline: none;
  color: var(--text);
}
.rte-content:empty::before {
  content: attr(data-placeholder);
  color: var(--muted-2);
  pointer-events: none;
}
.rte-content h1, .rte-content h2, .rte-content h3, .rte-content h4 {
  margin: 0.8em 0 0.4em; font-weight: 700; line-height: 1.25;
}
.rte-content h1 { font-size: 1.6em; }
.rte-content h2 { font-size: 1.35em; }
.rte-content h3 { font-size: 1.15em; }
.rte-content h4 { font-size: 1em; }
.rte-content p { margin: 0 0 0.7em; }
.rte-content p:last-child { margin-bottom: 0; }
.rte-content ul, .rte-content ol { padding-left: 1.8em !important; margin: 0 0 0.7em; }
.rte-content ul { list-style: disc inside !important; }
.rte-content ol { list-style: decimal inside !important; }
.rte-content li { margin-bottom: 0.25em; display: list-item !important; }
.rte-content li::marker { color: var(--text-2); }
.rte-content li > p, .rte-content li > div {
  display: inline; margin: 0; padding: 0;
}
.rte-content li > p:not(:first-child)::before, .rte-content li > div:not(:first-child)::before {
  content: " ";
}
.rte-content a { color: var(--accent); text-decoration: underline; }
.rte-content strong { font-weight: 700; }
.rte-content em { font-style: italic; }
.rte-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px; margin: 0.6em 0;
  color: var(--muted);
}
.rte-content code {
  background: var(--panel-3);
  padding: 1px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.9em;
}

/* ============ SECTION HEADERS (DIVIDERS) ============ */
.section-card { padding: 0; }
.section-card .card-body { padding: 18px 22px 22px; }
.section-card .card-head .badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.25);
  border-radius: 999px; font-size: 10px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase;
}

/* ============ ACTION BAR ============ */
.action-bar {
  position: sticky; bottom: 16px;
  margin-top: 8px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}
.action-bar-right { display: flex; gap: 10px; align-items: center; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 6px 18px rgba(99,102,241,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn.primary:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(99,102,241,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn.ghost {
  background: var(--panel);
  color: var(--text-2);
  border-color: var(--border);
}
.btn.ghost:hover { background: var(--panel-2); border-color: var(--border-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-arrow { font-size: 14px; }

/* ============ DRAFT SWITCH ============ */
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  user-select: none;
}
.switch:hover { background: var(--panel-3); }
.switch input { display: none; }
.switch-track {
  width: 32px; height: 18px;
  background: rgba(15,23,42,0.15);
  border-radius: 999px; position: relative;
  transition: background 0.2s;
}
.switch-track::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 999px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(15,23,42,0.2);
}
.switch input:checked ~ .switch-track { background: var(--warn); }
.switch input:checked ~ .switch-track::after { transform: translateX(14px); }
.switch-label { color: var(--muted); }
.switch input:checked ~ .switch-label { color: var(--text-2); }

/* ============ TOAST ============ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  color: var(--text);
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: slideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.toast.good { border-color: rgba(16,185,129,0.35); }
.toast.good::before { background: var(--good); box-shadow: 0 0 8px var(--good); }
.toast.bad { border-color: rgba(239,68,68,0.35); }
.toast.bad::before { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ LOADING ============ */
.loading {
  display: flex; align-items: center; gap: 10px;
  padding: 28px;
  color: var(--muted);
  font-size: 13px;
  justify-content: center;
}
.loading .spinner { width: 14px; height: 14px; border-color: var(--border-strong); border-top-color: var(--accent); }

@media (max-width: 720px) {
  .page { padding: 24px 14px 60px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
  .brand { flex-wrap: wrap; }
  .status { margin-left: 0; }
  .action-bar { flex-direction: column; gap: 10px; align-items: stretch; }
  .action-bar-right { justify-content: flex-end; }
}
