/* style.css — うごラク グローバルスタイル (ダークテーマ) */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #1a1a2e;
  --bg2:        #16213e;
  --bg3:        #0f3460;
  --surface:    #1e2a3a;
  --surface2:   #253447;
  --accent:     #e94560;
  --accent2:    #0f8eff;
  --text:       #e0e0e0;
  --text-dim:   #8899aa;
  --border:     #2a3f5a;
  --canvas-bg:  #ffffff;
  --radius:     6px;
  --shadow:     0 2px 12px rgba(0,0,0,0.5);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ========== レイアウト ========== */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- ヘッダーツールバー ---- */

#toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
}
.toolbar-group:last-child { border-right: none; }

#appTitle {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-right: 4px;
}

#projectTitle {
  color: var(--text-dim);
  cursor: pointer;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
#projectTitle:hover { color: var(--text); }

/* ---- メインエリア ---- */

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- キャンバスエリア ---- */

#canvasArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  padding: 12px;
}

#canvasWrapper {
  position: relative;
  width: min(800px, calc(100vw - 24px));
  aspect-ratio: 4 / 3;
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--canvas-bg);
  flex-shrink: 0;
}

#canvasWrapper canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  touch-action: none;
  display: block;
}

#onionCanvas { z-index: 1; pointer-events: none; }
#drawCanvas  { z-index: 2; cursor: crosshair; }

/* ---- フレームカウンター (再生中) ---- */

#playFrameCounter {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 6px;
  height: 16px;
}

/* ---- フレームストリップ ---- */

#frameStripWrapper {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 6px 8px;
  gap: 6px;
  flex-shrink: 0;
  height: 110px;
}

#frameStrip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#frameStrip::-webkit-scrollbar { height: 4px; }
#frameStrip::-webkit-scrollbar-track { background: transparent; }
#frameStrip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.frame-thumb {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s;
  background: #fff;
  user-select: none;
}
.frame-thumb:hover   { border-color: var(--accent2); }
.frame-thumb.active  { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.frame-thumb.drag-over { border-color: var(--accent2); opacity: 0.7; }
.frame-thumb.dragging  { opacity: 0.4; }

.frame-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.frame-num {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  color: rgba(0,0,0,0.5);
  font-weight: 600;
  line-height: 1;
}

#frameCount {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ========== ボタン共通 ========== */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  user-select: none;
}
button:hover  { background: var(--surface2); border-color: var(--accent2); }
button.active { background: var(--accent2); border-color: var(--accent2); color: #fff; }

.btn-accent  { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.15); }

.btn-small {
  padding: 3px 8px;
  font-size: 11px;
}
.btn-danger { border-color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; }

/* ---- icon buttons ---- */
.btn-icon { padding: 5px 8px; font-size: 16px; line-height: 1; }

/* ========== 入力コントロール ========== */

input[type="range"] {
  accent-color: var(--accent2);
  width: 80px;
}

input[type="color"] {
  width: 30px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

/* ========== カラーパレット ========== */

#colorPalette {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 120px;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.color-swatch:hover  { transform: scale(1.2); border-color: #fff; }
.color-swatch.active { border: 2px solid var(--accent); transform: scale(1.15); }

/* ========== ステータスバー ========== */

#statusBar {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
  transition: opacity 0.4s;
  z-index: 100;
  white-space: nowrap;
}

/* ========== モーダル ========== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: min(480px, 95vw);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-box h2 {
  font-size: 16px;
  color: var(--accent2);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ---- プロジェクトリスト ---- */

#projectList { display: flex; flex-direction: column; gap: 8px; }

.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.project-item img {
  border-radius: 3px;
  object-fit: contain;
  background: #fff;
  flex-shrink: 0;
}
.project-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.project-info strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-info small { color: var(--text-dim); font-size: 11px; }
.project-actions { display: flex; flex-direction: column; gap: 4px; }

/* ---- プログレスバー ---- */

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--surface);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar-inner {
  height: 100%;
  background: var(--accent2);
  border-radius: 5px;
  transition: width 0.1s;
  width: 0%;
}
.progress-label {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---- 共有モーダル ---- */

.share-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ========== レスポンシブ (モバイル) ========== */

@media (max-width: 600px) {
  #toolbar { padding: 4px 6px; gap: 4px; }
  .toolbar-group { padding: 0 4px; gap: 3px; }
  #appTitle { font-size: 13px; }

  #canvasArea { padding: 6px; }

  #frameStripWrapper { height: 90px; padding: 4px 6px; }
  .frame-thumb { width: 66px; height: 66px; }

  button { padding: 4px 8px; font-size: 11px; }
  input[type="range"] { width: 60px; }
  #colorPalette { max-width: 80px; }

  #statusBar { bottom: 100px; }
}

/* ========== スクロールバー全般 ========== */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar       { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
