/* App shell: a left menu that scrolls by itself (so a long menu never pushes tabs off the bottom of the page) and one view at a time. */
html, body { height: 100%; }
#main-layout.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; }
#main-layout.shell.hidden { display: none !important; }

.sidebar { display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--bg-secondary); border-right: 1px solid var(--border); }
.brand { padding: 1.1rem 1.25rem 0.9rem; font-weight: 700; letter-spacing: 0.08em; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand span { display: block; margin-top: 0.15rem; font-size: 0.7rem; font-weight: 500; letter-spacing: 0.04em; color: var(--text-muted); }
.nav { list-style: none; margin: 0; padding: 0.5rem 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.7rem 1.25rem; color: var(--text-muted); text-decoration: none; font-size: 0.92rem; border-left: 3px solid transparent; }
.nav a:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.03); }
.nav a.active { color: var(--text-primary); background: rgba(20, 184, 166, 0.1); border-left-color: var(--accent-teal); }
.nav a:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: -2px; }
.nav-sep { padding: 1rem 1.25rem 0.35rem; font-size: 0.7rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); }
.ext { color: var(--text-muted); }
.badge { min-width: 1.4rem; padding: 0 0.4rem; text-align: center; border-radius: 999px; background: var(--accent-amber); color: #111827; font-size: 0.75rem; font-weight: 700; }
.sidebar-foot { padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-foot .btn { width: 100%; }

.main { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.view.hidden { display: none !important; }
.view.page { overflow-y: auto; padding: 1.5rem 1.75rem 3rem; display: block; }
.view.page > h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.lede { margin: 0 0 1.25rem; color: var(--text-muted); max-width: 70ch; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.9rem; margin-bottom: 1.75rem; }
.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.1rem; min-width: 0; overflow-wrap: anywhere; }
.card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.card p { margin: 0.2rem 0; color: var(--text-muted); font-size: 0.88rem; }
.empty { padding: 1.5rem; border: 1px dashed var(--border); border-radius: 8px; color: var(--text-muted); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: var(--border); color: var(--text-primary); }
.pill.ok { background: rgba(20, 184, 166, 0.2); color: #5eead4; }
.pill.warn { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.pill.bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
h2.section { margin: 1.5rem 0 0.6rem; font-size: 1rem; }

/* Agents */
.feed { display: grid; gap: 0.5rem; }
.msg { background: var(--bg-secondary); border: 1px solid var(--border); border-left: 3px solid var(--accent-slate); border-radius: 6px; padding: 0.6rem 0.85rem; overflow-wrap: anywhere; }
.msg.objection { border-left-color: var(--accent-red); }
.msg.approval, .msg.handoff { border-left-color: var(--accent-teal); }
.msg.decision, .msg.question { border-left-color: var(--accent-amber); }
.msg-head { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.msg-head strong { color: var(--text-primary); }
.msg p { margin: 0; font-size: 0.9rem; }

/* Call desk: big, calm type for a nervous caller */
.call-card { padding: 1.25rem 1.4rem; margin-bottom: 1.1rem; }
.call-card h3 { font-size: 1.25rem; }
.call-script { margin: 0.9rem 0; padding: 1rem 1.15rem; border-left: 4px solid var(--accent-teal); background: var(--bg-primary); border-radius: 6px; font-size: 1.15rem; line-height: 1.65; white-space: pre-wrap; }
.call-script small { display: block; margin-bottom: 0.35rem; font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); }
.contact { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; padding: 0.7rem 0; border-top: 1px solid var(--border); }
.contact .who { min-width: 0; overflow-wrap: anywhere; }
.contact .phone { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* Video studio */
.studio { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.studio-list { display: grid; gap: 0.5rem; }
.studio-item { text-align: left; width: 100%; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem 0.85rem; color: var(--text-primary); cursor: pointer; font: inherit; }
.studio-item.active { border-color: var(--accent-teal); }
.studio-item small { display: block; color: var(--text-muted); }
.field { display: grid; gap: 0.3rem; margin-bottom: 0.9rem; }
.field label { font-size: 0.8rem; color: var(--text-muted); }
.field input, .field textarea { width: 100%; padding: 0.65rem; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 4px; color: var(--text-primary); font: inherit; }
.field textarea { min-height: 5rem; resize: vertical; }
.scene { border: 1px solid var(--border); border-radius: 6px; padding: 0.7rem 0.8rem; margin-bottom: 0.6rem; background: var(--bg-secondary); }
.scene .scene-head { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.notice { padding: 0.8rem 1rem; border-radius: 6px; background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.4); font-size: 0.88rem; margin-bottom: 1rem; }
.btnrow { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }

@media (max-width: 900px) {
  #main-layout.shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { display: none; }
  .nav { display: flex; overflow-x: auto; overflow-y: hidden; padding: 0; }
  .nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: 0.75rem 1rem; }
  .nav a.active { border-bottom-color: var(--accent-teal); }
  .nav-sep, .sidebar-foot { display: none; }
  .studio { grid-template-columns: 1fr; }
  .view.page { padding: 1rem 1rem 3rem; }
}

.chip { font: inherit; font-size: 0.8rem; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); cursor: pointer; }
.chip:hover { border-color: var(--accent-teal); }
.chip:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }
.field label input[type=checkbox] { width: auto; margin-right: 0.4rem; }

/* Embedded in the OCP dashboard: the left menu becomes a tab bar across the top. */
html.embedded #main-layout.shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
html.embedded .sidebar { height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
html.embedded .brand, html.embedded .nav-sep, html.embedded .sidebar-foot, html.embedded .ext-li { display: none; }
html.embedded .nav { display: flex; overflow-x: auto; overflow-y: hidden; padding: 0; }
html.embedded .nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; padding: 0.75rem 1rem; }
html.embedded .nav a.active { border-bottom-color: var(--accent-teal); }

/* Video Studio: the cast, the big player, who-says-what */
.cast-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.9rem; margin-bottom: 1.25rem; }
.cast-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.cast-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; }
.cast-body { padding: 0.65rem 0.8rem 0.8rem; display: grid; gap: 0.4rem; align-content: start; flex: 1; grid-template-rows: auto minmax(2.4em, auto) auto; }
.cast-body small { color: var(--text-muted); font-size: 0.78rem; }
.cast-name { font: inherit; font-weight: 600; font-size: 1rem; padding: 0.3rem 0.45rem; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--text-primary); width: 100%; }
.cast-name:hover, .cast-name:focus { border-color: var(--border); background: var(--bg-primary); }
.stage-box { margin: 0.5rem 0 1.25rem; }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage-overlay { position: absolute; left: 0; right: 0; bottom: 6px; padding: 2.5rem 1.25rem 1rem; background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0)); display: grid; gap: 0.35rem; }
.stage-who { justify-self: start; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #5eead4; background: rgba(0, 0, 0, 0.55); padding: 2px 8px; border-radius: 4px; }
.stage-cap { font-size: clamp(1rem, 2.2vw, 1.5rem); line-height: 1.35; color: #fff; text-shadow: 0 1px 3px #000; max-width: 62ch; }
.stage-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(255, 255, 255, 0.2); }
.stage-fill { height: 100%; width: 0; background: var(--accent-teal); }
.stage-controls { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.6rem; }
.stage-sound { font-size: 0.85rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.3rem; }
.stage-time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 0.85rem; }
.stage-thumbs { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.stage-thumbs img { width: 84px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; border: 2px solid transparent; opacity: 0.6; }
.stage-thumbs img.active { border-color: var(--accent-teal); opacity: 1; }
.voices { margin-top: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }
.voices summary { cursor: pointer; }
.voice-row { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: 0.5rem; align-items: center; margin: 0.35rem 0; }
.voice-row select { min-width: 0; padding: 0.35rem; background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.scene.line { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 0.7rem; align-items: start; }
.line-face { width: 72px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; background: #000; }
.line-main { display: grid; gap: 0.35rem; min-width: 0; }
.line-main select, .line-main textarea { width: 100%; padding: 0.45rem; background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.field select { padding: 0.55rem; background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border); border-radius: 4px; font: inherit; }
@media (max-width: 560px) { .scene.line { grid-template-columns: 1fr; } .line-face { width: 100%; max-width: 160px; } }

.toggle-line { display: flex; gap: 0.4rem; align-items: center; padding: 0.4rem 1.5rem; font-size: 0.8rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }

.score-line { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: baseline; margin: 0.4rem 0 0.8rem; }
.score { font-size: 2.6rem; font-weight: 700; color: var(--accent-teal); font-variant-numeric: tabular-nums; line-height: 1; }
