/* DrawX — Core Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-sm {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-sm:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-share {
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 5px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-share:hover { background: var(--accent); color: #fff; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
  font-size: 13px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Form Elements */
input[type="text"], input[type="number"], select, textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
  width: 100%;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }

input[type="color"] {
  width: 32px; height: 26px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-tertiary);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--bg-primary);
}

input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* Toggle Switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-slider {
  width: 28px; height: 15px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 11px; height: 11px;
  background: var(--text-muted);
  border-radius: 50%;
  top: 1px; left: 1px;
  transition: all 0.2s;
}
.toggle-label input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-label input:checked + .toggle-slider::after { transform: translateX(13px); background: #fff; }

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 48px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  min-width: 200px;
  animation: toastIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.info { border-color: var(--accent); }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Modals */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  min-width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
.setting-item { display: flex; flex-direction: column; gap: 6px; }
.setting-item label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

.shortcuts-list h3 { font-size: 13px; margin-bottom: 12px; font-weight: 600; }
.shortcut-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  align-items: center;
}
.shortcut-grid span { font-size: 11px; color: var(--text-secondary); }
kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Code blocks */
.code-block, .dev-code {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--accent2);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
  line-height: 1.5;
}

.copy-btn, .copy-dev-btn {
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.copy-btn:hover, .copy-dev-btn:hover { background: var(--accent); color: #fff; }

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  z-index: 500;
  min-width: 160px;
  box-shadow: var(--shadow-md);
  display: none;
}
.context-menu.visible { display: block; }
.ctx-item {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary);
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.ctx-danger { color: var(--error); }
.ctx-item.ctx-danger:hover { background: rgba(239,68,68,0.1); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Developer Panel */
.dev-panel {
  position: fixed;
  width: 420px;
  height: 520px;
  min-width: 320px;
  min-height: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  z-index: 400;
  box-shadow: var(--shadow-lg);
  resize: both;
  overflow: auto;
}
.dev-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  cursor: move;
  user-select: none;
}
.dev-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.dev-tab {
  flex: 1;
  padding: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.dev-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.dev-tab-content { padding: 12px; display: none; }
.dev-tab-content.active { display: block; }

/* Emoji Picker */
.emoji-picker {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  z-index: 600;
  box-shadow: var(--shadow-lg);
  width: 260px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.emoji-item {
  font-size: 22px;
  text-align: center;
  padding: 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
  line-height: 1;
}
.emoji-item:hover { background: var(--bg-hover); }

/* Mini toggle */
.mini-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
}
.mini-toggle input { display: none; }

/* Coming soon */
.coming-soon {
  color: var(--text-muted);
  font-size: 12px;
  padding: 20px;
  text-align: center;
}

/* Rulers */
.ruler {
  background: var(--bg-secondary);
  border-color: var(--border);
}
.ruler-h {
  position: absolute;
  top: 0; left: 16px; right: 0;
  height: 16px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
  overflow: hidden;
}
.ruler-v {
  position: absolute;
  top: 16px; left: 0; bottom: 0;
  width: 16px;
  border-right: 1px solid var(--border);
  z-index: 10;
  overflow: hidden;
}
