* { box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: -apple-system, "Segoe UI", "Heebo", Arial, sans-serif; margin: 0; background:#f6f6f8; color:#222; display:flex; flex-direction:column; overflow:hidden; }
header { background:#1f1f2e; color:#fff; padding: 10px 16px; display:flex; justify-content:space-between; align-items:center; flex:none; }
header h1 { font-size: 18px; margin: 0; }
#topbar { font-size: 13px; opacity: .9; }
#app { padding: 12px; display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.card { background:#fff; border-radius: 8px; padding: 12px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.hidden { display: none; }
.row { display:flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 8px 0; }
label { display:flex; flex-direction:column; gap: 4px; font-size: 13px; }
input, select, textarea, button { font: inherit; padding: 6px 8px; border: 1px solid #bbb; border-radius: 6px; background:#fff; }
button { cursor: pointer; background:#1f1f2e; color:#fff; border-color:#1f1f2e; }
button.secondary { background:#fff; color:#1f1f2e; }
button:disabled { opacity: .5; cursor: not-allowed; }
textarea { width: 100%; min-height: 80px; resize: vertical; }

#sim { display:grid; grid-template-columns: 280px 1fr; grid-template-rows: auto auto auto 1fr; gap: 12px; flex: 1 1 auto; min-height: 0; }
#sim.hidden { display: none; }
#token-bar { grid-column: 1 / 3; grid-row: 1; }
#session-controls { grid-column: 1 / 3; grid-row: 2; }
#roles { grid-column: 1; grid-row: 3 / 5; overflow:auto; }
#action { grid-column: 2; grid-row: 3; overflow:auto; }
#transcript { grid-column: 2; grid-row: 4; min-height: 0; overflow-y: auto; }

button.danger { background:#c0392b; color:#fff; border-color:#c0392b; }
.banner.success { background:#e8f5e9; border:1px solid #66bb6a; color:#1b5e20; padding:8px 12px; border-radius:6px; margin:8px; }

.toggle-btn.on { background:#27ae60; color:#fff; border-color:#27ae60; }
.toggle-btn.off { background:#fff; color:#1f1f2e; }

.btn-primary { font-weight:600; padding:6px 14px; border-radius:6px; }
.btn-primary.start { background:#27ae60; color:#fff; border-color:#27ae60; }
.btn-primary.pause { background:#e67e22; color:#fff; border-color:#e67e22; }
.btn-primary:disabled { opacity:.5; cursor:not-allowed; }

.segmented { display:inline-flex; border-radius:6px; overflow:hidden; border:1px solid #bbb; margin-top:4px; }
.segmented .seg-btn { background:#fff; color:#1f1f2e; border:none; border-right:1px solid #ddd; border-radius:0; padding:4px 8px; font-size:12px; }
.segmented .seg-btn:last-child { border-right:none; }
.segmented .seg-btn.active { background:#1f1f2e; color:#fff; font-weight:600; }
.segmented.mine { box-shadow: 0 0 0 2px #f1c40f; }

.thinking-banner { display:flex; align-items:center; gap:8px; padding: 10px 12px; background:#fffbe6; border:1px solid #f6d97a; border-radius:6px; margin:6px 0; }
.spinner { display:inline-block; width:14px; height:14px; border:2px solid #c8a83a; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.turn { padding: 10px 12px; border-radius: 6px; margin: 8px 0; border-right: 4px solid; background:#fafafa; }
.turn.voodoo_lawyer { border-color:#c0392b; }
.turn.witness_guy   { border-color:#27ae60; }
.turn.hilit         { border-color:#d4ac0d; }
.turn.judge_kirsch  { border-color:#8e44ad; }
.turn .speaker { font-weight: bold; font-size: 13px; opacity:.85; margin-bottom: 4px; }
.turn .text { white-space: pre-wrap; }
.kind { font-size: 11px; color:#888; margin-right: 6px; }

.role-row { display:flex; justify-content:space-between; align-items:center; padding:6px 0; border-bottom: 1px solid #eee; }
.role-row:last-child { border-bottom: none; }
.role-row .name { font-weight: 600; }
.role-row .ctrls { display:flex; gap:6px; }
.role-row.thinking .name::after { content: " ⏳"; }

.option { border: 1px solid #ccc; border-radius:6px; padding: 8px 10px; margin: 6px 0; cursor: pointer; }
.option:hover { background:#eef; }
.option .risk { font-size: 12px; color:#666; }

.error { color:#c0392b; }
.success { color:#27ae60; }
.banner { padding: 8px 12px; background:#fff3cd; border-radius:6px; margin: 8px 0; }
.banner.warn { background:#ffe0e0; border:1px solid #e08080; color:#8b1a1a; }
.role-row.not_started { border: 1px solid #c0392b; border-radius: 6px; padding: 6px 8px; background:#fff5f5; }
.chip { display:inline-block; padding: 2px 8px; font-size: 11px; border-radius:10px; margin-inline-start: 6px; }
.chip.ai { background:#dbe7ff; color:#1a3a8b; }
.chip.human { background:#dcf3df; color:#1a5a2a; }
.chip.not_started { background:#ffd4d4; color:#8b1a1a; }
.role-pick-card { border:1px solid #ccc; border-radius:8px; padding:10px; margin:8px 0; cursor:pointer; }
.role-pick-card:hover { background:#f0f4ff; }
.role-pick-card.selected { border:2px solid #1f1f2e; background:#eef; }

/* Voice input (Web Speech API) */
.mic-wrapper { margin: 6px 0; }
.mic-consent-label { display:flex; align-items:center; gap:6px; font-size:12px; color:#555; cursor:pointer; margin-bottom:6px; }
.mic-consent-label input[type=checkbox] { width:auto; padding:0; border:none; }
.mic-row { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.mic-btn { background:#fff; color:#333; border:1px solid #bbb; border-radius:6px; padding:5px 10px; font-size:18px; line-height:1; cursor:pointer; min-width:38px; }
.mic-btn.mic-listening { background:#c0392b; color:#fff; border-color:#c0392b; }
.mic-btn:disabled { opacity:.4; cursor:not-allowed; }
.interim { font-style:italic; color:#aaa; font-size:13px; }
.mic-status { font-size:12px; min-height:18px; }
.mic-status.mic-recording { color:#c0392b; display:flex; align-items:center; gap:6px; }
.mic-status.mic-error { color:#c0392b; }
.rec-dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:#c0392b; animation:blink-rec 0.9s ease-in-out infinite; }
@keyframes blink-rec { 0%,100% { opacity:1; } 50% { opacity:0.15; } }

.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; z-index:1000; }
.modal-overlay.hidden { display:none; }
.modal-box { background:#fff; border-radius:10px; padding:24px; min-width:320px; max-width:420px; box-shadow: 0 8px 32px rgba(0,0,0,.2); }

.history-table { width:100%; border-collapse:collapse; font-size:13px; }
.history-table th { text-align:right; padding:6px 8px; border-bottom:2px solid #ddd; background:#f6f6f8; font-weight:600; }
.history-table td { padding:6px 8px; border-bottom:1px solid #eee; vertical-align:middle; }
.history-table tr:last-child td { border-bottom:none; }
.history-table tr:hover td { background:#f8f8ff; }
.history-empty { padding:24px; text-align:center; color:#888; }
