/* screens visibility */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100vh; }
.scrollable { overflow-y: auto; }

:root{
  --bg:#000;
  --white:#fff;
  --accent:#007AFF;
  --border: rgba(255,255,255,0.35);
  --panel: rgba(0,0,0,0.20);
  --panel2: rgba(255,255,255,0.06);
  --muted: rgba(255,255,255,0.70);

  --globalNavH: 128px; /* JS измеряет и обновляет */
}
*{ box-sizing:border-box; }
body{
  margin:0; background:var(--bg);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  overflow:hidden;
  color: var(--white);
}
body, button, input, textarea, select { color: var(--white); text-shadow:none; }

.screen{
  position:fixed; inset:0;
  display:none;
  flex-direction:column;
  background:var(--bg);
  overflow:hidden;
}
.screen.active{ display:flex; }

/* Скролл включаем только там, где нужно (iOS/Android) */
.screen.scrollable{
  overflow-y:auto;
  -webkit-overflow-scrolling: touch;
}

/* --- TOP BRAND (без слогана) --- */
#topText{
  position:fixed; left:0; right:0; top:0; z-index:80;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  pointer-events:none;
}
#brandRow{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  gap:12px;
  font-weight:900;
  letter-spacing:0.10em;
  text-transform:uppercase;
  font-size: 20px;
  color:#fff;
}
#brandLeft{ justify-self:end; }
#brandCenter{ justify-self:center; width:1px; height:1px; }
#brandRight{ justify-self:start; }

/* --- CALL FAB --- */
#callFab{
  position:fixed;
  right:12px;
  bottom: calc(var(--globalNavH) + 16px + env(safe-area-inset-bottom, 0px));
  z-index:90;

  background:var(--accent);
  color:#fff;
  border:none;
  border-radius:999px;
  padding:12px 14px;
  font-weight:950;
  text-decoration:none;
  display:flex;
  align-items:center;
  gap:8px;
  box-shadow:0 10px 30px rgba(0,0,0,0.35);
  -webkit-tap-highlight-color: transparent;
}
#callFab span{ font-size:14px; color:#fff; }

/* --- MAIN STAGE --- */
#stage{ position:relative; width:100vw; height:100vh; overflow:hidden; background:#000; }
video, canvas{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }

#angleRail{
  position:fixed;
  left:12px;
  top: 18vh;
  z-index:85;
  display:flex;
  flex-direction:column;
  gap:10px;
  pointer-events:none;
  color:#fff;
}
.angleItem{ display:flex; flex-direction:column; gap:4px; min-width: 118px; }
.angleValue{
  font-size:26px;
  font-weight:950;
  line-height:1;
  color:#fff;
}
.angleLabel{
  font-size:13px;
  font-weight:850;
  color:#fff;
  opacity:0.92;
  letter-spacing:0.02em;
}

/* --- CONTENT AREA --- */
.content-area{
  width:100%;
  max-width:520px;
  margin:0 auto;
  padding: 86px 16px calc(var(--globalNavH) + 26px + env(safe-area-inset-bottom, 0px));
  display:flex;
  flex-direction:column;
  gap:12px;
  justify-content:flex-start;
  flex:1;
}
input, textarea{
  width:100%;
  padding:14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.18);
  background:#0b0b0f;
  font-size:16px;
  outline:none;
  color:#fff;
}
select{
  width:100%;
  padding:14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.18);
  background:#0b0b0f;
  font-size:16px;
  outline:none;
  color:#fff;
}

.primary{
  background:var(--accent);
  color:#fff;
  border:none;
  border-radius:12px;
  padding:14px 16px;
  font-weight:950;
  font-size:14px;
  cursor:pointer;
  -webkit-tap-highlight-color: transparent;
}
.secondary{
  background:#0b0b0f;
  border:1px solid rgba(255,255,255,0.22);
  color:#fff;
}

/* --- TOAST + COUNTDOWN --- */
#toast{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom: calc(var(--globalNavH) + 14px + env(safe-area-inset-bottom, 0px));
  z-index:95;
  background:rgba(0,0,0,0.72);
  border:1px solid rgba(255,255,255,0.18);
  padding:10px 12px;
  border-radius:14px;
  font-size:13px;
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
  max-width:92vw;
  text-align:center;
  color:#fff;
}
#toast.show{ opacity:1; }

