:root{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #e5e7eb;
}

*,
*::before,
*::after{
  box-sizing: border-box;
}

body{
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, #1f2937 0, #030712 55%) fixed;
  color: #e5e7eb;
}

.wrap{
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* HEADER */

.header{
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1{
  margin: 0 0 4px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f9fafb;
}

.subtitle{
  margin: 0;
  font-size: 13px;
  color: #9ca3af;
}

.badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-ok{
  background: rgba(34,197,94,0.18);
  color: #bbf7d0;
}

/* CURRENT EMOTION */

.header-right{
  display: flex;
  align-items: center;
}

.current-emotion{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 12px;
  background: radial-gradient(circle at top right,#111827 0,#020617 80%);
  box-shadow: 0 10px 28px rgba(0,0,0,0.8);
  border: 1px solid rgba(148,163,184,0.35);
}

.current-emotion-label{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
}

.current-emotion-value{
  font-size: 18px;
  font-weight: 700;
  color: #fbbf24;
}

/* CONTROLS */

.controls{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15,23,42, 0.95);
  box-shadow: 0 12px 35px rgba(0,0,0,0.45);
}

button{
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg,#2563eb,#7c3aed);
  color: #f9fafb;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.1s ease;
  box-shadow: 0 6px 18px rgba(37,99,235,0.45);
}

button:hover:not([disabled]){
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(37,99,235,0.6);
}

button:active:not([disabled]){
  transform: translateY(0);
  box-shadow: 0 4px 14px rgba(0,0,0,0.8);
}

button[disabled]{
  background: #4b5563;
  box-shadow: none;
  opacity: 0.7;
  cursor: not-allowed;
}

label{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #9ca3af;
}

input[type="number"]{
  width: 56px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  font-size: 13px;
  outline: none;
}

input[type="number"]:focus{
  border-color: #6366f1;
  box-shadow: 0 0 0 1px rgba(99,102,241,0.7);
}

.status{
  margin-left: auto;
  font-weight: 600;
  font-size: 13px;
  color: #a5b4fc;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* STATUS SPINNER */

.status-spinner{
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(129,140,248,0.3);
  border-top-color: #60a5fa;
  border-right-color: #818cf8;
  animation: spin 0.8s linear infinite;
}

.status-spinner--hidden{
  display: none;
}

/* GRID */

.grid{
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: flex-start;
}

/* VIDEO BOX */

.videoBox{
  position: relative;
  background: radial-gradient(circle at center, #0f172a 0, #020617 70%);
  border-radius: 20px;
  overflow: hidden;
  min-height: 480px;
  box-shadow:
    0 18px 45px rgba(0,0,0,0.85),
    0 0 0 1px rgba(148,163,184,0.1);
}

/* отзеркаливаем и видео, и канвас */

video,
#overlay{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transform: scaleX(-1);
  transform-origin: center;
}

video{
  object-fit: contain;
  object-position: center;
}

#overlay{
  pointer-events: none;
}

.video-overlay-bar{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 10px;
  background: linear-gradient(to top,rgba(0,0,0,0.85),transparent);
  font-size: 11px;
  color: #e5e7eb;
}

.video-hint{
  opacity: 0.9;
}

/* RIGHT PANEL */

.panel{
  background: radial-gradient(circle at top left,#111827 0,#020617 75%);
  border-radius: 20px;
  padding: 14px 14px 16px;
  box-shadow:
    0 18px 45px rgba(0,0,0,0.85),
    0 0 0 1px rgba(148,163,184,0.15);
  max-height: 82vh;
  overflow: auto;
}

.panel h2{
  margin: 10px 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: #e5e7eb;
}

/* DATA CARDS */

.kv{
  background: rgba(15,23,42,0.85);
  border-radius: 12px;
  padding: 8px 9px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid rgba(148,163,184,0.25);
}

.row{
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
}

.k{
  color: #9ca3af;
}

.v{
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #e5e7eb;
}

.highlight-row .v{
  color: #fbbf24;
  font-weight: 700;
}

/* SPIN ANIMATION (используется и для статуса) */

@keyframes spin{
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* RESPONSIVE */

@media (max-width: 900px){
  .grid{
    grid-template-columns: minmax(0, 1fr);
  }

  .status{
    width: 100%;
    margin-left: 0;
    text-align: right;
    margin-top: 4px;
  }

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

  .current-emotion{
    align-items: flex-start;
  }
}
