/* リセットと基本設定 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-main: #0a0c10;
  --bg-sidebar: rgba(18, 22, 32, 0.85);
  --bg-card: rgba(30, 37, 54, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #00a2ff;
  --primary-glow: rgba(0, 162, 255, 0.4);
  --secondary: #00ff88;
  --accent: #a855f7;
  --accent-gradient: linear-gradient(135deg, #00a2ff, #a855f7);
  --font-family: 'Outfit', 'Noto Sans JP', sans-serif;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
}

/* アプリ全体のレイアウト */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* サイドバー（コントロールパネル） */
.sidebar {
  width: 380px;
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
}

/* ブランドロゴ */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand .logo {
  font-size: 28px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* グループパネル */
.panel-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.panel-group h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

/* フォームグループ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

.help-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 各種入力コントロールのスタイリング */
select {
  width: 100%;
  padding: 10px 14px;
  background: rgba(10, 12, 16, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: all 0.3s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* カスタムアップロードボタン */
.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 20px;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
}

.upload-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
}

.upload-btn input[type="file"] {
  display: none;
}

/* スライダー */
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  cursor: pointer;
  transition: transform 0.1s ease;
}

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

.val-display {
  font-size: 12px;
  font-weight: 600;
  min-width: 28px;
  text-align: right;
  color: var(--primary);
}

/* キャンバス背景切り替えボタン */
.bg-switch-group {
  display: flex;
  gap: 8px;
  background: rgba(10, 12, 16, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 4px;
}

.btn-bg-switch {
  flex: 1;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-bg-switch:hover {
  color: var(--text-main);
}

.btn-bg-switch.active {
  background: var(--primary);
  color: #fff;
}

/* カラーグリッド */
.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  background: rgba(10, 12, 16, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 4px 10px;
  gap: 8px;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  background: none;
}

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

input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.color-picker-wrapper input[type="text"] {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 13px;
  text-transform: uppercase;
  outline: none;
}

/* アクションボタン */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
}

.btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(168, 85, 247, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.credits {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* 右側：プレビューエリア */
.preview-area {
  flex: 1;
  background-color: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
}

.canvas-container {
  width: 100%;
  max-width: 900px;
  aspect-ratio: 4 / 3;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: auto;
}

#preview-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ハンドル（制御用） */
.handle {
  cursor: grab;
  transition: transform 0.1s ease;
}

.handle:active {
  cursor: grabbing;
}

.handle:hover circle:first-child {
  transform: scale(1.15);
}

.handle-label {
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-muted);
  user-select: none;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.6);
}

/* ズームコントロールパネル */
.zoom-controls {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 22, 32, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 6px 12px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* 元に戻す・やり直すパネル（.zoom-controlsと同じ見た目だが左上に置く。
   後ろに書くことで.zoom-controlsのright指定より優先させる） */
.undo-redo-controls {
  left: 24px;
  right: auto;
  padding: 8px 10px;
  gap: 10px;
}

.undo-redo-controls .btn-zoom {
  width: 44px;
  height: 44px;
  font-size: 22px;
  border-radius: 8px;
}

.btn-zoom:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn-zoom:disabled:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
}

.btn-zoom, .btn-zoom-reset {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-zoom {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-zoom-reset {
  padding: 4px 10px;
  height: 28px;
}

.btn-zoom:hover, .btn-zoom-reset:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

#zoom-display {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  min-width: 40px;
  text-align: center;
  user-select: none;
}
