/* ==========================================================================
   カラーリムーバー / スタイルシート
   ダークテーマを基調としたツール系UI
   ========================================================================== */

:root {
  --bg-base: #0a0c11;
  --bg-panel: #12151d;
  --bg-panel-elevated: #191d28;
  --bg-field: #0e1119;
  --border-color: #262b3a;
  --border-color-strong: #363c50;

  --text-primary: #eef0f6;
  --text-secondary: #8b93aa;
  --text-tertiary: #5a6178;

  --accent: #5eead4;
  --accent-strong: #22d3ee;
  --accent-magenta: #f472b6;
  --danger: #f87171;
  --warning: #fbbf24;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-elevated: 0 24px 60px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.3);

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN',
    'Hiragino Sans', 'Yu Gothic UI', 'Noto Sans JP', sans-serif;
}

* {
  box-sizing: border-box;
}

/* hidden属性は各要素のdisplay指定より常に優先させる */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(94, 234, 212, 0.08), transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, rgba(244, 114, 182, 0.06), transparent 55%),
    var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: inherit;
}

/* ---------------------------------------------------------------------- */
/* ヘッダー */
/* ---------------------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 28px 40px 12px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-header__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.12), rgba(244, 114, 182, 0.1));
  border: 1px solid var(--border-color-strong);
  flex-shrink: 0;
}

.app-header__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #f4f6fb 20%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-header__subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.steps {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.steps__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-color-strong);
  font-size: 11px;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------- */
/* ワークスペース全体レイアウト */
/* ---------------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 12px 40px 40px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

/* ---------------------------------------------------------------------- */
/* キャンバスパネル */
/* ---------------------------------------------------------------------- */

.canvas-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 420px;
  border: 1.5px dashed var(--border-color-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--bg-panel-elevated);
  outline: none;
}

.dropzone.is-dragover {
  border-color: var(--accent-strong);
  background: rgba(34, 211, 238, 0.06);
  transform: scale(1.005);
}

.dropzone__icon {
  color: var(--accent);
  margin-bottom: 4px;
}

.dropzone__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.canvas-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.canvas-toolbar__group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.canvas-toolbar__zoom {
  padding-left: 12px;
  border-left: 1px solid var(--border-color);
}

.canvas-toolbar__zoom-value {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.canvas-toolbar__push {
  margin-left: auto;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color-strong);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-icon:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.canvas-frame {
  position: relative;
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  max-height: 62vh;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background:
    linear-gradient(45deg, #14161d 25%, transparent 25%),
    linear-gradient(-45deg, #14161d 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #14161d 75%),
    linear-gradient(-45deg, transparent 75%, #14161d 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #0d0f15;
  padding: 16px;
  overflow: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.canvas-frame.is-loaded {
  opacity: 1;
}

#previewCanvas {
  display: block;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  box-shadow: var(--shadow-soft);
}

.magnifier {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color-strong);
  box-shadow: var(--shadow-elevated);
  pointer-events: none;
  z-index: 10;
}

.canvas-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-tertiary);
  text-align: center;
}

.error-message {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--danger);
  font-size: 13px;
}

/* ---------------------------------------------------------------------- */
/* コントロールパネル */
/* ---------------------------------------------------------------------- */

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.control-block {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
}

.control-block__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.control-block__label {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.control-block__row .control-block__label {
  margin-bottom: 0;
}

.control-block__value {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.control-block__link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.control-block__link:hover {
  color: var(--accent-strong);
}

.control-block__hint {
  font-size: 11.5px;
  color: var(--text-tertiary);
  text-align: right;
}

/* 削除する色リスト */

.color-target-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.color-target-list::-webkit-scrollbar {
  width: 6px;
}

.color-target-list::-webkit-scrollbar-thumb {
  background: var(--border-color-strong);
  border-radius: 999px;
}

.color-target-list__empty {
  font-size: 12.5px;
  color: var(--text-tertiary);
  padding: 8px 0;
}

.color-target-list__max {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--warning);
}

.color-target {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-field);
  border: 1px solid var(--border-color);
}

.color-target__swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border-color-strong);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 2px var(--bg-field);
}

.color-target__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-target__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.color-target__rgb {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-target__value {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.color-target__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.color-target__remove:hover {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
}

/* エッジ処理のトグルスイッチ */

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-color-strong);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.switch input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-primary);
  transition: transform 0.2s ease;
}

.switch input:checked {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.switch input:checked::before {
  transform: translateX(14px);
}

/* スライダー */

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-magenta) 100%);
  opacity: 1;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.slider:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--accent-strong);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.slider:not(:disabled)::-webkit-slider-thumb:hover,
.slider:not(:disabled):active::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.18);
  transform: scale(1.05);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--accent-strong);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.slider:not(:disabled)::-moz-range-thumb:hover {
  box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.18);
  transform: scale(1.05);
}

.slider--mini {
  height: 3px;
}

.slider--mini::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
}

.slider--mini::-moz-range-thumb {
  width: 13px;
  height: 13px;
}

/* 出力サイズ */

.size-fields {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-bottom: 12px;
}

.size-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.size-field__label {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.size-field__input {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color-strong);
  background: var(--bg-field);
  color: var(--text-primary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.size-field__input:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
}

.size-fields__separator {
  padding-bottom: 8px;
  color: var(--text-tertiary);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox input {
  accent-color: var(--accent-strong);
  width: 15px;
  height: 15px;
}

/* ボタン */

.control-block--actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

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

.btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #052225;
}

.btn--primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(34, 211, 238, 0.25);
}

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

.btn--ghost {
  background: transparent;
  border: 1px solid var(--border-color-strong);
  color: var(--text-secondary);
}

.btn--ghost:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ---------------------------------------------------------------------- */
/* トースト（拡大警告・色上限などの通知を共通化） */
/* ---------------------------------------------------------------------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 340px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-panel-elevated);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--warning);
  font-size: 13px;
  box-shadow: var(--shadow-elevated);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast svg {
  flex-shrink: 0;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------------------------------------------------------------------- */
/* 使い方モーダル */
/* ---------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-elevated);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal__header h2 {
  margin: 0;
  font-size: 17px;
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal__close:hover {
  background: var(--bg-field);
  color: var(--text-primary);
}

.modal__steps {
  margin: 0 0 22px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal__steps strong {
  display: block;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 2px;
}

.modal__tips h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.modal__tips ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------- */
/* レスポンシブ対応 */
/* ---------------------------------------------------------------------- */

@media (max-width: 900px) {
  .app-header {
    padding: 20px 20px 8px;
  }

  .steps {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px 20px 32px;
  }

  .control-panel {
    position: static;
  }

  .dropzone {
    min-height: 280px;
  }

  .canvas-frame {
    max-height: 50vh;
  }

  .toast {
    left: 16px;
    right: 16px;
    max-width: none;
  }
}
