/* =========================================================
   電器マン ボイス生成アプリ
   白基調・モバイルファースト・大きなタップターゲット
   アクセント: 電圧アンバー(#F0A400) × 濃紺(#1B2440)
   ========================================================= */
:root {
  --ink: #1b2440;          /* 濃紺(文字) */
  --ink-soft: #5a6378;     /* 補助文字 */
  --bg: #ffffff;           /* 白基調 */
  --bg-soft: #f4f6fa;      /* 薄いグレー */
  --line: #dfe4ee;         /* 罫線 */
  --volt: #f0a400;         /* 電圧アンバー(主ボタン) */
  --volt-deep: #c78600;
  --blue: #2b62d9;         /* 補助アクション */
  --ok: #1a9e5c;
  --err: #d8402f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 36, 64, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg-soft);
  line-height: 1.65;
}
h1, h2, h3 { margin: 0; line-height: 1.35; }
p { margin: .4em 0; }
.hidden { display: none !important; }

/* ---------- ヘッダー ---------- */
.app-header {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-title { display: flex; align-items: center; gap: 10px; }
.app-title h1 { font-size: 1.05rem; letter-spacing: .02em; }
.app-sub { margin: 0; font-size: .68rem; color: #b8c2dd; letter-spacing: .12em; }
.brand-bolt {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--volt); color: var(--ink);
  font-size: 1.3rem; flex: none;
}
.app-nav { display: flex; gap: 8px; }
.nav-btn {
  min-height: 40px; padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 10px;
  background: transparent; color: #fff;
  font-size: .82rem; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
}
.nav-btn:active { background: rgba(255,255,255,.15); }

/* ---------- レイアウト ---------- */
.app-main { max-width: 760px; margin: 0 auto; padding: 14px 12px 60px; }
.card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 1.05rem; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.step-tag {
  background: var(--ink); color: var(--volt);
  font-size: .66rem; letter-spacing: .14em;
  padding: 3px 8px; border-radius: 6px; flex: none;
}
.hint { color: var(--ink-soft); font-size: .8rem; }

/* ---------- フォーム ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  font-size: 16px; /* iPhoneのズーム防止 */
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff; color: var(--ink);
  font-family: inherit;
}
textarea { resize: vertical; min-height: 180px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 3px solid rgba(43, 98, 217, .45); outline-offset: 1px;
}
.input-meta {
  display: flex; justify-content: space-between; flex-wrap: wrap;
  gap: 6px; font-size: .78rem; color: var(--ink-soft); margin-bottom: 10px;
}
#charCount { font-weight: 700; color: var(--ink); }

