:root {
  color-scheme: light;
  --blue: #1976d2;
  --blue-2: #0f5fb3;
  --red: #c62828;
  --green: #15803d;
  --amber: #b45309;
  --ink: #202631;
  --muted: #667085;
  --line: #d6dde8;
  --panel: #ffffff;
  --soft: #f5f7fb;
  --bg: #e9edf3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(390px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(32, 38, 49, .12);
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.login-card p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-card button {
  width: 100%;
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.app-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--blue);
  color: #fff;
}

.brand {
  font-size: 21px;
  font-weight: 780;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.current-user {
  font-size: 13px;
  font-weight: 700;
}

.header-logout {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .38);
  background: transparent;
}

.header-logout:hover {
  background: rgba(255, 255, 255, .14);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 38, 49, .42);
}

.modal-card {
  width: min(980px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(32, 38, 49, .2);
}

.small-modal {
  width: min(420px, 100%);
}

.modal-title,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-footer {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.modal-close {
  height: 32px;
}

.modal-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.account-admin-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.compact-title {
  margin-bottom: 8px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.admin-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-row label {
  margin-bottom: 0;
}

.doctor-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-top: 2px;
}

.doctor-checks label,
.remove-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.doctor-checks input,
.remove-line input {
  width: auto;
  height: auto;
}

@media (max-width: 860px) {
  .account-admin-layout {
    grid-template-columns: 1fr;
  }
}

.layout {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 300px minmax(440px, 1fr) 340px;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.left-rail,
.right-rail {
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow: auto;
}

.stage {
  min-height: 0;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 52px 92px;
  gap: 12px;
}

.tool-panel,
.preview-toolbar,
.decision-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-panel {
  padding: 13px;
}

.panel-title,
.preview-toolbar,
.decision-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin-bottom: 12px;
}

h2,
p {
  margin: 0;
}

h2 {
  font-size: 15px;
  font-weight: 760;
}

.panel-title span,
.preview-toolbar span,
.decision-bar p {
  color: var(--muted);
  font-size: 12px;
}

button {
  height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  color: #fff;
  background: var(--blue);
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
}

button:hover {
  background: var(--blue-2);
}

button.primary {
  background: var(--green);
}

button.recording {
  background: var(--red);
}

button.warning {
  background: var(--amber);
}

button.ghost {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.pill {
  height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 760;
}

.pill-idle {
  background: rgba(255, 255, 255, .18);
}

.pill-live {
  color: #fff;
  background: var(--green);
}

.device-list {
  display: grid;
  gap: 8px;
}

.device {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.device.active {
  border-color: var(--blue);
  background: #eef6ff;
}

.device strong {
  font-size: 14px;
}

.device span {
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

input,
select {
  height: 34px;
  padding: 0 9px;
}

textarea {
  min-height: 188px;
  resize: vertical;
  padding: 10px;
  line-height: 1.55;
}

.meter-row {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
}

meter {
  width: 100%;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-grid div {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.status-grid span {
  color: var(--muted);
  font-size: 12px;
}

.status-grid b {
  font-size: 14px;
}

.preview-toolbar {
  padding: 0 14px;
}

.preview-toolbar strong {
  display: block;
  font-size: 16px;
}

.record-badge {
  min-width: 132px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  background: #697386;
  font-size: 13px;
  font-weight: 780;
}

.record-badge.on {
  background: var(--red);
}

.preview-frame {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #111827;
  border-radius: 8px;
}

.doctor-preview {
  position: relative;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0) 30%),
    linear-gradient(135deg, #d6e0ea 0%, #eef2f6 42%, #ccd7e5 100%);
}

.preview-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doctor-preview:not(.has-video) .preview-person {
  animation: breathe 2.4s ease-in-out infinite;
}

.doctor-preview.has-video .safe-line,
.doctor-preview.has-video .face-guide,
.doctor-preview.has-video .preview-person,
.doctor-preview.has-video .preview-notice {
  display: none;
}

.safe-line {
  position: absolute;
  z-index: 2;
  background: rgba(25, 118, 210, .45);
}

.safe-line-h {
  top: 50%;
  left: 8%;
  width: 84%;
  height: 1px;
}

.safe-line-v {
  top: 8%;
  left: 50%;
  width: 1px;
  height: 84%;
}

.face-guide {
  position: absolute;
  z-index: 2;
  top: 18%;
  left: 50%;
  width: 34%;
  aspect-ratio: 1;
  border: 1px dashed rgba(21, 128, 61, .72);
  border-radius: 50%;
  transform: translateX(-50%);
}

.preview-person {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 10%;
  width: 54%;
  height: 62%;
  transform: translateX(-50%);
}

.head {
  width: 42%;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background: #f1c6a8;
  box-shadow: inset 0 -12px 0 rgba(115, 65, 45, .12);
}

.body {
  width: 100%;
  height: 58%;
  margin-top: 7%;
  border-radius: 40% 40% 6px 6px;
  background: linear-gradient(180deg, #f8fbff 0 22%, #dfe8f2 22% 100%);
}

.teleprompter-overlay {
  position: absolute;
  z-index: 5;
  left: 8%;
  top: 66%;
  width: 84%;
  height: 24%;
  overflow: hidden;
  padding: 12px;
  border-radius: 7px;
  color: #fff;
  background: rgba(0, 0, 0, .58);
  font-size: 28px;
  line-height: 1.45;
  text-align: center;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.teleprompter-resize {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 18px;
  border-right: 3px solid rgba(255, 255, 255, .85);
  border-bottom: 3px solid rgba(255, 255, 255, .85);
  cursor: nwse-resize;
}

.preview-notice {
  position: absolute;
  z-index: 6;
  top: 14px;
  left: 14px;
  right: 14px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #fff;
  background: rgba(32, 38, 49, .72);
  font-size: 13px;
  text-align: center;
}

.control-strip {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 8px;
}

#directorTalkButton.talking {
  color: #fff;
  border-color: var(--red);
  background: var(--red);
}

.decision-bar {
  padding: 14px;
}

.decision-actions {
  display: flex;
  gap: 8px;
}

.clip-preview-link {
  min-width: 112px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

.clip-preview-link.disabled {
  color: var(--muted);
  pointer-events: none;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-line input {
  width: 16px;
  height: 16px;
}

.log-panel {
  min-height: 180px;
}

#eventLog {
  max-height: 230px;
  margin: 0;
  padding-left: 20px;
  overflow: auto;
}

#eventLog li {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@keyframes breathe {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(5px); }
}

@media (max-width: 1180px) {
  .layout {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .stage {
    min-height: 760px;
  }
}