#countdown{
  position:fixed; inset:0; z-index:120;
  display:none; align-items:center; justify-content:center;
  background:rgba(0,0,0,0.55);
  font-size:96px; font-weight:950;
  color:#fff;
}
#countdown.active{ display:flex; }

.mic-btn{
  width:70px; height:70px; border-radius:50%;
  background:#ff3b30;
  font-size:30px;
  align-self:center;
  display:flex; align-items:center; justify-content:center;
  border:none;
  color:#fff;
  cursor:pointer;
}
.recording{ animation:pulse 1s infinite; }
@keyframes pulse { 0%{opacity:1} 50%{opacity:0.4} 100%{opacity:1} }

/* --- RESULT SCREEN --- */
#screen-result img{ background:#000; }

.bottomBar{
  position:fixed;
  left:0; right:0;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index:90;
  padding: 0 10px;
  display:flex;
  gap:6px;
  align-items:center;
}
.barBtn{
  height:44px;
  border-radius:14px;
  border:1px solid var(--border);
  background:var(--panel);
  -webkit-tap-highlight-color: transparent;
  user-select:none;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:900;
  letter-spacing:0.01em;
  color:#fff;
  overflow:hidden;
  flex:1;
}
.barBtn:active{ transform:scale(0.99); }

/* --- BALANCE SCREEN --- */
.balanceCard{
  width:100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  padding: 14px;
}
#balanceTimer{
  font-size: 84px;
  font-weight: 950;
  text-align:center;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin: 8px 0 0;
  line-height: 1.0;
}
#balanceHint{
  text-align:center;
  opacity: .85;
  line-height: 1.35;
  font-weight: 700;
  margin-top: -2px;
}
#balanceScore{
  text-align:center;
  font-weight: 950;
  letter-spacing: 0.03em;
  margin-top: 8px;
  opacity: .92;
}

#balanceScopeWrap{
  width:100%;
  height: 240px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  position: relative;
  overflow:hidden;
}
#balanceScopeCanvas{
  position:absolute; inset:0;
  width:100%; height:100%;
}

#balanceGraphWrap{
  width:100%;
  height: 240px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  position: relative;
  overflow:hidden;
}
#balanceCanvas{
  position:absolute; inset:0;
  width:100%; height:100%;
}
.legend{
  display:flex;
  justify-content:center;
  gap:18px;
  font-size: 12px;
  font-weight: 800;
  opacity: .9;
  flex-wrap:wrap;
}
.dot{ font-size: 16px; line-height: 1; }

.balanceSettings{
  width:100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.bsRow{ display:flex; flex-direction:column; gap:8px; }
.bsLabel{
  font-weight: 900;
  letter-spacing: 0.02em;
  opacity: .92;
  display:flex;
  justify-content:space-between;
}
.bsToggle{
  display:flex;
  gap:10px;
  align-items:center;
  font-weight: 850;
  opacity: .92;
  user-select:none;
}
.bsToggle input{ width:18px; height:18px; }

/* --- GLOBAL NAV (8 кнопок, 2 ряда) --- */
#globalNav{
  position:fixed;
  left:10px;
  right:10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index:92;

  display:grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 44px;
  gap:6px;

  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  padding: 8px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.navItem{
  border-radius:14px;
  border:1px solid var(--border);
  background:var(--panel);
  -webkit-tap-highlight-color: transparent;
  user-select:none;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:900;
  letter-spacing:0.01em;
  color:#fff;
  overflow:hidden;
  padding:0 10px;
  min-width:0;
}
.navItem:active{ transform:scale(0.99); }
.navItem.accent{
  background: rgba(0,122,255,0.20);
  border-color: rgba(0,122,255,0.95);
  color: #9dc3ff;
}
.navItem.disabled{
  opacity:0.55;
  pointer-events:none;
}

/* height tile */
.navHeight{
  justify-content:flex-start;
  gap:10px;
}
.navHeight span{
  white-space:nowrap;
  opacity:0.95;
  font-size:12px;
  letter-spacing:0.03em;
  flex:0 0 auto;
}
.navHeight input{
  border:none;
  background:transparent;
  padding:0;
  margin:0;
  height:42px;
  width:100%;
  min-width:40px;
  font-size:18px;
  font-weight:950;
  outline:none;
  color:#fff;
}

/* --- PAIN MAP V2 --- */
#screen-pain-map-v2{
  background:#000;
}
.pmv2{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}
.pmv2-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 8px 12px 6px;
  gap:10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  position: sticky;
  top: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 5;
}
.pmv2-back{
  width:42px;
  height:36px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.18);
  background:rgba(255,255,255,0.06);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:950;
  cursor:pointer;
}
.pmv2-title{
  margin:0;
  font-size:16px;
  font-weight:950;
  letter-spacing:0.02em;
  text-align:center;
  flex:1;
}
.pmv2-toggle{
  display:flex;
  gap:6px;
  align-items:center;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.18);
  background:rgba(255,255,255,0.06);
  padding:4px;
}
.pmv2-toggle input{ display:none; }
.pmv2-toggle label{
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:950;
  letter-spacing:0.04em;
  cursor:pointer;
  color: rgba(255,255,255,0.85);
  user-select:none;
}
.pmv2-toggle input:checked + label{
  background: rgba(0,122,255,0.85);
  color:#fff;
}

