/* 2026-08-07 preview/download and status layout cleanup */
.status-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.status-heading h2 {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.state-label {
  flex: 0 0 auto;
  white-space: nowrap;
  text-align: right;
}

.preview-panel-heading {
  display: block;
}

.preview-state-label {
  display: none !important;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.download-panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid #d5ddea;
  border-radius: 12px;
  background: var(--surface-soft);
  text-align: left;
}

.download-panel[hidden] {
  display: none !important;
}

.download-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.download-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  margin: 0;
}

.download-icon svg {
  width: 32px;
  height: 32px;
}

.download-panel h3 {
  width: auto;
  margin: 0 0 3px;
  text-align: left;
  font-size: 0.95rem;
}

.download-panel p {
  width: auto;
  max-width: none;
  margin: 0;
  text-align: left;
  font-size: 0.82rem;
}

#downloadLink {
  flex: 0 0 auto;
  width: auto;
  min-width: 190px;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  margin: 0;
  text-align: center;
}

@media (max-width: 640px) {
  .status-heading {
    gap: 10px;
  }

  .status-heading h2 {
    font-size: 1.05rem;
  }

  .state-label {
    font-size: 0.78rem;
  }

  .download-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .download-copy {
    align-items: flex-start;
  }

  #downloadLink {
    width: 100%;
  }
}


/* Layout refresh: webcam side panel, moved status bar, and final result below */
.single-action-row {
  grid-template-columns: minmax(220px, 320px);
  justify-content: start;
}

.mode-card:has(input:disabled) {
  opacity: 0.7;
  cursor: not-allowed;
}

.mode-card:has(input:disabled):hover {
  transform: none;
  box-shadow: none;
}

.recording-stage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.recording-stage-layout.has-webcam-panel {
  grid-template-columns: minmax(0, 1fr) 300px;
}

.stage-panel,
.webcam-panel,
.relocated-status-panel,
.result-panel {
  padding: 24px;
}

.stage-shell {
  margin-top: 16px;
  min-height: 320px;
  border: 1px solid #202834;
  border-radius: 16px;
  background: linear-gradient(145deg, #212733, #10151d);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.stage-placeholder {
  max-width: 560px;
  padding: 32px;
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
  color: #d8e0ed;
}

.stage-placeholder strong {
  font-size: 1.08rem;
  color: #fff;
}

.stage-placeholder p,
.stage-subtitle,
.webcam-panel-subtitle,
.preview-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.stage-placeholder-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.stage-placeholder-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.webcam-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.overlay-position-group {
  display: grid;
  gap: 12px;
}

.overlay-position-label {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.overlay-position-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.overlay-position-btn {
  min-height: 64px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: #4e5c74;
  font-size: 1.6rem;
  font-weight: 700;
}

.overlay-position-btn[data-active="true"] {
  color: var(--blue);
  border-color: #84abff;
  background: #f5f9ff;
  box-shadow: inset 0 0 0 1px rgba(47,115,241,0.08);
}

.webcam-preview-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.webcam-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.webcam-preview-heading strong {
  font-size: 0.96rem;
}

.webcam-preview-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.webcam-preview-card video {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: none;
  border-radius: 12px;
  background: #0d1118;
  object-fit: cover;
}

.webcam-preview-placeholder {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed #cad6ea;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
  background: #fff;
}

.relocated-status-panel {
  margin-top: 18px;
}

.relocated-status-panel .status-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.relocated-status-panel #stopBtn {
  min-width: 220px;
}

.result-panel {
  margin-top: 18px;
}

.result-panel[hidden] {
  display: none !important;
}

.result-video-shell {
  margin-top: 16px;
}

.result-panel .download-panel {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 18px 20px;
  border-style: solid;
  text-align: left;
}

.result-panel .download-copy {
  display: flex;
  align-items: center;
  gap: 14px;
}

.result-panel .download-icon {
  width: 44px;
  height: 44px;
  margin: 0;
}

.result-panel .download-copy h3,
.result-panel .download-copy p {
  margin: 0;
  max-width: none;
  text-align: left;
}

.result-panel #downloadLink {
  display: inline-flex;
  width: auto;
  min-width: 200px;
  flex-shrink: 0;
}

