/* Первый экран: спидометр, кнопка GO, график, плитки, маскот и настройки. */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: clamp(20px, 3vw, 40px); padding-block: 28px 12px; align-items: start; }
.hero-main { min-width: 0; display: grid; gap: 16px; }
.hero-main h1 { font-size: clamp(26px, 3.4vw, 40px); max-width: 22ch; }
.lede { color: var(--dim); max-width: 60ch; margin-top: -6px; }
.hero-side { display: grid; gap: 18px; min-width: 0; }

/* сцена: HUD-рамка с уголками */
.stage { position: relative; border: 1px solid var(--line-2); border-radius: 4px; padding: clamp(14px, 2.4vw, 26px); background: linear-gradient(180deg, rgba(16, 19, 31, .88), rgba(9, 11, 20, .92)); }
.stage::before, .stage::after { content: ''; position: absolute; width: 22px; height: 22px; border: 2px solid var(--lime); pointer-events: none; }
.stage::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.stage::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }

.dial-wrap { position: relative; max-width: 620px; margin: 0 auto; aspect-ratio: 600 / 500; container-type: inline-size; }
#dial { width: 100%; height: 100%; }
.arc-track { fill: none; stroke: #1b2236; stroke-width: 16; stroke-linecap: round; }
.arc-zone { fill: none; stroke-width: 4; stroke-linecap: butt; opacity: .55; }
.arc-val { fill: none; stroke-width: 16; stroke-linecap: round; }
.arc-glow { fill: none; stroke-width: 34; stroke-linecap: round; opacity: .18; }
.tick { stroke: var(--line-2); stroke-width: 2; }
.tick-minor { stroke: #26304a; stroke-width: 1.5; }
.tick-lbl { fill: var(--dim); font: 500 15px var(--f-num); text-anchor: middle; dominant-baseline: middle; }
.needle { fill: var(--lime); }
.needle-shadow { fill: rgba(0, 0, 0, .55); }
.hub { fill: #0b0d18; stroke: var(--lime); stroke-width: 3; }

.go { position: absolute; left: 50%; top: 60%; width: 22cqw; height: 22cqw; transform: translate(-50%, -50%); border-radius: 50%; border: 0; background: radial-gradient(circle at 35% 30%, #e9ff6a, var(--lime) 55%, #a6d400); color: var(--ink); cursor: pointer; display: grid; place-items: center; padding: 0; -webkit-tap-highlight-color: transparent; transition: width .45s var(--ease-out), height .45s var(--ease-out), background-color .2s; box-shadow: 0 0 0 6px rgba(7, 8, 15, .9), 0 0 40px rgba(200, 255, 0, .35); }
.go::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--lime); opacity: 0; animation: go-ring 2.6s var(--ease-out) infinite; pointer-events: none; }
.go-t { font: 400 7.6cqw/1 var(--f-head); letter-spacing: .02em; transition: opacity .2s; }
@keyframes go-ring { 0% { transform: scale(1); opacity: .7; } 70%, 100% { transform: scale(1.5); opacity: 0; } }
@media (hover: hover) and (pointer: fine) { .go:hover { filter: brightness(1.08); } }
.go:active { transform: translate(-50%, -50%) scale(.96); }
.stage[data-state="running"] .go, .stage[data-state="checking"] .go { width: 11cqw; height: 11cqw; background: #151a2a; box-shadow: 0 0 0 4px rgba(7, 8, 15, .9), inset 0 0 0 2px var(--mag); color: var(--mag); }
.stage[data-state="running"] .go::before, .stage[data-state="checking"] .go::before { display: none; }
.stage[data-state="running"] .go-t, .stage[data-state="checking"] .go-t { font-size: 0; }
.stage[data-state="running"] .go-t::before, .stage[data-state="checking"] .go-t::before { content: ''; display: block; width: 3.6cqw; height: 3.6cqw; background: currentColor; border-radius: 2px; }

.readout { position: absolute; left: 50%; top: 76%; transform: translateX(-50%); text-align: center; pointer-events: none; width: 60%; }
.r-val { font: 400 13.5cqw/1 var(--f-head); letter-spacing: -.01em; color: var(--text); text-shadow: 0 0 24px rgba(200, 255, 0, .28); }
.r-unit { color: var(--dim); font-size: max(13px, 2.8cqw); margin-top: .2em; }
.stage[data-state="idle"] .r-val { color: var(--faint); text-shadow: none; }
.stage[data-phase="download"] .r-val { color: var(--lime); }
.stage[data-phase="upload"] .r-val { color: var(--cyan); text-shadow: 0 0 24px rgba(25, 229, 255, .3); }
.stage[data-phase="ping"] .r-val { color: var(--text); }
.stage[data-state="result"] .r-val { color: var(--text); }

.phase { text-align: center; color: var(--dim); min-height: 1.6em; margin-top: 6px; transition: color .2s; }
.stage[data-state="running"] .phase { color: var(--lime); }

.graph { position: relative; height: 128px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.graph canvas { width: 100%; height: 100%; }
.graph-empty { position: absolute; inset: 10px 0 0; display: grid; place-items: center; color: var(--faint); font-size: 14px; pointer-events: none; transition: opacity .3s; }
.stage[data-graph="on"] .graph-empty { opacity: 0; }

/* мониторинг: вместо спидометра — крупный пинг и длинный график */
.mon-read { display: grid; gap: 14px; padding-block: 6px 0; }
.mon-big { display: flex; align-items: baseline; gap: 12px; }
.mon-big span { font: 400 clamp(56px, 11vw, 104px)/1 var(--f-head); color: var(--lime); }
.mon-big small { color: var(--dim); font-size: 18px; }
.mon-stats { margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.mon-stats div { background: var(--panel); padding: 10px 12px; }
.mon-stats dt { color: var(--dim); font-size: 14px; }
.mon-stats dd { margin: 2px 0 0; font: 600 22px var(--f-num); font-variant-numeric: tabular-nums; }
.mon-verdict { font-size: 16px; color: var(--dim); }
.mon-verdict b { font-family: var(--f-head); font-weight: 400; color: var(--lv-c, var(--lime)); }
.stage[data-mode="monitor"] .dial-wrap { aspect-ratio: auto; display: flex; justify-content: center; padding: 6px 0 2px; container-type: normal; }
.stage[data-mode="monitor"] #dial, .stage[data-mode="monitor"] .readout { display: none; }
.stage[data-mode="monitor"] .go { position: relative; left: auto; top: auto; transform: none; width: 108px; height: 108px; }
.stage[data-mode="monitor"] .go:active { transform: scale(.96); }
.stage[data-mode="monitor"] .go-t { font-size: 22px; }
.stage[data-mode="monitor"][data-state="running"] .go { width: 64px; height: 64px; }
.stage[data-mode="monitor"][data-state="running"] .go-t { font-size: 0; }
.stage[data-mode="monitor"][data-state="running"] .go-t::before { width: 20px; height: 20px; }
.stage[data-mode="monitor"] .phase { margin-bottom: 8px; }
.stage[data-mode="monitor"] .graph { height: 230px; }

.alert { border: 1px solid var(--mag); background: var(--mag-a); border-radius: 6px; padding: 14px 18px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; }
.alert p { max-width: 62ch; }
.alert-act { display: flex; flex-wrap: wrap; gap: 10px; }

/* плитки метрик: единая панель приборов */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.tile { position: relative; background: var(--panel); padding: 14px 14px 12px; display: grid; gap: 2px; align-content: start; min-width: 0; overflow: hidden; }
.t-l { color: var(--dim); font-size: 14px; line-height: 1.25; min-height: 2.5em; }
.t-v { font: 600 clamp(22px, 2.4vw, 30px)/1.1 var(--f-num); font-variant-numeric: tabular-nums; color: var(--faint); transition: color .25s; }
.t-u { color: var(--dim); font-size: 13px; }
.tile[data-done] .t-v { color: var(--text); }
.tile[data-k="down"][data-done] .t-v, .tile[data-k="down"][data-on] .t-v { color: var(--lime); }
.tile[data-k="up"][data-done] .t-v, .tile[data-k="up"][data-on] .t-v { color: var(--cyan); }
.tile[data-bad="1"] .t-v { color: var(--mag); }
.tile[data-na] .t-v { color: var(--faint); }
.tile[data-on]::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--lime), transparent); animation: tile-scan 1.2s linear infinite; }
@keyframes tile-scan { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.tile[data-pop] .t-v { animation: pop .5s var(--ease-out); }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.14); } 100% { transform: scale(1); } }

/* маскот */
.mascot { position: relative; display: grid; gap: 10px; justify-items: center; }
.bubble { position: relative; width: 100%; min-height: 74px; padding: 14px 18px; border: 1px solid var(--cyan); background: rgba(25, 229, 255, .07); border-radius: 4px 14px 14px 14px; color: var(--text); font-size: 17px; line-height: 1.35; display: flex; align-items: center; }
.bubble::after { content: ''; position: absolute; left: 36px; bottom: -9px; width: 16px; height: 16px; background: var(--ink-2); border-right: 1px solid var(--cyan); border-bottom: 1px solid var(--cyan); transform: rotate(45deg); }
.bubble p { animation: say .35s var(--ease-out); }
@keyframes say { from { opacity: 0; transform: translateY(6px); } }
.m-stage { position: relative; width: min(100%, 340px); aspect-ratio: 1; margin-top: 6px; transform: translate(calc(var(--mx, 0) * 10px), calc(var(--my, 0) * 6px)) rotate(calc(var(--mx, 0) * 2.5deg)); transition: transform .25s var(--ease-out); }
.m-body { position: absolute; inset: 0; transform-origin: 50% 90%; animation: bob 3.4s ease-in-out infinite alternate; }
.m-body img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .5)); transition: opacity .22s var(--ease-out); }
.m-body img.out { opacity: 0; }
.m-body img.in { animation: m-in .22s var(--ease-out) both; }
@keyframes m-in { from { opacity: 0; } }
@keyframes bob { from { transform: translateY(0) scale(1); } to { transform: translateY(-8px) scale(1.015); } }
.trail { position: absolute; left: -6%; top: 42%; height: 18%; width: calc(14% + var(--spd, 0) * 46%); border-radius: 50%; background: linear-gradient(90deg, transparent, rgba(200, 255, 0, .0) 5%, rgba(200, 255, 0, .55)); filter: blur(5px); opacity: 0; transform-origin: right center; transition: opacity .3s; }
.mascot[data-pose="run"] .trail { opacity: 1; animation: trail .14s ease-in-out infinite alternate; }
@keyframes trail { from { transform: scaleX(.86); } to { transform: scaleX(1.08); } }
.mascot[data-pose="run"] .m-body { animation: run .3s ease-in-out infinite alternate; }
@keyframes run { from { transform: translateY(2px) rotate(-1.2deg); } to { transform: translateY(-12px) rotate(1.2deg); } }
.mascot[data-pose="wow"] .m-body { animation: wow 1.1s var(--ease-out) 1, bob 3.4s ease-in-out 1.1s infinite alternate; }
@keyframes wow { 0% { transform: translateY(30px) scale(.9); } 35% { transform: translateY(-34px) scale(1.06); } 60% { transform: translateY(0) scale(.98); } 100% { transform: translateY(0) scale(1); } }
.mascot[data-pose="sad"] .m-body { animation: sag 4.5s ease-in-out infinite alternate; }
@keyframes sag { from { transform: translateY(6px) scale(.97); } to { transform: translateY(10px) scale(.96); } }
.mascot[data-pose="sleep"] .m-body { animation: breathe 4.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035) translateY(-3px); } }
.zzz { position: absolute; right: 8%; top: 18%; opacity: 0; pointer-events: none; }
.zzz i { position: absolute; font: 400 26px var(--f-head); color: var(--cyan); opacity: 0; font-style: normal; }
.mascot[data-pose="sleep"] .zzz { opacity: 1; }
.mascot[data-pose="sleep"] .zzz i { animation: zz 3.2s ease-out infinite; }
.zzz i:nth-child(2) { animation-delay: 1s !important; font-size: 20px; }
.zzz i:nth-child(3) { animation-delay: 2s !important; font-size: 15px; }
@keyframes zz { 0% { transform: translate(0, 14px) scale(.7); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(18px, -46px) scale(1.15); opacity: 0; } }
.shock { position: absolute; left: 14%; top: 4%; font: 400 64px/1 var(--f-head); color: var(--lime); opacity: 0; transform: scale(.4) rotate(-12deg); pointer-events: none; text-shadow: 0 0 20px rgba(200, 255, 0, .6); }
.mascot[data-shock] .shock { animation: shock .9s var(--ease-out) both; }
.mascot[data-shock] .m-body { animation: jolt .5s var(--ease-out) 1; }
@keyframes shock { 0% { opacity: 0; transform: scale(.4) rotate(-12deg); } 25% { opacity: 1; transform: scale(1.2) rotate(8deg); } 100% { opacity: 0; transform: scale(1) rotate(0) translateY(-14px); } }
@keyframes jolt { 0% { transform: translateY(0); } 20% { transform: translateY(-26px) scale(1.05); } 100% { transform: translateY(0); } }

