:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-alt: #eef2f7;
  --text: #111827;
  --text-muted: #6b7280;
  --color-primary-2: #37B59F;
  --primary: var(--color-primary-2);
  --primary-hover: #2d9a87;
  --accent: var(--color-primary-2);
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --border: #d5dce5;
  --focus: #93c5fd;
  --focus-green: #7dd3c0;

  --radius: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Manrope, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  color: var(--text);
  background:
    radial-gradient(1200px 550px at 100% -10%, #e9f0ff 0%, rgba(233, 240, 255, 0) 70%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: var(--space-4) auto 0;
  padding: 0 var(--space-4);
  min-height: 40px;
  color: var(--text);
}

.brand-link {
  color: var(--primary);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  text-decoration: none;
  transition: color 160ms ease-out;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
}

.brand-logo img {
  display: block;
  height: 32px;
  width: auto;
}

.brand-link:hover {
  color: var(--primary-hover);
}

.brand-logo:hover img {
  opacity: 0.9;
}

.brand-link:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus);
}

.brand-link-secondary {
  color: var(--text-muted);
  font-weight: 400;
}

.brand-link-secondary:hover {
  color: var(--text);
}

/* Page footer (full-width, multi-column) */
.page-footer {
  width: 100%;
  margin-top: var(--space-7);
  padding: var(--space-7) 0 var(--space-5);
  background: linear-gradient(180deg, var(--surface-alt) 0%, #e6ecf3 100%);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.footer-main {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: var(--space-6);
  padding-bottom: var(--space-6);
}

.footer-brand .footer-logo {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  text-decoration: none;
  transition: color 160ms ease-out;
}

.footer-brand .footer-logo:hover {
  color: var(--primary-hover);
}

.footer-brand .footer-logo:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus);
}

.footer-brand .footer-logo img {
  display: block;
  height: 32px;
  width: auto;
}

.footer-desc {
  margin: var(--space-4) 0;
  font-size: 14px;
  line-height: 22px;
  color: var(--text-muted);
  max-width: 280px;
}

.footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: color 160ms ease-out, border-color 160ms ease-out, background 160ms ease-out;
}

.footer-social a:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: #e8f7f4;
}

.footer-social a:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus);
}

.footer-col .footer-title {
  margin: 0 0 var(--space-3);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.footer-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-menu li {
  margin-bottom: var(--space-2);
}

.footer-menu a {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 160ms ease-out;
}

.footer-menu a:hover {
  color: var(--primary);
}

.footer-menu a:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus);
}

.footer-newsletter-form {
  margin-bottom: var(--space-3);
}

.footer-newsletter-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.footer-newsletter-row input {
  flex: 1;
  min-width: 160px;
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}

.footer-newsletter-row input::placeholder {
  color: var(--text-muted);
}

.footer-newsletter-row input:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--focus-green);
}

.footer-newsletter-disc {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--text-muted);
}

.footer-copyright {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-muted);
}

.footer-copyright p {
  margin: 0;
}

.footer-copyright a {
  color: var(--primary);
  text-decoration: none;
  transition: color 160ms ease-out;
}

.footer-copyright a:hover {
  color: var(--primary-hover);
}

.footer-copyright a:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus);
}

.footer-copyright ul {
  display: flex;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.app {
  width: min(1200px, 94vw);
  margin: var(--space-6) auto;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  animation: reveal 160ms ease-out;
}

h1 {
  margin: 0 0 var(--space-2);
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
}

h2 {
  margin: var(--space-2) 0;
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
}

.subtitle {
  margin: 0 0 var(--space-5);
  color: var(--text-muted);
}

.camera-panel {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 3 / 4;
  margin: 0 auto var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b1220;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

video,
img {
  width: 100%;
  display: block;
}

#video,
#preview {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  object-fit: cover;
  background: #0b1220;
}

.camera-help {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  margin: 0;
  max-width: min(90%, 560px);
  padding: var(--space-2) var(--space-3);
  border-radius: 999px;
  font-size: 13px;
  line-height: 18px;
  color: #f9fbff;
  background: rgba(11, 18, 32, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-align: center;
}

.camera-panel.is-live .camera-help {
  opacity: 0.86;
}

.camera-panel.is-live .camera-placeholder {
  display: none;
}

.camera-feedback {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 3;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 16px;
  color: #f9fbff;
  background: rgba(11, 18, 32, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.camera-feedback[data-state="success"] {
  background: rgba(22, 163, 74, 0.9);
  border-color: rgba(187, 247, 208, 0.45);
}

.camera-feedback[data-state="warning"] {
  background: rgba(217, 119, 6, 0.9);
  border-color: rgba(254, 215, 170, 0.45);
}

.camera-feedback[data-state="danger"] {
  background: rgba(220, 38, 38, 0.92);
  border-color: rgba(254, 202, 202, 0.5);
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  gap: var(--space-2);
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: #e8eef8;
  background:
    radial-gradient(500px 220px at 50% 0%, rgba(79, 141, 255, 0.22) 0%, rgba(79, 141, 255, 0) 70%),
    linear-gradient(180deg, rgba(8, 14, 28, 0.9) 0%, rgba(8, 14, 28, 0.95) 100%);
}

.camera-placeholder-title {
  margin: 0;
  font-size: 22px;
  line-height: 30px;
  font-weight: 700;
  color: #f8fbff;
}

.camera-placeholder-copy {
  margin: 0;
  max-width: 56ch;
  color: #cfd7e7;
}

.controls {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: 0 0 var(--space-4);
}

.btn {
  min-height: 40px;
  min-width: 40px;
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out, box-shadow 160ms ease-out;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-primary:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus-green);
}

.btn-primary:active:not(:disabled) {
  background: #268a78;
  border-color: #268a78;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: #b6c0cd;
  background: #f8fbff;
}

.btn-secondary:active:not(:disabled) {
  border-color: #9eaab9;
  background: #eef3f9;
}

.btn:focus-visible,
.file-label:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus);
}

.file-label {
  display: inline-flex;
  align-items: center;
}

#fileInput {
  display: none;
}