@media (max-width: 980px) {
  .recording-stage-layout.has-webcam-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .single-action-row {
    grid-template-columns: 1fr;
  }

  .stage-panel,
  .webcam-panel,
  .relocated-status-panel,
  .result-panel {
    padding: 18px;
  }

  .stage-shell {
    min-height: 260px;
  }

  .webcam-preview-placeholder {
    min-height: 160px;
  }

  .relocated-status-panel .status-actions {
    justify-content: stretch;
  }

  .relocated-status-panel #stopBtn {
    width: 100%;
    min-width: 0;
  }

  .result-panel .download-panel {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .result-panel .download-copy {
    align-items: flex-start;
  }

  .result-panel #downloadLink {
    width: 100%;
    min-width: 0;
  }
}


/* Final recorder layout correction — intentionally last in the stylesheet. */
#workspaceGrid.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

#workspaceGrid.workspace-grid.has-webcam-panel {
  grid-template-columns: minmax(0, 1fr) 300px;
}

#workspaceGrid .setup-panel {
  min-width: 0;
}

#webcamPanel.webcam-panel {
  position: static;
  inset: auto;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

#webcamPanel.webcam-panel[hidden] {
  display: none !important;
}

#webcamPanel .panel-heading {
  display: block;
}

#webcamPanel .panel-heading h2 {
  margin: 0;
}

#webcamPanel .webcam-panel-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

#webcamPanel .overlay-position-group {
  display: grid;
  gap: 10px;
}

#webcamPanel .overlay-position-label {
  margin: 0;
  color: #4f5c73;
  font-size: 0.86rem;
  font-weight: 700;
}

#webcamPanel .overlay-position-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#webcamPanel .overlay-position-btn {
  min-height: 58px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #fff;
  color: #506078;
  box-shadow: none;
  font-size: 1.55rem;
  line-height: 1;
}

#webcamPanel .overlay-position-btn[data-active="true"] {
  color: var(--blue);
  border-color: var(--blue);
  background: #f4f8ff;
  box-shadow: 0 0 0 2px rgba(47, 115, 241, 0.08);
}

/* The preview used to fill the finished-video area; reset it for the side panel. */
#webcamPanel .webcam-preview-card {
  position: static;
  inset: auto;
  z-index: auto;
  overflow: visible;
  display: block;
  min-width: 0;
  border-radius: 0;
  background: transparent;
}

#webcamPanel .webcam-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
  margin-bottom: 10px;
  background: transparent;
}

#webcamPanel .webcam-preview-heading strong::before {
  display: none;
}

#webcamPanel .webcam-preview-card video {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  max-height: none;
  border-radius: 12px;
  background: #0d1118;
  object-fit: cover;
}

#webcamPanel .webcam-preview-placeholder {
  min-height: 170px;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px dashed #cfd9e8;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.5;
}

#webcamPanel .webcam-preview-placeholder[hidden] {
  display: none !important;
}

/* Status is now one full-width panel below the setup/webcam row. */
#recorderStatus.relocated-status-panel {
  width: 100%;
  margin-top: 18px;
}

#recorderStatus .status-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

#recorderStatus #stopBtn {
  min-width: 220px;
}

/* Finished video is hidden until Stop completes, then download sits underneath it. */
#previewPanel.result-panel {
  width: 100%;
  margin-top: 18px;
}

#previewPanel.result-panel[hidden] {
  display: none !important;
}

#previewPanel .preview-grid {
  display: block;
}

#previewPanel .video-shell {
  width: 100%;
  min-height: 300px;
}

#previewPanel .download-panel {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  padding: 16px 18px;
  border-style: solid;
  text-align: left;
}

#previewPanel .download-panel[hidden] {
  display: none !important;
}

#previewPanel .download-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#previewPanel .download-icon {
  flex: 0 0 auto;
  margin: 0;
}

#previewPanel .download-panel h3,
#previewPanel .download-panel p {
  width: auto;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  text-align: left;
}

#previewPanel #downloadLink {
  flex: 0 0 auto;
  width: auto;
  min-width: 200px;
}

/* Start remains in the setup card; Stop lives with the status panel. */
.setup-panel .single-action-row {
  grid-template-columns: minmax(220px, 320px);
  justify-content: start;
}

.mode-card:has(input:disabled) {
  opacity: 0.68;
  cursor: not-allowed;
}

