:root {
  color-scheme: light;
  --bg: #f3f3f3;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-alt: #f7f7f7;
  --border: #cfcfcf;
  --border-strong: #9d9d9d;
  --text: #111111;
  --muted: #4f4f4f;
  --accent: #111111;
  --accent-deep: #111111;
  --accent-soft: #efefef;
  --success: #1d5f39;
  --warning: #7a5a00;
  --danger: #8f1d1d;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body.pre-upload .page-shell {
  grid-template-columns: minmax(0, 38rem);
  justify-content: center;
}

body.verification-stage .page-shell {
  grid-template-columns: minmax(17rem, 22rem) minmax(24rem, 34rem);
  justify-content: center;
  align-items: start;
}

body.verification-stage .status-panel {
  max-width: 22rem;
}

body.verification-stage .workspace {
  max-width: 34rem;
  align-content: start;
}

body.exam-stage .page-shell {
  grid-template-columns: minmax(0, 1fr);
  max-width: min(96vw, 1280px);
  margin: 0 auto;
  gap: 0.75rem;
  padding-top: 0.75rem;
}

body.exam-stage .status-panel {
  display: block;
}

body.exam-stage .status-panel > :not(#actionRow) {
  display: none;
}

body.exam-stage .status-panel > #sessionReviewCard:not(.hidden) {
  display: block;
  margin-bottom: 0.75rem;
}

body.exam-stage .action-row {
  display: flex;
  justify-content: flex-end;
}

body.exam-stage .workspace {
  grid-template-columns: minmax(0, 1fr) 6rem;
  grid-template-areas: "viewer video";
  align-items: start;
  gap: 0.85rem;
}

button,
input,
textarea {
  font: inherit;
}

button,
input,
textarea,
iframe {
  border: 0;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1rem 1.5rem 0;
}

.brand-block h1 {
  margin-bottom: 0;
}

.session-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  width: min(52rem, 100%);
}

.session-chip {
  display: grid;
  gap: 0.2rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: #ffffff;
  box-shadow: none;
}

.session-chip-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.session-chip strong {
  font-size: 0.92rem;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(19rem, 23rem) minmax(0, 1fr);
  gap: 1rem;
  padding: 1.5rem;
}

.status-panel,
.workspace {
  display: grid;
  gap: 1.5rem;
}

.status-panel {
  align-content: start;
}

body.pre-upload .status-panel {
  max-width: 38rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  box-shadow: var(--shadow);
}

