/* ============================================================
   app.css — タブUI専用スタイル（style.css の変数を利用）
   ============================================================ */

/* タブ */
.tabs {
  display: flex; gap: 4px; max-width: 1080px; margin: 0 auto;
  padding: 0 40px; border-bottom: 1px solid var(--line);
}
.tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-family: inherit; font-size: 15px;
  padding: 16px 20px; cursor: pointer; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--note-green); border-bottom-color: var(--note-green); font-weight: 700; }

.panel { display: none; }
.panel.active { display: block; }

/* セットアップ案内 */
.setup-guide { display: grid; gap: 12px; margin-bottom: 24px; }
.step {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 20px;
}
.step.done { opacity: .6; }
.step .num {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700;
  background: var(--note-green); color: var(--btn-fg);
}
.step > div { flex: 1; }
.step .ok { color: var(--note-green); font-weight: 700; }

/* 生成カード */
.make-card { text-align: center; }
/* 入力欄はカード中央に置いた「左揃えの1カラム」にまとめる（散らからないように） */
.make-form { max-width: 600px; margin: 4px auto 22px; text-align: left; }
.opt-row { display: flex; gap: 28px; justify-content: center; flex-wrap: wrap; margin: 20px 0 24px; }
.make-form .opt-row { justify-content: flex-start; margin: 0 0 18px; }
.opt { text-align: left; }
.opt > label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.len-custom { margin-top: 8px; max-width: 220px; }

/* 1つの設定ブロック */
.field { margin: 0 0 18px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 12px; color: var(--text-dim); margin: 0 0 8px; }
.field textarea { resize: vertical; }

.field .metric-note { margin-top: 4px; }
.field .opt-row { margin: 0; }

/* トグルスイッチ（登録キャラを使う 等） */
.field label.toggle {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  margin: 0; font-size: 13.5px; color: var(--text);
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 42px; height: 24px; border-radius: 999px; background: var(--line);
  position: relative; flex: none; transition: background .15s;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.toggle input:checked + .toggle-track { background: var(--note-green); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--note-green-dim); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  background: var(--bg-raised); border: 0; border-right: 1px solid var(--line);
  color: var(--text-dim); font-family: inherit; font-size: 13px; line-height: 1.3;
  padding: 10px 16px; cursor: pointer;
}
.seg button span { font-size: 11px; color: var(--text-faint); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--note-green); color: var(--btn-fg); font-weight: 700; }
.seg button.on span { color: var(--btn-fg); }

.btn.big { font-size: 16px; padding: 15px 40px; }
.est { margin-top: 12px; font-size: 12px; }

.gen-status {
  margin-top: 20px; padding: 16px; border-radius: 10px;
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--text-dim);
}
.gen-status.err { border-color: var(--danger); color: var(--danger); }
.spinner {
  display: inline-block; width: 16px; height: 16px; margin-right: 8px;
  border: 2px solid var(--line); border-top-color: var(--note-green);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 生成結果 */
.result-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.result-head h2 { margin: 0; }
.header-img {
  width: 100%; max-width: 560px; border-radius: 10px;
  border: 1px solid var(--line); margin-bottom: 16px; display: block;
}
.article {
  background: var(--log-bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; margin-top: 16px; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 14px; line-height: 1.9; max-height: 60vh; overflow: auto;
}

.article-list li { cursor: pointer; }
.article-list li:hover .title { color: var(--note-green); }

/* 実績・学習の統計 */
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 20px 0; }
.stat {
  flex: 1; min-width: 120px; text-align: center;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 10px; padding: 18px;
}
.stat .n { font-size: 28px; font-weight: 700; color: var(--note-green); }
.stat .l { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* モード切替 */
.mode-row { display: grid; gap: 10px; margin-top: 8px; }
.mode-btn {
  justify-content: flex-start; text-align: left; flex-direction: column;
  align-items: flex-start; gap: 3px; padding: 14px 18px;
}
.mode-btn span { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.mode-btn.on { border-color: var(--note-green); background: rgba(65,201,180,.08); }
.mode-btn.on span { color: var(--note-green-dim); }

.btn.sm { padding: 8px 16px; font-size: 13px; }
.dim { color: var(--text-dim); font-size: 13.5px; }

@media (max-width: 700px) {
  .tabs { padding: 0 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: 14px 12px; font-size: 14px; white-space: nowrap; }

  .make-form { max-width: 100%; }
  .make-form .opt-row { flex-direction: column; gap: 16px; }
  .opt { width: 100%; }
  /* 種類・長さ・画像のセグメントは指で押しやすいよう横いっぱいに */
  #segType, #segLen, #segGenImg { display: flex; width: 100%; }
  #segType button, #segLen button, #segGenImg button { flex: 1; padding: 11px 8px; }
  .len-custom { max-width: 100%; }

  .btn.big { width: 100%; padding: 15px 20px; }
  .header-img { max-width: 100%; }
  .stat { min-width: calc(50% - 8px); }  /* 4つを2×2に */
  .article-list li { flex-wrap: wrap; row-gap: 6px; }
  .article-list li .title { flex-basis: 100%; order: 3; white-space: normal; }
}