.mode-card:has(input:disabled):hover {
  transform: none;
  box-shadow: none;
}

@media (max-width: 980px) {
  #workspaceGrid.workspace-grid.has-webcam-panel {
    grid-template-columns: minmax(0, 1fr) 270px;
  }
}

@media (max-width: 760px) {
  #workspaceGrid.workspace-grid.has-webcam-panel {
    grid-template-columns: 1fr;
  }

  #webcamPanel.webcam-panel {
    padding: 18px;
  }

  .setup-panel .single-action-row {
    grid-template-columns: 1fr;
  }

  #recorderStatus .status-actions {
    justify-content: stretch;
  }

  #recorderStatus #stopBtn {
    width: 100%;
    min-width: 0;
  }

  #previewPanel .download-panel {
    flex-direction: column;
    align-items: stretch;
  }

  #previewPanel #downloadLink {
    width: 100%;
    min-width: 0;
  }
}


/* Compact horizontal recording status bar */
#recorderStatus.relocated-status-panel {
  padding: 14px 16px 16px;
}

#recorderStatus .compact-status-heading {
  display: block;
  padding: 0 0 10px;
  margin: 0;
  border-bottom: 1px solid var(--border);
}

#recorderStatus .compact-status-heading h2 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.3;
  font-weight: 750;
}

#recorderStatus .status-inline-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0;
  margin-top: 10px;
}

#recorderStatus .status-state-cell {
  display: flex;
  align-items: center;
  padding: 0 18px 0 0;
  border-right: 1px solid var(--border);
}

#recorderStatus .state-label {
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(22, 184, 106, 0.10);
  font-size: 0.78rem;
  line-height: 1;
}

#recorderStatus[data-state="recording"] .state-label {
  background: rgba(218, 60, 72, 0.10);
}

#recorderStatus[data-state="preparing"] .state-label,
#recorderStatus[data-state="finalizing"] .state-label {
  background: rgba(224, 151, 35, 0.12);
}

#recorderStatus[data-state="error"] .state-label {
  background: rgba(218, 60, 72, 0.10);
}

#recorderStatus .stats-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  align-items: stretch;
  margin: 0;
}

#recorderStatus .stats-list > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 0 16px;
  border-bottom: 0;
  border-right: 1px solid var(--border);
}

#recorderStatus .stats-list dt {
  gap: 7px;
  font-size: 0.72rem;
  line-height: 1.15;
  white-space: nowrap;
}

#recorderStatus .stats-list dt svg {
  width: 15px;
  height: 15px;
}

#recorderStatus .stats-list dd {
  width: 100%;
  margin: 0;
  padding-left: 22px;
  font-size: 0.78rem;
  line-height: 1.2;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#recorderStatus .status-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
  padding: 0 0 0 18px;
  border-top: 0;
}

#recorderStatus #stopBtn {
  min-width: 164px;
  min-height: 42px;
  padding: 9px 16px;
  color: #fff;
  border-color: #df4854;
  background: linear-gradient(180deg, #f04f5c, #db3947);
  box-shadow: 0 7px 16px rgba(219, 57, 71, 0.18);
  white-space: nowrap;
}

#recorderStatus #stopBtn:hover:not(:disabled) {
  background: linear-gradient(180deg, #e94855, #c93340);
}

#recorderStatus #stopBtn:disabled {
  color: #738096;
  border-color: #d8dfeb;
  background: #f1f4f8;
  box-shadow: none;
}

@media (max-width: 980px) {
  #recorderStatus .status-inline-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #recorderStatus .status-state-cell {
    padding: 0 0 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  #recorderStatus .stats-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #recorderStatus .stats-list > div:first-child {
    padding-left: 0;
  }

  #recorderStatus .stats-list > div:last-child {
    border-right: 0;
  }

  #recorderStatus .status-actions {
    justify-content: flex-end;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 700px) {
  #recorderStatus .stats-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }

  #recorderStatus .stats-list > div {
    padding: 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  #recorderStatus .stats-list > div:nth-child(2n) {
    border-right: 0;
  }

  #recorderStatus .stats-list > div:nth-last-child(-n+2) {
    border-bottom: 0;
  }

  #recorderStatus .stats-list dd {
    padding-left: 22px;
  }

  #recorderStatus #stopBtn {
    width: 100%;
    min-width: 0;
  }
}


