:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --line: #d9dee7;
  --text: #141b2d;
  --muted: #667085;
  --accent: #111827;
  --accent-2: #374151;
  --ok: #16a34a;
  --warn: #b45309;
  --danger: #dc2626;
  --shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}
code {
  padding: 2px 5px;
  border-radius: 6px;
  background: #eef2f7;
  color: #111827;
  font-size: 0.95em;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.logo {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.links a {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #ffffff;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.15;
}
.links a.active,
.links a:hover {
  color: var(--text);
  border-color: #9ca3af;
  background: #f3f4f6;
}

.shell {
  width: min(1440px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 40px;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}
.hero-single {
  grid-template-columns: 1fr;
}
.hero-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.hero-card {
  padding: 26px;
  overflow: hidden;
  position: relative;
}
.hero-card:after {
  display: none;
}
h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 4.2vw, 54px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}
.lead {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
  max-width: 850px;
}
.note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.warning {
  color: var(--warn);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}
.metric {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.metric strong {
  display: block;
  font-size: 24px;
  letter-spacing: -0.04em;
  line-height: 1;
  overflow-wrap: anywhere;
}
.metric span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}
.face-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
}
.face-grid.emotions-off {
  grid-template-columns: 1fr;
}
.stage {
  padding: 12px;
}
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 14px;
  background: #0f172a;
  border: 1px solid var(--line);
}
video,
canvas.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
canvas.graph-canvas {
  width: 100%;
  max-width: 100%;
  height: 220px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
canvas.hidden-sample {
  display: none;
}
.status-pill {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(209, 213, 219, 0.9);
  color: #374151;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
}
.dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--warn);
}
.dot.live {
  background: var(--ok);
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
button,
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #111827;
  cursor: pointer;
  color: #ffffff;
  background: #111827;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
  box-shadow: none;
  text-align: center;
}
button:hover,
.button:hover {
  background: #1f2937;
}
button.secondary,
.button.secondary {
  color: #111827;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: none;
}
button.secondary:hover,
.button.secondary:hover {
  background: #f3f4f6;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.panel {
  padding: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: -0.03em;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.kpi {
  min-width: 0;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.kpi .value {
  font-size: 28px;
  line-height: 1;
  font-weight: 850;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}
.kpi .label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.bar-list {
  display: grid;
  gap: 10px;
}
.bar {
  display: grid;
  grid-template-columns: minmax(120px, 165px) minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.bar-value {
  text-align: right;
  color: var(--text);
}
.bar-track {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #111827;
  transition: width 0.12s linear;
}
.table {
  display: grid;
  gap: 8px;
}
.row {
  display: grid;
  grid-template-columns: minmax(80px, 1.1fr) minmax(52px, 0.7fr) minmax(
      0,
      1.4fr
    );
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.row strong {
  color: var(--text);
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
}
.card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}
.small-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.small-list div {
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  line-height: 1.4;
}

@media (max-width: 1050px) {
  .hero,
  .grid,
  .face-grid {
    grid-template-columns: 1fr;
  }
  .face-grid.emotions-off {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .links {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .nav {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: 10px 12px;
  }
  .brand {
    font-size: 15px;
    white-space: normal;
  }
  .links {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    width: 100%;
  }
  .links a {
    width: 100%;
    padding: 9px 10px;
    text-align: center;
  }
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
    padding-bottom: 26px;
  }
  .hero {
    gap: 10px;
    margin-bottom: 10px;
  }
  .hero-card,
  .panel,
  .card {
    border-radius: 14px;
  }
  .hero-card {
    padding: 18px;
  }
  h1 {
    font-size: clamp(28px, 10vw, 38px);
    letter-spacing: -0.045em;
  }
  .lead {
    font-size: 14px;
    line-height: 1.5;
  }
  .metrics,
  .kpi-row {
    grid-template-columns: 1fr;
  }
  .metric {
    padding: 11px;
  }
  .metric strong {
    font-size: 22px;
  }
  .stage {
    padding: 8px;
  }
  .video-wrap {
    aspect-ratio: auto;
    height: min(72vh, 560px);
    min-height: 330px;
    border-radius: 12px;
  }
  .body-video {
    height: min(76vh, 620px);
  }
  .controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }
  button,
  .button {
    width: 100%;
    padding: 10px 12px;
  }
  .panel {
    padding: 12px;
    margin-bottom: 10px;
  }
  .panel h2 {
    font-size: 16px;
  }
  .kpi .value {
    font-size: 25px;
  }
  .bar {
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 6px 8px;
  }
  .bar-label {
    white-space: normal;
  }
  .bar-track {
    grid-column: 1 / -1;
    height: 7px;
  }
  .row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .cards {
    gap: 10px;
    margin-top: 10px;
  }
  .card {
    padding: 14px;
  }
  .card h2 {
    font-size: 17px;
  }
  canvas.graph-canvas {
    height: 180px;
  }
}

@media (max-width: 380px) {
  .shell {
    width: min(100% - 14px, 1440px);
  }
  .video-wrap {
    min-height: 300px;
    height: 68vh;
  }
  .status-pill {
    left: 8px;
    top: 8px;
    max-width: calc(100% - 16px);
  }
}