.pmv2-body{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 10px 12px;
}
.pmv2-card{
  width:min(520px, 92vw);
  height: clamp(240px, 46vh, 520px);
  border-radius:22px;
  border: 1px solid rgba(255,255,255,0.14);
  background: radial-gradient(120% 120% at 50% 10%, rgba(255,255,255,0.06), rgba(0,0,0,0.10));
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  overflow:hidden;
}
#pmv2Svg{
  width: 88%;
  height: 88%;
  opacity: 0.98;
}

.pmv2-zones{
  width:100%;
  padding: 10px 12px 10px;
}
.pmv2-zones-grid{
  width:min(520px, 92vw);
  margin:0 auto;
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:8px;
}
.pmv2-zone{
  min-height:44px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  font-weight:950;
  font-size:13px;
  line-height:1.10;
  padding: 8px 10px;
  color:#fff;
  text-align:center;
  cursor:pointer;
  transition: background-color .25s ease, border-color .25s ease, transform .08s ease;
  -webkit-tap-highlight-color: transparent;
  user-select:none;
}
.pmv2-zone:active{ transform:scale(0.99); }
.pmv2-zone.active{
  border-color: rgba(0,122,255,0.95);
  background: rgba(0,122,255,0.20);
}

.pmv2-footer{
  width:100%;
  padding: 10px 12px 14px;
}
.pmv2-footer-inner{
  width:min(520px, 92vw);
  margin:0 auto;
  border-radius:18px;
  border:1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  padding: 10px 12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.pmv2-intensity-row{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  font-weight:950;
  letter-spacing:0.02em;
  color:#fff;
}
.pmv2-intensity-row small{ opacity:.75; font-weight:800; }
#pmv2Intensity{
  font-size:22px;
  color:#fff;
}
#pmv2Slider{ width:100%; }
#pmv2Save{
  height:50px;
  border-radius:14px;
  border:none;
  background: var(--accent);
  color:#fff;
  font-weight:950;
  font-size:18px;
  cursor:pointer;
}
#pmv2Save:disabled{
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.55);
  cursor:not-allowed;
}

.note{
  font-size:12px;
  line-height:1.35;
  opacity:.78;
  color: rgba(255,255,255,0.75);
}

/* ================================
 COMPLAINTS WIZARD (CW) — styles
 ================================ */

/* общий контейнер визарда */
#screen-complaints .cw{
width:100%;
max-width:520px;
margin:0 auto;
padding: 86px 16px calc(var(--globalNavH) + 26px + env(safe-area-inset-bottom, 0px));
display:flex;
flex-direction:column;
gap:12px;
}

/* верх: прогресс + шаг */
#screen-complaints .cwTop{
position: sticky;
top: 0;
z-index: 6;
padding-top: max(8px, env(safe-area-inset-top, 0px));
background: rgba(0,0,0,0.78);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(255,255,255,0.10);
margin: -86px -16px 0;
padding-left: 16px;
padding-right: 16px;
padding-bottom: 10px;
}