/* One-button recorder layout: webcam controls below modes */
#workspaceGrid.workspace-grid,
.workspace-grid {
  grid-template-columns: 1fr !important;
}

.setup-panel {
  display: block;
}

.setup-panel > #webcamPanel.webcam-panel {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(260px, 340px);
  align-items: start;
  gap: 18px;
  margin-top: 18px;
  padding: 18px 0 0;
  border-top: 1px solid var(--border);
  background: transparent;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.setup-panel > #webcamPanel.webcam-panel[hidden] {
  display: none !important;
}

.setup-panel > #webcamPanel .panel-heading {
  display: none;
}

.setup-panel > #webcamPanel .overlay-position-group {
  display: grid;
  gap: 10px;
  align-content: start;
}

.setup-panel > #webcamPanel .overlay-position-label {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.setup-panel > #webcamPanel .overlay-position-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.setup-panel > #webcamPanel .overlay-position-btn {
  min-height: 58px;
  font-size: 1.5rem;
}

.setup-panel > #webcamPanel .webcam-preview-card {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  margin: 0;
  min-height: 0;
}

.setup-panel > #webcamPanel .webcam-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setup-panel > #webcamPanel .webcam-preview-card video {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 220px;
}

.setup-panel > #webcamPanel .webcam-preview-placeholder {
  min-height: 170px;
}

#recorderStatus .status-actions {
  display: flex !important;
  justify-content: flex-end;
  align-items: center;
}

#recorderStatus .record-toggle-button {
  min-width: 220px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#recorderStatus .record-toggle-button.is-start {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

#recorderStatus .record-toggle-button.is-start:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.32);
}

#recorderStatus .record-toggle-button.is-stop {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.24);
}

#recorderStatus .record-toggle-button.is-stop:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(220, 38, 38, 0.32);
}

#recorderStatus .record-toggle-button:disabled {
  opacity: 0.85;
  cursor: wait;
  transform: none;
}

@media (max-width: 980px) {
  .setup-panel > #webcamPanel.webcam-panel {
    grid-template-columns: 1fr;
  }

  .setup-panel > #webcamPanel .overlay-position-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .setup-panel > #webcamPanel .overlay-position-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #recorderStatus .record-toggle-button {
    width: 100%;
    min-width: 0;
  }
}


/* Webcam control refinement: compact monitor-style position selector */
.setup-panel > #webcamPanel.webcam-panel {
  grid-template-columns: 210px minmax(320px, 430px) !important;
  justify-content: start;
  align-items: start;
  gap: 24px;
}

.setup-panel > #webcamPanel .overlay-position-group {
  width: 210px;
}

.setup-panel > #webcamPanel .overlay-position-monitor {
  position: relative;
  width: 190px;
  height: 150px;
  display: grid;
  grid-template-columns: 1fr 1fr !important;
  grid-template-rows: 1fr 1fr;
  gap: 0 !important;
  padding: 8px;
  border: 2px solid #bfd0e7;
  border-radius: 14px;
  background: #fbfdff;
  box-shadow: inset 0 0 0 4px #fff;
}

.setup-panel > #webcamPanel .overlay-position-monitor::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -13px;
  width: 3px;
  height: 12px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: #9fb2cd;
}

.setup-panel > #webcamPanel .overlay-position-monitor::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -17px;
  width: 54px;
  height: 4px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: #9fb2cd;
}

.setup-panel > #webcamPanel .overlay-position-btn {
  min-width: 0;
  min-height: 0;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  color: #63728a;
  font-size: 1.55rem;
  line-height: 1;
}

.setup-panel > #webcamPanel .overlay-position-btn:hover:not(:disabled) {
  transform: none;
  background: #eef4ff;
  color: var(--blue);
}

.setup-panel > #webcamPanel .overlay-position-btn[data-active="true"] {
  color: var(--blue);
  background: #eaf2ff;
  border: 1px solid #8db4ff;
  box-shadow: inset 0 0 0 1px rgba(47,115,241,0.08);
}

.setup-panel > #webcamPanel .webcam-preview-card {
  width: min(100%, 430px);
}

#recorderStatus .status-actions:empty {
  display: none !important;
}

#recorderStatus #recordToggleBtn {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1;
}

