:root {
  --base: #FAFAFA;
  --surface: #FFFFFF;
  --stroke: #E0E0E0;
  --stroke-hover: #CCCCCC;
  --text: #1A1A1A;
  --text-dim: #666666;
  --accent: #2D2D2D;
  --error: #DC3545;
  --success: #28A745;
  --radius: 4px;
  --transition: 150ms ease;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--base);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

.panel {
  width: 340px;
  background: var(--surface);
  border-right: 1px solid var(--stroke);
  padding: 24px;
  overflow-y: auto;
  max-height: 100vh;
}

.panel-header {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--stroke);
}

.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.control-group {
  margin-bottom: 12px;
}

.control-label {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

input[type="text"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="text"]:hover,
select:hover {
  border-color: var(--stroke-hover);
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.input-with-btn input {
  flex: 1;
}

.btn-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.btn-row .btn {
  flex: 1;
}

.btn {
  padding: 8px 12px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
  background: #F5F5F5;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-sm {
  padding: 6px 10px;
  font-size: 11px;
}

.btn-primary {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #1A1A1A;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--stroke);
  border-radius: 2px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-value {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}

.num-input {
  width: 50px !important;
  padding: 4px 6px !important;
  font-size: 11px;
  text-align: center;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 2px;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.color-palette {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: var(--accent);
}

.swatch-hex {
  display: none;
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  color: var(--text-dim);
}

.color-swatch {
  position: relative;
}

.color-target-selector {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  min-width: 200px;
}

.selector-title {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-dim);
}

.selector-preview {
  width: 100%;
  height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  margin-bottom: 6px;
}

.selector-hex {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text);
}

.selector-btn {
  display: block;
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 4px;
  background: var(--base);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.selector-btn:hover {
  background: var(--stroke);
}

.selector-btn.cancel {
  background: transparent;
  color: var(--text-dim);
  margin-top: 8px;
}

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  padding-bottom: 80px;
  background: 
    radial-gradient(circle at 1px 1px, var(--stroke) 1px, transparent 0);
  background-size: 24px 24px;
}

.toolbar {
  position: fixed;
  bottom: 0;
  left: 340px;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--stroke);
  padding: 12px 24px;
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

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

.toolbar-section select,
.toolbar-section input {
  width: 140px;
  padding: 6px 8px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  font-size: 12px;
}

#zoom-level {
  font-size: 12px;
  min-width: 40px;
  text-align: center;
}

.canvas-container {
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

canvas {
  display: block;
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  overflow: hidden;
}

.tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-dim);
}

.tab:hover {
  background: #F5F5F5;
}

.tab.active {
  background: var(--accent);
  color: var(--surface);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 200ms ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--error);
  color: white;
}

.toast.success {
  background: var(--success);
  color: white;
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--stroke);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn .spinner {
  width: 10px;
  height: 10px;
  border-width: 1.5px;
  border-top-color: currentColor;
}

.image-preview {
  width: 100%;
  height: 120px;
  border: 1px dashed var(--stroke);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
  background: #F5F5F5;
}

.image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.image-preview .placeholder {
  color: var(--text-dim);
  font-size: 12px;
}

.inline-row {
  display: flex;
  gap: 8px;
}

.inline-row > * {
  flex: 1;
}

.toggle-group {
  display: flex;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: var(--surface);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-dim);
}

.toggle-btn:not(:last-child) {
  border-right: 1px solid var(--stroke);
}

.toggle-btn:hover {
  background: #F5F5F5;
}

.toggle-btn.active {
  background: var(--accent);
  color: var(--surface);
}
