:root {
  --ui-bg: #0B0F17;
  --ui-panel: #111827;
  --ui-surface: #182132;
  --ui-border: #263248;
  --ui-text: #F8FAFC;
  --ui-muted: #94A3B8;
  --ui-accent: #F59E0B;
  --ui-accent-hover: #D97706;
  --ui-primary: #3B82F6;
  --ui-green: #10B981;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, textarea, select {
  font-family: inherit;
}

/* Top Navbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ui-border);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #F59E0B 0%, #EF4444 100%);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #111827;
  font-size: 16px;
}

.brand-title {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: #34D399;
  font-size: 12px;
  font-weight: 600;
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mode-switch {
  display: inline-flex;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  padding: 3px;
  border-radius: 10px;
}

.mode-btn {
  background: transparent;
  color: var(--ui-muted);
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--ui-primary);
  color: #fff;
}

.select-input {
  background: var(--ui-surface);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn:hover { background: #222D42; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--ui-primary);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { background: #2563EB; }

.btn-pro {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  border-color: transparent;
  color: #111827;
  font-weight: 700;
}
.btn-pro:hover { filter: brightness(1.06); }

.btn-pro.unlocked {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #fff;
}

/* Main Workspace */
.studio-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.editor-pane {
  background: var(--ui-panel);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 64px);
  overflow: hidden;
}

.editor-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--ui-border);
  background: #0E1420;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ui-muted);
  padding: 12px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--ui-accent);
  background: rgba(245, 158, 11, 0.06);
}

.editor-scroll {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.field-group {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ui-muted);
  margin-bottom: 5px;
}

.field-input, .field-textarea {
  width: 100%;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.field-input:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--ui-primary);
}

.subcard {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.subcard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #E2E8F0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.theme-card {
  border: 2px solid var(--ui-border);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  background: var(--ui-surface);
  text-align: left;
  color: var(--ui-text);
  position: relative;
}

.theme-card.active {
  border-color: var(--ui-accent);
}

.theme-swatch {
  height: 36px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.12);
}

.theme-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  color: #fff;
}

.theme-badge.pro {
  background: #F59E0B;
  color: #111827;
}

/* Preview Stage */
.preview-pane {
  padding: 20px 24px 36px;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 45%), #090D14;
}

.stage-toolbar {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.slide-tabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.slide-pill {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  color: var(--ui-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.slide-pill.active {
  background: var(--ui-accent);
  color: #111827;
  border-color: transparent;
}

/* Live Rendered Bento Surface */
.bento-surface-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.bento-poster {
  width: 100%;
  max-width: 720px;
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  transition: all 0.2s ease;
}

.bento-deck {
  width: 100%;
  max-width: 980px;
  aspect-ratio: 16 / 9;
  border-radius: 22px;
  padding: 32px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.b-card {
  border-radius: 16px;
  padding: 16px;
  border: 1px solid transparent;
}

.b-hero-row {
  display: grid;
  grid-template-columns: 1fr 116px;
  gap: 14px;
  align-items: center;
}

.b-word-box {
  height: 112px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.b-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.b-progress-track {
  height: 6px;
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}
.b-progress-fill {
  height: 100%;
  border-radius: 999px;
}

.b-mid-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.b-bottom-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.b-okr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.b-rhythm-bars {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  align-items: end;
  height: 106px;
  padding-top: 10px;
}

.b-rhythm-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
}

.b-rhythm-fill {
  width: 100%;
  border-radius: 4px;
  min-height: 8px;
}

.b-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.b-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.b-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-top: 14px;
  opacity: 0.75;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  background: #111827;
  border: 1px solid #2D3B55;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 25px 70px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.close-btn {
  background: transparent;
  border: 1px solid var(--ui-border);
  color: var(--ui-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}

.pro-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
}

.pro-list li {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--ui-border);
  padding: 8px 10px;
  border-radius: 10px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  background: #1E293B;
  color: #F8FAFC;
  border: 1px solid #334155;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  display: none;
}
.toast.show { display: block; }

@media (max-width: 1024px) {
  .studio-layout { grid-template-columns: 1fr; }
  .editor-pane, .preview-pane { max-height: none; }
  .b-kpi-grid, .b-mid-grid, .b-bottom-grid, .b-okr-grid { grid-template-columns: 1fr; }
  .bento-deck { aspect-ratio: auto; }
}
