/* CDNShark Looking Glass ---------------------------------------------------
   Dark by default: this is a network tool that people read terminal output in,
   and a light terminal is a hard sell. Colour is used sparingly and always
   carries meaning - accent for the active thing, amber for degraded, red for
   loss - so a glance at the hop table tells you where the problem is. */

:root {
  --accent: #3fa3e0;
  --accent-dim: rgba(63, 163, 224, 0.15);
  --bg: #0a0e13;
  --panel: #111823;
  --panel-2: #161f2c;
  --line: #1f2a38;
  --line-soft: #18212d;
  --text: #e7eef6;
  --muted: #8695a6;
  --muted-2: #5f6d7e;
  --good: #3ecf8e;
  --warn: #e8b339;
  --bad: #e5534b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ── Header ─────────────────────────────────────────────────────────────── */

header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0d141d, var(--bg));
}
.head {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 0; flex-wrap: wrap;
}
.head img { height: 30px; width: auto; display: block; }
.head .sep { width: 1px; height: 24px; background: var(--line); }
.head h1 {
  font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .01em;
}
.head .spacer { flex: 1; }
.yourip {
  font: 12px/1 var(--mono); color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  padding: 7px 10px; border-radius: 7px; white-space: nowrap;
}
.yourip b { color: var(--text); font-weight: 500; }

/* ── Location picker ────────────────────────────────────────────────────── */

.locations {
  display: grid; gap: 10px; margin: 22px 0;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.loc {
  text-align: left; cursor: pointer; position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px;
  color: inherit; font: inherit;
  transition: border-color .12s, background .12s, transform .12s;
}
.loc:hover { border-color: #2c3a4c; transform: translateY(-1px); }
.loc[aria-pressed="true"] {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-dim), var(--panel));
}
.loc .flag { font-size: 17px; line-height: 1; }
.loc .top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.loc .name { font-weight: 600; font-size: 13.5px; }
.loc .meta { font-size: 12px; color: var(--muted); display: block; }
.loc .ip { font: 11.5px/1.5 var(--mono); color: var(--muted-2); margin-top: 6px; display: block; }
.loc.all { border-style: dashed; }
.loc .rtt {
  position: absolute; top: 12px; right: 13px;
  font: 11px/1 var(--mono); color: var(--muted);
}
.loc .rtt.live { color: var(--good); }

/* ── Query bar ──────────────────────────────────────────────────────────── */

.query {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  display: grid; gap: 10px;
  grid-template-columns: 1fr auto auto auto auto;
}
@media (max-width: 860px) { .query { grid-template-columns: 1fr 1fr; } }

.query input[type=text], .query select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font: 14px var(--sans); min-width: 0;
}
.query input[type=text] { font-family: var(--mono); font-size: 13.5px; }
.query input:focus, .query select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
button.go {
  background: var(--accent); color: #04121c; border: 0;
  border-radius: 8px; padding: 10px 22px;
  font: 600 14px var(--sans); cursor: pointer;
}
button.go:hover { filter: brightness(1.08); }
button.go:disabled { opacity: .5; cursor: default; filter: none; }

