/* src/ui/base.css */
:root {
  --buncss-light: ;
  --buncss-dark: initial;
  color-scheme: dark;
  --bg: #191c22;
  --surface: #1e2127;
  --panel: #16191e;
  --raised: #23272e;
  --line: #30343c;
  --line-soft: #282c33;
  --text: #e8ebf0;
  --muted: #9298a4;
  --dim: #89919f;
  --positive: #a3be8c;
  --negative: #bf7780;
  --accent: #9abfbb;
  --brand-end: #5eead4;
  --button: #e8ebef;
  --button-text: #191c22;
  --lag-slow: #ebcb8b;
  --lag-late: #d08770;
  --lag-unknown: #5c6370;
  --radius: 4px;
  --width: 1240px;
  --gutter: 56px;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  font-family: Twemoji Country Flags, Inter, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 90px;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 13px;
}

button {
  font: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

h1, h2 {
  text-wrap: balance;
  margin: 0;
  font-weight: 500;
}

p {
  margin: 0;
  line-height: 1.65;
}

code {
  color: var(--text);
  font-family: ui-monospace, SF Mono, Menlo, monospace;
  font-size: .92em;
}

::selection {
  color: #fff;
  background: #8fbcbb55;
}

.wrap {
  width: calc(100% - 2 * var(--gutter));
  max-width: var(--width);
  margin-inline-start: auto;
  margin-inline-end: auto;
}

.button {
  display: inline-flex;
  background: var(--button);
  color: var(--button-text);
  border: 1px solid var(--button);
  border-radius: var(--radius);
  white-space: nowrap;
  justify-content: space-between;
  align-items:  center;
  gap: 36px;
  height: 46px;
  padding: 0 18px;
  transition: background .12s, border-color .12s, transform .12s;
  font-size: 12px;
  font-weight: 600;
}

.button-arrow {
  transition: transform .12s;
}

.button:hover {
  background: #fff;
  border-color: #fff;
  transform: translateY(-2px);
}

.button:hover .button-arrow {
  transform: translateX(4px);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.button-secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: none;
}

.button-secondary:hover {
  background: var(--raised);
  border-color: var(--muted);
}

.button-small {
  gap: 22px;
  height: 35px;
  padding-inline-start: 13px;
  padding-inline-end: 13px;
  font-size: 11px;
}

.eyebrow {
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items:  center;
  gap: 9px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
}

.status-dot {
  background: var(--brand-end);
  border-radius: 50%;
  width: 5px;
  height: 5px;
}

.toggle {
  display: inline-flex;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  align-items:  center;
  gap: 8px;
}

.toggle input {
  accent-color: var(--accent);
  cursor: pointer;
  width: 14px;
  height: 14px;
  margin: 0;
}

.flag {
  display: inline-block;
  width: 1.6em;
  font-size: 13px;
  line-height: 1;
}

@media (width <= 980px) {
  :root {
    --gutter: 32px;
  }
}

@media (width <= 600px) {
  :root {
    --gutter: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* src/ui/layout.css */
.site-header {
  position: sticky;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line-soft);
  top: 0;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 16px;
  height: 74px;
}

.product {
  display: flex;
  align-items:  center;
  min-width: 0;
}

.brand {
  display: inline-flex;
  letter-spacing: -.65px;
  white-space: nowrap;
  align-items:  center;
  gap: 9px;
  font-size: 17px;
  font-weight: 600;
}

.brand-shark {
  display: block;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.brand-domain {
  color: var(--muted);
  font-weight: 450;
}

.product-name {
  border-left: 1px solid var(--line);
  letter-spacing: -.4px;
  color: var(--text);
  white-space: nowrap;
  margin-left: 14px;
  padding-left: 14px;
  font-size: 15px;
  font-weight: 500;
}

.hero {
  padding-block-start: 72px;
  padding-block-end: 40px;
}

.hero .eyebrow {
  margin-bottom: 22px;
}

.hero h1 {
  letter-spacing: -2.4px;
  max-width: 760px;
  font-size: 50px;
  line-height: 1.08;
}

.highlight {
  display: inline-block;
  color: #0000;
  -webkit-text-fill-color: transparent;
  animation: 16s linear infinite sheen;
  background: linear-gradient(90deg, #94b7d5, #d5e7ef 16%, #89cfdf 33%, #75a6da 50%, #b2c4dc 68%, #d5e7ef 84%, #94b7d5) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}

@keyframes sheen {
  to {
    background-position: 200% 0;
  }
}

.hero-description {
  letter-spacing: -.15px;
  color: var(--muted);
  max-width: 560px;
  margin-top: 22px;
  font-size: 14px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items:  center;
  gap: 16px 23px;
  margin-top: 29px;
}

.freshness {
  display: flex;
  color: var(--dim);
  align-items:  center;
  gap: 8px;
  margin-top: 26px;
  font-size: 11px;
}

.freshness:before {
  content: "";
  background: var(--positive);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--positive) 20%, transparent);
  border-radius: 50%;
  width: 6px;
  height: 6px;
}

.freshness.stale:before {
  background: var(--negative);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--negative) 20%, transparent);
}

.kpi-panel {
  background: linear-gradient(90deg, #203039, #20272e 48%, #20252e);
  border: 1px solid #34414b;
  border-radius: 6px;
  padding: 32px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
}

.kpi-grid > div {
  display: flex;
  border-left: 1px solid #7794b226;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 8px;
  padding-left: 32px;
}

.kpi-grid > div:first-child {
  border-left: 0;
  padding-left: 0;
}

.kpi-grid dd {
  letter-spacing: -1.2px;
  font-variant-numeric: tabular-nums;
  margin: 0;
  font-size: 30px;
  font-weight: 450;
}

.kpi-grid dd span {
  color: var(--brand-end);
}

.kpi-grid dt {
  color: var(--muted);
  font-size: 10px;
}

.kpi-note {
  color: var(--dim);
  border-top: 1px solid #7794b226;
  margin-top: 24px;
  padding-top: 18px;
  font-size: 11px;
}

.kpi-note:empty {
  display: none;
}

.section {
  border-bottom: 1px solid var(--line-soft);
  padding-block-start: 72px;
  padding-block-end: 72px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items:  flex-end;
  gap: 40px;
  margin-bottom: 32px;
}

.section-heading .eyebrow {
  margin-bottom: 14px;
}

.section-heading h2 {
  letter-spacing: -1.5px;
  font-size: 34px;
  line-height: 1.12;
}

.section-heading h2 span {
  color: var(--muted);
}

.section-aside {
  color: var(--muted);
  max-width: 380px;
  font-size: 12px;
  line-height: 1.75;
}

.site-footer {
  padding-block-start: 56px;
  padding-block-end: 20px;
}

.footer-top {
  display: grid;
  grid-template-columns: 1fr minmax(0, 460px);
  gap: 40px;
}

.footer-brand > p {
  color: var(--muted);
  margin-top: 14px;
  font-size: 11px;
}

.footer-socials {
  display: flex;
  color: var(--dim);
  align-items:  center;
  gap: 16px;
  margin-top: 20px;
}

.footer-socials a:hover {
  color: var(--text);
}

.footer-socials svg {
  display: block;
  width: 15px;
  height: 15px;
}

.footer-about > span {
  font-size: 10px;
  font-weight: 500;
}

.footer-about p {
  color: var(--muted);
  margin-top: 10px;
  font-size: 11px;
}

.footer-about a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.footer-about a:hover {
  color: var(--accent);
}

.footer-bottom {
  display: flex;
  border-top: 1px solid var(--line);
  color: var(--dim);
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-block-start: 22px;
  padding-block-end: 8px;
  font-size: 9px;
}

@media (width <= 980px) {
  .section-heading {
    flex-direction: column;
    align-items:  flex-start;
    gap: 20px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 28px;
  }

  .kpi-grid > div:nth-child(3) {
    border-left: 0;
    padding-left: 0;
  }

  .footer-top {
    grid-template-columns: 1fr;
  }
}

@media (width <= 600px) {
  .nav {
    height: 62px;
  }

  .brand {
    gap: 6px;
    font-size: 15px;
  }

  .brand-shark {
    width: 32px;
    height: 32px;
  }

  .nav .brand-domain {
    display: none;
  }

  .product-name {
    margin-left: 10px;
    padding-left: 10px;
    font-size: 14px;
  }

  .hero {
    padding-block-start: 48px;
    padding-block-end: 32px;
  }

  .hero h1 {
    letter-spacing: -1.6px;
    font-size: 36px;
  }

  .kpi-panel {
    padding: 22px;
  }

  .kpi-grid > div {
    padding-left: 18px;
  }

  .kpi-grid dd {
    letter-spacing: -.6px;
    font-size: 20px;
  }

  .section {
    padding-block-start: 52px;
    padding-block-end: 52px;
  }

  .section-heading h2 {
    letter-spacing: -1.2px;
    font-size: 28px;
  }

  .footer-bottom {
    flex-direction: column;
  }
}

/* src/ui/tables.css */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 100%;
  font-size: 12px;
}

th, td {
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 16px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th:nth-child(2), td:nth-child(2), th:nth-child(3), th:nth-child(4), td:nth-child(4) {
  text-align: left;
}

th {
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  font-size: 10px;
  font-weight: 500;
}

td:first-child {
  color: var(--dim);
}

td:nth-child(3) {
  text-align: left;
  color: var(--muted);
}

tbody tr {
  cursor: pointer;
  transition: background .12s;
}

tbody tr:hover {
  background: var(--raised);
}

.table-note {
  color: var(--muted);
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.75;
}

td.empty {
  text-align: left;
  white-space: normal;
  color: var(--text);
  cursor: default;
  padding-block-start: 22px;
  padding-block-end: 22px;
}

td.empty p {
  color: var(--muted);
  margin-top: 6px;
}

tbody tr:has(td.empty):hover {
  background: none;
}

.table-tools {
  display: flex;
  color: var(--muted);
  align-items:  center;
  gap: 24px;
  margin-bottom: 14px;
  font-size: 12px;
}

.slot {
  display: inline-block;
  background: color-mix(in srgb, currentColor 14%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.5;
}

.slot-open {
  color: var(--positive);
}

.slot-full {
  color: var(--negative);
}

.slot-refused {
  color: var(--lag-late);
}

.slot-no_answer, .slot-unreachable {
  color: var(--muted);
}

.slot-not_probed {
  color: var(--lag-unknown);
}

.slot-when {
  color: var(--muted);
  margin-left: 8px;
}

.table-actions {
  display: flex;
  align-items:  center;
  gap: 24px;
  margin-top: 22px;
}

.table-actions p {
  color: var(--muted);
  max-width: 420px;
  font-size: 11px;
  line-height: 1.6;
}

@media (width <= 980px) {
  .table-tools {
    flex-direction: column;
    align-items:  flex-start;
    gap: 20px;
  }
}

@media (width <= 600px) {
  .table-actions {
    flex-direction: column;
    align-items:  flex-start;
  }
}

/* src/ui/graph.css */
#legend {
  display: flex;
  list-style: none;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
  padding: 0;
  font-size: 11px;
}

#legend li {
  display: flex;
  align-items:  center;
  gap: 7px;
}

#legend span {
  border-radius: 50%;
  width: 8px;
  height: 8px;
}

