* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; }
input[type="text"] { font: inherit; padding: 9px 11px; border: 1px solid #c9ced6; border-radius: 8px; width: 100%; }
label { display: block; font-size: 13px; color: #444; margin: 12px 0 4px; }
.primary { background: #2d8cff; color: #fff; border: none; border-radius: 8px; padding: 9px 16px; }
.primary:hover { background: #1f7ae0; }
.primary.big { width: 100%; padding: 12px; font-size: 16px; margin-top: 14px; }
.danger { background: #e02828; color: #fff; border: none; border-radius: 8px; padding: 10px 14px; }
.fineprint { font-size: 12px; color: #888; }
.error { color: #c00; font-size: 14px; }
.optional { color: #999; }

/* Landing */
.landing { background: #f6f8fb; min-height: 100vh; }
.landing-top { display: flex; align-items: baseline; gap: 16px; padding: 22px 32px; }
.logo { font-size: 24px; font-weight: 700; color: #0b5cad; }
.tagline { color: #666; }
.landing-main { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; padding: 24px; }
.landing-card { background: #fff; border: 1px solid #e2e7ee; border-radius: 14px; padding: 24px; width: 360px; box-shadow: 0 2px 10px rgba(20,40,80,.05); }
.landing-card h1 { font-size: 19px; margin: 0 0 6px; }
.created { margin-top: 16px; }
.linkrow { display: flex; gap: 8px; margin: 8px 0; }
.linkrow input { flex: 1; }
.linkrow button { border: 1px solid #c9ced6; background: #fff; border-radius: 8px; padding: 0 14px; }
.landing .fineprint { width: 100%; text-align: center; }

/* Pre-join */
.prejoin { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f6f8fb; }
.prejoin-card { background: #fff; border: 1px solid #e2e7ee; border-radius: 14px; padding: 26px; width: 420px; box-shadow: 0 2px 14px rgba(20,40,80,.07); }
.prejoin-card h1 { font-size: 20px; margin: 0 0 14px; }
.pj-preview { position: relative; background: #111; border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; }
.pj-preview video { width: 100%; height: 100%; object-fit: cover; }
.pj-nocam { position: absolute; inset: 0; color: #aaa; display: flex; align-items: center; justify-content: center; }
.pj-toggles { display: flex; gap: 10px; margin-top: 12px; }
.toggle { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid #c9ced6; background: #fff; }
.toggle.on { border-color: #2d8cff; color: #0b5cad; background: #eaf4ff; }

/* In-call */
.incall { height: 100vh; display: flex; flex-direction: column; background: #1c1e21; }
.agent-banner { background: #fff8e1; color: #5d4a00; font-size: 13px; padding: 7px 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.agent-badges { display: inline-flex; gap: 6px; }
.badge { background: #5d4a00; color: #fff; border-radius: 20px; padding: 2px 10px; font-size: 12px; }
.call-body { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.gallery { flex: 1; display: grid; gap: 8px; padding: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-content: center; }
.tile { position: relative; background: #2b2e33; border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; border: 3px solid transparent; }
.tile.speaking { border-color: #3ecf5a; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile .tname { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.tile .avatar { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 44px; color: #9db2c8; }
.toolbar { display: flex; gap: 10px; justify-content: center; padding: 12px; }
.tool { background: #2b2e33; color: #eee; border: none; border-radius: 10px; padding: 9px 13px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 15px; min-width: 64px; }
.tool span { font-size: 11px; color: #bbb; }
.tool.on { background: #3a3f46; }
.tool.off { background: #e02828; color: #fff; }
.tool.end { background: #e02828; color: #fff; }
.tool.leave { justify-content: center; }

.panel { width: 340px; background: #fff; display: flex; flex-direction: column; border-left: 1px solid #ddd; }
.panel-tabs { display: flex; border-bottom: 1px solid #e5e5e5; }
.ptab { flex: 1; background: none; border: none; padding: 12px 4px; font-size: 14px; color: #555; border-bottom: 2px solid transparent; position: relative; }
.ptab.active { color: #0b5cad; border-bottom-color: #2d8cff; font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e02828; vertical-align: super; }
.tabpage { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chatlog, .transcriptlog, .whisperlog { flex: 1; overflow-y: auto; padding: 12px; }
.chatrow { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #eee; }
.chatrow input { flex: 1; }
.chat-msg { margin-bottom: 10px; font-size: 14px; }
.chat-msg .who { font-weight: 600; font-size: 12px; color: #0b5cad; }
.tseg { margin-bottom: 9px; font-size: 14px; line-height: 1.35; }
.tseg .who { font-weight: 600; color: #333; }
.tseg.provisional { color: #999; font-style: italic; }
.tevent { font-size: 12px; color: #8a6d00; background: #fff8e1; border-radius: 6px; padding: 3px 8px; margin: 4px 0 9px; display: inline-block; }
.agent-section { padding: 12px 14px; border-bottom: 1px solid #f0f0f0; }
.agent-section h3 { margin: 0 0 8px; font-size: 13px; color: #333; text-transform: uppercase; letter-spacing: .04em; }
.agentlist .agentrow { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 5px 0; }
.presence { width: 9px; height: 9px; border-radius: 50%; background: #bbb; }
.presence.connected { background: #3ecf5a; }
.presence.working { background: #f5a623; }
.presence.unavailable { background: #e02828; }
.whisper { background: #eef4ff; border-left: 3px solid #2d8cff; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; font-size: 14px; }
.whisper .wfrom { font-size: 12px; font-weight: 600; color: #0b5cad; }
.card { border: 1px solid #d7e3f4; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fbfdff; }
.card .ctype { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #2d8cff; letter-spacing: .06em; }
.card .ctitle { font-weight: 600; margin: 2px 0; }
.card .cbody { font-size: 14px; }
.card .cactions { margin-top: 8px; display: flex; gap: 8px; }
.card .cactions button { border-radius: 6px; padding: 5px 12px; border: 1px solid #c9ced6; background: #fff; }
.card .cactions .accept { background: #2d8cff; color: #fff; border-color: #2d8cff; }
.card.done { opacity: .55; }
.posturebox label { display: flex; gap: 8px; align-items: center; font-size: 14px; color: #333; margin: 7px 0; }

/* Retention modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: #fff; border-radius: 14px; padding: 26px; width: 440px; max-width: 92vw; }
.modal-card h2 { margin-top: 0; }
.retention-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.retention-opts button { padding: 12px; border-radius: 8px; border: 1px solid #c9ced6; background: #fff; font-size: 15px; text-align: left; }
.retention-opts button.primary { background: #2d8cff; color: #fff; border: none; text-align: center; }
.retention-opts button.danger { background: #e02828; color: #fff; border: none; }
.retention-opts button span { display: block; font-size: 12px; opacity: .75; }
#retentionDone { margin-top: 14px; width: 100%; padding: 11px; border-radius: 8px; border: 1px solid #c9ced6; background: #fff; }

@media (max-width: 760px) {
  .panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 20; width: 88vw; }
  .gallery { grid-template-columns: 1fr; }
}
