/* ══════════════════════════════════════════════════════════════════════════
   ui2.css — ChatCut採用パターン A1〜A3(現行UIの小改修)
   指示: KUGINA_COMMAND/指示_UI採用パターン_ChatCut棚卸し_2026-08-14.md
   ────────────────────────────────────────────────────────────────────────
   ★憲法第2条(黄ゾーン=既存レイアウト変更はデフォルトOFF): 本改修は URL ?ui2 で
     body.ui2 が付いたときだけ効く。★?ui2 が無ければ1バイトも効かない(全セレクタが
     body.ui2 配下=グローバルロードでも本番は無風)。城野が実機ONで裁定→OK後にデフォルトON。
   A1 書き出しを常に右上 / A2 残高チップの常設 / A3 エラー後の質問チップ+再試行。
   ★真似るのは配置と体験のみ。意匠・文言は自前。
   ══════════════════════════════════════════════════════════════════════════ */

/* ── A2: 残高チップの常設(先頭・pill・常に見える) ────────────────────────── */
/*   現行ヘッダーは flex:0 0 auto の非スクロール帯。狭幅では flex-wrap で残高が
     二段目へ回り込み目立たなくなる。?ui2 では残高を右クラスタの先頭に固定し
     チップ化=いつでも真っ先に見える。sticky は保険(スクロール文脈があれば効く)。 */
body.ui2.is-cloud-product .cloud-header {
  position: sticky;
  top: 0;
  z-index: 40;
}
body.ui2 .cloud-header-right { flex-wrap: nowrap; }
body.ui2 .cloud-balance:not([hidden]) {
  order: -2;                       /* 右クラスタの先頭へ */
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2, rgba(127,127,127,.08));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;                 /* 押すとプラン(A2: 押下でプラン画面) */
}
body.ui2 .cloud-balance:not([hidden])::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18);
  flex: none;
}
body.ui2 .cloud-plan-btn:not([hidden]) { order: -1; }   /* 残高のすぐ隣にプラン */

/* ── A1: 書き出しを常に右上 ──────────────────────────────────────────── */
.ui2-export-btn {
  order: -1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-foreground);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.ui2-export-btn:hover { filter: brightness(1.05); }
.ui2-export-btn:disabled,
.ui2-export-btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  filter: none;
}
.ui2-export-btn svg { width: 15px; height: 15px; }

/* 書き出し先(出口バー)へジャンプしたときの一瞬のハイライト */
.ui2-export-flash {
  animation: ui2-flash 1.2s ease-out 1;
  border-radius: 12px;
}
@keyframes ui2-flash {
  0%   { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .55); }
  100% { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0); }
}

/* ── A3: エラー後の「何が起きた?」チップ + 再試行 ──────────────────────── */
.ui2-error-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.ui2-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2, rgba(127,127,127,.06));
  color: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}
.ui2-chip:hover { border-color: var(--accent); }
.ui2-chip.is-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-foreground);
}
.ui2-error-note {
  flex-basis: 100%;
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2, #6b7280);
}
.ui2-error-note[hidden] { display: none; }

/* ── スマホ幅(≤640px)のヘッダー(2026-08-23・既定ON化の条件=8/16の宿題③) ────────────
   styles.css の城野裁定(2026-07-13)は「横スクロールは使わない・入り切らない分は2行目へ折る」。
   上の A2 の `flex-wrap: nowrap` は広い画面のためのもので、狭幅ではそれが styles.css の折返しを
   打ち消し、既存の「始める/ログイン」が潰れて1文字ずつ縦に折れていた(8/16 ③)。
   ★狭幅では折返しに戻し、各ボタンは縮ませない(=styles.css の設計どおり2行目へ)。
   ★横スクロールは出さない: 375px で documentElement.scrollWidth <= clientWidth を機械で確認(check_ui2_375)。 */
@media (max-width: 640px) {
  body.ui2 .cloud-header-right { flex-wrap: wrap; }
  body.ui2 .cloud-header-right > * { flex-shrink: 0; white-space: nowrap; }
  .ui2-export-btn { padding: 6px 11px; }
}
