/* Network Quality Monitor — popup styles */

:root {
  color-scheme: dark;
  --bg: #0b1220;
  --card: rgba(255, 255, 255, 0.055);
  --card-edge: rgba(255, 255, 255, 0.09);
  --text: #e7edf7;
  --muted: #93a1b8;
  --accent: #94a3b8;
  --accent-soft: rgba(148, 163, 184, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  width: 340px;
  font-family: ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  user-select: none;
}

main {
  position: relative;
  overflow: hidden;
  padding: 12px 16px 14px;
  background:
    radial-gradient(420px 260px at 50% -60px, var(--accent-soft), transparent 70%),
    var(--bg);
  transition: background 0.6s ease;
}

main[data-state="good"]    { --accent: #22c55e; --accent-soft: rgba(34, 197, 94, 0.20); }
main[data-state="fair"]    { --accent: #f59e0b; --accent-soft: rgba(245, 158, 11, 0.20); }
main[data-state="bad"]     { --accent: #ef4444; --accent-soft: rgba(239, 68, 68, 0.22); }
main[data-state="offline"] { --accent: #64748b; --accent-soft: rgba(100, 116, 139, 0.22); }
main[data-state="paused"]  { --accent: #64748b; --accent-soft: rgba(100, 116, 139, 0.16); }

/* ---------------- header / footer bars */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { width: 18px; height: 18px; fill: var(--accent); flex: none; transition: fill 0.4s; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 12.5px; letter-spacing: 0.2px; white-space: nowrap; }
.brand-text span { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}

.icon-btn {
  flex: none; width: 28px; height: 28px;
  display: grid; place-items: center;
  border: none; border-radius: 9px;
  background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
.icon-btn:hover { background: var(--card); color: var(--text); }

/* ---------------- hero */

.hero { text-align: center; padding: 14px 0 12px; }

.face {
  position: relative;
  width: 92px; height: 92px;
  border: none; border-radius: 50%;
  margin: 0 auto;
  display: grid; place-items: center;
  cursor: pointer;
  background: radial-gradient(circle at 50% 38%, var(--accent-soft), transparent 72%);
  transition: transform 0.15s ease;
}
.face:active { transform: scale(0.93); }

.face .ring {
  position: absolute; inset: 6px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.55;
  transition: border-color 0.4s;
}
main[data-live="1"] .face .ring { animation: pulse 2.4s ease-out infinite; }
@keyframes pulse {
  0%   { transform: scale(0.92); opacity: 0.6; }
  70%  { transform: scale(1.12); opacity: 0; }
  100% { transform: scale(1.12); opacity: 0; }
}

#emoji { font-size: 46px; line-height: 1; transition: transform 0.25s; }
main.bounce #emoji { animation: bounce 0.45s ease; }
@keyframes bounce {
  0% { transform: scale(1); } 35% { transform: scale(1.25) rotate(-6deg); } 100% { transform: scale(1); }
}

h1 { font-size: 19px; font-weight: 800; margin-top: 8px; letter-spacing: 0.2px; }
#verdictSub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

.mos { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 8px; }
.stars { position: relative; font-size: 15px; letter-spacing: 2px; line-height: 1; }
.stars .base { color: rgba(255, 255, 255, 0.16); }
.stars .fill {
  position: absolute; left: 0; top: 0;
  width: 0%; overflow: hidden; white-space: nowrap;
  color: var(--accent);
  transition: width 0.5s ease, color 0.4s;
}
#mosNum { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------------- metric chips */

.chips { display: flex; gap: 8px; margin-bottom: 10px; }
.chip {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 13px;
  padding: 8px 6px 7px;
  text-align: center;
  position: relative;
}
.chip .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s, box-shadow 0.3s;
}
.chip b { display: block; font-size: 15px; font-weight: 800; }
.chip label { display: block; font-size: 9.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

/* ---------------- chart panel */

.panel {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 13px;
  padding: 8px 10px 8px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.panel:hover { border-color: var(--accent); background: rgba(255, 255, 255, 0.07); }
.panel:hover #sparkExpand { color: var(--accent); }

.panelHead {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; letter-spacing: 0.4px; color: var(--muted);
  margin-bottom: 4px;
}
#sparkNote { text-transform: uppercase; font-weight: 700; }
#sparkExpand { font-weight: 700; transition: color 0.15s; }

#spark { display: block; width: 100%; height: 72px; }

.strip { display: flex; gap: 2px; margin-top: 8px; height: 16px; align-items: stretch; }
.strip .seg {
  flex: 1; border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.1s;
}
.strip .seg:hover { transform: scaleY(1.25); }

.legendRow {
  display: flex; justify-content: space-between;
  font-size: 9.5px; color: var(--muted);
  margin-top: 5px; letter-spacing: 0.3px;
}

/* ---------------- footer */

.foot { margin-bottom: 2px; }

.liveStatus { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.liveStatus .livedot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
}
main[data-live="1"] .liveStatus .livedot { animation: livepulse 1.6s ease-out infinite; }
@keyframes livepulse {
  0%   { box-shadow: 0 0 0 0 var(--accent); opacity: 1; }
  70%  { box-shadow: 0 0 0 6px transparent; opacity: 0.7; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

.btn {
  border: none; border-radius: 99px;
  padding: 7px 16px;
  font: inherit; font-weight: 800; font-size: 12px;
  color: #08101e;
  background: var(--accent);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: filter 0.15s, background 0.4s;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: 0.75; cursor: default; }
.btn.busy::before {
  content: "";
  width: 11px; height: 11px;
  border: 2px solid rgba(8, 16, 30, 0.35);
  border-top-color: #08101e;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- help */

.help { margin-top: 9px; font-size: 11px; color: var(--muted); }
.help summary { cursor: pointer; outline: none; }
.help summary:hover { color: var(--text); }
.help table { width: 100%; margin: 8px 0 4px; border-collapse: collapse; font-size: 10.5px; }
.help td, .help th { padding: 3px 4px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.06); }
.help .g { color: #4ade80; } .help .f { color: #fbbf24; } .help .b { color: #f87171; }
.help p { margin-top: 6px; line-height: 1.45; }

/* ---------------- settings panel */

.settings {
  position: absolute; inset: 0;
  padding: 12px 16px;
  background:
    radial-gradient(420px 260px at 50% -60px, var(--accent-soft), transparent 70%),
    var(--bg);
  transform: translateX(105%);
  transition: transform 0.25s ease;
  z-index: 5;
}
.settings.open { transform: translateX(0); }
.settings header { margin-bottom: 14px; }
.settings header strong { font-size: 14px; }
.settings header span { width: 28px; }

.srow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.srow > label:first-child { color: var(--text); font-size: 12.5px; }
.slabel { min-width: 0; }
.slabel label { color: var(--text); font-size: 12.5px; }
.slabel small { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; margin-top: 3px; max-width: 180px; }
.srow select { flex: none; }

select {
  font: inherit; font-size: 12px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 9px;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: var(--accent); }
option { background: #131c2e; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.2s;
}
.switch span::before {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }

.about { margin-top: 14px; font-size: 10.5px; color: var(--muted); line-height: 1.5; }

/* ---------------- trends overlay */

.ranges { display: flex; gap: 6px; margin-bottom: 12px; }
.rbtn {
  flex: 1;
  border: 1px solid var(--card-edge);
  background: var(--card);
  color: var(--muted);
  border-radius: 9px;
  padding: 6px 4px;
  font: inherit; font-size: 11px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rbtn:hover { color: var(--text); }
.rbtn.active { background: var(--accent); color: #08101e; border-color: var(--accent); }

.trendWrap { position: relative; }
#trendChart { display: block; width: 100%; height: 150px; }
.trendEmpty {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  padding: 0 24px; font-size: 11.5px; color: var(--muted); line-height: 1.5;
}
.trendEmpty[hidden] { display: none; }

.tstats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px;
  margin-top: 12px;
}
.tstats .ts {
  background: var(--card); border: 1px solid var(--card-edge);
  border-radius: 10px; padding: 7px 4px; text-align: center;
}
.tstats .ts b { display: block; font-size: 14px; font-weight: 800; }
.tstats .ts label { display: block; font-size: 8.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
