@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --bg:          #0D1117;
  --surface:     #161B22;
  --surface-2:   #21262D;
  --surface-3:   #2D333B;
  --border:      #30363D;
  --border-hi:   #484F58;
  --text:        #E6EDF3;
  --text-2:      #8B949E;
  --text-3:      #6E7681;
  --accent:      #E8003D;
  --accent-dim:  rgba(232,0,61,0.15);
  --accent-glow: rgba(232,0,61,0.3);
  --blue:        #1E5EFF;
  --green:       #3FB950;
  --r:           8px;
  --r-sm:        4px;
  --r-lg:        14px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
  z-index: 100;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.topbar-right { justify-content: flex-end; }

.topbar-center {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  user-select: none;
}

.logo-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), #FF3399);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.logo strong { color: var(--accent); }

/* Format toggle */
.format-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 3px;
  gap: 2px;
}

.format-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
  letter-spacing: 0.2px;
}

.format-btn.active {
  background: var(--accent);
  color: white;
}

.format-btn:not(.active):hover {
  background: var(--surface-3);
  color: var(--text);
}

/* Top bar buttons */
.btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hi);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--r);
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: #c8002e;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary:disabled, .btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

/* ============================================================
   WORKSPACE
   ============================================================ */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================================
   EDITOR PANEL (LEFT)
   ============================================================ */
.editor-panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.editor-panel::-webkit-scrollbar { width: 4px; }
.editor-panel::-webkit-scrollbar-track { background: transparent; }
.editor-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Accordion Sections */
.editor-section {
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  min-height: 44px;
}

.section-header:hover:not(.no-toggle) { background: var(--surface-2); }
.section-header.no-toggle { cursor: default; }

.section-hd-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.s-icon { font-size: 14px; }

.s-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text);
}

.s-chevron {
  color: var(--text-3);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.s-chevron.open { transform: rotate(180deg); }

.section-body {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
}

.section-body.open { display: flex; }

/* Add slide button */
.btn-icon-add {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-icon-add:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ============================================================
   DESIGN SYSTEM CONTROLS
   ============================================================ */
.field-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-2);
}

.field-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  cursor: pointer;
}

.field-select:hover { border-color: var(--border-hi); }
.field-select:focus { border-color: var(--accent); }

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

.color-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.color-item input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  padding: 2px;
  transition: border-color 0.15s;
}

.color-item input[type="color"]:hover { border-color: var(--border-hi); }

.color-item span {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
  text-align: center;
}

/* ============================================================
   SLIDE LIST
   ============================================================ */
.slide-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  gap: 8px;
}

.slide-list-item:hover { background: var(--surface-2); }

.slide-list-item.active {
  background: var(--accent-dim);
  border-color: rgba(232,0,61,0.3);
}

.sli-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.sli-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}

.slide-list-item.active .sli-num {
  background: var(--accent);
  color: white;
}

.sli-icon { font-size: 13px; flex-shrink: 0; }

.sli-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sli-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.slide-list-item:hover .sli-actions,
.slide-list-item.active .sli-actions { opacity: 1; }

.sli-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  line-height: 1;
}

.sli-btn:hover { background: var(--border-hi); color: var(--text); }
.sli-btn.del:hover { background: rgba(232,0,61,0.2); color: #ff6060; }
.sli-btn:disabled { opacity: 0.25; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   SLIDE EDITOR FORM
   ============================================================ */
.editor-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-2);
}

.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.form-input:hover { border-color: var(--border-hi); }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

.form-textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

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

.img-thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--border);
  display: block;
}

.img-placeholder {
  width: 100%;
  height: 56px;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 11px;
  gap: 6px;
}

.img-btn-row { display: flex; gap: 6px; }

.btn-sm {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  transition: all 0.15s;
}

.btn-sm:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-hi); }
.btn-sm.del:hover { background: rgba(232,0,61,0.15); color: #ff6060; }

.color-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.color-row input[type="color"] {
  width: 40px;
  height: 34px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  padding: 2px;
}

.card-block {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-block-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.card-block-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.btn-add-card {
  width: 100%;
  padding: 6px;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-add-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--text-3);
  text-align: center;
}

.empty-state p { font-size: 12px; }

/* ============================================================
   PREVIEW PANEL (RIGHT)
   ============================================================ */
.preview-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

/* Subtle dot grid background */
.preview-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-height: 100%;
  position: relative;
  z-index: 1;
  padding: 20px;
}

/* Toolbar */
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
}

.nav-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.nav-btn:hover { background: var(--accent); }

.slide-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 40px;
  text-align: center;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.btn-export-png {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-export-png:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Preview frame */
.preview-frame {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 20px 60px rgba(0,0,0,0.6);
  flex-shrink: 0;
}

.slide-renderer {
  transform-origin: top left;
  overflow: hidden;
}

/* Pagination dots */
.preview-pagination {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pg-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-hi);
  cursor: pointer;
  transition: all 0.2s;
}

.pg-dot.active {
  background: var(--accent);
  width: 20px;
  border-radius: 3px;
}

.pg-dot:hover:not(.active) { background: var(--text-3); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.15s ease;
}

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

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 520px;
  max-width: 92vw;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

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

.modal-hd h2 { font-size: 16px; font-weight: 700; }

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover { background: rgba(232,0,61,0.15); color: #ff6060; }

.modal-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 20px;
}

/* Slide type picker */
.slide-type-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.slide-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-2);
}

.slide-type-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-2px);
}

.slide-type-card:hover .stc-label { color: var(--accent); }

.stc-thumb {
  width: 46px;
  height: 80px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.stc-thumb.cover { background: linear-gradient(160deg, #0a0a1a 0%, #1a0a2e 100%); }
.stc-thumb.cover::after { content: ''; position: absolute; bottom: 10px; left: 6px; right: 6px; height: 3px; background: #FF3399; border-radius: 2px; }

.stc-thumb.info { background: #F0F4FF; }
.stc-thumb.info::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, #E8003D, #FF3399); }
.stc-thumb.info::after { content: ''; position: absolute; bottom: 10px; left: 6px; right: 6px; height: 12px; background: white; border-radius: 2px; border: 1px solid #D6E0F5; }

.stc-thumb.person { background: #F0F4FF; display: flex; align-items: center; justify-content: center; font-size: 26px; }

.stc-thumb.split { background: linear-gradient(90deg, #E8003D 50%, #1a0a2e 50%); }

.stc-thumb.cta { background: linear-gradient(135deg, #E8003D, #FF3399); display: flex; align-items: center; justify-content: center; font-size: 22px; }

.stc-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  text-align: center;
  transition: color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 9999;
  transition: all 0.25s ease;
  transform: translateY(60px);
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  transform: none;
  opacity: 1;
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--accent); color: #ff6060; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* Slide count picker */
.slide-count-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
  gap: 12px;
}

.slide-count-btn span {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-2);
}

.slide-count-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
}

.slide-count-btn:hover span { color: var(--accent); }

/* Form divider */
.form-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Range slider row */
.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-range {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent-glow);
  transition: box-shadow 0.15s;
}

.form-range::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.form-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.range-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
