/* ==========================================
   기본 리셋 및 전역 스타일
   ========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fef2f2;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* 전체 앱 레이아웃 */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* ==========================================
   헤더 스타일
   ========================================== */
.app-header {
  height: 60px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.logo-icon {
  width: 26px;
  height: 26px;
}

.logo-text {
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 액션 버튼 공통 */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

.action-btn:hover:not(:disabled) {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.action-btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.action-btn.primary {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.action-btn.primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.action-btn.danger:hover:not(:disabled) {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: #fecaca;
}

/* ==========================================
   메인 레이아웃 (좌측 도구 + 중앙 캔버스)
   ========================================== */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* 좌측 툴바 패널 */
.toolbar-panel {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  z-index: 5;
}

.tool-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* 1. 도구 그리드 */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 6px;
  background-color: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.tool-btn:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.tool-btn.active {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* 2. 크기 조절기 */
.size-badge {
  font-size: 0.8rem;
  font-weight: 600;
  background-color: #f1f5f9;
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text-main);
}

.size-control-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.size-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  cursor: pointer;
}

.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.1s ease;
}

.size-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.size-preview-box {
  width: 36px;
  height: 36px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: #222222;
  transition: width 0.1s ease, height 0.1s ease, background-color 0.2s ease;
}

/* 3. 색상 선택 */
.current-color-indicator-wrap {
  position: relative;
  width: 26px;
  height: 26px;
}

.color-picker-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.current-color-indicator {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #222222;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1, 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.current-color-indicator:hover {
  transform: scale(1.1);
}

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

.palette-color {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.palette-color:hover {
  transform: scale(1.18);
  z-index: 2;
}

.palette-color.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--primary);
}

/* ==========================================
   캔버스 영역
   ========================================== */
.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background-color: #e2e8f0;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
  position: relative;
}

.canvas-card {
  background-color: #ffffff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  touch-action: none; /* 모바일/터치 제스처 방지 */
}

#paintCanvas {
  display: block;
  cursor: crosshair;
  background-color: #ffffff;
  touch-action: none;
}

/* 원형 커서 가이드 인디케이터 */
.cursor-indicator {
  position: absolute;
  pointer-events: none;
  border: 1px solid rgba(0, 0, 0, 0.6);
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 100;
  box-sizing: border-box;
}

/* ==========================================
   푸터 상태바
   ========================================== */
.app-footer {
  height: 38px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  z-index: 10;
}

.tips-container {
  display: flex;
  gap: 14px;
}

.tip-item kbd {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.canvas-info span {
  font-weight: 600;
  color: var(--text-main);
}

/* ==========================================
   반응형 모바일 & 태블릿 스타일
   ========================================== */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .toolbar-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
  }

  .tool-section {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .section-title {
    display: none;
  }

  .tool-grid {
    display: flex;
  }

  .tool-btn {
    padding: 8px 10px;
  }

  .size-slider {
    width: 90px;
  }

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

  .palette-color {
    width: 22px;
    height: 22px;
  }

  .canvas-wrapper {
    padding: 10px;
  }

  .tips-container {
    display: none;
  }

  .btn-label {
    display: none;
  }

  .action-btn {
    padding: 8px;
  }
}

