:root {
  color-scheme: dark;
  font: 16px/1.5 system-ui, sans-serif;
  background: #0c141b;
  color: #eaf1f5;
}
body { margin: 0; }
main {
  width: min(calc(100% - 32px), 1480px);
  margin: 28px auto;
  box-sizing: border-box;
  padding: clamp(16px, 3vw, 36px);
  background: #14212b;
  border: 1px solid #354953;
  border-radius: 18px;
}
h1 { margin: 0; letter-spacing: -.04em; }
h2 { font-size: 1.2rem; }
label { display: block; margin: 12px 0 6px; }
input, button, select { box-sizing: border-box; font: inherit; border-radius: 8px; padding: 9px 14px; }
input { width: min(100%, 550px); margin-bottom: 8px; border: 1px solid #577078; background: #101820; color: inherit; }
.field-actions input { flex: 1 1 220px; min-width: 0; margin: 0; }
button:focus-visible, input:focus-visible { outline: 2px solid #82dfc2; outline-offset: 3px; }
button { border: 1px solid transparent; background: #82dfc2; color: #102a27; font-weight: 650; cursor: pointer; }
button.secondary { border-color: #a4b7bf; background: transparent; color: inherit; }
button:disabled { opacity: .5; cursor: default; }
video { display: block; width: 100%; background: #0b1118; }
[hidden] { display: none !important; }

#desktop { display: block; touch-action: none; user-select: none; }
#desktop:focus { outline: 2px solid #82dfc2; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid #344752;
  margin-bottom: 22px;
}
.product-name { margin: 0 0 2px; color: #b4c7d1; font-size: .9rem; }
.page-header h1 { font-size: clamp(1.65rem, 4vw, 2.35rem); }
#connection-state {
  padding: 5px 12px;
  border-radius: 20px;
  background: #223440;
  color: #d9e5ea;
  font-weight: 650;
}
#connection-state[data-stage="waiting"] { background: #3d321e; color: #ffdd9c; }
#connection-state[data-stage="active"] { background: #153c34; color: #a5f0d6; }
.connection-card {
  max-width: 640px;
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid #344752;
  border-radius: 12px;
  background: #101b24;
}
.connection-card h2 { margin: 0; }
.field-actions, .file-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.field-help { margin: 8px 0 0; color: #b4c7d1; font-size: .9rem; }
.field-help:empty { display: none; }
#assistant-download { margin: 0 0 14px; }
#assistant-download a { color: #a5e9ff; text-underline-offset: 3px; }
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 0;
}
.session-bar p { margin: 0; }
.session-bar:has(p:empty):has(button[hidden]) { display: none; }
.session-layout, .session-sidebar { display: grid; gap: 16px; }
.session-sidebar { align-content: start; min-width: 0; }
.session-layout:not(:has(.preview:not([hidden]))) .session-sidebar { max-width: 686px; }
.preview { align-self: start; background: #081017; border: 1px solid #344752; padding: 8px; border-radius: 12px; min-width: 0; }
main:has(.preview:not([hidden])) { width: calc(100% - 24px); padding-inline: clamp(12px, 2vw, 28px); }
.preview-header { padding: 4px 6px 10px; }
.preview-header h2, #control-help { margin: 0; }
#control-help { margin-top: 4px; font-size: .9rem; color: #b4c7d1; }
.preview-toolbar, .preview-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.preview-toolbar { justify-content: space-between; }
.preview-actions label, .preview-actions input { margin: 0; }
.preview-actions select { max-width: 100%; color: inherit; background: #101820; border: 1px solid #577078; }
.preview-actions input { width: min(110px, 100%); padding: 0; }
.preview-screen {
  height: 68vh;
  min-height: 180px;
  overflow: auto;
  resize: vertical;
  border-radius: 5px;
  background: #050a0e;
}
.preview-screen > :is(img, video) { width: var(--view-zoom, 100%); margin-inline: auto; }
.preview-screen > :focus-visible { outline-offset: -3px; }
.preview:fullscreen { box-sizing: border-box; display: flex; flex-direction: column; border: 0; border-radius: 0; }
.preview:fullscreen .preview-screen { flex: 1; resize: none; min-height: 0; }
.diagnostics { min-width: 0; background: #101b24; border: 1px solid #344752; border-radius: 12px; padding: 16px; align-self: start; }
.diagnostics h2 { margin: 0 0 14px; }
.incoming-file { padding: 10px; border-radius: 8px; background: #192934; }
#file-name { margin: 0 0 8px; overflow-wrap: anywhere; }
#file-picker { width: 100%; font-size: .9rem; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 18px; }
.metrics div { padding: 8px 10px; background: #192934; border-radius: 7px; }
.metrics dt, #chart-summary { font-size: .85rem; color: #b4c7d1; }
.metrics dd { margin: 4px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; }
figure { margin: 0; }
figcaption { font-size: .9rem; font-weight: 600; }
#response-chart { display: block; width: 100%; height: 150px; }
#chart-summary { margin: 4px 0 0; }
@media (min-width: 1050px) {
  .session-layout:has(.preview:not([hidden])) .session-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