.hint { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.err {
  margin-top: 12px; padding: 11px 13px; border-radius: 8px;
  background: rgba(229, 83, 75, .1); border: 1px solid rgba(229, 83, 75, .35);
  color: #ffb3ae; font-size: 13px;
}

/* ── Result tabs ────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 4px; margin: 22px 0 0; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 9px 14px; cursor: pointer;
  font: 500 13px var(--sans); margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button[hidden] { display: none; }

.panel { display: none; padding-top: 16px; }
.panel.on { display: block; }

/* ── Terminal output ────────────────────────────────────────────────────── */

.term {
  background: #070b10; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; font: 12.5px/1.65 var(--mono);
  white-space: pre-wrap; word-break: break-word;
  max-height: 460px; overflow-y: auto; color: #c8d6e4;
}
.term:empty::after { content: "Waiting for output…"; color: var(--muted-2); }
.term .l-err { color: #ff8b84; }
.term .node-tag { color: var(--accent); }

/* ── Hop table ──────────────────────────────────────────────────────────── */

table.hops { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hops th {
  text-align: left; font-weight: 500; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted-2);
  padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
table.hops td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.hops tr:hover td { background: var(--panel); }
table.hops .n { color: var(--muted); font: 12px var(--mono); width: 34px; }
table.hops .addr { font: 12.5px var(--mono); }
table.hops .host { color: var(--muted); font-size: 11.5px; display: block; margin-top: 2px; word-break: break-all; }
table.hops .num { text-align: right; font: 12.5px var(--mono); width: 76px; }
table.hops .asn { font-size: 12px; }
table.hops .asn b { color: var(--accent); font: 500 12px var(--mono); }
table.hops .asn span { color: var(--muted); display: block; font-size: 11.5px; }
.loss-0 { color: var(--muted); }
.loss-some { color: var(--warn); }
.loss-all { color: var(--bad); }
.timeout td { opacity: .45; }

/* A magnitude rule under the number gives the shape of the path at a glance.
   It sits at the bottom and grows from the right so it lines up with the
   right-aligned figure above it; a filled block behind the text reads as a
   selection highlight instead of a measurement. */
.bar { position: relative; }
.bar i {
  position: absolute; right: 10px; bottom: 4px; height: 2px;
  background: var(--accent); opacity: .55; border-radius: 2px;
}
.bar span { position: relative; }

/* ── Map ────────────────────────────────────────────────────────────────── */

.map {
  position: relative; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; background: #0c121a;
}
.map img { width: 100%; display: block; opacity: .30; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map .dot {
  position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px rgba(63,163,224,.18);
}
.map .dot.approx { background: var(--muted); box-shadow: 0 0 0 3px rgba(134,149,166,.12); }
.map .dot.origin { background: var(--good); box-shadow: 0 0 0 4px rgba(62,207,142,.2); }
.map .dot.dest { background: var(--warn); box-shadow: 0 0 0 4px rgba(232,179,57,.2); }
.map .dot b {
  position: absolute; left: 13px; top: -5px; white-space: nowrap;
  font: 11px var(--mono); color: var(--text);
  background: rgba(10,14,19,.82); padding: 2px 6px; border-radius: 4px;
}
.map-note { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ── AS path ────────────────────────────────────────────────────────────── */

.aspath { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.as {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 13px; min-width: 150px;
}
.as b { display: block; font: 500 12px var(--mono); color: var(--accent); }
.as .org { font-size: 12.5px; margin-top: 2px; }
.as .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.as-arrow { align-self: center; color: var(--muted-2); }

/* ── Compare grid ───────────────────────────────────────────────────────── */

.cmp { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.cmp .card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.cmp .card h3 { margin: 0 0 2px; font-size: 13.5px; display: flex; gap: 7px; align-items: center; }
.cmp .card .sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.cmp .big { font: 600 27px/1.1 var(--sans); }
.cmp .big small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.cmp .row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 4px 0; color: var(--muted); }
.cmp .row b { color: var(--text); font: 500 12.5px var(--mono); }
/* Beat the rule above: a non-zero loss figure must stay amber inside a card. */
.cmp .row b.loss-some { color: var(--warn); }
.cmp .row b.loss-all { color: var(--bad); }
.cmp .spark { height: 34px; width: 100%; margin: 9px 0 4px; display: block; }
.cmp .card.best { border-color: rgba(62,207,142,.45); }
.cmp .badge {
  font: 500 10.5px var(--sans); text-transform: uppercase; letter-spacing: .05em;
  color: var(--good); background: rgba(62,207,142,.12);
  padding: 2px 7px; border-radius: 20px; margin-left: auto;
}
.cmp .pending { color: var(--muted-2); font-size: 12.5px; }

/* ── Location detail / speed test ───────────────────────────────────────── */

.detail { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 12px; }
.box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px;
}
.box h3 { margin: 0 0 3px; font-size: 13.5px; }
.box p.sub { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv code { font: 12px var(--mono); color: var(--text); word-break: break-all; }
.copy {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 5px; font: 11px var(--sans); padding: 2px 7px; cursor: pointer; margin-left: 6px;
}
.copy:hover { color: var(--text); border-color: var(--accent); }
.btnrow { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.btnrow button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 7px 13px; font: 13px var(--sans); cursor: pointer;
}
.btnrow button:hover:not(:disabled) { border-color: var(--accent); }
.btnrow button:disabled { opacity: .5; cursor: default; }
.meter { margin-top: 13px; }
.meter .val { font: 600 25px/1.1 var(--sans); }
.meter .val small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.meter .track { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 9px; }
.meter .track i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.meter .cap { color: var(--muted); font-size: 12px; margin-top: 7px; }

footer {
  border-top: 1px solid var(--line); margin-top: 46px; padding: 20px 0 34px;
  color: var(--muted-2); font-size: 12.5px;
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
}
footer .spacer { flex: 1; }

.spin {
  display: inline-block; width: 11px; height: 11px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