.hint {
  color: var(--muted);
  max-width: 720px;
  margin-bottom: 20px;
  font-size: 12px;
  line-height: 1.75;
}

#graph-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items:  start;
  gap: 20px;
}

.graph-scroll {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

#graph {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
}

#graph line {
  stroke: var(--line);
  stroke-opacity: .45;
  stroke-width: 1;
}

#graph circle {
  stroke: var(--panel);
  stroke-width: 1.5;
  cursor: pointer;
}

#graph .layer {
  fill: var(--muted);
  letter-spacing: .04em;
  font-size: 11px;
}

#graph.focus line {
  stroke-opacity: .12;
}

#graph.focus circle {
  opacity: .2;
}

#graph.focus line.up {
  stroke: var(--accent);
  stroke-opacity: .95;
}

#graph.focus line.down {
  stroke: var(--text);
  stroke-opacity: .5;
}

#graph.focus circle.hl {
  opacity: 1;
}

#graph circle.match {
  stroke: var(--text);
  stroke-width: 1.5;
}

#graph circle.sel {
  stroke: var(--text);
  stroke-width: 2;
}

#detail {
  position: sticky;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 16px;
  font-size: 12px;
  top: 94px;
}

#detail dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
}

#detail dl + dl {
  border-top: 1px solid var(--line-soft);
  margin-top: 12px;
  padding-top: 12px;
}