#screen-complaints .cwTitleRow{
display:flex;
align-items:baseline;
justify-content:space-between;
gap:10px;
padding: 8px 0 8px;
}
#screen-complaints .cwTitle{
margin:0;
font-weight:950;
letter-spacing:0.06em;
font-size:18px;
}
#screen-complaints .cwStepHint{
font-size:12px;
font-weight:850;
opacity:.78;
letter-spacing:0.03em;
}

/* прогресс бар */
#screen-complaints .cwProgress{
height:10px;
width:100%;
border-radius:999px;
background: rgba(255,255,255,0.10);
border: 1px solid rgba(255,255,255,0.10);
overflow:hidden;
}
#screen-complaints .cwProgress > div{
height:100%;
width:0%;
background: rgba(0,122,255,0.85);
border-radius:999px;
transition: width .25s ease;
}

/* карточки/секции */
#screen-complaints .cwCard{
background: rgba(255,255,255,0.06);
border: 1px solid rgba(255,255,255,0.16);
border-radius: 16px;
padding: 12px;
}
#screen-complaints .cwCardTitle{
font-weight:950;
letter-spacing:0.02em;
margin: 0 0 8px 0;
font-size:14px;
opacity:0.95;
}
#screen-complaints .cwSub{
font-size:12px;
line-height:1.35;
opacity:.72;
margin-top:6px;
}

/* сетка полей */
#screen-complaints .cwGrid2{
display:grid;
grid-template-columns: 1fr 1fr;
gap:10px;
}
@media (max-width: 380px){
#screen-complaints .cwGrid2{ grid-template-columns: 1fr; }
}

#screen-complaints .cwLabel{
display:flex;
justify-content:space-between;
align-items:baseline;
gap:10px;
font-weight:900;
letter-spacing:0.02em;
font-size:12px;
opacity:.92;
margin: 0 0 6px 0;
}
#screen-complaints .cwLabel small{
font-weight:850;
opacity:.75;
}

/* чипы быстрых ответов */
#screen-complaints .cwChips{
display:flex;
flex-wrap:wrap;
gap:8px;
}
#screen-complaints .cwChip{
border-radius:999px;
border:1px solid rgba(255,255,255,0.20);
background: rgba(0,0,0,0.30);
padding:8px 10px;
font-weight:900;
font-size:12px;
letter-spacing:0.02em;
color:#fff;
cursor:pointer;
user-select:none;
-webkit-tap-highlight-color: transparent;
transition: transform .08s ease, background-color .2s ease, border-color .2s ease;
}
#screen-complaints .cwChip:active{ transform: scale(0.99); }
#screen-complaints .cwChip.active{
border-color: rgba(0,122,255,0.95);
background: rgba(0,122,255,0.20);
color:#9dc3ff;
}

/* блок red flags */
#screen-complaints .cwAlert{
border-radius:16px;
border:1px solid rgba(255,59,48,0.35);
background: rgba(255,59,48,0.10);
padding: 12px;
}
#screen-complaints .cwAlert strong{
display:block;
font-weight:950;
letter-spacing:0.02em;
margin-bottom:6px;
}
#screen-complaints .cwAlert p{
margin:0;
font-size:12px;
opacity:.9;
line-height:1.35;
}

/* нижние действия */
#screen-complaints .cwActions{
display:flex;
gap:10px;
margin-top: 4px;
}
#screen-complaints .cwActions .primary{
flex:1.2;
}
#screen-complaints .cwActions .secondary{
flex:0.8;
}

/* кнопка микрофона компактная (для wizard) */
#screen-complaints .cwMicRow{
display:flex;
gap:10px;
align-items:center;
}
#screen-complaints .cwMicBtn{
width:52px;
height:52px;
border-radius:50%;
background:#ff3b30;
border:none;
color:#fff;
font-size:22px;
display:flex;
align-items:center;
justify-content:center;
}
#screen-complaints .cwMicBtn.recording{
animation:pulse 1s infinite;
}

/* место под “итоговый текст отчёта” */
#screen-complaints .cwReport{
width:100%;
min-height: 160px;
padding:14px;
border-radius:12px;
border:1px solid rgba(255,255,255,0.18);
background:#0b0b0f;
font-size:14px;
line-height:1.35;
outline:none;
color:#fff;
white-space:pre-wrap;
}

/* скрытие/показ шагов */
#screen-complaints .cwStep{ display:none; }
#screen-complaints .cwStep.active{ display:block; }