@media (max-width: 760px) {
  .setup-panel > #webcamPanel.webcam-panel {
    grid-template-columns: 1fr !important;
  }

  .setup-panel > #webcamPanel .overlay-position-group {
    width: 100%;
  }

  .setup-panel > #webcamPanel .overlay-position-monitor {
    width: min(190px, 100%);
  }
}


/* Three-column webcam controls layout */
.setup-panel > #webcamPanel.webcam-panel {
  display: block;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.setup-panel > #webcamPanel .panel-heading {
  margin-bottom: 14px;
}

.setup-panel > #webcamPanel .webcam-controls-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.setup-panel > #webcamPanel .webcam-control-card {
  min-height: 250px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.setup-panel > #webcamPanel .overlay-position-card,
.setup-panel > #webcamPanel .overlay-style-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.setup-panel > #webcamPanel .overlay-position-label,
.setup-panel > #webcamPanel .slider-header-row label {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

.setup-panel > #webcamPanel .overlay-position-monitor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  width: 160px;
  height: 160px;
  margin-top: 14px;
  border: 2px solid #c8d7ef;
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, #fbfdff, #f3f7ff);
}

.setup-panel > #webcamPanel .overlay-position-monitor::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -16px;
  width: 10px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #9eb0cf;
}

.setup-panel > #webcamPanel .overlay-position-monitor::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -22px;
  width: 64px;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #9eb0cf;
}

.setup-panel > #webcamPanel .overlay-position-btn {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 2rem;
  font-weight: 700;
  color: #60718f;
}

.setup-panel > #webcamPanel .overlay-position-btn:nth-child(1),
.setup-panel > #webcamPanel .overlay-position-btn:nth-child(2) {
  border-bottom: 1px solid #d7e3f4;
}

.setup-panel > #webcamPanel .overlay-position-btn:nth-child(1),
.setup-panel > #webcamPanel .overlay-position-btn:nth-child(3) {
  border-right: 1px solid #d7e3f4;
}

.setup-panel > #webcamPanel .overlay-position-btn[data-active="true"] {
  background: #edf4ff;
  color: var(--blue);
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.22);
}

.setup-panel > #webcamPanel .overlay-style-card {
  gap: 18px;
}

.setup-panel > #webcamPanel .slider-control-group {
  width: 100%;
  display: grid;
  gap: 10px;
}

.setup-panel > #webcamPanel .slider-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setup-panel > #webcamPanel .slider-header-row span {
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 700;
}

.setup-panel > #webcamPanel input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.setup-panel > #webcamPanel .webcam-preview-card {
  display: grid;
  gap: 12px;
  min-height: 250px;
  margin: 0;
}

.setup-panel > #webcamPanel .webcam-preview-card video,
.setup-panel > #webcamPanel .webcam-preview-placeholder {
  width: 100%;
  min-height: 170px;
}

.setup-panel > #webcamPanel .webcam-preview-card video {
  max-height: 220px;
  object-fit: cover;
  background: #0f172a;
}

@media (max-width: 1100px) {
  .setup-panel > #webcamPanel .webcam-controls-layout {
    grid-template-columns: 1fr;
  }

  .setup-panel > #webcamPanel .webcam-control-card {
    min-height: 0;
  }
}


/* Slider behavior + live webcam style preview */
.setup-panel > #webcamPanel .overlay-style-card {
  justify-content: center;
}

.setup-panel > #webcamPanel .slider-control-group + .slider-control-group {
  margin-top: 20px;
}

.setup-panel > #webcamPanel input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dbeafe, #bfdbfe);
  outline: none;
}

.setup-panel > #webcamPanel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 5px rgba(30, 64, 175, 0.35);
  cursor: pointer;
}

.setup-panel > #webcamPanel input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 5px rgba(30, 64, 175, 0.35);
  cursor: pointer;
}

.setup-panel > #webcamPanel .webcam-preview-card {
  align-content: start;
}

.setup-panel > #webcamPanel .webcam-preview-card video,
.setup-panel > #webcamPanel .webcam-preview-placeholder {
  transition: width .15s ease, height .15s ease, border-radius .15s ease;
}