/* настройки */
.ctl { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--line); background: rgba(16, 19, 31, .8); border-radius: 4px; }
.seg { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 6px; }
#modeSeg { grid-template-columns: repeat(3, minmax(0, 1fr)); } #engSeg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg legend { grid-column: 1 / -1; padding: 0; margin-bottom: 2px; color: var(--dim); font-size: 14px; }
.seg label { position: relative; display: block; min-width: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.seg span { display: grid; gap: 2px; align-content: center; min-height: 58px; padding: 8px 9px; border: 1px solid var(--line-2); border-radius: 6px; text-align: left; line-height: 1.2; transition: border-color .15s, background-color .15s; }
.seg b { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.seg small { color: var(--dim); font-size: 13px; }
.seg input:checked + span { border-color: var(--lime); background: var(--lime-a); }
.seg input:checked + span small { color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .seg input:not(:checked):hover + span { border-color: var(--dim); } }
.seg input:disabled + span { opacity: .45; }
.eng-note { color: var(--dim); font-size: 14px; line-height: 1.4; margin-top: -4px; }
.eng-note:empty { display: none; }
.eng-note b { color: var(--text); font-weight: 600; }
.plan { display: grid; gap: 6px; }
.plan span { color: var(--dim); font-size: 14px; }
.plan input { min-height: 46px; background: var(--ink); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 12px; font: 500 17px var(--f-num); color: var(--text); width: 100%; }
.plan input:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
.plan input::placeholder { color: var(--faint); }

.net { padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px; background: rgba(16, 19, 31, .6); }
.net-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.net-h h2 { font-size: 17px; }
.net-l { margin: 10px 0 0; display: grid; gap: 6px; font-size: 15px; }
.net-l div { display: flex; justify-content: space-between; gap: 14px; }
.net-l dt { color: var(--dim); flex: none; }
.net-l dd { margin: 0; text-align: right; font-family: var(--f-num); font-size: 14px; overflow-wrap: anywhere; }
.net[data-hidden] .net-l dd.sens { filter: blur(7px); user-select: none; }

@media (max-width: 1020px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-main, .hero-side { display: contents; }
  .hero > *, .hero-main > *, .hero-side > * { min-width: 0; }
  .hero-main h1 { order: 1; } .lede { order: 2; } .mascot { order: 3; } .alert { order: 4; } .stage { order: 5; } .tiles { order: 6; } .ctl { order: 7; } .net { order: 8; }
  .hero { gap: 16px; }
  .mascot { grid-template-columns: 112px 1fr; align-items: center; justify-items: stretch; gap: 14px; }
  .mascot .m-stage { grid-column: 1; grid-row: 1; width: 112px; margin: 0; }
  .mascot .bubble { grid-column: 2; grid-row: 1; min-height: 68px; font-size: 16px; padding: 12px 14px; border-radius: 14px 14px 14px 4px; }
  .bubble::after { left: -9px; bottom: 22px; border: 0; border-left: 1px solid var(--cyan); border-bottom: 1px solid var(--cyan); }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .stage { padding: 12px 10px 14px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .seg legend { font-size: 13px; }
  .mon-stats { grid-template-columns: repeat(2, 1fr); }
  .tick-lbl { font-size: 19px; }
}
