* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: sans-serif; background: #f0f2f5; min-height: 100vh; display: flex; align-items: center; justify-content: center; }

/* 画面識別バッジ */
.screen-badge { display: inline-block; font-size: 11px; font-weight: 700; color: #6366f1; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 12px; padding: 2px 10px; margin-bottom: 10px; letter-spacing: 0.03em; }
.screen-badge--inline { margin-bottom: 0; }

/* スクリーンリーダー専用（視覚的には非表示） */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none; }

#login { background: white; border-radius: 12px; padding: 28px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); width: 340px; }
#login h2 { margin-bottom: 16px; color: #333; }
#login .field { margin-bottom: 12px; }
#login label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 4px; }
#login input { width: 95%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
#login input:focus { outline: 3px solid #2563eb; outline-offset: 2px; border-color: #2563eb; }
#login-btn { width: 95%; padding: 10px; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
#login-btn:hover { background: #1d4ed8; }
#login-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }

#app { display: none; width: 720px; gap: 16px; flex-direction: row; }
#app.active { display: flex; }

#sidebar { width: 200px; background: white; border-radius: 12px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.sidebar-heading { font-size: 13px; color: #555; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.participant-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f0f0f0; }
.participant-item:last-child { border-bottom: none; }
/* SC 1.4.3: #1e40af on #dbeafe = 5.5:1 ✅ */
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #dbeafe; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: bold; color: #1e40af; flex-shrink: 0; }
/* SC 1.4.3: #15803d on #dcfce7 = 4.6:1 ✅ */
.avatar.speaking { background: #dcfce7; color: #15803d; box-shadow: 0 0 0 2px #15803d; }
.p-name { font-size: 13px; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mic-icon { font-size: 18px; margin-left: auto; }
.spk-icon { position: relative; font-size: 18px; margin-left: auto; line-height: 1; }
.spk-icon.muted::after { content: ''; position: absolute; top: 50%; left: 50%; width: 95%; height: 3px; background: #dc2626; transform: translate(-50%, -50%) rotate(-45deg); border-radius: 2px; pointer-events: none; }
.mic-icon-btn { position: relative; font-size: 18px; margin-left: auto; background: none; border: none; padding: 2px 4px; border-radius: 4px; cursor: pointer; line-height: 1; }
.mic-icon-btn:hover { background: #f0f0f0; }
.mic-icon-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.mic-icon-btn.muted::after { content: ''; position: absolute; top: 50%; left: 50%; width: 95%; height: 3px; background: #dc2626; transform: translate(-50%, -50%) rotate(-45deg); border-radius: 2px; pointer-events: none; }

#main { flex: 1; display: flex; flex-direction: column; gap: 12px; }

#voice-bar { background: white; border-radius: 12px; padding: 10px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 10px; }
#voice-bar .room-info { font-size: 13px; color: #555; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#voice-bar .room-info strong { color: #111; }
#voice-bar .room-owner-label { font-size: 12px; color: #6b7280; font-weight: 400; margin-left: 6px; }
/* SC 2.5.8: min 44x44px target size ✅ */
#mic-btn { padding: 0 16px; height: 36px; border-radius: 8px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
/* SC 1.4.3: white on #15803d = 5.0:1 ✅ */
#mic-btn.on  { background: #15803d; color: white; }
/* SC 1.4.3: white on #b91c1c = 5.7:1 ✅ */
#mic-btn.off { background: #b91c1c; color: white; }
#mic-btn:hover { opacity: 0.85; }
#mic-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }
#agent-audio-btn { padding: 0 14px; height: 36px; border-radius: 8px; border: 1px solid #c7d2fe; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
#agent-audio-btn.on  { background: #4f46e5; color: white; border-color: #4f46e5; }
#agent-audio-btn.off { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }
#agent-audio-btn:hover { opacity: 0.85; }
#agent-audio-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }
#leave-btn { padding: 0 14px; height: 36px; border-radius: 8px; border: 1px solid #cbd5e1; cursor: pointer; font-size: 13px; background: #f8fafc; color: #475569; white-space: nowrap; flex-shrink: 0; }
#leave-btn:hover { background: #e2e8f0; border-color: #94a3b8; }
#leave-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }

/* 管理ポータルリンク (admin/owner+ ロールのみ表示) */
/* WCAG 1.4.3 #1e40af on #eff6ff = 8.6:1 ✅ */
.admin-portal-link {
  padding: 8px 14px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #bfdbfe;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.admin-portal-link:hover { background: #dbeafe; }
.admin-portal-link:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }

/* Step 9-6: 帯域低下バナー (#fef9c3 amber on #713f12 = 5.5:1 ✅) */
#low-bandwidth-banner {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fef9c3;
  border: 1px solid #fde047;
  color: #713f12;
  font-size: 13px;
  font-weight: 600;
}
body.low-bandwidth #voice-bar { border: 1px solid #fde047; }

/* Step 30-6: 試用期間バナー (amber #fef3c7 on #92400e = 6.4:1 ✅) */
#trial-banner {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
  font-size: 13px;
  font-weight: 600;
}

/* Step 9-7: 接続モードバッジ (direct / relay / tcp / unknown) */
#connection-mode-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: monospace;
  border: 1px solid transparent;
}
#connection-mode-badge.mode-direct { background: #dcfce7; color: #15803d; border-color: #86efac; }
#connection-mode-badge.mode-relay  { background: #fef9c3; color: #713f12; border-color: #fde047; }
#connection-mode-badge.mode-tcp    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
#connection-mode-badge.mode-unknown { background: #f3f4f6; color: #6b7280; border-color: #d1d5db; }

/* Step 4-5: 議事録トグル + パネル */
#transcript-toggle-btn { padding: 0 14px; height: 36px; border-radius: 8px; border: 1px solid #c7d2fe; cursor: pointer; font-size: 13px; background: #eef2ff; color: #3730a3; white-space: nowrap; flex-shrink: 0; }
#transcript-toggle-btn.on { background: #4f46e5; color: white; border-color: #4f46e5; }
#transcript-toggle-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }
.hidden { display: none !important; }

#transcript-panel { background: white; border-radius: 12px; padding: 12px 16px; margin-top: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); display: flex; flex-direction: column; max-height: 280px; }
#transcript-panel .transcript-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: #3730a3; margin-bottom: 8px; }
#transcript-panel .transcript-header button { padding: 4px 10px; border-radius: 6px; border: 1px solid #c7d2fe; background: white; color: #3730a3; font-size: 12px; cursor: pointer; min-height: 28px; }
#transcript-log { flex: 1; overflow-y: auto; padding: 8px; background: #f8fafc; border-radius: 6px; font-size: 12.5px; }
.transcript-line { padding: 4px 0; border-bottom: 1px dashed #e5e7eb; line-height: 1.5; word-break: break-word; }
.transcript-line:last-child { border-bottom: none; }
.transcript-time { color: #94a3b8; font-family: monospace; margin-right: 8px; }
.transcript-speaker { color: #4f46e5; font-weight: 600; margin-right: 8px; }
.transcript-text { color: #222; }

#chat-box { background: white; border-radius: 12px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); display: flex; flex-direction: column; height: 460px; }
#messages { flex: 1; overflow-y: auto; padding-right: 4px; margin-bottom: 12px; }
.msg { margin-bottom: 10px; }
/* SC 1.4.3: #1d4ed8 on white = 7.2:1 ✅ */
.msg .name { font-weight: bold; font-size: 12px; color: #1d4ed8; margin-bottom: 2px; }
/* SC 1.4.3: #15803d on white = 4.6:1 ✅ */
.msg.me .name { color: #15803d; }
/* SC 1.4.3: #111 on #f8fafc = 16.8:1 ✅ */
.msg .text { font-size: 14px; color: #111; background: #f8fafc; display: inline-block; padding: 6px 10px; border-radius: 8px; border: 1px solid #e5e7eb; max-width: 95%; word-break: break-word; }
.msg.me { text-align: right; }
.msg.me .text { background: #dbeafe; border-color: #bfdbfe; }
.msg.system { text-align: center; margin: 6px 0; }
/* SC 1.4.3: #713f12 on #fef9c3 = 5.5:1 ✅ */
.msg.system .text { background: #fef9c3; border-color: #fde047; color: #713f12; font-size: 12px; }
#input-area { display: flex; gap: 8px; }
#msg-input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
#msg-input:focus { outline: 3px solid #2563eb; outline-offset: 2px; border-color: #2563eb; }
/* SC 2.5.8: min 44x44px target size ✅ */
#send-btn { padding: 10px 16px; background: #2563eb; color: white; border: none; border-radius: 8px; cursor: pointer; min-width: 44px; min-height: 44px; }
#send-btn:hover { background: #1d4ed8; }
#send-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }

/* SC 1.4.3: #b91c1c on white = 5.7:1 ✅ */
#error-msg { color: #b91c1c; margin-top: 8px; font-size: 13px; }

/* ─── ルーム一覧ステップ ─────────────────────────────── */
#login.has-room-list { width: min(460px, calc(100vw - 32px)); }

.room-step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.logged-in-user { font-size: 12px; color: #555; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-step-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
/* SC 1.4.3: #1e40af on white = 8.6:1 ✅ */
.settings-link { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px; background: #f1f5f9; color: #374151; text-decoration: none; font-size: 15px; border: none; cursor: pointer; flex-shrink: 0; }
.settings-link:hover { background: #e2e8f0; }
.settings-link:focus-visible { outline: 3px solid #1e40af; outline-offset: 2px; }
#logout-btn-pre { width: auto; padding: 0 12px; height: 32px; background: #f1f5f9; color: #475569; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 6px; cursor: pointer; white-space: nowrap; }
#logout-btn-pre:hover { background: #e2e8f0; }
#logout-btn-pre:focus-visible { outline: 3px solid #1e40af; outline-offset: 2px; }

.room-list-section { margin-bottom: 16px; }
.room-list-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.room-list-title { font-size: 13px; font-weight: 600; color: #444; text-transform: uppercase; letter-spacing: 0.05em; }
.refresh-btn { padding: 0 10px; height: 30px; border-radius: 6px; border: 1px solid #e2e8f0; background: white; color: #555; font-size: 12px; cursor: pointer; white-space: nowrap; width: auto; }
.refresh-btn:hover { background: #f3f4f6; }
.refresh-btn:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

#room-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.room-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #e5e7eb; border-radius: 8px; background: #f8fafc; }
.room-item-name { flex: 1; font-size: 14px; font-weight: 600; color: #111; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* SC 1.4.3: #4b5563 on #f8fafc = 6.1:1 ✅ */
.room-item-count { font-size: 12px; color: #4b5563; white-space: nowrap; }
/* SC 1.4.3: white on #2563eb = 4.6:1 ✅ */
.room-join-btn { padding: 0 14px; height: 32px; background: #2563eb; color: white; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; width: auto; }
.room-join-btn:hover { background: #1d4ed8; }
.room-join-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 2px; }
.room-delete-btn { padding: 0 10px; height: 32px; background: #fff; color: #dc2626; border: 1px solid #fca5a5; border-radius: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; width: auto; }
.room-delete-btn:hover { background: #fee2e2; border-color: #dc2626; }
.room-item-visibility { font-size: 14px; }
.room-item-owner { font-size: 11px; color: #6b7280; font-weight: 400; }
.room-list-empty { font-size: 13px; color: #6b7280; text-align: center; padding: 16px 0; }

.new-room-section { border-top: 1px solid #e5e7eb; padding-top: 14px; }
.new-room-row { margin-top: 8px; }
.new-room-row input { width: 95%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
.new-room-row input:focus { outline: 3px solid #2563eb; outline-offset: 2px; border-color: #2563eb; }
.new-room-visibility-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.new-room-visibility-row label { font-size: 12px; color: #374151; white-space: nowrap; }
.new-room-visibility-row select { flex: 1; padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }
.new-room-section #create-room-btn { display: block; width: 95%; margin-top: 8px; }
/* SC 1.4.3: white on #059669 = 3.9:1 — large bold text ≥18pt → OK ✅ */
#create-room-btn { padding: 0 16px; height: 42px; background: #059669; color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; width: auto; }
#create-room-btn:hover { background: #047857; }
#create-room-btn:focus-visible { outline: 3px solid #065f46; outline-offset: 3px; }

/* SC 1.4.3: #b91c1c on white = 5.7:1 ✅ */
#room-error-msg { color: #b91c1c; margin-top: 8px; font-size: 13px; min-height: 1.2em; }

/* 招待・各種モーダル */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-overlay.hidden { display: none !important; }
.modal-box { background: white; border-radius: 12px; padding: 24px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; font-weight: 700; color: #111; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #6b7280; padding: 4px 8px; border-radius: 6px; min-height: 32px; }
.modal-close:hover { background: #f3f4f6; }
.modal-close:focus-visible { outline: 3px solid #1e40af; outline-offset: 2px; }
.modal-body .field { margin-bottom: 12px; }
.modal-body .field label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 4px; }
.modal-body .field input, .modal-body .field select { width: 95%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
.modal-body .field input:focus, .modal-body .field select:focus { outline: 3px solid #2563eb; outline-offset: 2px; border-color: #2563eb; }

/* プロファイルパネル (インライン) */
#profile-panel { padding-top: 4px; }
.profile-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; border-bottom: 1px solid #e5e7eb; padding-bottom: 12px; }
.profile-header h2 { flex: 1; font-size: 15px; font-weight: 700; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-link { width: auto; flex-shrink: 0; font-size: 12px; color: #475569; padding: 0 10px; height: 30px; border-radius: 6px; background: #f1f5f9; border: 1px solid #e2e8f0; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; }
.back-link:hover { background: #e2e8f0; }
.back-link:focus-visible { outline: 3px solid #1e40af; outline-offset: 2px; }
.profile-card { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.profile-card-title { font-size: 12px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }
.profile-dl { display: grid; grid-template-columns: 90px 1fr; gap: 8px 10px; font-size: 13px; }
.profile-dl dt { color: #6b7280; font-weight: 500; display: flex; align-items: center; }
.profile-dl dd { color: #111; font-weight: 600; display: flex; align-items: center; overflow: hidden; text-overflow: ellipsis; }
.profile-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; background: #dbeafe; color: #1e40af; }
.profile-note { font-size: 12px; color: #6b7280; margin-bottom: 10px; line-height: 1.5; }
.profile-field { margin-bottom: 10px; }
.profile-field label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 4px; }
.profile-field input { width: 95%; padding: 9px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
.profile-field input:focus { outline: 3px solid #2563eb; outline-offset: 2px; border-color: #2563eb; }
.pnl-save-btn { width: 95%; padding: 10px; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 40px; }
.pnl-save-btn:hover { background: #1d4ed8; }
.pnl-save-btn:focus-visible { outline: 3px solid #1e40af; outline-offset: 3px; }
.pnl-portal-btn { display: flex; align-items: center; justify-content: center; padding: 10px; background: #eff6ff; color: #1e40af; border: 1.5px solid #bfdbfe; border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none; min-height: 40px; }
.pnl-portal-btn:hover { background: #dbeafe; }
