/* ================================================
   Modern Creative Studio UI (rgba edition)
   ================================================ */

:root {
  /* メインカラー */
  --bg-deep: rgba(18, 18, 18, 1);       /* 最背面 */
  --bg-panel: rgba(32, 32, 32, 1);      /* パネル背景 */
  --bg-input: rgba(45, 45, 45, 1);      /* 入力項目 */
  --border: rgba(255, 255, 255, 0.08);   /* 境界線 */

  /* アクセント */
  --accent: rgba(0, 122, 255, 1);       /* 鮮やかなブルー */
  --accent-hover: rgba(10, 132, 255, 1);
  --success: rgba(48, 209, 88, 1);      /* 保存などの成功色 */

  /* テキスト */
  --text-primary: rgba(245, 245, 247, 1);
  --text-secondary: rgba(161, 161, 170, 1);
  --text-muted: rgba(113, 113, 122, 1);

  --radius: 8px;
  --header-h: 56px;
  --footer-h: 40px;
}

/* --- ベース --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- ヘッダー --- */
.top {
  height: var(--header-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
}

.top h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
/* --- ヘッダー内ツールバー (top-tools) --- */
.top-tools {
  display: flex;
  align-items: center;
  gap: 8px;                    /* アイコン間の間隔 */
  margin: auto;           /* 右寄せ */
}

.top-tools button {
  background: transparent;     /* 背景なしで軽く */
  border: none;
  color: var(--text-primary);
  font-size: 18px;             /* アイコンサイズ */
  min-width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.top-tools button:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.top-tools button:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.15);
}

/* 保存ボタンだけ少し目立たせる（オプション） */
.top-tools #saveJpg,
.top-tools #savePng,
.top-tools #saveWebp {
  background: var(--accent);
  color: white;
  font-size: 14px;
  width: auto;
  padding: 0 12px;
  gap: 6px;
}

.top-tools #saveJpg:hover,
.top-tools #savePng:hover,
.top-tools #saveWebp:hover {
  background: var(--accent-hover);
}

/* レスポンシブ（狭い画面でアイコン小さく） */
@media (max-width: 768px) {
  .top-tools button {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  .top-tools #saveJpg,
  .top-tools #savePng,
  .top-tools #saveWebp {
    padding: 0 8px;
    font-size: 13px;
  }
}
/* --- メインエディターエリア --- */
.editor {
  flex: 1; /* ヘッダーとフッターの間を埋める */
  display: flex;
  overflow: hidden;
}

/* サイドバー (左右共通) */
.tools, .props {
  width: 336px;
  background: var(--bg-panel);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tools { border-right: 1px solid var(--border); }
.props { border-left: 1px solid var(--border); }

/* --- キャンバス作業領域 --- */
#canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: auto;
  background: var(--bg-deep);
  display: flex;                    /* flexを残す（中央寄せに便利） */
  justify-content: center;
  align-items: center;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Fabric.jsのwrapperを中央に配置（!importantは最小限） */
.canvas-container {
  margin: auto;                     /* 横中央寄せ */
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

/* canvas要素自体は実寸優先 */
#canvas {
  display: block;
  width: auto;
  height: auto;
  background: rgba(255, 255, 255, 1) !important;  /* 背景だけは確実に */
}

/* --- ボタン --- */
button {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover {
  background: rgba(60, 60, 60, 1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

/* 保存ボタン系 */
#saveJpg, #savePng, #saveWebp {
  background: var(--accent);
  border: none;
}
#saveJpg:hover, #savePng:hover, #saveWebp:hover {
  background: var(--accent-hover);
}
#fitImage {
  background: var(--accent);
  color: white;
  border: none;
  width: 100%;
  margin: 12px 0;
  padding: 10px;
  font-weight: 600;
}

#fitImage:hover {
  background: var(--accent-hover);
}
/* --- フォーム要素 --- */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 10px;
  font-size: 14px;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

/* カラーパレット */
input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 100%;
  height: 36px;
  background: none;
  cursor: pointer;
}
::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* --- フッター --- */
footer {
  height: var(--footer-h);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  font-size: 12px;
  color: var(--text-muted);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  margin: 4px;
}

footer a:hover {
  color: var(--accent);
}

/* --- 整列ボタンのグリッド --- */
.align-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

/* スクロールバー */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* --- モーダル --- */
.modal {
  display: none; /* JSで制御 */
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-panel);
  width: 90%;
  max-width: 500px;
  padding: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: relative;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  animation: modalUp 0.3s ease-out;
}

@keyframes modalUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

#closeHelp {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-dim);
}

#closeHelp:hover { color: #fff; }

/* --- ボタン・入力 --- */
button {
  background: var(--bg-input);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
  transition: 0.2s;
}

button:hover { background: rgba(70, 70, 70, 1); }

#openHelp {
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
}
/* 元のダサい入力枠を完全に隠す */
#imageInput {
  display: none;
}

