/* ===========================
   リセット・変数
=========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --border: #2a2a3a;
  --accent: #7c6ff0;
  --accent-hover: #9a8ff5;
  --text: #e8e8f0;
  --text-sub: #8888a0;
  --success: #4caf80;
  --error: #e05555;
  --warning: #e0a040;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ===========================
   ヘッダー
=========================== */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo span {
  color: var(--accent);
}

.nav { display: flex; gap: 4px; align-items: center; }

.nav-link {
  text-decoration: none;
  color: var(--text-sub);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--bg3);
}

/* 認証ユーザー情報 */
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.nav-user-email {
  font-size: 12px;
  color: var(--text-sub);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge-admin {
  font-size: 10px;
  font-weight: 700;
  background: rgba(124,111,240,0.2);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 8px;
  letter-spacing: 0.3px;
}

.nav-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-sub);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-logout:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ===========================
   メイン
=========================== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ===========================
   モードタブ
=========================== */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.mode-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-sub);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  position: relative;
}

.mode-tab:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--accent);
}

.mode-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.mode-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tab-icon { font-size: 16px; }

.badge {
  position: absolute;
  top: -8px;
  right: -4px;
  background: var(--warning);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
  white-space: nowrap;
}

/* ===========================
   コンテンツ 2カラム
=========================== */
.content {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .content { grid-template-columns: 1fr; }
}

/* ===========================
   フォームパネル
=========================== */
.form-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.form-section {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.required { color: var(--error); }

.form-select, .form-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  appearance: none;
  transition: border-color 0.15s;
}

.form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888a0' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.char-count { text-align: right; font-size: 11px; color: var(--text-sub); margin-top: 4px; }

/* アップロードエリア */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
}

.upload-placeholder {
  text-align: center;
  padding: 24px;
  pointer-events: none;
}

.upload-icon { font-size: 28px; }
.upload-placeholder p { color: var(--text-sub); font-size: 13px; margin-top: 6px; }
.upload-hint { font-size: 11px; }

.upload-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
}

/* アスペクト比 */
.ratio-group {
  display: flex;
  gap: 10px;
}

.ratio-option {
  cursor: pointer;
}

.ratio-option input { display: none; }

.ratio-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 7px;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
  user-select: none;
}

.ratio-16-9 { width: 80px; height: 48px; }
.ratio-9-16 { width: 38px; height: 64px; }
.ratio-1-1  { width: 54px; height: 54px; }

.ratio-option input:checked + .ratio-box {
  border-color: var(--accent);
  background: rgba(124,111,240,0.15);
  color: var(--accent);
}

/* 動画長さ */
.duration-group { display: flex; gap: 12px; }

.duration-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
}

.duration-option input { accent-color: var(--accent); }

/* LoRAスライダー */
.form-range {
  width: 100%;
  accent-color: var(--accent);
  height: 4px;
  margin-top: 6px;
}

/* 生成ボタン */
.btn-generate {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
}

.btn-generate:hover:not(:disabled) { background: var(--accent-hover); }
.btn-generate:active:not(:disabled) { transform: scale(0.98); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

.cost-info {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 10px;
}

.cost-info strong { color: var(--warning); }

/* スピナー */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================
   結果パネル
=========================== */
.result-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  flex-direction: column;
}

.result-placeholder {
  text-align: center;
  color: var(--text-sub);
}

.result-icon { font-size: 48px; display: block; margin-bottom: 12px; }

/* 進捗 */
.progress-area {
  text-align: center;
}

.progress-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.progress-hint { font-size: 12px; color: var(--text-sub); margin-top: 6px; }

/* 画像結果 */
.image-result, .video-result {
  width: 100%;
}

.image-result img {
  width: 100%;
  border-radius: var(--radius);
  display: block;
}

.video-result video {
  width: 100%;
  border-radius: var(--radius);
  display: block;
  background: #000;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn-download {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--success);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn-download:hover { opacity: 0.85; }

.btn-retry {
  padding: 10px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.btn-retry:hover { border-color: var(--accent); }

.result-meta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-sub);
  line-height: 1.8;
}

/* エラー */
.error-area {
  text-align: center;
}

.error-icon { font-size: 40px; display: block; margin-bottom: 10px; }

#errorMessage {
  color: var(--error);
  font-size: 14px;
}

/* ===========================
   Phase 2 追加スタイル
=========================== */

/* form-input（テキスト1行） */
.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  transition: border-color 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* form-label-hint */
.form-label-hint {
  font-size: 10px;
  color: var(--text-sub);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

/* 日本語テキストオプション */
.jptext-options {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg3);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.jptext-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.jptext-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label-sm {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-select-sm {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  appearance: none;
}

/* カラースウォッチ */
.color-options {
  display: flex;
  gap: 6px;
  align-items: center;
}

.color-option input { display: none; }

.color-swatch {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.12s, transform 0.1s;
}

.color-option input:checked + .color-swatch {
  border-color: var(--accent);
  transform: scale(1.2);
}

/* 動画アップロード進捗バー */
.upload-progress {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-progress-bar {
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}

#videoUploadLabel {
  font-size: 11px;
  color: var(--text-sub);
}

/* 動画プレビュー */
.upload-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}
