:root {
  /* Surfaces */
  --bg-deep: #0B0F1A;
  --bg-dark: #111726;
  --surface: rgba(23, 30, 48, 0.92);
  --surface-solid: #171E30;
  --surface-raised: #1F2839;
  --surface-hover: rgba(255, 255, 255, 0.07);
  --surface-active: rgba(255, 255, 255, 0.12);

  /* Brand */
  --accent: #6366F1;
  --accent-hover: #4F46E5;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-glow: rgba(99, 102, 241, 0.45);

  /* Text */
  --text-primary: #F1F3F9;
  --text-secondary: #A7B0C4;
  --text-muted: #6B7488;

  /* Lines */
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --canvas-bg: #FFFFFF;
  --danger: #F43F5E;
  --success: #34D399;
  --warning: #FBBF24;

  --toolbar-width: 60px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.48);

  --transition-fast: 140ms cubic-bezier(0.2, 0, 0.2, 1);
  --transition-normal: 240ms cubic-bezier(0.2, 0, 0.2, 1);

  --font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-md: 14px;
}

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

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: var(--font-family);
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app-container {
  display: flex;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
}

#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: var(--canvas-bg);
  /* A soft inner edge separates the board from the dark chrome. */
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.35);
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
  display: block;
}

#text-edit-overlay {
  position: absolute;
  display: none;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font-family);
  z-index: 20;
  outline: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  white-space: pre;
  caret-color: currentColor;
}

/* ---------- Zoom pill ---------- */

.zoom-pill {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  z-index: 60;
}

.pill-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.pill-btn svg { width: 16px; height: 16px; }

.pill-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.zoom-value {
  min-width: 52px;
  height: 30px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.zoom-value:hover { background: var(--surface-hover); }

.pill-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
}

/* ---------- Status indicator ---------- */

.status-indicator {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 7px 14px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  z-index: 60;
  border: 1px solid var(--border);
  transition: color var(--transition-fast);
  user-select: none;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.status-indicator.status-unsaved { color: var(--text-primary); }
.status-indicator.status-unsaved .status-dot {
  background: var(--warning);
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: var(--surface-solid);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  z-index: 300;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

::selection {
  background: var(--accent);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
