:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; border: none;
  transition: all 0.2s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #059669; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-pad { padding: 24px; }

/* Nav */
.nav {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 700;
}
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: bold;
}
.nav-links { display: flex; align-items: center; gap: 12px; }
.nav-links a { font-size: 14px; color: var(--text-muted); }
.nav-links a:hover { color: var(--primary); }
.nav-links a.active { color: var(--primary); font-weight: 500; }
.row { display: flex; align-items: center; gap: 10px; }

/* Hero / Banner Carousel */
.carousel {
  position: relative; height: 480px; overflow: hidden;
  border-radius: var(--radius); margin: 24px 0;
}
.carousel-slides { display: flex; transition: transform 0.5s ease; height: 100%; }
.carousel-slide {
  min-width: 100%; height: 100%;
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.carousel-slide::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.7), rgba(16,185,129,0.6));
}
.carousel-content {
  position: relative; z-index: 1; text-align: center; color: white; max-width: 700px;
  padding: 40px;
}
.carousel-content h1 { font-size: 48px; font-weight: 800; margin-bottom: 16px; }
.carousel-content p { font-size: 20px; margin-bottom: 24px; opacity: 0.9; }
.carousel-dots {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.carousel-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.5); cursor: pointer;
  transition: all 0.3s;
}
.carousel-dot.active { background: white; width: 28px; border-radius: 5px; }
.carousel-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.2); border: none;
  color: white; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.carousel-arrow:hover { background: rgba(255,255,255,0.3); }
.carousel-arrow.prev { left: 20px; }
.carousel-arrow.next { right: 20px; }