#detail dt {
  color: var(--muted);
}

#detail dd {
  color: var(--text);
  overflow-wrap: anywhere;
  margin: 0;
}

.peer-list {
  display: flex;
  flex-direction: column;
  align-items:  flex-start;
}

.peer-link {
  color: inherit;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
  background: none;
  border: 0;
  padding: 0;
}

.peer-link:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.peer-link:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.network-asn {
  display: block;
  color: var(--muted);
  margin-top: 2px;
  font-size: 11px;
}

.graph-search {
  display: flex;
  align-items:  center;
  gap: 14px;
  margin-bottom: 14px;
}

#search {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  width: min(360px, 100%);
  height: 35px;
  padding: 0 12px;
  font-size: 12px;
}

#search::placeholder {
  color: var(--dim);
}

#search:focus {
  outline: none;
  border-color: var(--accent);
}

#search-count {
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
}

.country-filter {
  position: relative;
}

.country-filter summary {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  align-items:  center;
  gap: 10px;
  height: 35px;
  padding: 0 12px;
  font-size: 12px;
}

.country-filter summary::-webkit-details-marker {
  display: none;
}

.country-filter[open] summary, .country-filter summary:hover {
  border-color: var(--muted);
}

.country-filter.active summary {
  color: var(--text);
  border-color: var(--accent);
}

