/* カラーエディタ */
#colorMenu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--kaku-bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 12px;
  display: none;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--kaku-shadow-lg);
  z-index: var(--z-index-modal);
  width: 280px;
}

#colorMenu.show {
  display: flex;
}

.cp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.cp-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--kaku-text-primary);
}

.cp-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cp-sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cp-alpha-info {
  display: flex;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--kaku-text-secondary);
  margin-bottom: 2px;
}

.cp-quick-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin: 10px 0;
  min-height: 80px;
  max-height: 250px;
  overflow-y: auto;
  padding: 12px;
  background: var(--kaku-bg-ghost);
  border-radius: 12px;
  border: 1px solid var(--kaku-border-light);
  align-content: flex-start;
}

/* パレット内のスウォッチ共通スタイル */
.cp-quick-palette .qp-swatch {
  width: 32px; /* Fixed size */
  height: 32px;
  margin: 0 auto; /* Center within grid cell */
  border-radius: 50%;
  border: 2px solid var(--kaku-bg-primary);
  box-shadow: var(--kaku-shadow-sm);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.cp-quick-palette .qp-swatch:hover {
  transform: scale(1.1);
}

.cp-quick-palette .qp-swatch:active {
  transform: scale(0.9);
}

.cp-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.cp-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--kaku-border-light);
  border-radius: 8px;
  color: var(--kaku-text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.cp-action-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.cp-action-btn:active {
  background: var(--kaku-accent-primary);
  color: var(--kaku-text-inverse);
  transform: scale(0.98);
}

.cp-action-btn .material-symbols-outlined {
  font-size: 18px;
}

/* カラーインジケーター */
.color-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #000;
  border: 2px solid #fff;
  cursor: pointer;
}

/* パレットグリッド */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.palette-section {
  margin-bottom: 15px;
}

.palette-subtitle {
  font-size: 14px;
  color: var(--kaku-text-secondary);
  margin: 0 0 8px 0;
}

.palette-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--kaku-border-light);
  cursor: pointer;
  transition: transform var(--kaku-transition-fast);
}

.palette-swatch:active {
  transform: scale(0.9);
}

.palette-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--kaku-accent-primary);
}

/* 自作カラーエディタ内部要素 */
.color-picker-container {
  background: var(--kaku-bg-tertiary);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
}

.sv-wrapper {
  position: relative;
  width: 100%;
  height: 150px;
  margin-bottom: 10px;
  cursor: crosshair;
}

#sv-canvas {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.picker-cursor {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.hue-wrapper {
  margin-bottom: 10px;
}

.hue-slider {
  width: 100%;
  height: 15px;
  border-radius: 8px;
  background: linear-gradient(
    to right,
    #f00 0%,
    #ff0 17%,
    #0f0 33%,
    #0ff 50%,
    #00f 67%,
    #f0f 83%,
    #f00 100%
  );
  appearance: none;
  outline: none;
}

.hue-slider::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #888;
  cursor: pointer;
}

.color-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-preview-box {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 1px solid var(--kaku-border-medium);
}

/* SV（彩度・明度）ボックス */
.cp-sv-box {
  width: 100%;
  height: 150px;
  position: relative;
  background-color: red;
  cursor: crosshair;
  border: 1px solid #888;
  touch-action: none;
}

.cp-sv-white {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
}

.cp-sv-black {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
}

.cp-cursor {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
  transform: translate(-5px, -5px);
  pointer-events: none;
}

/* スライダー共通 */
.cp-range {
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 6px;
  outline: none;
  border: 1px solid #555;
  margin: 0;
}

.cp-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #888;
  cursor: pointer;
  margin-top: -2px;
}

/* 色相スライダー */
#hueSlider {
  background: linear-gradient(
    to right,
    #f00 0%,
    #ff0 17%,
    #0f0 33%,
    #0ff 50%,
    #00f 67%,
    #f0f 83%,
    #f00 100%
  );
}

/* 不透明度スライダー */
.alpha-bg {
  background-image: linear-gradient(
      45deg,
      #ccc 25%,
      transparent 25%,
      transparent 75%,
      #ccc 75%
    ),
    linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
  border-radius: 6px;
}

#alphaSlider {
  background: linear-gradient(
    to right,
    transparent,
    var(--alpha-slider-color, red)
  );
}