/* Section */
.section { padding: 48px 0; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.section-title h2 { font-size: 28px; font-weight: 700; }
.section-title p { color: var(--text-muted); margin-top: 4px; }

/* Template Grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}
.template-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s;
  cursor: pointer;
}
.template-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}
.template-preview {
  height: 200px;
  background-size: cover;
  background-position: top center;
  background-color: #f1f5f9;
  position: relative;
}
.template-badge {
  position: absolute; top: 12px; left: 12px;
  background: rgba(99,102,241,0.9);
  color: white; padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.template-info { padding: 16px; }
.template-info h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.template-info p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.template-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-muted);
}
.template-meta span { display: flex; align-items: center; gap: 4px; }

/* Category tabs */
.category-tabs {
  display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap;
}
.cat-tab {
  padding: 8px 18px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.cat-tab:hover { border-color: var(--primary); color: var(--primary); }
.cat-tab.active {
  background: var(--primary); color: white; border-color: var(--primary);
}

/* Search bar */
.search-bar {
  position: relative; max-width: 500px; margin: 0 auto 32px;
}
.search-bar input {
  width: 100%; padding: 14px 20px 14px 48px;
  border: 1px solid var(--border); border-radius: 50px;
  font-size: 15px; background: var(--surface);
  transition: all 0.2s;
}
.search-bar input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.search-bar::before {
  content: '🔍'; position: absolute; left: 18px; top: 50%;
  transform: translateY(-50%); font-size: 16px;
}

/* Dashboard */
.dashboard { padding: 32px 0; }
.dash-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.dash-header h1 { font-size: 28px; font-weight: 700; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--surface); padding: 20px;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .sub { font-size: 12px; color: var(--secondary); margin-top: 4px; }

.sites-list { display: flex; flex-direction: column; gap: 12px; }
.site-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  transition: all 0.2s;
}
.site-item:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.site-item .left { display: flex; align-items: center; gap: 14px; }
.site-thumb {
  width: 56px; height: 56px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: bold; font-size: 20px;
}
.site-item h3 { font-size: 16px; font-weight: 600; }
.site-item .meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.status-badge {
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 500;
}
.status-badge.published { background: #dcfce7; color: #166534; }
.status-badge.draft { background: #fef3c7; color: #92400e; }

/* Editor */
.editor-layout {
  display: flex; height: calc(100vh - 64px);
}
.editor-sidebar {
  width: 280px; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.sidebar-tab {
  flex: 1; padding: 12px; text-align: center;
  font-size: 13px; cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.sidebar-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.sidebar-content { flex: 1; overflow-y: auto; padding: 16px; }
.block-palette { display: flex; flex-direction: column; gap: 8px; }
.block-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s;
}
.block-item:hover {
  border-color: var(--primary); background: #f5f3ff;
}
.block-item .icon { font-size: 24px; }
.block-item .name { font-size: 14px; font-weight: 500; }
.block-item .desc { font-size: 12px; color: var(--text-muted); }

.editor-canvas {
  flex: 1; overflow-y: auto; background: #f1f5f9;
  padding: 24px;
}
.canvas-frame {
  max-width: 1100px; margin: 0 auto;
  background: white; min-height: 100%;
  box-shadow: var(--shadow-lg); border-radius: var(--radius);
  overflow: hidden;
}

.block-wrapper {
  position: relative; transition: all 0.2s;
}
.block-wrapper:hover { outline: 2px solid var(--primary-light); }
.block-wrapper.selected { outline: 2px solid var(--primary); }
.block-toolbar {
  position: absolute; top: -32px; right: 0;
  display: none; gap: 4px;
  background: var(--primary); padding: 4px;
  border-radius: var(--radius-sm);
}
.block-wrapper:hover .block-toolbar,
.block-wrapper.selected .block-toolbar { display: flex; }
.block-toolbar button {
  width: 24px; height: 24px; border: none;
  background: rgba(255,255,255,0.2); color: white;
  border-radius: 4px; font-size: 12px; cursor: pointer;
}
.block-toolbar button:hover { background: rgba(255,255,255,0.3); }

/* Property panel */
.property-panel {
  width: 300px; background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.prop-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
}
.prop-body { padding: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 6px; color: var(--text);
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; transition: all 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.color-input {
  display: flex; align-items: center; gap: 8px;
}
.color-input input[type="color"] {
  width: 40px; height: 36px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
}
.color-input input[type="text"] { flex: 1; }

/* Block types */
.block-hero {
  padding: 80px 40px; text-align: center;
  background: linear-gradient(135deg, #6366f1, #10b981);
  color: white;
}
.block-hero h1 { font-size: 48px; font-weight: 800; margin-bottom: 16px; }
.block-hero p { font-size: 20px; margin-bottom: 24px; opacity: 0.9; }
.block-hero img {
  max-width: 500px; margin: 24px auto 0;
  border-radius: var(--radius);
}

.block-features { padding: 60px 40px; text-align: center; }
.block-features h2 { font-size: 32px; margin-bottom: 8px; }
.block-features .subtitle { color: var(--text-muted); margin-bottom: 40px; }
.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}
.feature-item { padding: 24px; }
.feature-item .icon { font-size: 48px; margin-bottom: 16px; }
.feature-item h3 { font-size: 18px; margin-bottom: 8px; }
.feature-item p { color: var(--text-muted); font-size: 14px; }

.block-gallery { padding: 60px 40px; text-align: center; }
.block-gallery h2 { font-size: 32px; margin-bottom: 32px; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}
.gallery-item {
  aspect-ratio: 4/3;
  background-size: cover; background-position: center;
  border-radius: var(--radius-sm);
  transition: transform 0.3s;
}
.gallery-item:hover { transform: scale(1.03); }

.block-cta {
  padding: 60px 40px; text-align: center;
  background: #10b981; color: white;
}
.block-cta h2 { font-size: 32px; margin-bottom: 8px; }
.block-cta p { font-size: 18px; margin-bottom: 24px; opacity: 0.9; }

.block-text { padding: 60px 40px; }
.block-text h2 { font-size: 32px; margin-bottom: 16px; }
.block-text.center { text-align: center; }
.block-text.left { text-align: left; }
.block-text.right { text-align: right; }
.block-text p { color: var(--text-muted); font-size: 16px; line-height: 1.8; }

.block-video { padding: 60px 40px; text-align: center; }
.block-video h2 { font-size: 32px; margin-bottom: 24px; }
.video-wrapper {
  position: relative; max-width: 800px; margin: 0 auto;
  aspect-ratio: 16/9; background: #000;
  border-radius: var(--radius); overflow: hidden;
}
.video-wrapper iframe { width: 100%; height: 100%; border: none; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  max-width: 420px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.auth-tabs {
  display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.auth-tabs button {
  flex: 1; padding: 12px; background: none; border: none;
  font-size: 15px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.auth-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.muted { color: var(--text-muted); font-size: 13px; }

/* Toast */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  background: var(--text); color: white;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  font-size: 14px;
}
.toast.success { background: var(--secondary); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Admin */
.admin-layout { padding: 32px 0; }
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: var(--surface); padding: 4px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  width: fit-content;
}
.admin-tab {
  padding: 8px 18px; border-radius: 6px;
  font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.admin-tab:hover { background: var(--bg); }
.admin-tab.active { background: var(--primary); color: white; }

.data-table {
  width: 100%; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border);
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table th { background: var(--bg); font-weight: 600; font-size: 13px; color: var(--text-muted); }
.data-table tr:last-child td { border-bottom: none; }

/* View / Public site */
.public-nav {
  position: fixed; top: 0; left: 0; right: 0; height: 64px;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 50;
}
.public-nav .logo-text { font-size: 18px; font-weight: 700; }
.public-nav-links { display: flex; gap: 24px; }
.public-nav-links a { font-size: 14px; color: var(--text-muted); }
.public-nav-links a:hover { color: var(--primary); }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* Upload */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 40px;
  text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover { border-color: var(--primary); background: #f5f3ff; }
.upload-area .icon { font-size: 48px; margin-bottom: 12px; }

.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px; margin-top: 16px;
}
.media-item {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  background-size: cover; background-position: center;
  border: 2px solid transparent; cursor: pointer;
  position: relative; overflow: hidden;
  transition: all 0.2s;
}
.media-item:hover { border-color: var(--primary); }
.media-item.selected { border-color: var(--primary); }

/* Chart */
.chart-container {
  background: var(--surface); padding: 24px;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.chart-bar {
  display: flex; align-items: flex-end; gap: 8px;
  height: 180px; margin-top: 16px;
}
.chart-bar-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.chart-bar-fill {
  width: 100%; background: linear-gradient(to top, var(--primary), var(--primary-light));
  border-radius: 4px 4px 0 0; transition: height 0.5s;
  min-height: 2px;
}
.chart-bar-label { font-size: 11px; color: var(--text-muted); }
.chart-bar-value { font-size: 12px; font-weight: 600; color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .carousel { height: 360px; margin: 16px 0; }
  .carousel-content h1 { font-size: 28px; }
  .carousel-content p { font-size: 16px; }
  .section { padding: 32px 0; }
  .section-title h2 { font-size: 22px; }
  .template-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .template-preview { height: 140px; }
  .editor-layout { flex-direction: column; }
  .editor-sidebar, .property-panel { width: 100%; height: auto; max-height: 40vh; }
}