/* 代わりのラベルをボタンとしてデザイン */
.custom-file-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  background: rgba(0, 122, 255, 0.15); /* ほのかにアクセントカラー */
  color: rgba(0, 122, 255, 1);
  border: 1px dashed rgba(0, 122, 255, 0.5); /* ドラッグ＆ドロップ感を出す破線 */
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-file-upload:hover {
  background: rgba(0, 122, 255, 0.25);
  border-color: rgba(0, 122, 255, 1);
  transform: translateY(-1px);
}

.custom-file-upload i {
  font-size: 18px;
}

.input-unit {
  flex: 1;
}

/* カラーピッカーのラッパーを少しスリムに */
.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px; /* 少し狭めてスッキリさせる */
  background: rgba(45, 45, 45, 1);
  padding: 6px; /* パディングを少し詰める */
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 中のカラーピッカー自体も少しサイズ調整 */
input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px; /* 40pxから32pxへ */
  height: 32px;
  background: none;
  cursor: pointer;
  padding: 0;
}

/* カラーピッカー横のテキスト */
.color-input-wrapper span {
  font-size: 11px;
  color: rgba(160, 160, 160, 1);
  font-weight: 600;
  text-transform: uppercase;
}

/* チェックボックスの微調整（ラベルとの間隔） */
.input-unit .custom-check {
  margin-top: 8px; /* カラーピッカーとの距離 */
  color: var(--text-secondary);
  font-size: 12px;
}

/* --- チェックボックスのカスタム化 (脱ダサい) --- */
.custom-check {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-main);
  gap: 10px;
  margin: 10px 0;
}

/* 本物のチェックボックスは隠す */
.custom-check input {
  display: none;
}

/* チェックボックスの外見 */
.checkmark {
  width: 18px;
  height: 18px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 4px;
  position: relative;
  transition: all 0.2s;
}

.custom-check input:checked + .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.custom-check input:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.side-controls{
	display: -webkit-box;
	display: -moz-box;
	display: box;
	display: flex;
	-webkit-box-lines: multiple;
	-moz-box-lines: multiple;
	box-lines: multiple;
	-webkit-flex-wrap: wrap;
	-moz-flex-wrap: wrap;
	flex-wrap: wrap;
	-webkit-justify-content: space-around;
	-moz-justify-content: space-around;
	justify-content: space-around;
	flex-direction: row;
	-moz-box-pack: justify;
	-ms-box-pack: justify;
	box-pack: justify;
	-webkit-align-items: stretch;
	-ms-flex-align: stretch;
	align-items: stretch;
	flex-flow: row wrap;
}
.tools h3,
.props h3{
  margin: 0;
}
/* キャンバスサイズ横並びにするためのコンテナ */
.row-group {
  display: flex;
  gap: 12px;      /* 入力項目間の余白 */
  margin-top: 15px;
}

/* 各入力セット（ラベル＋入力欄）を均等に広げる */
.input-unit {
  flex: 1;
}

/* input-unit内のラベルは、margin-topを打ち消すと高さが揃います */
.input-unit label {
  margin-top: 0;
  margin-bottom: 6px;
}

/* 数値入力欄をrgbaで再定義（すでにある場合は微調整） */
.input-unit input[type="number"] {
  width: 100%;
  background: rgba(45, 45, 45, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: rgba(245, 245, 245, 1);
  padding: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input-unit input[type="number"]:focus {
  border-color: rgba(0, 122, 255, 1);
}

/* --- スライダー全体のデザイン --- */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent; /* 背景を透明にして自作トラックを見せる */
  cursor: pointer;
  margin: 15px 0;
}

/* 実行中のトラック（溝）のデザイン */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* つまみ（丸い部分）のデザイン */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: rgba(0, 122, 255, 1); /* アクセントカラー */
  margin-top: -6px; /* (トラックの高さ/2) - (つまみの高さ/2) */
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}

input[type="range"]:hover::-webkit-slider-thumb {
  background: rgba(10, 132, 255, 1);
  transform: scale(1.1);
}

/* Firefox用の設定 */
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  height: 16px;
  width: 16px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 122, 255, 1);
}

/* --- 数値入力ラッパー --- */
.number-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* 本物のスピンボタンは跡形もなく消す */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  padding-right: 35px; /* ボタン用の余白 */
}

/* 自作ボタンのコンテナ */
.spin-buttons {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 28px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* 上下ボタン共通 */
.spin-buttons button {
  flex: 1;
  background: rgba(60, 60, 60, 1);
  color: rgba(160, 160, 160, 1);
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.spin-buttons button:hover {
  background: rgba(80, 80, 80, 1);
  color: rgba(255, 255, 255, 1);
}

.spin-buttons .spin-up {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-top-right-radius: 6px;
}

.spin-buttons .spin-down {
  border-bottom-right-radius: 6px;
}

/* 右下のズーム制御ボタン（既存の.top-tools buttonと同じスタイル） */
.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 40px;
  text-align: center;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.zoom-btn:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.15);
}
