/* SpeedTest - minimalist theme, light/dark aware. */
:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-2: #eef0f3;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e4e7ec;
  --accent: #e4002b;        /* Turn5 red */
  --download: #2563eb;
  --upload: #10b981;
  --latency: #f59e0b;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* Always reserve the scrollbar gutter so short pages (no scrollbar) and tall
   pages (with scrollbar) keep the same content width - otherwise the centered
   layout shifts a few px between pages. */
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.site-header .brand { display: flex; align-items: center; gap: 12px; }
.site-header .brand img { height: 30px; width: auto; display: block; }
.site-header .brand .title { font-weight: 600; letter-spacing: .2px; }
.site-header nav { display: flex; gap: 6px; }
.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.site-header nav a:hover { background: var(--surface); color: var(--text); }
.site-header nav a.active { background: var(--accent); color: #fff; }

/* Main */
main {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 22px 40px;
}
/* Data-table pages (History) need more room than prose. */
main.wide { max-width: 1040px; }

/* Footer / cookie + logging notice */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 16px 22px;
  text-align: center;
}
.site-footer strong { color: var(--text); font-weight: 600; }

/* Gauge + test area */
.tester { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.gauge-wrap { position: relative; width: 300px; max-width: 82vw; aspect-ratio: 1; }
.gauge { width: 100%; height: 100%; transform: rotate(0deg); }
.gauge .track { fill: none; stroke: var(--surface-2); stroke-width: 16; stroke-linecap: round; }
.gauge .value { fill: none; stroke-width: 16; stroke-linecap: round; transition: stroke-dashoffset .12s linear, stroke .3s; }
.gauge-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.gauge-center .reading { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.gauge-center .unit { font-size: 15px; color: var(--muted); margin-top: 4px; }
.gauge-center .phase-label {
  margin-top: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted); min-height: 15px; white-space: nowrap;
}
.gauge-center .phase-icon { font-size: 20px; height: 22px; }

/* Live graph */
.graph { width: 100%; max-width: 620px; height: 90px; display: block; }

/* Start button */
.btn {
  border: none; cursor: pointer; font: inherit; font-weight: 600;
  border-radius: 999px; padding: 13px 34px; font-size: 16px;
  background: var(--accent); color: #fff; transition: transform .08s, opacity .15s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); }

/* Single / multi-thread toggle */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg-btn {
  border: none; background: none; cursor: pointer; font: inherit; font-weight: 600;
  font-size: 13px; color: var(--muted); padding: 7px 16px; border-radius: 999px;
  transition: background .15s, color .15s;
}
.seg-btn.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.seg-btn:disabled { cursor: default; opacity: .55; }

/* Phase steps */
.phases { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.phases .step {
  font-size: 12px; color: var(--muted); padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}
.phases .step.active { color: var(--text); border-color: var(--accent); }
.phases .step.done { color: var(--upload); }

/* Metric tiles */
.metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%;
  max-width: 620px;
}
.metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.metric .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.metric .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.metric.dl .dot { background: var(--download); }
.metric.ul .dot { background: var(--upload); }
.metric.lat .dot, .metric.jit .dot, .metric.load .dot, .metric.bloat .dot { background: var(--latency); }
.metric .value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.metric .value .u { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.metric .value.pending { color: var(--muted); }

/* Share + meta */
.share {
  width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: none;
}
.share.show { display: block; }
.share label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.share .row { display: flex; gap: 8px; margin-top: 8px; }
.share input {
  flex: 1; font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.share .copied { color: var(--upload); font-size: 13px; margin-top: 8px; min-height: 16px; }
.meta { color: var(--muted); font-size: 12.5px; text-align: center; max-width: 620px; }

/* History table */
.page-title { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.page-sub { color: var(--muted); margin: 0 0 22px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 620px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }
td a { color: var(--accent); text-decoration: none; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* Tips content */
.prose h2 { font-size: 18px; margin: 26px 0 8px; }
.prose h1 { font-size: 24px; margin: 0 0 6px; }
.prose p, .prose li { color: var(--text); }
.prose ul { padding-left: 20px; }
.prose li { margin: 5px 0; }
.callout {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; margin: 16px 0; color: var(--muted);
}

/* Delete button + confirmation modal */
td.actions { white-space: nowrap; }
td.actions a { margin-right: 14px; }
button.del {
  border: none; background: none; color: var(--accent); cursor: pointer;
  font: inherit; font-weight: 600; padding: 0;
}
button.del:hover { text-decoration: underline; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 400px; width: 100%; padding: 22px; box-shadow: 0 12px 44px rgba(16,24,40,.28);
  max-height: 85vh; overflow-y: auto;
}
.modal.wide { max-width: 480px; }
.modal h3 { margin: 0 0 10px; font-size: 18px; }
.modal h4 { margin: 16px 0 4px; font-size: 14px; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.modal p strong { color: var(--text); }
.modal ul { margin: 0 0 14px; padding-left: 18px; }
.modal li { margin: 4px 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.modal li strong { color: var(--text); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.modal .actions .btn { padding: 10px 18px; font-size: 14px; }
.btn.danger { background: var(--accent); color: #fff; }

/* Phones: compact the test screen so it fits without scrolling, and turn the
   history table into stacked cards. */
@media (max-width: 560px) {
  main { padding: 12px 14px 18px; }
  .site-header { padding: 9px 12px; }
  .site-header .brand img { height: 24px; }
  .site-header .brand .title { font-size: 14px; }
  .site-header nav { gap: 3px; }
  .site-header nav a { padding: 6px 9px; font-size: 12.5px; }

  .tester { gap: 9px; }
  .gauge-wrap { width: 140px; }
  .gauge-center .reading { font-size: 27px; }
  .gauge-center .unit { font-size: 12px; margin-top: 1px; }
  .gauge-center .phase-label { margin-top: 4px; font-size: 10.5px; }
  .gauge-center .phase-icon { font-size: 15px; height: 16px; }
  .graph { height: 38px; }
  .btn { padding: 10px 24px; font-size: 15px; }
  .phases { gap: 6px; }
  .phases .step { font-size: 11px; padding: 4px 9px; }
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .metric { padding: 6px 10px; border-radius: 10px; }
  .metric .label { font-size: 9.5px; }
  .metric .value { font-size: 15px; margin-top: 2px; }
  .share { padding: 10px 12px; }
  .share .row { margin-top: 6px; }
  .share input { padding: 8px 10px; }
  .meta { font-size: 11.5px; }

  /* History cards */
  .table-wrap { border: none; overflow: visible; }
  table { min-width: 0; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow);
    margin-bottom: 12px; padding: 4px 2px;
  }
  tbody tr:hover { background: var(--surface); }
  td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; border: none; padding: 8px 14px; white-space: normal;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
  }
  td.actions { justify-content: flex-end; padding-top: 12px; }
  td.actions::before { display: none; }
  td.actions a {
    margin-right: 0; padding: 7px 18px; border: 1px solid var(--accent); border-radius: 999px;
  }
}