/* Slider correction: normalized 0–100 scale and distortion-free preview */
.setup-panel > #webcamPanel input[type="range"] {
  width: 100%;
  height: 22px;
  padding: 0;
  margin: 2px 0 0;
  appearance: auto;
  -webkit-appearance: auto;
  accent-color: var(--blue);
  background: transparent;
  border: 0;
  border-radius: 0;
}

/* Let the browser render a consistent, correctly scaled native range track. */
.setup-panel > #webcamPanel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: auto;
  width: auto;
  height: auto;
  border: 0;
  box-shadow: none;
}

.setup-panel > #webcamPanel input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 4px rgba(30, 64, 175, 0.25);
}

.setup-panel > #webcamPanel .webcam-preview-card video {
  min-height: 0 !important;
  object-fit: cover !important;
  object-position: center !important;
}


/* Final webcam-control polish: centered position selector and meaningful size scale */
.setup-panel > #webcamPanel .overlay-position-card {
  align-items: center !important;
  justify-content: flex-start;
  text-align: center;
}

.setup-panel > #webcamPanel .overlay-position-label {
  width: 100%;
  text-align: center;
}

.setup-panel > #webcamPanel .overlay-position-monitor {
  margin: 16px auto 28px !important;
}

.setup-panel > #webcamPanel .slider-range-hints {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.setup-panel > #webcamPanel #overlaySizeRange {
  direction: ltr;
}


/* Final recorder grid polish: 2 rows of 3 matching cards */
.setup-panel {
  display: grid;
  gap: 18px;
}

.setup-panel .mode-picker {
  margin: 0;
}

.setup-panel .mode-grid,
.setup-panel > #webcamPanel .webcam-controls-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.setup-panel > #webcamPanel.webcam-panel {
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.setup-panel > #webcamPanel .panel-heading {
  display: none;
}

.setup-panel > #webcamPanel .webcam-controls-layout {
  gap: 18px;
}

.setup-panel > #webcamPanel .webcam-control-card {
  min-height: 205px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.setup-panel > #webcamPanel .overlay-position-card,
.setup-panel > #webcamPanel .overlay-style-card,
.setup-panel > #webcamPanel .webcam-preview-card {
  justify-content: flex-start;
}

.setup-panel > #webcamPanel .overlay-position-label,
.setup-panel > #webcamPanel .slider-header-row label,
.setup-panel > #webcamPanel .webcam-preview-heading strong {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
}

.setup-panel > #webcamPanel .overlay-position-card {
  align-items: center;
}

.setup-panel > #webcamPanel .overlay-position-monitor {
  margin: 18px auto 0;
}

.setup-panel > #webcamPanel .overlay-style-card {
  gap: 18px;
}

.setup-panel > #webcamPanel .slider-control-group {
  width: 100%;
}

.setup-panel > #webcamPanel .slider-range-hints {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.setup-panel > #webcamPanel .webcam-preview-card {
  align-items: stretch;
}

.setup-panel > #webcamPanel .webcam-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.setup-panel > #webcamPanel .webcam-preview-heading span {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.setup-panel > #webcamPanel .webcam-preview-card video,
.setup-panel > #webcamPanel .webcam-preview-placeholder {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.setup-panel > #webcamPanel .webcam-preview-card video {
  min-height: 150px;
  max-height: 170px;
}

.setup-panel > #webcamPanel .webcam-preview-placeholder {
  min-height: 150px;
  display: grid;
  place-items: center;
  text-align: center;
}

.setup-panel .inline-message {
  margin-top: 0;
  padding-top: 2px;
  border-top: 0;
}

@media (max-width: 1100px) {
  .setup-panel .mode-grid,
  .setup-panel > #webcamPanel .webcam-controls-layout {
    grid-template-columns: 1fr;
  }

  .setup-panel > #webcamPanel .webcam-control-card {
    min-height: 0;
  }
}


/* Firefox polish: compatibility notice below webcam controls + visible sliders */
.setup-panel > #firefoxWebcamNotice.browser-compatibility-notice {
  margin-top: 0;
}

