/* ─── Design Tokens ─── */
:root {
  /* Blue premium palette */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-900: #1e3a5f;

  /* Surfaces */
  --bg: #f0f4fa;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-hover: #f1f5f9;
  --border: rgba(59, 130, 246, 0.15);
  --border-focus: rgba(59, 130, 246, 0.45);

  /* Text */
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Misc */
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
  --transition: 150ms ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Ambient Glow ─── */
.ambient-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 500px;
  background: radial-gradient(ellipse, rgba(59, 130, 246, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── App Shell ─── */
.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.logo-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--blue-400);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.15);
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.header-link:hover { color: var(--text); }

/* ─── Subtitle ─── */
.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-weight: 400;
}

/* ─── Workspace ─── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

/* ─── Panel ─── */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(59, 130, 246, 0.04);
  overflow: hidden;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.panel-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
}
.stat-sep {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 10px;
}

/* ─── Textarea ─── */
textarea {
  flex: 1;
  width: 100%;
  padding: 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  resize: none;
  outline: none;
}
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

/* ─── Preview ─── */
.preview-area {
  flex: 1;
  padding: 8px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  min-height: 380px;
}
.preview-area canvas {
  display: none;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
.preview-area canvas.visible {
  display: block;
}
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  opacity: 0.5;
}
.empty-state p {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.empty-state kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  gap: 16px;
}
.toolbar-settings {
  display: flex;
  align-items: center;
  gap: 14px;
}
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.setting {
  display: flex;
  align-items: center;
  gap: 6px;
}
.setting label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.setting input[type="number"] {
  width: 58px;
  padding: 4px 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
  text-align: center;
  transition: border-color var(--transition);
}
.setting input:focus {
  outline: none;
  border-color: var(--border-focus);
}
.divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ─── Stepper ─── */
.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px;
}
.stepper-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition);
}
.stepper-btn:hover {
  background: var(--blue-600);
  color: #fff;
}
.stepper-val {
  min-width: 22px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

/* ─── Toggle Group ─── */
.toggle-group {
  display: flex;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.toggle-btn:hover {
  color: var(--text-secondary);
}
.toggle-btn.active {
  background: var(--blue-600);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--border-focus);
  color: var(--text);
  background: rgba(59, 130, 246, 0.05);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 10px;
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(59, 130, 246, 0.06);
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--text);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ─── Footer ─── */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding: 12px 0;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}
.footer svg {
  flex-shrink: 0;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .app { padding: 16px; }
  .workspace { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar-settings { flex-wrap: wrap; }
  .toolbar-actions { justify-content: flex-end; }
  .header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