/* ---------- ボタン ---------- */
.btn {
  min-height: 48px;             /* スマホで押しやすい高さ */
  padding: 10px 18px;
  border: none; border-radius: 12px;
  font-size: .95rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: filter .15s;
}
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-big { min-height: 56px; font-size: 1.05rem; flex: 1 1 auto; }
.btn-block { width: 100%; }
.btn-primary { background: var(--volt); color: var(--ink); box-shadow: 0 3px 0 var(--volt-deep); }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-danger { background: var(--err); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-mini {
  min-height: 40px; padding: 6px 12px; font-size: .8rem;
  border-radius: 10px;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.sticky-actions { position: sticky; bottom: 8px; background: rgba(255,255,255,.94); padding: 8px; border-radius: 12px; }

/* ---------- 分割結果 ---------- */
.summary-bar {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  background: var(--bg-soft); border-radius: 10px;
  padding: 10px 12px; font-size: .85rem; font-weight: 600;
}
.cost { color: var(--volt-deep); }
.segment-edit-list { margin-top: 12px; display: grid; gap: 10px; }
.seg-edit {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px;
}
.seg-edit-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .78rem; color: var(--ink-soft); margin-bottom: 6px;
}
.seg-no { font-weight: 800; color: var(--ink); }
.seg-edit textarea { min-height: 90px; font-size: 15px; }
.seg-over { color: var(--err); font-weight: 700; }

/* ---------- 進捗 ---------- */
.progress-area { margin-bottom: 8px; }
.progress-label { font-size: .88rem; font-weight: 700; margin-bottom: 6px; }
.progress-track {
  height: 14px; border-radius: 999px; background: var(--bg-soft);
  border: 1px solid var(--line); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(45deg, var(--volt), var(--volt) 12px, #ffc94d 12px, #ffc94d 24px);
  transition: width .3s;
}

/* ---------- 生成結果 ---------- */
.result-list { display: grid; gap: 10px; margin-top: 14px; }
.result-item {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px;
  background: #fff;
}
.result-item.playing { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(43,98,217,.18); }
.result-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
}
.result-no { font-weight: 800; }
.badge {
  font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.badge-pending { background: var(--bg-soft); color: var(--ink-soft); }
.badge-generating { background: #fff3d6; color: var(--volt-deep); }
.badge-done { background: #e2f6ec; color: var(--ok); }
.badge-error { background: #fde8e5; color: var(--err); }
.result-chars { font-size: .74rem; color: var(--ink-soft); margin-left: auto; }
.result-text {
  font-size: .84rem; color: var(--ink-soft);
  max-height: 4.8em; overflow: hidden; margin-bottom: 8px;
}
.result-error { color: var(--err); font-size: .8rem; font-weight: 600; margin-bottom: 6px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.output-actions { border-top: 1px dashed var(--line); padding-top: 14px; margin-top: 16px; }

/* ---------- 結合 ---------- */
.merge-area { border-top: 1px dashed var(--line); margin-top: 16px; padding-top: 12px; }
.merge-area h3 { font-size: .95rem; }
.merge-result { margin-top: 8px; display: grid; gap: 8px; }
.merge-file {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg-soft); border-radius: 10px; padding: 10px;
  font-size: .84rem; font-weight: 600;
}

/* ---------- パネル(設定・履歴) ---------- */
.panel-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(27,36,64,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.panel {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0;
  max-height: 88vh; display: flex; flex-direction: column;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 1rem; }
.panel-close {
  width: 44px; height: 44px; border: none; border-radius: 10px;
  background: var(--bg-soft); font-size: 1rem; cursor: pointer;
}
.panel-body { padding: 16px; overflow-y: auto; }
.setting { margin-bottom: 18px; }
.setting label { font-weight: 700; font-size: .88rem; display: block; margin-bottom: 4px; }
.setting input[type="range"] { width: 100%; accent-color: var(--volt); height: 34px; }
.setting-toggle { display: block; }
.setting-toggle input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--volt); }
.setting output { color: var(--volt-deep); }

/* ---------- 履歴 ---------- */
.history-list { display: grid; gap: 10px; }
.history-item {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px;
}
.history-title { font-weight: 700; font-size: .92rem; }
.history-meta { font-size: .76rem; color: var(--ink-soft); margin: 4px 0 8px; }

/* ---------- ログイン ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ink); padding: 20px;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 28px 22px;
  width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.brand { text-align: center; margin-bottom: 18px; }
.brand h1 { font-size: 1.2rem; margin-top: 10px; }
.brand-sub { font-size: .68rem; letter-spacing: .2em; color: var(--ink-soft); }
.alert {
  background: #fde8e5; color: var(--err);
  border-radius: 10px; padding: 10px 12px; font-size: .84rem; font-weight: 600;
}

/* ---------- フッター ---------- */
.app-footer {
  text-align: center; font-size: .7rem; color: var(--ink-soft);
  padding: 20px 0 32px;
}

/* ---------- PC向け調整 ---------- */
@media (min-width: 640px) {
  .app-title h1 { font-size: 1.2rem; }
  .panel-backdrop { align-items: center; }
  .panel { border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 発音チェックのレポート */
.verify-report {
  background: #f6f8fb;
  border: 1px solid #dfe6ef;
  border-radius: 10px;
  padding: 10px 14px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 14px;
}
.verify-line { margin: 4px 0; }

/* ボタン内スピナー(ぐるぐる) */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(27, 36, 64, 0.25);
  border-top-color: #1b2440;
  border-radius: 50%;
  vertical-align: -3px;
  animation: dv-spin 0.8s linear infinite;
}
.btn-loading { opacity: 0.85; }
@keyframes dv-spin { to { transform: rotate(360deg); } }

/* 進捗バーをなめらかに動かす */
.progress-fill { transition: width 0.4s ease; }

/* 読み替え辞書 */
.dict-list { margin: 10px 0; max-height: 300px; overflow-y: auto; }
.dict-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.dict-row input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  font-size: 15px;
}
.dict-arrow { color: #8a94a6; flex-shrink: 0; }
.dict-bulk { margin-top: 14px; }
.dict-bulk summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.dict-bulk textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  font-size: 15px;
  margin: 8px 0;
}

/* チャンネル切り替え */
.channel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.channel-row label { font-weight: 700; flex-shrink: 0; }
.channel-row select {
  flex: 1;
  padding: 12px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
}

/* AI変換モード選択 */
.convert-mode {
  padding: 12px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
}

/* Vrewプロンプト表示 */
#vrewArea textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  background: #f6f8fb;
}

/* 動画の仕込みツール */
.prep-tools {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fbf7ee;
  border: 1px solid #eadfc8;
  border-radius: 12px;
}
#ytArea textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  background: #f6f8fb;
}
