:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee7;
  --accent: #0f7b6c;
  --accent-strong: #0a5d52;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(20, 32, 44, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

button:hover,
.file-button:hover {
  border-color: #9aa8b8;
  background: #f9fafb;
}

button:active,
.file-button:active {
  transform: translateY(1px);
}

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

.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.secondary {
  color: var(--danger);
}

.app-shell {
  width: min(1760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
}

.workspace,
.control-panel {
  min-width: 0;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr);
  gap: 14px;
}

.topbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.1;
}

h2 {
  font-size: 15px;
}

.status-pill {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--accent-strong);
  border-color: rgba(15, 123, 108, 0.35);
  background: rgba(15, 123, 108, 0.08);
}

.status-pill.warn {
  color: var(--warn);
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.08);
}

.viewer {
  position: relative;
  min-height: 0;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #111827;
  box-shadow: var(--shadow);
}

#imageView,
#video,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#video {
  background: #111827;
}

#imageView {
  display: none;
  background: #111827;
}

#imageView.visible {
  display: block;
}

#video.hidden {
  display: none;
}

#overlay {
  pointer-events: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #cbd5e1;
  font-size: 18px;
}

.empty-state.hidden {
  display: none;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  min-height: 38px;
  padding: 0 10px;
}

.field input[type="range"] {
  padding: 0;
}

.field b {
  color: var(--ink);
  font-weight: 700;
}

.file-button input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.capabilities {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid button {
  grid-column: 1 / -1;
}

.metrics dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
}

.metrics dt {
  color: var(--muted);
  font-size: 12px;
}

.metrics dd {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 750;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #344054;
  background: #f8fafc;
  border: 1px solid #e4e7ec;
  border-radius: 7px;
  padding: 10px;
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}

.log-section pre {
  max-height: 160px;
}

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

  .control-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-panel,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .viewer {
    min-height: 300px;
  }
}
