/* 対話AIルーム 共通スタイル（フェーズ1） */

:root {
  --navy: #1E2761;
  --gold: #D4A843;
  --gold-dark: #B8902F;
  --bg: #F5F6FA;
  --panel: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --line: #D9DCE5;
  --ok: #1A7F37;
  --ok-bg: #E8F5EC;
  --info: #1E4E8C;
  --info-bg: #E8F0FB;
  --error: #B42318;
  --error-bg: #FDECEA;
  --danger: #B42318;
  /* 話者の色（在りさん・アルさんは users.color、AIは固定） */
  --color-ai: #7C3AED;
  --radius: 10px;
  --bottombar-h: 84px;
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, "Yu Gothic", sans-serif;
  line-height: 1.7;
}

h1 { font-size: 1.5rem; margin: 0 0 0.8rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.8rem; }
a { color: var(--navy); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 48px;
  padding: 0.5em 1.1em;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--navy); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2A3680; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-warn { background: var(--gold); border-color: var(--gold-dark); color: var(--navy); }
.btn-off { background: #FFF4E5; border-color: #E0A040; }
.btn-active { background: var(--info-bg); border-color: var(--info); }
.btn-small { min-height: 36px; padding: 0.2em 0.8em; font-size: 0.9rem; }
.btn-large { min-height: 56px; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* ---------- お知らせ ---------- */
.alert {
  margin: 0 0 1rem;
  padding: 0.8em 1em;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.alert-error { background: var(--error-bg); border-color: #F3B4AE; color: var(--error); }
.alert-ok { background: var(--ok-bg); border-color: #A9D8B6; color: var(--ok); }
.alert-info { background: var(--info-bg); border-color: #B5CCEB; color: var(--info); }

/* ---------- フォーム ---------- */
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.3rem; font-weight: bold; }
.field input, .bottombar-field input, .bottombar-field select {
  font: inherit;
  font-weight: normal;
  min-height: 48px;
  padding: 0.4em 0.7em;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.field input:focus { outline: 3px solid var(--gold); border-color: var(--navy); }

/* ---------- 上部バー ---------- */
.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  background: var(--navy);
  color: #fff;
}
.topbar-title { color: #fff; font-weight: bold; font-size: 1.15rem; text-decoration: none; }
.topbar-sub {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #E6E8F2;
}
.topbar-user { margin-left: auto; display: inline-flex; align-items: center; gap: 0.4em; }
.topbar-sub + .topbar-user { margin-left: 0; }
.user-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.topbar-logout { margin: 0; }
.topbar .btn-small { background: transparent; color: #fff; border-color: rgba(255,255,255,0.6); }
.topbar-link { text-decoration: none; }

/* ---------- ログイン・一覧・同意 ---------- */
.login-box {
  max-width: 440px;
  margin: 8vh auto 2rem;
  padding: 2rem;
  background: var(--panel);
  border-radius: var(--radius);
  border-top: 6px solid var(--navy);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.lead { color: var(--muted); }
.container { max-width: 880px; margin: 1.5rem auto; padding: 0 1rem; }
.container.narrow { max-width: 680px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.session-list { list-style: none; margin: 0; padding: 0; }
.session-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}
.session-item:first-child { border-top: none; }
.session-info { flex: 1; min-width: 0; }
.session-actions { display: grid; gap: 0.4rem; justify-items: stretch; text-align: center; }
.session-date { font-weight: bold; color: var(--navy); }
.session-title { font-size: 1.1rem; overflow-wrap: anywhere; }
.session-meta { font-size: 0.9rem; }
.session-stats { margin-top: 0.1rem; }
.session-stats strong { color: var(--navy); }
.session-item[hidden] { display: none; }
.session-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.4rem 0 0.2rem; }
.session-filter label { font-weight: bold; }
.session-filter input { flex: 1; min-width: 12rem; font: inherit; min-height: 48px; padding: 0.4em 0.7em; border: 2px solid var(--line); border-radius: var(--radius); }
.session-filter input:focus { outline: 3px solid var(--gold); border-color: var(--navy); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 1rem; }
.hist-stats strong { color: var(--navy); font-size: 1.1rem; }
.hist-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.6rem 0; }
.mat-details { margin-top: 0.5rem; }
.mat-details summary { cursor: pointer; color: var(--navy); font-weight: bold; padding: 0.3rem 0; }
body.page-history .container { max-width: 880px; }
body.page-history .utterances { margin-top: 0.8rem; }
.consent-text ul { padding-left: 1.3em; }
.form-actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }

/* ---------- 通話画面 ---------- */
body.page-room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
#room-app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.6rem 1rem calc(var(--bottombar-h) + 0.6rem);
}
.statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.5rem;
  margin-bottom: 0.5rem;
}
.conn { padding: 0.05em 0.6em; border-radius: 999px; background: #EEF0F5; }
.conn-connected { background: var(--ok-bg); color: var(--ok); }
.conn-connecting, .conn-reconnecting { background: #FFF4E5; color: #9A5B00; }
.conn-disconnected { background: var(--error-bg); color: var(--error); }
#room-message { margin-bottom: 0.5rem; }

.room-tabs { display: none; }

.room-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  column-gap: 1rem;
  row-gap: 0; /* 共有画面がないときに中央列がずれないよう、上下の間隔は共有画面側の margin でとる */
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr) minmax(280px, 380px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "call stage material"
    "call conv  material";
}
.room-grid.has-stage { grid-template-rows: minmax(0, 3fr) minmax(0, 1fr); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 0;
  overflow: auto;
}
.panel-call { grid-area: call; display: flex; flex-direction: column; }
.panel-stage { grid-area: stage; display: flex; flex-direction: column; padding: 0.6rem; margin-bottom: 1rem; background: #111827; color: #fff; }
.panel-conv { grid-area: conv; }
.panel-material { grid-area: material; }
.panel-title { font-size: 1.1rem; color: var(--navy); border-bottom: 2px solid var(--gold); padding-bottom: 0.2rem; }
.panel-head { display: flex; align-items: flex-end; gap: 0.6rem; border-bottom: 2px solid var(--gold); margin: 0 0 0.8rem; }
.panel-head .panel-title { flex: 1; border-bottom: none; margin: 0 0 0.2rem; padding: 0; }
.panel-head .btn { margin-bottom: 0.3rem; }
.placeholder { color: #9CA3AF; text-align: center; margin-top: 3rem; }

/* 参加者 */
.participants { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.participant {
  --pcolor: #6B7280;
  border: 3px solid var(--line);
  border-left: 10px solid var(--pcolor);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.participant-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.participant-name { font-weight: bold; font-size: 1.1rem; color: var(--pcolor); }
.participant-state { font-size: 0.9rem; color: var(--muted); }
.participant.is-muted .participant-state { color: var(--error); }
/* 話している人の枠が光る */
.participant.is-speaking {
  border-color: var(--pcolor);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pcolor) 35%, transparent), 0 0 18px var(--pcolor);
}
.participant-ai { margin-top: 0.6rem; }
.participant-ai.is-thinking { border-color: var(--color-ai); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-ai) 30%, transparent); animation: ai-pulse 1.4s ease-in-out infinite; }
.participant-ai.is-thinking .participant-state { color: var(--color-ai); font-weight: bold; }
@keyframes ai-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--color-ai) 15%, transparent); } }
.participant-video { margin-top: 0.4rem; }
.participant-video video { width: 100%; border-radius: 6px; background: #000; display: block; }
.participant-volume { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.3rem; font-size: 0.9rem; }
.participant-volume input { flex: 1; accent-color: var(--pcolor); }

.call-controls { display: grid; gap: 0.6rem; margin-top: auto; padding-top: 1rem; }
.call-controls .btn { font-size: 1rem; padding-left: 0.4em; padding-right: 0.4em; } /* 「マイクを入れる（いまオフ）」などが2行に折れないように */

/* 共有画面 */
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.stage-label { font-weight: bold; }
.panel-stage .btn-small { background: transparent; color: #fff; border-color: rgba(255,255,255,0.6); }
.stage-video { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #000; border-radius: 6px; }
.stage-video video { width: 100%; height: 100%; object-fit: contain; }

/* 会話の流れ */
/* 区切り線 */
.turn-divider { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0; color: var(--muted); font-size: 0.9rem; font-weight: bold; }
.turn-divider::before, .turn-divider::after { content: ""; flex: 1; border-top: 2px dashed var(--line); }
.turn-divider span { white-space: normal; text-align: center; }
/* 資料（本のページの写真） */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mat-add { display: grid; gap: 0.5rem; margin-bottom: 0.8rem; }
.mat-add-btn { cursor: pointer; }
.mat-add-btn:focus-within, .visually-hidden:focus + .mat-page-field { outline: none; }
.mat-page-field { display: flex; align-items: center; gap: 0.5rem; font-weight: bold; font-size: 0.9rem; }
.mat-page-field input { width: 6.5rem; font: inherit; font-weight: normal; min-height: 44px; padding: 0.3em 0.6em; border: 2px solid var(--line); border-radius: var(--radius); }
.materials { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; }
.mat-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.7rem; background: #FFFDF7; }
.mat-local { color: var(--muted); font-style: italic; }
.mat-head { display: flex; gap: 0.7rem; align-items: flex-start; }
.mat-thumb { flex: none; width: 96px; padding: 0; border: 2px solid var(--line); border-radius: 6px; background: #fff; cursor: zoom-in; overflow: hidden; display: flex; flex-direction: column; font: inherit; }
.mat-thumb-cap { display: block; font-size: 0.9rem; font-weight: bold; line-height: 1.3; padding: 0.15rem 0; background: #F3F4F6; color: var(--navy); text-align: center; }
.mat-thumb:focus-visible { outline: 3px solid var(--gold); }
a.mat-thumb { text-decoration: none; }
.mat-thumb img { width: 100%; height: auto; display: block; }
.mat-info { min-width: 0; flex: 1; }
.mat-page { display: flex; align-items: center; gap: 0.4rem; font-weight: bold; color: var(--navy); }
.mat-page-input { width: 5.5rem; font: inherit; font-weight: bold; min-height: 40px; padding: 0.2em 0.5em; border: 2px solid var(--line); border-radius: 6px; }
.mat-by { margin-top: 0.2rem; }
.mat-state { margin-top: 0.2rem; font-size: 0.9rem; color: var(--muted); }
.mat-state.mat-reading { color: var(--navy); font-weight: bold; }
.mat-state.mat-reading::after { content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-left: 0.5em; border: 2px solid var(--navy); border-right-color: transparent; border-radius: 50%; vertical-align: -0.1em; animation: ai-spin 0.9s linear infinite; }
.mat-state.mat-failed { color: var(--error); font-weight: bold; }
.mat-text { margin-top: 0.5rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.95rem; }
.mat-text.is-clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.btn-link { background: none; border: none; padding: 0.2rem 0; color: var(--navy); text-decoration: underline; font: inherit; font-size: 0.9rem; cursor: pointer; }
.mat-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.mat-edit { margin-top: 0.5rem; }
.mat-edit textarea { width: 100%; font: inherit; font-size: 0.95rem; padding: 0.4em 0.6em; border: 2px solid var(--line); border-radius: var(--radius); resize: vertical; }
.mat-edit textarea:focus { outline: 3px solid var(--gold); border-color: var(--navy); }
.mat-edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.4rem; }
.mat-viewer { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.88); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: zoom-out; padding: 1rem; }
.mat-viewer[hidden] { display: none; }
.mat-viewer img { max-width: 100%; max-height: calc(100% - 2.5rem); object-fit: contain; background: #fff; }
.mat-viewer-close { color: #fff; margin: 0.6rem 0 0; font-size: 0.9rem; }
body.is-viewing { overflow: hidden; }

/* 今日だけの追加指示（会話の流れの上） */
.session-note { margin: 0 0 0.8rem; padding: 0.5rem 0.8rem; border: 1px solid var(--gold); border-radius: var(--radius); background: #FFFBEF; }
.session-note-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.session-note-label { font-weight: bold; color: var(--navy); }
.note-view { margin-top: 0.2rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-view.note-empty { color: var(--muted); }
.note-form textarea { width: 100%; margin-top: 0.4rem; font: inherit; padding: 0.4em 0.6em; border: 2px solid var(--line); border-radius: var(--radius); resize: vertical; }
.note-form textarea:focus { outline: 3px solid var(--gold); border-color: var(--navy); }
.note-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.4rem; }

/* プロンプトの編集 */
.small { font-size: 0.9rem; }
.table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; }
.table th, .table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 0.9rem; color: var(--muted); white-space: nowrap; }
.table tr.is-hidden-kind td { color: var(--muted); background: #F9FAFB; }
.table tr.is-current-version td { background: #F5F3FF; }
.inline-form { display: inline-flex; gap: 0.3rem; margin: 0; }
.table .btn { white-space: nowrap; }
.add-kind { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.prompt-body { width: 100%; min-height: 20rem; font: inherit; font-size: 0.95rem; line-height: 1.7; padding: 0.6em 0.8em; border: 2px solid var(--line); border-radius: var(--radius); resize: vertical; font-weight: normal; }
.prompt-body:focus { outline: 3px solid var(--gold); border-color: var(--navy); }
.prompt-preview { white-space: pre-wrap; overflow-wrap: anywhere; background: #F3F4F6; padding: 0.6rem 0.8rem; border-radius: var(--radius); font: inherit; font-size: 0.9rem; margin: 0.4rem 0 0; }
.field select, .field input[type="text"] { font: inherit; font-weight: normal; min-height: 48px; padding: 0.4em 0.7em; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; }
.try-result { margin-top: 0.8rem; padding: 0.6rem 0.9rem; border: 2px solid var(--color-ai); border-radius: var(--radius); background: color-mix(in srgb, var(--color-ai) 6%, #fff); }
.try-text { white-space: pre-wrap; overflow-wrap: anywhere; }
body.page-prompts .container { max-width: 980px; }

/* 日付の区切り線 */
.day-divider { display: flex; align-items: center; gap: 0.6rem; margin: 0.8rem 0 0.2rem; color: var(--navy); font-weight: bold; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; border-top: 2px solid var(--gold); }
.day-divider span { white-space: normal; text-align: center; }
/* AIのカード（紫） */
.ai-item { list-style: none; }
.ai-question { margin: 0 0 0.4rem; padding: 0.4rem 0.8rem; border-left: 8px solid var(--pcolor, #6B7280); background: #F3F4F6; border-radius: 0 var(--radius) var(--radius) 0; overflow-wrap: anywhere; }
.ai-question strong { color: var(--pcolor, #374151); }
.ai-card { border: 2px solid var(--color-ai); border-radius: var(--radius); background: color-mix(in srgb, var(--color-ai) 6%, #fff); padding: 0.5rem 0.9rem 0.7rem; }
.ai-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.ai-badge { background: var(--color-ai); color: #fff; font-weight: bold; padding: 0 0.7em; border-radius: 999px; }
.ai-kind { font-weight: bold; color: var(--color-ai); }
.ai-time { margin-left: auto; font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ai-body { margin-top: 0.3rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-body.ai-thinking { color: var(--color-ai); font-style: italic; }
.ai-body.ai-thinking::after { content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-left: 0.5em; border: 2px solid var(--color-ai); border-right-color: transparent; border-radius: 50%; vertical-align: -0.1em; animation: ai-spin 0.9s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-body.ai-failed { color: var(--error); font-weight: bold; }
.ai-card.ai-failed { border-color: var(--error); background: var(--error-bg); }
.ai-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.utterances { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.utt {
  --pcolor: #6B7280;
  border-left: 8px solid var(--pcolor);
  background: color-mix(in srgb, var(--pcolor) 7%, #fff);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.4rem 0.8rem 0.5rem;
}
.utt-head { display: flex; align-items: baseline; gap: 0.8rem; }
.utt-name { font-weight: bold; color: var(--pcolor); }
.utt-time { font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.utt-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.utt-processing .utt-text { color: var(--muted); font-style: italic; }
.utt-failed .utt-text { color: var(--error); }
.btn-new-utt {
  position: sticky;
  bottom: 0.5rem;
  display: flex;
  margin: 0.6rem auto 0;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.tab.has-new::after { content: " ●"; color: var(--gold); }

/* 自分のマイク（文字起こし）の状態 */
.rec { padding: 0.05em 0.6em; border-radius: 999px; background: #EEF0F5; }
.rec-on { background: var(--error-bg); color: var(--error); }
.rec-on::before { content: "● "; }
.rec-wait { background: var(--ok-bg); color: var(--ok); }

/* 画面下の固定バー */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  z-index: 10;
}
.bottombar-inner { display: flex; align-items: stretch; gap: 0.8rem; padding: 0.6rem 1rem; }
/* 下の帯は左右2つの枠：左＝区切ってAIにまとめてもらう（金茶）／右＝AIに直接質問する（紫） */
.bar-block { border: 2px solid; border-radius: 12px; padding: 0.4rem 0.8rem 0.6rem; min-width: 0; }
.bar-cut { flex: 1.15 1 0; background: #FBF3DC; border-color: var(--gold-dark); }
.bar-ask { flex: 1 1 0; background: #F3EEFD; border-color: var(--color-ai); display: flex; flex-direction: column; justify-content: flex-start; }
.bar-title { margin: 0 0 0.35rem; font-size: 1rem; line-height: 1.3; color: var(--navy); }
.bar-ask .bar-title { color: #5B21B6; }
.bar-ask .bottombar-question { flex: 0 0 auto; }
.bar-ask .btn-ask-send { font-size: 1.1rem; padding: 0.2em 1em; }
.bar-cut .bottombar-field { margin-bottom: 0.4rem; }
.bar-cut-row { display: flex; align-items: center; gap: 0.5rem; }
.bar-cut-row .btn-ask { flex: 1 1 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn-ask {
  min-height: 60px;
  padding: 0.4em 1.6em;
  font-size: 1.25rem;
  background: var(--gold);
  border-color: var(--gold-dark);
  color: var(--navy);
}
.btn-ask:disabled { background: #E5E7EB; border-color: #D1D5DB; color: #6B7280; opacity: 1; }
.badge { font-size: 0.8rem; padding: 0.1em 0.6em; border-radius: 999px; background: #fff; color: var(--muted); border: 1px solid #D1D5DB; }
.bottombar-field { display: flex; align-items: center; gap: 0.5rem; font-weight: bold; }
.bottombar-question { flex: 1; }
.bottombar-question input { flex: 1; min-width: 0; }
.btn-ask:not(:disabled):hover { background: #E0B74F; border-color: var(--gold-dark); }
.btn-ask.is-busy .ask-label { display: none; }
.btn-ask .ask-busy { font-size: 1.1rem; font-weight: bold; padding: 0; background: none; border: none; color: var(--color-ai); }
.btn-ask-send { flex: none; background: var(--color-ai); border-color: var(--color-ai); color: #fff; }
.btn-ask-send:disabled { background: #E5E7EB; border-color: #D1D5DB; color: #6B7280; opacity: 1; }
.btn-more { display: none; }

/* PC幅（v10）：左の枠も1段にして、下の帯を低くする。左右の枠の高さと、中の行の高さ・下端をそろえる */
@media (min-width: 900px) {
  .bottombar-inner { padding: 0.45rem 1rem; }
  .bar-block { padding: 0.3rem 0.8rem 0.5rem; display: grid; grid-template-rows: auto 1fr; align-content: stretch; }
  .bar-title { margin-bottom: 0.3rem; }
  .bar-ask { grid-template-columns: minmax(0, 1fr); }
  .bar-cut { grid-template-columns: auto minmax(0, 1fr); column-gap: 0.8rem; }
  .bar-cut .bar-title { grid-column: 1 / -1; }
  .bar-cut .bottombar-field { margin-bottom: 0; align-self: end; }
  .bar-cut-row { align-self: end; min-width: 0; }
  .bar-ask .bottombar-question { align-self: end; min-width: 0; width: 100%; }
  .bar-cut select, .bar-ask input, .bar-ask .btn-ask-send, .bar-cut .btn-ask { min-height: 52px; box-sizing: border-box; }
  .bar-cut .btn-ask { padding: 0.2em 0.8em; font-size: 1.15rem; font-weight: bold; width: 100%; }
  .bar-ask .btn-ask-send { padding: 0.2em 1em; }
  .bar-cut .btn-ask .ask-label { white-space: nowrap; }
}
/* あまり広くないPCでは、大ボタンの「→ AIに聞く」を省く（1行に収めるため。見出しで意味は伝わる） */
@media (min-width: 900px) and (max-width: 1199px) {
  .bar-cut .ask-long { display: none; }
}

/* ---------- スマホ幅：上部タブで切り替え ---------- */
/* 下の帯の実際の高さは room.js が測って --bottombar-h に入れる（中身が帯に隠れないように） */
@media (max-width: 899px) {
  :root { --bottombar-h: 72px; }

  /* スマホでは画面の高さに固定せず、ページ全体を普通に縦スクロールさせる */
  body.page-room { display: block; height: auto; overflow: visible; }
  #room-app { display: block; padding: 0.5rem 0.6rem calc(var(--bottombar-h) + 1rem); }

  .room-tabs {
    display: flex;
    gap: 0.4rem;
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 -0.6rem 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg);
  }
  .tab {
    flex: 1;
    min-height: 48px;
    font: inherit;
    font-weight: bold;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
  }
  .tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

  .room-grid,
  .room-grid.has-stage {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }
  .room-grid[data-active-tab="call"] .panel:not([data-panel="call"]),
  .room-grid[data-active-tab="conv"] .panel:not([data-panel="conv"]),
  .room-grid[data-active-tab="material"] .panel:not([data-panel="material"]) { display: none; }
  .panel { overflow: visible; }
  .placeholder { margin: 1.5rem 0; }

  /* 共有画面は通話タブの一番上に、16:9 で出す */
  .panel-stage { order: -1; margin-bottom: 0; }
  .stage-video { flex: none; height: 56vw; max-height: 60vh; }

  /* 入室ボタンなどの操作は、通話の列の一番上（見出しのすぐ下）に出す */
  .panel-call .panel-title { order: -2; }
  .call-controls { order: -1; margin: 0 0 0.8rem; padding-top: 0; }

  /* 下の帯は、上＝左の枠（AIの返し方＋ひとまずここまで）／下＝右の枠（質問）。質問の枠は「AIに質問する」を押すと開く */
  .bottombar-inner {
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  }
  .bar-block { padding: 0.3rem 0.6rem 0.5rem; }
  .bar-title { font-size: 1rem; margin-bottom: 0.25rem; }
  /* 画面でいちばん大きいボタンにする（ほかの大きなボタンは、高さ48pxにそろえる） */
  .btn:not(.btn-small) { padding-top: 0.3em; padding-bottom: 0.3em; }
  .btn-large { min-height: 48px; }
  .btn-ask { flex: 1 1 auto; min-width: 0; min-height: 72px; padding: 0.2em 0.6em; font-size: 1.1rem; }
  .ask-long { display: none; }
  .badge { font-size: 0.9rem; padding: 0 0.4em; }
  .btn-more { display: inline-flex; flex: none; align-items: center; min-height: 72px; padding: 0.2em 0.5em; font-size: 1rem; white-space: nowrap; }
  .btn-ask .ask-label { white-space: nowrap; }
  .bar-ask .bottombar-question input, .bar-ask .btn-ask-send { min-height: 48px; }
  .bar-ask { display: none; }
  .bottombar.is-open .bar-ask { display: flex; }
  .bottombar-field { font-size: 0.95rem; }
  .bottombar-field select, .bottombar-field input { flex: 1; min-width: 0; min-height: 44px; }

  .btn-new-utt { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottombar-h) + 0.6rem); margin: 0; z-index: 9; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 2px solid var(--line); padding: 0.4rem 0; }
  .table td { border-bottom: none; padding: 0.2rem 0.2rem; }
  .table td[data-label]::before { content: attr(data-label) "："; color: var(--muted); font-size: 0.9rem; }
  .session-item { flex-direction: column; align-items: stretch; }
  .topbar-sub { flex-basis: 100%; order: 3; }
}

/* v08 C：管理画面 */
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 0; }
.admin-setting { padding: 0.8rem 0; border-top: 1px solid var(--line); }
.admin-try-result { margin: 0.5rem 0 0; }
.admin-pw { display: inline-block; margin-left: 0.3rem; }
.admin-pw summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; }
.admin-pw[open] { display: block; margin: 0.5rem 0 0; }
.field input[type="color"] { min-height: 48px; width: 6rem; padding: 0.2rem; }

/* v11：発言する（チャット）／Zoomの文字起こしを貼る */
.panel-conv .panel-head { flex-wrap: wrap; }
.chat-box {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0.8rem -1rem -1rem; /* 会話の列の左右いっぱいに広げ、下に固定する（列の余白を打ち消す） */
  padding: 0.5rem 1rem 0.8rem;
  background: #EEF3FB;
  border-top: 2px solid var(--navy);
}
.chat-label { display: block; margin: 0 0 0.3rem; font-weight: bold; color: var(--navy); font-size: 0.95rem; }
.chat-row { display: flex; align-items: stretch; gap: 0.5rem; }
.chat-row textarea {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0.4em 0.6em;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 3.2em;
  max-height: 40vh;
}
.chat-row textarea:focus { outline: 3px solid var(--gold); border-color: var(--navy); }
.chat-send { flex: none; min-width: 5em; }
/* 「新しい発言があります」は、発言欄の上に出す */
.panel-conv .btn-new-utt { bottom: calc(var(--chat-h, 7rem) + 0.5rem); }

.zoom-modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; }
.zoom-modal[hidden] { display: none; }
.zoom-dialog { width: min(720px, 100%); background: #fff; border-radius: var(--radius); padding: 1rem 1.2rem 1.2rem; margin: auto 0; }
.zoom-dialog h2 { margin: 0 0 0.6rem; color: var(--navy); font-size: 1.2rem; }
.zoom-dialog textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 0.5em 0.7em; border: 2px solid var(--line); border-radius: var(--radius); resize: vertical; min-height: 12em; }
.zoom-dialog textarea:focus { outline: 3px solid var(--gold); border-color: var(--navy); }
.zoom-file-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0; }
.zoom-file-row label.btn { cursor: pointer; }
.zoom-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
.zoom-summary { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; padding: 0.6rem 0.8rem; background: #FBF3DC; border: 1px solid var(--gold-dark); border-radius: var(--radius); }
.zoom-count strong { color: var(--navy); font-size: 1.1rem; }
.zoom-count.zoom-new strong { font-size: 1.3rem; }
.zoom-count.zoom-attn strong { color: var(--error); }
.zoom-options { margin: 0.8rem 0; padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius); }
.zoom-options legend { font-weight: bold; color: var(--navy); padding: 0 0.3rem; }
.zoom-options label { display: block; padding: 0.25rem 0; }
.zoom-h { margin: 0.8rem 0 0.3rem; font-size: 1rem; color: var(--navy); }
.zoom-name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.zoom-name { font-weight: bold; }
.zoom-name-auto { color: var(--ok); }
.zoom-name-select { font: inherit; min-height: 44px; padding: 0.2em 0.5em; border: 2px solid var(--line); border-radius: var(--radius); }
.zoom-remember { display: block; margin-top: 0.4rem; font-size: 0.9rem; }
.zoom-sample-list { margin: 0; padding-left: 1.2rem; font-size: 0.92rem; }
.zoom-sample-list li { overflow-wrap: anywhere; }

@media (max-width: 899px) {
  .chat-box { bottom: var(--bottombar-h); } /* スマホは下の固定バーのすぐ上に出す */
  .chat-row textarea { min-height: 3em; }
  .chat-send { min-height: 48px; }
  .panel-conv .btn-new-utt { bottom: calc(var(--bottombar-h) + var(--chat-h, 7rem) + 0.6rem); }
  .zoom-modal { padding: 0.5rem; }
  .zoom-name-select { min-height: 48px; }
}
.zoom-names-form { display: flex; gap: 0.3rem; align-items: center; }
.zoom-names-form input[type="text"] { font: inherit; min-width: 10rem; min-height: 40px; padding: 0.2em 0.5em; border: 2px solid var(--line); border-radius: var(--radius); }
/* 発言欄は、発言が少ないときも会話の列の一番下に置く */
.panel-conv { display: flex; flex-direction: column; }
.panel-conv > * { flex-shrink: 0; }
.panel-conv .chat-box { margin-top: auto; }
.panel-conv .utterances + .btn-new-utt + .chat-box { margin-top: auto; }

/* v12：PCでは「会話の流れ」の枠を縦並び（見出し・一覧 → 発言欄）にし、一覧だけをスクロールさせる。発言欄は一覧と重ならない */
@media (min-width: 900px) {
  .panel-conv { overflow: hidden; }
  .panel-conv .conv-scroll { flex: 1 1 0; min-height: 0; overflow: auto; }
  .panel-conv .chat-box { position: static; flex: none; margin: 0.5rem -1rem -1rem; }
  .panel-conv .btn-new-utt { bottom: 0.5rem; }
}

/* v12：発言欄の案内文と、スマホでの高さ */
.chat-hint { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--muted); }
@media (max-width: 899px) {
  .chat-hint { display: none; }
  .chat-label { font-size: 0.85rem; margin: 0 0 0.15rem; }
  .chat-box { padding: 0.3rem 1rem 0.4rem; }
  .chat-row textarea { min-height: 44px; }
  .chat-box.is-open .chat-row textarea { min-height: 92px; }
  .chat-box.kb-open { bottom: var(--kb, 0px); z-index: 11; }
}