.control-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 100%;
  min-width: 0;
}

.control-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.input-text {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--surface);
}

.input-text::placeholder {
  color: var(--text-muted);
}

.input-text:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--focus);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.status {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-alt);
  margin: 0 0 var(--space-4);
}

.status::before {
  content: "i";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e2f6f3;
  color: #1f8070;
  flex-shrink: 0;
}

.status[data-state="success"] {
  border-left-color: var(--success);
}

.status[data-state="success"]::before {
  content: "ok";
  background: #dcfce7;
  color: #166534;
}

.status[data-state="warning"] {
  border-left-color: var(--warning);
}

.status[data-state="warning"]::before {
  content: "!";
  background: #fff1db;
  color: #92400e;
}

.status[data-state="danger"] {
  border-left-color: var(--danger);
}

.status[data-state="danger"]::before {
  content: "x";
  background: #fee2e2;
  color: #991b1b;
}

.progress-panel {
  margin: 0 0 var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e4ebf5;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #4f8dff);
  transition: width 160ms ease-out;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 20px;
  margin-top: var(--space-2);
}

.results {
  display: grid;
  gap: var(--space-2);
}

.results-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.results-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-4);
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  color: var(--text);
  transition: background-color 160ms ease-out, color 160ms ease-out;
}

.results-accordion summary::-webkit-details-marker {
  display: none;
}

.results-accordion summary::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-left: var(--space-2);
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  vertical-align: 0.2em;
  transition: transform 160ms ease-out;
}

.results-accordion[open] summary::after {
  transform: rotate(-135deg);
  vertical-align: -0.1em;
}

.results-accordion summary:hover {
  background: var(--surface-alt);
}

.results-accordion-panel {
  padding: 0 var(--space-4) var(--space-4);
  display: grid;
  gap: var(--space-4);
}

.results-accordion-panel h3 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  margin: 0 0 var(--space-2);
}

.results-accordion-panel h3:not(:first-child) {
  margin-top: var(--space-4);
}

pre {
  margin: 0;
  padding: var(--space-4);
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
}

.results-cleaned-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.results-textarea {
  margin: 0;
  padding: var(--space-4);
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  resize: vertical;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}

.results-textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px var(--focus);
}

.results-cleaned-wrap .btn {
  align-self: flex-start;
}

.run-log {
  margin-top: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.run-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.run-log-header h2 {
  margin: 0;
}

.run-log-subtitle {
  margin: var(--space-2) 0 var(--space-3);
}

.run-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: var(--space-2);
}

.run-item {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.run-item-empty {
  color: var(--text-muted);
}

.run-item-meta {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 18px;
}

.run-item-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.run-item-status-failed {
  border-color: #fecaca;
  background: #fef2f2;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .app {
    width: 100vw;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    padding: var(--space-4);
  }

  .controls {
    gap: var(--space-2);
  }

  .btn,
  .file-label {
    flex: 1 1 calc(50% - var(--space-2));
    justify-content: center;
    text-align: center;
  }

  .progress-meta {
    flex-direction: column;
    gap: var(--space-1);
  }

  .run-log-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  .footer-main {
    grid-template-columns: 1fr;
    gap: var(--space-5);
    padding-bottom: var(--space-5);
  }

  .footer-brand .footer-desc {
    max-width: none;
  }

  .footer-copyright {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}