.status-panel > .card,
.workspace > .card {
  padding: 1.4rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

h1,
h2,
.lede {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  line-height: 1.1;
  font-weight: 700;
}

h2 {
  margin-bottom: 0.65rem;
  font-size: 1.08rem;
  font-weight: 700;
}

.lede,
.prompt,
.modal-copy,
li,
.support-message,
.viewer-placeholder,
.prompt-block {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.96rem;
}

.status-stack {
  display: grid;
  gap: 1rem;
}

.section-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.metrics {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.metrics div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: var(--panel-alt);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.alert-card ul {
  margin: 0;
  padding-left: 1.2rem;
}

.action-row {
  display: grid;
  gap: 0.7rem;
}

.flow-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.85rem;
}

.flow-list li {
  color: var(--text);
  padding-left: 0.15rem;
}

.flow-list strong,
.flow-list span {
  display: block;
}

.flow-list span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.primary-button,
.secondary-button {
  border-radius: 0.2rem;
  padding: 0.9rem 1.05rem;
  cursor: pointer;
  transition: opacity 140ms ease, background 140ms ease;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  background: #ffffff;
  color: var(--accent-deep);
  border: 1px solid var(--border);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:not(:disabled):hover {
  opacity: 0.92;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 0.2rem;
  padding: 0.38rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-idle {
  background: rgba(100, 82, 67, 0.14);
  color: var(--muted);
}

.badge-safe {
  background: rgba(29, 122, 86, 0.12);
  color: var(--success);
}

.badge-warning {
  background: rgba(184, 116, 0, 0.14);
  color: var(--warning);
}

.badge-danger {
  background: rgba(155, 28, 28, 0.12);
  color: var(--danger);
}

.upload-card {
  display: grid;
  gap: 1rem;
}

.generated-test-panel {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: var(--panel-alt);
}

.upload-card label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
}

.verification-panel {
  align-content: start;
}

.file-picker {
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: 0.2rem;
  background: var(--panel-alt);
  color: var(--muted);
}

.file-picker input {
  width: 100%;
}

.video-card,
.viewer-card {
  padding: 1.4rem;
}

body.exam-stage .video-card {
  grid-area: video;
  padding: 0.45rem;
}

body.exam-stage .viewer-card {
  grid-area: viewer;
  padding: 0.95rem;
}

body.verification-stage .video-card {
  padding: 1rem;
}

.video-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.video-stage {
  position: relative;
  overflow: hidden;
  border-radius: 0.2rem;
  aspect-ratio: 16 / 9;
  background: #101010;
  border: 1px solid #2b2b2b;
  width: min(100%, 28rem);
}

body.verification-stage .video-stage {
  width: 100%;
  max-width: 32rem;
}

body.exam-stage .video-stage {
  width: 100%;
  max-width: none;
  aspect-ratio: 1 / 1;
  max-width: 32px;
  max-height: 32px;
  min-height: 32px;
  min-width: 32px;
}

.video-card {
  align-content: start;
}

#cameraFeed,
#overlayCanvas,
.frame-guide,
.license-guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#cameraFeed,
#overlayCanvas {
  object-fit: cover;
}

.frame-guide {
  inset: 4%;
  width: auto;
  height: auto;
  border: 2px dashed rgba(255, 255, 255, 0.75);
  border-radius: 0.25rem;
  pointer-events: none;
}

.license-guide {
  display: grid;
  place-items: center;
  gap: 0.9rem;
  pointer-events: none;
}

.license-guide-card {
  width: 52%;
  aspect-ratio: 1.58 / 1;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 0.2rem;
  background:
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) top left / 2rem 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) top left / 2px 2rem no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) top right / 2rem 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) top right / 2px 2rem no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) bottom left / 2rem 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) bottom left / 2px 2rem no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) bottom right / 2rem 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)) bottom right / 2px 2rem no-repeat;
}

.license-guide p {
  margin: 0;
  padding: 0.45rem 0.8rem;
  border-radius: 0.2rem;
  background: rgba(0, 0, 0, 0.68);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
}

.viewer-placeholder,
.document-frame,
.image-preview,
.text-preview {
  width: 100%;
  min-height: 28rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: #fbfcfe;
}

.viewer-placeholder {
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
}

.document-frame {
  min-height: 40rem;
  background: #ffffff;
}

body.exam-stage .document-frame {
  min-height: clamp(20rem, 58vh, 34rem);
}

.image-preview {
  object-fit: contain;
  padding: 0.5rem;
}

.text-preview {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.95rem;
}

.notes-panel {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.generated-test-workspace {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.generated-questions {
  display: grid;
  gap: 1rem;
}

.generated-question {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: var(--panel-alt);
}

.generated-question h3,
.grading-item h3 {
  margin: 0;
  font-size: 1rem;
}

.generated-question-image {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: #ffffff;
}

.generated-options {
  display: grid;
  gap: 0.55rem;
}

.generated-source {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding-top: 0.2rem;
}

.generated-source summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}

.generated-source-frame {
  width: 100%;
  min-height: 32rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: #ffffff;
}

.generated-option {
  display: flex;
  align-items: start;
  gap: 0.55rem;
  color: var(--text);
}

.generated-option input {
  margin-top: 0.15rem;
}

.grading-breakdown {
  display: grid;
  gap: 0.75rem;
}

.grading-item {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
}

.grading-item-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.3fr) minmax(18rem, 0.9fr);
  align-items: start;
}

.grading-question-panel,
.grading-answer-panel {
  display: grid;
  gap: 0.75rem;
}

.grading-answer-panel {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: rgba(255, 255, 255, 0.75);
}

.grading-answer-panel p,
.grading-question-text {
  margin: 0;
}

.grading-question-image {
  max-height: none;
}

.grading-item.correct {
  border-color: rgba(29, 95, 57, 0.35);
  background: rgba(29, 95, 57, 0.06);
}