.country-menu {
  position: absolute;
  z-index: 30;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  width: 260px;
  max-height: 340px;
  top: calc(100% + 6px);
  left: 0;
  box-shadow: 0 12px 32px #0006;
}

.country-menu-head {
  position: sticky;
  display: flex;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  justify-content: space-between;
  align-items:  center;
  padding: 10px 12px;
  font-size: 10px;
  top: 0;
}

#country-clear {
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  font-size: 11px;
}

#country-list {
  list-style: none;
  margin: 0;
  padding: 6px;
}

#country-list label {
  display: flex;
  border-radius: var(--radius);
  cursor: pointer;
  align-items:  center;
  gap: 8px;
  padding: 7px 8px;
  font-size: 12px;
}

#country-list label:hover {
  background: var(--raised);
}

#country-list input {
  accent-color: var(--accent);
  margin: 0;
}

.country-name {
  flex: 1;
}

.country-count {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

@media (width <= 980px) {
  #graph-wrap {
    grid-template-columns: 1fr;
  }

  #detail {
    position: static;
  }
}

@media (width <= 600px) {
  .graph-search {
    flex-wrap: wrap;
  }
}

/* src/ui/dialog.css */
#config-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: min(760px, 100% - 32px);
  padding: 22px;
}

#config-dialog::backdrop {
  backdrop-filter: blur(3px);
  background: #0a0c0fb3;
}

#config-dialog > p {
  color: var(--muted);
  margin: 10px 0 14px;
  font-size: 12px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items:  center;
}

.dialog-head h3 {
  font-size: 14px;
  font-weight: 600;
}

.dialog-close {
  border-radius: var(--radius);
  color: var(--muted);
  background: none;
  border: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--text);
}

#config-json {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  resize: none;
  width: 100%;
  max-height: 50vh;
  padding: 12px 14px;
  font: 12px / 1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}

#config-json:focus {
  outline: none;
  border-color: var(--accent);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

#toast {
  border: 1px solid var(--line);
  border-left: 2px solid var(--positive);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--text);
  margin: 0;
  padding: 11px 16px;
  transition: opacity .18s, transform .18s;
  font-size: 12px;
  inset: auto 24px 24px auto;
  box-shadow: 0 8px 24px #00000059;
}

@starting-style {
  #toast:popover-open {
    opacity: 0;
    transform: translateY(8px);
  }
}

.dialog-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  align-items:  start;
  gap: 18px;
}

.dialog-options {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.option {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
}

.option p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.option input[type="number"] {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  width: 96px;
  height: 32px;
  padding: 0 10px;
}

.option input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.option input[aria-invalid] {
  border-color: var(--negative);
}

.option input[aria-invalid] + p {
  color: var(--negative);
}

@media (width <= 600px) {
  #toast {
    inset: auto 16px 16px;
  }

  .dialog-body {
    grid-template-columns: 1fr;
  }
}

/* src/ui/style.css */