@supports (-moz-appearance: none) {
  .setup-panel > #webcamPanel input[type="range"] {
    appearance: none;
    -moz-appearance: none;
    width: 100%;
    height: 22px;
    padding: 0;
    margin: 2px 0 0;
    background: transparent;
    border: 0;
    outline: none;
  }

  .setup-panel > #webcamPanel input[type="range"]::-moz-range-track {
    height: 6px;
    border: 0;
    border-radius: 999px;
    background: #dbe4f3;
  }

  .setup-panel > #webcamPanel input[type="range"]::-moz-range-progress {
    height: 6px;
    border: 0;
    border-radius: 999px;
    background: var(--blue);
  }

  .setup-panel > #webcamPanel input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 1px 5px rgba(30, 64, 175, 0.32);
    cursor: pointer;
  }

  .setup-panel > #webcamPanel input[type="range"]:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 4px rgba(47, 115, 241, 0.18), 0 1px 5px rgba(30, 64, 175, 0.32);
  }
}


/* Mobile screen-capture compatibility */
.mobile-unsupported-notice {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 17px 18px;
  border: 1px solid #b9d3ff;
  border-radius: 14px;
  background: #f2f7ff;
  color: #27446f;
}
.mobile-unsupported-notice[hidden] { display: none !important; }
.mobile-unsupported-icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; background: #dceaff; color: var(--blue);
  font-family: Georgia, serif; font-weight: 800; font-size: 1.05rem;
}
.mobile-unsupported-notice strong {
  display: block; margin-bottom: 5px; color: #16345f; font-size: 0.98rem;
}
.mobile-unsupported-notice p { margin: 0; line-height: 1.55; font-size: 0.9rem; }
.mobile-screen-capture-unsupported .mode-card { cursor: not-allowed; }
.mobile-screen-capture-unsupported .mode-card:has(input:disabled) { opacity: 0.58; }
.mobile-screen-capture-unsupported #recordToggleBtn:disabled { opacity: 0.62; cursor: not-allowed; }
@media (max-width: 760px) {
  .mobile-unsupported-notice { grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 15px; }
  .mobile-unsupported-icon { width: 32px; height: 32px; }
}


/* Exact overlay preview: miniature representation of the recorded frame */
.setup-panel > #webcamPanel .webcam-preview-card {
  overflow: visible;
}

.setup-panel > #webcamPanel .webcam-preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #d8e2f1;
  border-radius: 14px;
  background:
    linear-gradient(rgba(255,255,255,.88), rgba(255,255,255,.88)),
    linear-gradient(135deg, #e9eff8, #dfe8f5);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}

.setup-panel > #webcamPanel .webcam-preview-stage::before {
  content: "Recording frame";
  position: absolute;
  left: 10px;
  top: 8px;
  z-index: 1;
  padding: 3px 7px;
  border-radius: 999px;
  color: #74839c;
  background: rgba(255,255,255,.82);
  font-size: 0.68rem;
  font-weight: 700;
  pointer-events: none;
}

.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewVideo {
  position: absolute;
  z-index: 3;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  background: #0f172a;
  object-fit: cover;
}

.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewPlaceholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  min-width: 0;
  min-height: 0;
  padding: 34px 18px 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  text-align: center;
}

.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewPlaceholder[hidden],
.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewVideo.hidden {
  display: none !important;
}


/* Simple webcam preview: show the overlay itself, not a miniature screen */
.setup-panel > #webcamPanel .webcam-preview-stage {
  position: relative;
  width: 100%;
  min-height: 170px;
  aspect-ratio: auto !important;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
  border: 1px dashed #d5dfed;
  border-radius: 14px;
  background: #f8faff;
  box-shadow: none;
}

.setup-panel > #webcamPanel .webcam-preview-stage::before {
  display: none !important;
  content: none !important;
}

.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewVideo {
  position: relative;
  inset: auto;
  z-index: 2;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  background: #0f172a;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewPlaceholder {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
  min-height: 145px;
  padding: 18px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: center;
}


/* Clean webcam controls: four standalone position buttons + frameless preview */
.setup-panel > #webcamPanel .overlay-position-card {
  align-items: center;
}

.setup-panel > #webcamPanel .overlay-position-label {
  width: 100%;
  text-align: center;
}

.setup-panel > #webcamPanel .overlay-position-grid {
  width: min(100%, 230px);
  height: auto;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.setup-panel > #webcamPanel .overlay-position-grid::before,
.setup-panel > #webcamPanel .overlay-position-grid::after {
  display: none !important;
  content: none !important;
}

