:root {
  --bg: #0a0c0b;
  --bg2: #0e1110;
  --panel: rgba(16, 20, 18, .78);
  --line: #1e2522;
  --line2: #2a332f;
  --text: #e8ebe6;
  --muted: #7d867f;
  --dim: #4a534e;
  --amber: #ffb547;
  --cyan: #5ee6d6;
  --violet: #b69cff;
  --red: #ff6b5b;
  --green: #8fe36a;
  --land: #a9bdb0;
  --disc0: #131a17;
  --disc1: #090c0b;
  --rim: rgba(160, 190, 170, .16);
  --atm: rgba(94, 230, 214, .09);
  --plate: rgba(10, 12, 11, .88);
  --mono-family: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --mono: var(--mono-family);
  --sans: "Onest", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .045) 1px, transparent 0) 0 0 / 22px 22px,
    radial-gradient(1200px 700px at 78% 10%, rgba(94, 230, 214, .06), transparent 60%),
    radial-gradient(900px 600px at 10% 90%, rgba(255, 181, 71, .05), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
code { font-family: var(--mono); font-size: .92em; color: var(--cyan); }

/* ---------- top ---------- */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 16px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 13px;
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: -.02em; font-size: 15px; }
.brand span { color: var(--amber); }
.prompt { color: var(--muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt .pu { color: var(--green); }
.prompt .pp { color: var(--cyan); }
.prompt #cmd { color: var(--text); }
.cur { display: inline-block; width: 8px; height: 15px; background: var(--amber); vertical-align: -2px; margin-left: 3px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.back { color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }

/* ---------- hero ---------- */
main { padding: clamp(16px, 2.4vw, 32px) clamp(16px, 3vw, 36px) 40px; max-width: 1480px; margin: 0 auto; }
.hero { display: grid; grid-template-columns: minmax(360px, 460px) 1fr; gap: clamp(16px, 2vw, 28px); align-items: stretch; }

.panel, .stage, .tabs {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(6px);
}
/* «крестики» по углам, как метки на чертеже */
.panel::before, .stage::before, .tabs::before,
.panel::after, .stage::after, .tabs::after {
  content: ""; position: absolute; width: 11px; height: 11px; pointer-events: none;
  border-color: var(--dim); border-style: solid;
}
.panel::before, .stage::before, .tabs::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; border-color: var(--text); }
.panel::after, .stage::after, .tabs::after { right: -1px; bottom: -1px; border-width: 0 1px 1px 0; border-color: var(--text); }

.panel { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.shared {
  font-family: var(--mono); font-size: 12.5px; padding: 10px 12px;
  border: 1px dashed var(--amber); color: var(--amber); display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.shared button { background: var(--amber); color: #111; border: 0; padding: 4px 10px; font-family: var(--mono); font-size: 12px; }

/* маршрут вы ⇄ сервер */
.route { display: grid; grid-template-columns: minmax(0,1fr) 92px minmax(0,1fr); gap: 10px; align-items: start; }
.end .k { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.end .k i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.you .k i { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.srv .k i { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.end .v { font-weight: 700; font-size: 16px; line-height: 1.25; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.end .s { font: 12px/1.45 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.srv { text-align: right; }
.srv .k { justify-content: flex-end; }
.ip { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ip .blur { filter: blur(5px); transition: filter .2s; user-select: none; }
.ip button { background: none; border: 0; padding: 0; color: var(--dim); font: 11px var(--mono); text-decoration: underline dotted; }
.ip button:hover { color: var(--text); }
.wire { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 18px; font: 11px var(--mono); color: var(--muted); text-align: center; }
.wire i {
  display: block; width: 100%; height: 2px; position: relative;
  background: linear-gradient(90deg, var(--amber), var(--cyan)); opacity: .9;
}
.wire i::after {
  content: ""; position: absolute; top: -2px; left: 0; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px #fff; animation: travel 1.8s linear infinite;
}
@keyframes travel { from { left: 0; } to { left: calc(100% - 6px); } }
#dist { color: var(--text); font-weight: 500; }

/* кнопка старта */
.start {
  position: relative; overflow: hidden; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 18px 18px; border: 1px solid var(--amber);
  background: linear-gradient(90deg, rgba(255, 181, 71, .14), rgba(255, 181, 71, .02));
  transition: background .2s, transform .1s;
}
.start:hover { background: linear-gradient(90deg, rgba(255, 181, 71, .24), rgba(255, 181, 71, .05)); }
.start:active { transform: translateY(1px); }
.start .lbl { font: 700 19px var(--mono); letter-spacing: -.01em; color: var(--amber); }
.start .lbl::before { content: "▶ "; }
.start.running .lbl::before { content: "■ "; }
.start .phase { font: 12px var(--mono); color: var(--muted); }
.start .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 181, 71, .12); }
.start .bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .15s linear; box-shadow: 0 0 10px var(--amber); }
.start:disabled { cursor: progress; }

/* метрики */
.metrics { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.m { padding: 12px 14px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); position: relative; min-width: 0; }
.m .k { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.m .k i { width: 10px; height: 2px; display: inline-block; }
.m.down .k i { background: var(--amber); }
.m.up .k i { background: var(--cyan); }
.m .v { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.m .v b { font: 700 clamp(28px, 3vw, 38px)/1.1 var(--mono); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.m .v u { text-decoration: none; font: 12px var(--mono); color: var(--muted); }
.m .s { font: 11.5px var(--mono); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m.down .v b { color: var(--amber); }
.m.up .v b { color: var(--cyan); }
.m.active { background: rgba(255, 255, 255, .025); }
.m.active::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--text); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .2; } }

.scope-wrap { position: relative; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); }
.scope { display: block; width: 100%; height: 110px; }
.scope-k { position: absolute; top: 6px; right: 8px; font: 11px var(--mono); color: var(--muted); display: flex; gap: 10px; }
.scope-k .kd { color: var(--amber); } .scope-k .ku { color: var(--cyan); } .scope-k .kp { color: #f4f7f2; }

.bloat { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font: 12.5px var(--mono); color: var(--muted); }
.bloat .k { color: var(--dim); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; margin-right: 4px; }
.bloat b { color: var(--text); font-weight: 500; }
.grade b { display: inline-block; min-width: 30px; text-align: center; padding: 0 6px; border: 1px solid var(--line2); color: var(--text); }
.grade b.g-a { border-color: var(--green); color: var(--green); }
.grade b.g-b { border-color: #d7e35a; color: #d7e35a; }
.grade b.g-c { border-color: var(--amber); color: var(--amber); }
.grade b.g-d, .grade b.g-f { border-color: var(--red); color: var(--red); }

.log {
  margin: 0; min-height: 96px; max-height: 96px; overflow: hidden;
  font: 11.5px/1.6 var(--mono); color: var(--muted); white-space: pre-wrap;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.log .ok { color: var(--green); } .log .hl { color: var(--text); } .log .err { color: var(--red); } .log .c { color: var(--dim); }

.after { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.insights { display: grid; gap: 8px; font-size: 13.5px; }
.insights div { display: flex; gap: 10px; align-items: baseline; }
.insights div::before { content: "→"; color: var(--amber); font-family: var(--mono); }
.insights b { font-family: var(--mono); font-weight: 500; }
.share { display: flex; gap: 8px; flex-wrap: wrap; }
.share button, .ghost {
  background: transparent; border: 1px solid var(--line2); padding: 8px 12px;
  font: 12.5px var(--mono); color: var(--text); transition: border-color .15s, background .15s;
}
.share button:hover, .ghost:hover { border-color: var(--text); background: rgba(255, 255, 255, .04); }
.share button.done { border-color: var(--green); color: var(--green); }

/* ---------- сцена с глобусом ---------- */
.stage { position: sticky; top: 16px; align-self: start; height: min(calc(100vh - 110px), 880px); min-height: 560px; overflow: hidden; background: radial-gradient(ellipse at 50% 45%, rgba(20, 28, 25, .6), rgba(8, 10, 9, .6)); }
#globe { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#globe.grab { cursor: grabbing; }
.stage-top { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
.seg, .zoom { display: flex; border: 1px solid var(--line2); background: var(--plate); }
.seg button, .zoom button { background: none; border: 0; padding: 7px 12px; font: 12px var(--mono); color: var(--muted); }
.zoom button { width: 34px; padding: 7px 0; font-size: 15px; }
.zoom button + button, .seg button + button { border-left: 1px solid var(--line2); }
.seg button.on { color: var(--bg); background: var(--text); }
.seg button:not(.on):hover, .zoom button:hover { color: var(--text); }
.legend {
  position: absolute; left: 0; bottom: 0; right: 0; padding: 28px 14px 12px; display: flex; flex-wrap: wrap; gap: 6px 14px;
  background: linear-gradient(rgba(10,12,11,0), rgba(10,12,11,.92) 55%);
  font: 11.5px var(--mono); color: var(--text); pointer-events: none;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .muted { color: var(--muted); }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }
.legend .dot.you { --c: var(--amber); } .legend .dot.srv { --c: var(--cyan); }
.legend .sq { width: 7px; height: 7px; border: 1.2px solid var(--violet); display: inline-block; }
.gps {
  position: absolute; right: 14px; bottom: 44px; background: var(--plate); border: 1px solid var(--line2);
  font: 11.5px var(--mono); color: var(--muted); padding: 6px 10px;
}
.gps:hover { color: var(--text); border-color: var(--text); }
.tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  background: var(--plate); border: 1px solid var(--line2); padding: 8px 10px;
  font: 12px/1.55 var(--mono); color: var(--muted);
}
.tip b { color: var(--text); font-weight: 700; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r span:last-child { color: var(--text); }

/* ---------- вкладки ---------- */
.tabs { margin-top: clamp(16px, 2vw, 28px); }
.tabs nav { display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs nav button {
  background: none; border: 0; border-right: 1px solid var(--line); padding: 13px 20px;
  font: 500 13px var(--mono); color: var(--muted); white-space: nowrap; position: relative;
}
.tabs nav button.on { color: var(--text); background: rgba(255, 255, 255, .03); }
.tabs nav button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--amber); }
.tab { padding: 20px; }
.tab-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.tab-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
.note { color: var(--dim); font: 12px/1.5 var(--mono); margin: 14px 0 0; }
h3 { font: 500 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }

/* хопы */
.hops { list-style: none; margin: 0; padding: 0; font: 12.5px var(--mono); counter-reset: none; }
.hops li {
  display: grid; grid-template-columns: 34px minmax(120px, 170px) minmax(90px, 1fr) minmax(0, 1.4fr) minmax(0, 1.4fr);
  gap: 14px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line);
  animation: rowin .35s ease-out both;
}
@keyframes rowin { from { opacity: 0; transform: translateX(-6px); } }
.hops li.empty { display: block; color: var(--dim); border: 0; animation: none; }
.hops .n { color: var(--violet); }
.hops .addr { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.hops .rtt { display: flex; align-items: center; gap: 8px; }
.hops .rtt i { height: 4px; background: var(--violet); display: inline-block; min-width: 2px; opacity: .8; }
.hops .rtt span { min-width: 58px; }
.hops .geo, .hops .as { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hops li.lost { color: var(--dim); }
.hops li.lost .addr { color: var(--dim); }
.hops li.dest .addr { color: var(--amber); }
.hops li.head { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; animation: none; border-bottom: 1px solid var(--line); }
.hops li.head span { color: var(--dim) !important; }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); }
.tbl th { text-align: left; color: var(--dim); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
.tbl td { padding: 7px 10px 7px 0; border-bottom: 1px dashed var(--line); color: var(--text); white-space: nowrap; }
.tbl td.mut { color: var(--muted); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td .bar { display: inline-block; height: 4px; background: var(--amber); vertical-align: middle; margin-right: 8px; opacity: .8; }
.tbl a { color: var(--cyan); text-decoration: none; }
.tbl-wrap { overflow-x: auto; }
.hist-chart { margin-bottom: 18px; }
.hist-chart svg { display: block; width: 100%; height: 170px; }
.hist-chart .empty, .tbl .empty { color: var(--dim); font: 12.5px var(--mono); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); margin-bottom: 22px; }
.stats > div { padding: 12px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats .k { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stats b { display: block; font: 700 26px/1.2 var(--mono); letter-spacing: -.03em; margin-top: 4px; }
.stats u { text-decoration: none; font: 12px var(--mono); color: var(--muted); margin-left: 4px; }
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; }
.recent { list-style: none; margin: 0; padding: 0; font: 12.5px var(--mono); }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.recent li span:first-child { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent li span:last-child { color: var(--muted); white-space: nowrap; }
.recent i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; background: var(--c); }

.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px 28px; }
.how-grid h3 { color: var(--amber); }
.how-grid p { margin: 0; color: var(--muted); font-size: 14px; }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px clamp(16px, 3vw, 36px) 28px; font: 12px var(--mono); color: var(--dim); max-width: 1480px; margin: 0 auto; }
.foot a { color: var(--muted); }

/* ---------- адаптив ---------- */
@media (max-width: 1020px) {
  .hero { grid-template-columns: 1fr; }
  .stage { order: -1; position: relative; top: 0; min-height: 0; height: min(78vw, 520px); }
  .cols { grid-template-columns: 1fr; }
  .hops li { grid-template-columns: 28px minmax(110px, 1fr) 110px minmax(0, 1fr); }
  .hops .as { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .top { gap: 12px; }
  .prompt { display: none; }
  .brand { flex: 1; }
  .panel { padding: 16px; }
  .route { grid-template-columns: 1fr 1fr; }
  .wire { grid-column: 1 / -1; grid-row: 2; padding-top: 0; }
  .stage { height: 92vw; }
  .gps { bottom: 40px; }
  .legend .muted { display: none; }
  .hops li { grid-template-columns: 24px 1fr 90px; gap: 10px; }
  .hops .geo { grid-column: 2 / -1; margin-top: -4px; font-size: 11.5px; }
  .tab { padding: 16px; }
  .tab-head { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

[hidden] { display: none !important; }
