/* ========================================
   OEKAKI ATELIER  Wednesday-inspired dark theme
   ======================================== */

:root {
  --bg: #0a0a0f;
  --bg-2: #1a1525;
  --surface: #15131c;
  --surface-2: #1d1a26;
  --border: #2a2535;
  --border-strong: #3d3548;
  --text: #e8e6dd;
  --text-2: #9a92a8;
  --text-muted: #6b6478;
  --gold: #c9a961;
  --gold-soft: rgba(201,169,97,0.15);
  --purple: #6b2fbf;
  --purple-soft: rgba(107,47,191,0.2);
  --danger: #a13d3d;
  --success: #4a7d4a;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  touch-action: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(107,47,191,0.12), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(201,169,97,0.06), transparent 50%);
  z-index: -1;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

h1, h2, h3, .ロゴ題 {
  font-family: "Noto Serif JP", serif;
  font-weight: 500;
  letter-spacing: 0.12em;
  margin: 0;
}

/* ===== 画面切替 ===== */
.画面 {
  display: none;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}
.画面.表示中 { display: flex; }

/* ===== ヘッダー ===== */
.ヘッダー {
  padding: 24px 32px;
  text-align: center;
  background: linear-gradient(180deg, rgba(107,47,191,0.08), transparent);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.ヘッダー::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  width: 60%;
  max-width: 240px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.ロゴ題 {
  font-size: 30px;
  letter-spacing: 0.25em;
  color: var(--text);
}

.ロゴ副 {
  margin: 6px 0 0;
  font-family: "Noto Serif JP", serif;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.セクション見出し {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 32px 16px;
}

.セクション見出し h2 {
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--text-2);
  white-space: nowrap;
}

.装飾線 {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

/* ===== ホーム：キャラグリッド ===== */
.本体 {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.キャラグリッド {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
  align-content: start;
}

.キャラカード {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.キャラカード:hover { border-color: var(--gold); }
.キャラカード:active { transform: scale(0.98); }

.キャラカード::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.キャラカード:hover::before { border-color: rgba(201,169,97,0.3); inset: 4px; }

.キャラカード img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--bg-2);
  filter: brightness(0.95) contrast(1.05);
}

.キャラカード .名前 {
  font-family: "Noto Serif JP", serif;
  font-size: 16px;
  letter-spacing: 0.05em;
  color: var(--text);
}

.キャラカード .進捗バー {
  width: 100%;
  height: 2px;
  background: var(--border);
  overflow: hidden;
}

.キャラカード .進捗バー > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--gold));
}

.キャラカード .削除ボタン {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(10,10,15,0.8);
  color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}
.キャラカード .削除ボタン:hover { color: var(--danger); border-color: var(--danger); }

/* ===== ボタン ===== */
.主ボタン {
  font-family: "Noto Serif JP", serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.1em;
  padding: 16px 28px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--gold);
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 60px;
  min-width: 160px;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}
.主ボタン:hover { background: var(--gold-soft); box-shadow: 0 0 20px rgba(201,169,97,0.3); }
.主ボタン:active { transform: translateY(1px); }
.主ボタン .ボタン副 {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 11px;
  letter-spacing: 0.05em;
  font-weight: 400;
  color: var(--text-muted);
}

.副ボタン {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  letter-spacing: 0.08em;
  padding: 14px 24px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  min-height: 48px;
  min-width: 120px;
  transition: color 0.2s, border-color 0.2s;
}
.副ボタン:hover { color: var(--text); border-color: var(--text-2); }

.アイコンボタン {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 8px 14px;
  color: var(--text-2);
  border: 1px solid var(--border);
  transition: color 0.2s, border-color 0.2s;
}
.アイコンボタン:hover { color: var(--gold); border-color: var(--gold); }

.フッター {
  padding: 24px 32px 32px;
  display: flex;
  gap: 16px;
  justify-content: center;
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, rgba(107,47,191,0.06), transparent);
}

/* ===== 練習画面：ヘッダ ===== */
.練習ヘッダー {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 16px;
}
.ステップ表示 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.キャラ名 {
  font-family: "Noto Serif JP", serif;
  font-size: 18px;
  color: var(--text);
  letter-spacing: 0.05em;
}
.ステップ名 {
  font-family: "Noto Serif JP", serif;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--gold);
}
.保存表示 {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--success);
  border: 1px solid var(--success);
  padding: 6px 12px;
}
.保存表示.保存中 { color: var(--gold); border-color: var(--gold); }
.保存表示.失敗 { color: var(--danger); border-color: var(--danger); }

