* { box-sizing: border-box; }

/* ★2026-08-12 障害対応: 合言葉を入れて「入る」を押してもログイン画面が消えない不具合の修正。
   app.js は要素の hidden プロパティ（5箇所: gate / app / gate-error / debug-panel / banner）で
   表示を切り替えているが、ブラウザ標準の [hidden]{display:none} は「要素型セレクタ相当」の弱い指定で、
   .gate{display:flex} のようなクラス指定に負ける。
   → 結果、hidden 属性は付くのに見た目が消えず、ログイン画面とチャット画面が同時に出ていた。
   この1行で app.js の hidden 切り替えすべてが正しく効くようになる。
   ⚠️ .gate 等に display を足すときは、この規則より下に書いても勝てない（!important のため）。
      表示制御は必ず hidden プロパティ側で行うこと。 */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: #7494B0;
  margin: 0;
  padding: 0;
  color: #1E293B;
  min-height: 100vh;
}

h1 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #1E2A33;
}

/* --- 合言葉ゲート --- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-box {
  background: white;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.gate-avatar { margin-bottom: 8px; }

.gate-desc {
  color: #64748B;
  font-size: 13px;
  margin-bottom: 16px;
}

.gate-box input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

/* --- 全体レイアウト --- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #E8F1E9;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0,0,0,0.15);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #06C755;
  color: white;
  padding: 10px 14px;
}

.chat-header-avatar {
  background: white;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header-title { flex: 1; min-width: 0; }

.chat-header-name {
  font-weight: bold;
  font-size: 15px;
  line-height: 1.3;
}

.chat-header-sub {
  font-size: 10px;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- バージョン・コントロールバー --- */
.version-bar {
  background: #FEF9C3;
  color: #713F12;
  font-size: 11px;
  padding: 6px 14px;
  text-align: center;
  border-bottom: 1px solid #FDE68A;
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #F1F5F9;
  padding: 6px 14px;
  font-size: 11px;
  border-bottom: 1px solid #E2E8F0;
  flex-wrap: wrap;
}

.debug-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  cursor: pointer;
}

.log-status {
  font-weight: bold;
  color: #0F766E;
}

.log-status.log-status-off {
  color: #B91C1C;
}

/* --- 月間予算（実額）の消化状況 --- */
.budget-status {
  font-weight: bold;
  color: #0F766E;
}

/* warnAtPercent（budget.json）を超えたときに目立つ色にする。log-status-offと同じ赤で統一。 */
.budget-status.budget-status-warn {
  color: #B91C1C;
}

/* --- バナー --- */
.banner {
  margin: 8px 14px 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
}

.banner-info { background: #E0F2FE; color: #075985; border: 1px solid #7DD3FC; }
.banner-warn { background: #FEF3C7; color: #92400E; border: 1px solid #F59E0B; }
.banner-error { background: #FEF2F2; color: #B91C1C; border: 1px solid #FCA5A5; }
.banner-crisis { background: #7F1D1D; color: #FFF; border: 1px solid #450A0A; font-weight: bold; }

/* --- チャットログ --- */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 320px;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.bubble-row-user {
  justify-content: flex-end;
}

.bubble-row-assistant {
  justify-content: flex-start;
}

.bubble-avatar {
  background: white;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.bubble {
  max-width: 74%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.bubble-user {
  background: #06C755;
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble-assistant {
  background: white;
  color: #1E293B;
  border-bottom-left-radius: 4px;
}

.bubble-pending {
  min-width: 40px;
  min-height: 20px;
}

.bubble-pending:empty::after {
  content: "…";
  color: #94A3B8;
}

/* --- あいさつ直後の選択肢ボタン --- */
.choice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 32px; /* アシスタント吹き出しの開始位置（アバター26px+gap6px）に揃える */
}

.choice-btn {
  background: white;
  color: #06C755;
  border: 1.5px solid #06C755;
  border-radius: 999px;
  padding: 10px 15px;
  min-height: 40px;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}

.choice-btn:hover {
  background: #E9FBF0;
}

.choice-btn:active {
  background: #06C755;
  color: white;
}

/* --- デバッグパネル --- */
.debug-panel {
  max-height: 140px;
  overflow-y: auto;
  background: #0F172A;
  color: #A7F3D0;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10.5px;
  padding: 8px 12px;
  line-height: 1.6;
}

.debug-line { white-space: pre-wrap; word-break: break-all; }
.debug-line.debug-warn { color: #FCD34D; }
.debug-line.debug-crisis { color: #FCA5A5; font-weight: bold; }

/* --- 入力欄 --- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #F8FAFC;
  border-top: 1px solid #E2E8F0;
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid #CBD5E1;
  border-radius: 18px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  max-height: 120px;
  line-height: 1.5;
}

.composer textarea:focus {
  outline: none;
  border-color: #06C755;
  box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.2);
}

/* --- 汎用ボタン --- */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 18px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary { background: #06C755; color: white; }
.btn-primary:hover { background: #05A847; }
.btn-primary:disabled { background: #94A3B8; cursor: not-allowed; }

.btn-small {
  padding: 5px 12px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
  font-family: inherit;
}

.btn-small.secondary { background: rgba(255,255,255,0.25); color: white; }
.btn-small.secondary:hover { background: rgba(255,255,255,0.4); }

.error-text {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #B91C1C;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.disclaimer {
  padding: 10px 14px 16px;
  font-size: 10.5px;
  color: #64748B;
  text-align: center;
  background: #F1F5F9;
}

@media (max-width: 520px) {
  .app { box-shadow: none; }
}