.setup-panel > #webcamPanel .overlay-position-btn,
.setup-panel > #webcamPanel .overlay-position-btn:nth-child(1),
.setup-panel > #webcamPanel .overlay-position-btn:nth-child(2),
.setup-panel > #webcamPanel .overlay-position-btn:nth-child(3),
.setup-panel > #webcamPanel .overlay-position-btn:nth-child(4) {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: #fff;
  color: #60718f;
  font-size: 2rem;
  line-height: 1;
  box-shadow: none;
}

.setup-panel > #webcamPanel .overlay-position-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #9ebcff;
  background: #f8fbff;
}

.setup-panel > #webcamPanel .overlay-position-btn[data-active="true"] {
  border: 2px solid var(--blue);
  background: #f2f7ff;
  color: var(--blue);
  box-shadow: 0 8px 18px rgba(47, 115, 241, 0.10);
}

/* The preview card itself is the container. No second box around the camera. */
.setup-panel > #webcamPanel .webcam-preview-stage {
  position: relative;
  width: 100%;
  min-height: 170px;
  aspect-ratio: auto !important;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.setup-panel > #webcamPanel .webcam-preview-stage::before,
.setup-panel > #webcamPanel .webcam-preview-stage::after {
  display: none !important;
  content: none !important;
}

.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewVideo {
  position: relative;
  inset: auto;
  z-index: 2;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 175px;
  margin: auto;
  object-fit: cover;
  background: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.setup-panel > #webcamPanel .webcam-preview-stage #webcamPreviewPlaceholder {
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  min-height: 150px;
  padding: 16px 12px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0 !important;
  background: transparent;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .setup-panel > #webcamPanel .overlay-position-grid {
    width: min(100%, 260px);
  }
}


/* Final title alignment cleanup */
.setup-panel > #webcamPanel .overlay-style-card .slider-control-group:first-child .slider-header-row {
  position: relative;
  justify-content: center;
}

.setup-panel > #webcamPanel .overlay-style-card .slider-control-group:first-child .slider-header-row label {
  text-align: center;
}

.setup-panel > #webcamPanel .overlay-style-card .slider-control-group:first-child .slider-header-row span {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.setup-panel > #webcamPanel .webcam-preview-heading {
  justify-content: center;
  text-align: center;
}

.setup-panel > #webcamPanel .webcam-preview-heading span {
  display: none;
}

/* Keep the How-to and FAQ content columns vertically aligned */
.how-section,
.faq-section {
  grid-template-columns: minmax(240px, 0.68fr) minmax(0, 1.32fr);
  gap: 42px;
  align-items: start;
}


/* Reset button — compact secondary control matching the Screenio UI */
.setup-panel > #webcamPanel .overlay-reset-btn {
  min-height: 38px;
  width: 100%;
  margin-top: auto;
  padding: 8px 14px;
  border: 1px solid #cfe0ff;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  color: var(--blue-dark);
  box-shadow: none;
  font-size: 0.84rem;
  font-weight: 750;
}

.setup-panel > #webcamPanel .overlay-reset-btn span {
  font-size: 1rem;
  line-height: 1;
}

.setup-panel > #webcamPanel .overlay-reset-btn:hover:not(:disabled) {
  border-color: #a9c7ff;
  background: #e3eeff;
  color: var(--blue-dark);
  box-shadow: 0 5px 14px rgba(47, 115, 241, 0.10);
  transform: translateY(-1px);
}

.setup-panel > #webcamPanel .overlay-reset-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.setup-panel > #webcamPanel .overlay-reset-btn:focus-visible {
  outline: 3px solid rgba(47, 115, 241, 0.20);
  outline-offset: 2px;
}


/* Final mobile layout guard
   Keep content sections single-column on phones even though the shared
   desktop alignment rule appears later in this stylesheet. */
@media (max-width: 760px) {
  .how-section,
  .faq-section {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .how-section > *,
  .faq-section > *,
  .steps-list,
  .faq-list,
  .steps-list li,
  .steps-list li > div,
  .faq-list details,
  .faq-list summary {
    min-width: 0;
    max-width: 100%;
  }

  .steps-list,
  .faq-list {
    width: 100%;
  }

  .steps-list li {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .steps-list strong,
  .steps-list p,
  .faq-list summary,
  .faq-list details p {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 520px) {
  .how-section,
  .faq-section {
    gap: 22px;
  }
}