/* ===== 練習画面：本体 ===== */
.練習本体 {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.キャンバス領域 {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 12px 24px 12px;
  min-height: 0;
}

.キャンバス枠 {
  flex: 1;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  min-height: 0;
}

.キャンバス枠::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid var(--gold-soft);
  z-index: 10;
}

.重ねキャンバス {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#お手本キャンバス {
  pointer-events: none;
  opacity: 0.5;
  filter: invert(0.92) hue-rotate(180deg) saturate(0.7);
}

#過去レイヤーキャンバス {
  pointer-events: none;
  opacity: 0;
  z-index: 1;
}

#お絵かきキャンバス { z-index: 2; }

/* お手本のフィルタ説明:
   背景が暗いので invert で明るい線をベースに見せる
   invertだと色も反転するので hue-rotate で色合いを戻す近似 */

/* ===== ツールパネル ===== */
.ツールパネル {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.ツール群 {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.ツール群:last-child { border-bottom: none; padding-bottom: 0; }

.ラベル {
  font-family: "Noto Serif JP", serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--gold);
}

.副ラベル {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.色パレット {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.色チップ {
  aspect-ratio: 1 / 1;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s;
  position: relative;
}
.色チップ:hover { border-color: var(--gold); }
.色チップ.選択中 {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(201,169,97,0.6);
}

.太さ群 {
  display: flex;
  gap: 8px;
  justify-content: space-around;
}

.太さボタン {
  width: 48px;
  height: 48px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}
.太さボタン:hover { border-color: var(--gold); }
.太さボタン.選択中 { border-color: var(--gold); box-shadow: 0 0 8px rgba(201,169,97,0.4); }

.太さ点 {
  display: block;
  background: var(--text);
  border-radius: 50%;
}
.太さ点.サイズ細 { width: 4px; height: 4px; }
.太さ点.サイズ中 { width: 10px; height: 10px; }
.太さ点.サイズ太 { width: 22px; height: 22px; }

.ツールボタン {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  text-align: left;
  transition: color 0.2s, border-color 0.2s;
}
.ツールボタン:hover { color: var(--text); border-color: var(--gold); }
.ツールボタン.選択中 { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.ツールボタン.キケン { color: var(--text-muted); }
.ツールボタン.キケン:hover { color: var(--danger); border-color: var(--danger); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--border-strong);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--gold);
  cursor: pointer;
  border: 1px solid var(--gold);
}

input[type="text"] {
  font-family: "Noto Sans JP", "Inter", sans-serif;
  font-size: 16px;
  padding: 12px 14px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  outline: none;
  letter-spacing: 0.05em;
}
input[type="text"]:focus { border-color: var(--gold); }

/* ===== 解説パネル ===== */
.解説パネル {
  margin: 0 24px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.3s;
}
.解説パネル.折りたたみ { max-height: 48px; }

.解説ヘッダ {
  display: flex;
  align-items: center;
  gap: 12px;
}

.解説バッジ {
  font-family: "Cinzel", serif;
  font-size: 18px;
  letter-spacing: 0.05em;
  color: var(--gold);
  border: 1px solid var(--gold);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.解説ヘッダ h3 {
  flex: 1;
  font-family: "Noto Serif JP", serif;
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.05em;
  font-weight: 500;
}

.解説本文 {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
  overflow-y: auto;
  padding-right: 8px;
}
.解説本文 strong { color: var(--gold); font-weight: 500; }
.解説本文 ul { margin: 6px 0; padding-left: 20px; }

/* ===== ステップナビ ===== */
.ステップナビ {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(0deg, rgba(107,47,191,0.05), transparent);
  border-top: 1px solid var(--border);
  gap: 12px;
}

.ナビボタン {
  font-family: "Noto Serif JP", serif;
  font-size: 14px;
  letter-spacing: 0.08em;
  padding: 12px 20px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  min-height: 44px;
  transition: color 0.2s, border-color 0.2s;
}
.ナビボタン:hover { color: var(--text); border-color: var(--text-2); }
.ナビボタン.主 {
  color: var(--gold);
  border-color: var(--gold);
  letter-spacing: 0.1em;
}
.ナビボタン.主:hover { background: var(--gold-soft); box-shadow: 0 0 12px rgba(201,169,97,0.3); }
.ナビボタン:disabled { opacity: 0.3; pointer-events: none; }

.ステップ進捗 {
  display: flex;
  gap: 8px;
}

.ステップ丸 {
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-strong);
  background: transparent;
  transition: background 0.2s, border-color 0.2s;
}
.ステップ丸.現在 { background: var(--gold); border-color: var(--gold); }
.ステップ丸.完了 { background: var(--purple); border-color: var(--purple); }

/* ===== モーダル ===== */
.モーダル {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.モーダル.表示中 { display: flex; }

.モーダル中身 {
  background: var(--surface);
  border: 1px solid var(--gold);
  padding: 32px;
  min-width: 320px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.モーダル中身.横長 { width: 720px; max-width: 90vw; }

.モーダル中身::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(201,169,97,0.3);
  pointer-events: none;
}

.モーダル中身 h2 {
  font-size: 22px;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-align: center;
}

.モーダル副 {
  margin: -8px 0 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.プレビュー {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: var(--bg-2);
  border: 1px solid var(--border);
}

.モーダル中身 label {
  font-family: "Cinzel", sans-serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--gold);
}

.モーダルボタン群 {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ===== 検索モーダル ===== */
.検索入力行 {
  display: flex;
  gap: 8px;
}
.検索入力行 input { flex: 1; }

.検索結果グリッド {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
}

.検索結果アイテム {
  position: relative;
  cursor: pointer;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  aspect-ratio: 1 / 1;
  transition: border-color 0.2s;
  overflow: hidden;
}
.検索結果アイテム:hover { border-color: var(--gold); }
.検索結果アイテム img { width: 100%; height: 100%; object-fit: contain; }

.検索メッセージ {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  min-height: 20px;
}

/* ===== AIフィードバックパネル ===== */
.AIパネル {
  position: fixed;
  left: 0;
  right: 0;
  bottom: -100%;
  background: var(--surface);
  border-top: 1px solid var(--gold);
  padding: 24px 32px 28px;
  z-index: 90;
  transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.6);
  max-height: 50vh;
  overflow: hidden;
}
.AIパネル.表示中 { bottom: 0; }

.AIヘッダ {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.スパモンアイコン {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}
.AIバッジ {
  font-family: "Noto Serif JP", serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 4px 10px;
}
.AIヘッダ h3 {
  flex: 1;
  font-family: "Noto Serif JP", serif;
  font-size: 17px;
  color: var(--text);
  font-weight: 500;
}

.AI本文 {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
  letter-spacing: 0.02em;
  max-height: 26vh;
  overflow-y: auto;
  white-space: pre-wrap;
}
.AI本文 strong { color: var(--gold); }

.AIローディング {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.05em;
}

/* ===== 解析モーダル ===== */
.解析プレビュー枠 {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.解析プレビューCV {
  max-width: 100%;
  max-height: 100%;
}
.解析説明枠 {
  background: var(--bg-2);
  border-left: 2px solid var(--gold);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.解析説明見出し {
  font-family: "Noto Serif JP", serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--gold);
}
.解析説明テキスト {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.ロード点 {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: 点滅 1.4s infinite ease-in-out both;
}
.ロード点:nth-child(1) { animation-delay: -0.32s; }
.ロード点:nth-child(2) { animation-delay: -0.16s; }
@keyframes 点滅 {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.AIフッタ {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

/* ===== 縦持ち（ポートレート）対応 ===== */
@media (orientation: portrait) {
  .キャンバス領域 { flex-direction: column; padding: 8px 16px; }
  .ツールパネル {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 14px;
  }
  .ツール群 {
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding-bottom: 0;
    padding-right: 14px;
    min-width: 160px;
    flex-shrink: 0;
  }
  .ツール群:last-child { border-right: none; }
  .解説パネル { margin: 0 16px 8px; }
  .ステップナビ { padding: 12px 16px; flex-wrap: wrap; }
  .ナビボタン.主 { order: 4; flex: 1 0 100%; }
}

/* ===== 小画面（iPhone） ===== */
@media (max-width: 600px) {
  .ロゴ題 { font-size: 22px; letter-spacing: 0.2em; }
  .キャラグリッド { grid-template-columns: repeat(2, 1fr); padding: 0 16px 16px; gap: 10px; }
  .セクション見出し { padding: 16px; }
  .フッター { padding: 16px; flex-wrap: wrap; }
  .主ボタン { font-size: 12px; padding: 12px 16px; min-width: 140px; }
  .練習ヘッダー { padding: 10px 12px; }
  .キャラ名 { font-size: 14px; }
  .ステップ名 { font-size: 10px; }
}