.grading-item.incorrect {
  border-color: rgba(143, 29, 29, 0.3);
  background: rgba(143, 29, 29, 0.05);
}

.notes-panel textarea,
.preflight-textarea,
.modal-form input,
.generated-question textarea,
.generated-test-panel input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  padding: 0.85rem 0.95rem;
  resize: vertical;
  background: white;
}

.notes-panel textarea {
  min-height: 14rem;
  background: #f9fbfd;
}

body.exam-stage .notes-panel {
  margin-top: 0.75rem;
}

body.exam-stage .notes-panel textarea {
  min-height: clamp(7rem, 16vh, 10rem);
}

body.exam-stage .generated-question {
  padding: 0.75rem;
}

body.exam-stage .grading-item-layout {
  grid-template-columns: 1fr;
}

body.exam-stage .support-message,
body.exam-stage .viewer-placeholder,
body.exam-stage .prompt-block {
  font-size: 0.82rem;
  line-height: 1.3;
}

body.exam-stage .video-header h2,
body.exam-stage .viewer-card h2 {
  margin-bottom: 0.2rem;
}

body.exam-stage .video-card .eyebrow,
body.exam-stage .viewer-card .eyebrow {
  margin-bottom: 0.2rem;
}

body.exam-stage .video-card h2 {
  font-size: 0.72rem;
}

body.exam-stage .video-card .support-message {
  font-size: 0.68rem;
}

body.exam-stage .video-card .video-header {
  gap: 0.35rem;
}

body.exam-stage .video-card .badge {
  padding: 0.2rem 0.3rem;
  font-size: 0.62rem;
}

.preflight-textarea {
  min-height: 9rem;
}

@media (max-width: 900px) {
  .grading-item-layout {
    grid-template-columns: 1fr;
  }
}

.prompt-card {
  padding: 1rem;
  border-radius: 0.2rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  box-shadow: none;
}

.error-message {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(0, 0, 0, 0.4);
}

.modal.hidden,
.error-message.hidden,
.hidden {
  display: none;
}

.modal-panel {
  width: min(100%, 34rem);
  max-height: min(86vh, 52rem);
  overflow: auto;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal-form {
  display: grid;
  gap: 1rem;
}

.modal-form label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
}

.verification-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.capture-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

#simulatedVerificationFields {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

#simulatedVerificationFields.hidden {
  display: none;
}

#simulatedVerificationFields .capture-actions {
  grid-column: 1 / -1;
}

.capture-preview {
  width: 100%;
  max-height: 8.5rem;
  object-fit: contain;
  border-radius: 0.2rem;
  border: 1px solid var(--border);
  background: #fbfcfe;
  padding: 0.5rem;
}

.license-assist-panel {
  display: grid;
  gap: 0.75rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  background: var(--panel-alt);
}

.license-assist-panel .eyebrow {
  margin-bottom: 0.3rem;
}

.license-assist-panel .support-message {
  margin: 0;
}

.license-assist-canvas {
  width: 100%;
  aspect-ratio: 1.58 / 1;
  max-height: 8.5rem;
  border-radius: 0.2rem;
  border: 1px solid var(--border-strong);
  background: #f4f4f4;
}

.selfie-assist-canvas {
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.verification-panel .modal-form {
  gap: 0.75rem;
}

.verification-panel .modal-copy,
.verification-panel .support-message,
.verification-panel .prompt-block,
.verification-panel .capture-actions {
  font-size: 0.85rem;
  line-height: 1.35;
}

.verification-panel .eyebrow {
  margin-bottom: 0.25rem;
}

.verification-panel h2 {
  margin-bottom: 0.35rem;
}

.verification-panel .primary-button,
.verification-panel .secondary-button {
  padding: 0.72rem 0.8rem;
}

body.verification-stage .viewer-card {
  display: none;
}

@media (max-width: 1180px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .session-strip {
    width: 100%;
  }
}

@media (max-width: 960px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  body.verification-stage .page-shell {
    grid-template-columns: 1fr;
  }

  body.exam-stage .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "video"
      "viewer";
  }

  .session-strip {
    grid-template-columns: 1fr;
  }

  #simulatedVerificationFields {
    grid-template-columns: 1fr;
  }

  .document-frame {
    min-height: 28rem;
  }
}
