:root {
  --bg-0: #070a18;
  --bg-1: #0b1026;
  --bg-2: #0f1636;
  --panel: rgba(19, 24, 52, 0.55);
  --panel-strong: rgba(23, 29, 62, 0.78);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8ecff;
  --text-strong: #ffffff;
  --muted: #9aa3c7;
  --muted-2: #6d769a;
  --accent: #22c55e;
  --accent-2: #4ade80;
  --accent-soft: rgba(34, 197, 94, 0.18);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.18);
  --yellow: #facc15;
  --yellow-2: #fde047;
  --yellow-soft: rgba(250, 204, 21, 0.18);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.18);
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 20px 60px -10px rgba(0, 0, 0, 0.45), 0 4px 14px rgba(0, 0, 0, 0.25);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --ring-focus: 0 0 0 3px rgba(74, 222, 128, 0.35);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 800px at 10% -10%, rgba(59, 130, 246, 0.18), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, rgba(168, 85, 247, 0.18), transparent 55%),
    radial-gradient(900px 900px at 50% 110%, rgba(34, 197, 94, 0.14), transparent 55%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 55%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100dvh;
}

/* ===== Background Orbs ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  will-change: transform;
}
.orb-1 {
  width: 520px; height: 520px;
  top: -180px; left: -140px;
  background: radial-gradient(circle at 30% 30%, #3b82f6 0%, rgba(59, 130, 246, 0.3) 50%, transparent 70%);
  animation: floatOrb1 18s ease-in-out infinite;
}
.orb-2 {
  width: 480px; height: 480px;
  top: 10%; right: -160px;
  background: radial-gradient(circle at 60% 40%, #a855f7 0%, rgba(168, 85, 247, 0.3) 50%, transparent 70%);
  animation: floatOrb2 22s ease-in-out infinite;
}
.orb-3 {
  width: 560px; height: 560px;
  bottom: -220px; left: 20%;
  background: radial-gradient(circle at 50% 50%, #22c55e 0%, rgba(34, 197, 94, 0.25) 55%, transparent 70%);
  animation: floatOrb3 26s ease-in-out infinite;
}
@keyframes floatOrb1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, 30px) scale(1.06); }
  66%      { transform: translate(-20px, 50px) scale(0.96); }
}
@keyframes floatOrb2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-50px, 40px) scale(1.1); }
}
@keyframes floatOrb3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(30px, -40px) scale(1.05); }
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  background: linear-gradient(180deg, rgba(7, 10, 24, 0.85) 0%, rgba(7, 10, 24, 0.55) 60%, rgba(7, 10, 24, 0) 100%);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, #22c55e, #4ade80, #3b82f6, #a855f7, #22c55e);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15), 0 0 18px rgba(34, 197, 94, 0.55);
  animation: spin 8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  color: var(--text-strong);
}
.brand-accent {
  background: linear-gradient(90deg, #4ade80, #3b82f6 55%, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
.toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0;
}
.toggle:hover { transform: translateY(-1px); border-color: var(--panel-border-strong); }
.toggle:active { transform: translateY(0); }
.toggle:focus-visible { outline: none; box-shadow: var(--ring-focus); }

/* ===== Layout ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 10px 16px calc(48px + var(--safe-bottom));
}

/* ===== Reveal on scroll ===== */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Hero ===== */
.hero {
  position: relative;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(74, 222, 128, 0.10) 0%, transparent 40%),
    linear-gradient(315deg, rgba(168, 85, 247, 0.10) 0%, transparent 45%),
    var(--panel);
  border: 1px solid var(--panel-border-strong);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.04);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 200px at 50% -20%, rgba(74, 222, 128, 0.18), transparent 60%);
  pointer-events: none;
}
.hero-inner {
  position: relative;
  padding: 28px 22px 26px;
  text-align: center;
}

.flag-container {
  position: relative;
  width: 78px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
}
.flag-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(255,255,255,0.04) 8%, rgba(255,255,255,0.1) 18%, rgba(255,255,255,0.04) 33%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.flag-img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  animation: popIn 0.35s ease-out;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

.hero-label-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
}
.chip-primary {
  background: var(--accent-soft);
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--accent-2);
}
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.5);
  animation: pulseDot 1.6s ease-in-out infinite;
}
.status-dot.ready {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: pulseGreen 2.2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); }
  100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); }
}
@keyframes pulseGreen {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.ip-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 auto;
}
.ip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 10px 18px;
  border-radius: 16px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(22px, 4.5vw, 30px);
  letter-spacing: 0.3px;
  color: var(--text-strong);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--panel-border-strong);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  word-break: break-all;
  text-align: center;
  transition: border-color 0.2s;
  cursor: default;
}
.ip::before {
  content: attr(data-empty, "…");
  opacity: 0.35;
  font-weight: 500;
}
.ip:not(:empty)::before { display: none; }

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid var(--panel-border-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.copy-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(74, 222, 128, 0.45);
  color: var(--accent-2);
  transform: translateY(-1px);
}
.copy-btn:active { transform: translateY(0); }
.copy-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.copy-icon, .check-icon {
  width: 18px; height: 18px;
  flex: 0 0 auto;
}
.copy-btn.copied {
  background: var(--accent-soft);
  border-color: rgba(74, 222, 128, 0.5);
  color: var(--accent-2);
}

.country {
  margin-top: 14px;
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 700;
  background: linear-gradient(90deg, #4ade80, #3b82f6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.location {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

/* ===== Card ===== */
.card {
  position: relative;
  margin-top: 18px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.03);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
}
.card-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-strong);
}
.card-sub {
  margin-left: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.card-icon {
  width: 18px; height: 18px;
  color: var(--accent-2);
}
.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.18s, border-color 0.18s;
  padding: 0;
}
.refresh-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--accent-2);
  transform: rotate(180deg);
}
.refresh-btn:active { transform: rotate(360deg) scale(0.96); }
.refresh-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.refresh-icon {
  width: 17px; height: 17px;
}

/* ===== Connection Grid ===== */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px 16px 18px;
}
.item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}
.item:hover {
  border-color: var(--panel-border);
  background: rgba(255,255,255,0.045);
  transform: translateY(-1px);
}
.k {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.item-icon {
  width: 14px; height: 14px;
  color: var(--muted);
  opacity: 0.9;
}
.v {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  word-break: break-word;
}

/* ===== Ping Only Card ===== */
.ping-only-card {
  border-color: rgba(250, 204, 21, 0.22);
  background:
    linear-gradient(135deg, rgba(250, 204, 21, 0.08) 0%, transparent 45%),
    var(--panel);
}
.ping-header { border-bottom-color: rgba(250, 204, 21, 0.18); }
.ping-header .card-icon { color: var(--yellow-2); }

/* ===== Speed Grid ===== */
.speed-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 18px;
  margin-bottom: 4px;
}
.ping-grid { grid-template-columns: 1fr; }

.speed-item {
  position: relative;
  padding: 18px 16px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
    rgba(0,0,0,0.14);
  border: 1px solid var(--panel-border);
  text-align: center;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.speed-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(220px 80px at 50% 0%, var(--glow, rgba(74, 222, 128, 0.15)), transparent 70%);
  opacity: 0.9;
  pointer-events: none;
}
.speed-item:hover {
  transform: translateY(-2px);
  border-color: var(--panel-border-strong);
  box-shadow: var(--shadow-sm);
}
.speed-item .label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin-bottom: 6px;
}
.speed-item .value {
  display: block;
  font-family: var(--mono);
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 800;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  min-height: 34px;
  position: relative;
  z-index: 1;
}
.speed-item .value small {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}
.speed-icon-wrap {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  margin: 0 auto 10px;
  border: 1px solid transparent;
  position: relative;
  z-index: 1;
}
.speed-icon-wrap svg { width: 20px; height: 20px; }

.latency-icon {
  background: var(--yellow-soft);
  border-color: rgba(250, 204, 21, 0.35);
  color: var(--yellow-2);
}
.speed-item:has(.latency-icon) { --glow: rgba(250, 204, 21, 0.22); }
.speed-item:has(.latency-icon) .value { color: var(--yellow-2); }

.download-icon {
  background: var(--accent-soft);
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--accent-2);
}
.speed-item:has(.download-icon) { --glow: rgba(74, 222, 128, 0.22); }
.speed-item:has(.download-icon) .value { color: var(--accent-2); }

.upload-icon {
  background: var(--purple-soft);
  border-color: rgba(168, 85, 247, 0.35);
  color: #c084fc;
}
.speed-item:has(.upload-icon) { --glow: rgba(168, 85, 247, 0.22); }
.speed-item:has(.upload-icon) .value { color: #c084fc; }

.ping-icon {
  background: var(--yellow-soft);
  border-color: rgba(250, 204, 21, 0.4);
  color: var(--yellow-2);
}
.ping-item {
  background:
    linear-gradient(180deg, rgba(250, 204, 21, 0.05), rgba(250, 204, 21, 0.01)),
    rgba(0,0,0,0.14);
  border-color: rgba(250, 204, 21, 0.22);
  --glow: rgba(250, 204, 21, 0.2);
}
.ping-item .value { color: var(--yellow-2) !important; }

/* ===== Progress Bar ===== */
.speed-progress {
  height: 8px;
  margin: 4px 18px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  position: relative;
}
.speed-progress .bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e 0%, #3b82f6 50%, #a855f7 100%);
  background-size: 200% 100%;
  animation: shimmerBar 3s linear infinite;
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.35);
  border-radius: inherit;
}
@keyframes shimmerBar {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.speed-note {
  text-align: center;
  margin: 0 18px 14px;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

/* ===== Primary Buttons ===== */
.btn-primary, .btn-primary-yellow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: calc(100% - 36px);
  max-width: 320px;
  margin: 6px 18px 20px;
  padding: 15px 22px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.22s ease, filter 0.18s ease, opacity 0.18s ease;
  user-select: none;
}
.btn-primary svg, .btn-primary-yellow svg {
  width: 18px; height: 18px;
  flex: 0 0 auto;
}
.btn-primary {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  color: #052e16;
  box-shadow: 0 10px 26px -10px rgba(34, 197, 94, 0.65), 0 2px 0 rgba(255,255,255,0.25) inset, 0 -2px 0 rgba(0,0,0,0.2) inset;
  border-color: rgba(74, 222, 128, 0.5);
}
.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 14px 32px -10px rgba(34, 197, 94, 0.7), 0 2px 0 rgba(255,255,255,0.3) inset, 0 -2px 0 rgba(0,0,0,0.2) inset;
}
.btn-primary:active { transform: translateY(0); filter: brightness(0.98); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--ring-focus), 0 10px 26px -10px rgba(34, 197, 94, 0.65); }

.btn-primary-yellow {
  background: linear-gradient(180deg, #facc15 0%, #eab308 100%);
  color: #422006;
  box-shadow: 0 10px 26px -10px rgba(250, 204, 21, 0.65), 0 2px 0 rgba(255,255,255,0.35) inset, 0 -2px 0 rgba(0,0,0,0.18) inset;
  border-color: rgba(253, 224, 71, 0.6);
}
.btn-primary-yellow:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 14px 32px -10px rgba(250, 204, 21, 0.72), 0 2px 0 rgba(255,255,255,0.4) inset, 0 -2px 0 rgba(0,0,0,0.18) inset;
}
.btn-primary-yellow:active { transform: translateY(0); filter: brightness(0.98); }
.btn-primary-yellow:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(253, 224, 71, 0.4), 0 10px 26px -10px rgba(250, 204, 21, 0.65); }

.btn-primary:disabled, .btn-primary-yellow:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  filter: grayscale(0.25) !important;
}

/* ===== Footer ===== */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-top: 32px;
  padding: 10px 0 4px;
  color: var(--muted-2);
  font-size: 13px;
}
.footer-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.footer-dot { opacity: 0.5; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(40px);
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--panel-border-strong);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success {
  border-color: rgba(74, 222, 128, 0.45);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.25), var(--panel-strong));
}

/* ===== Light Mode ===== */
body.light {
  --bg-0: #f4f7fb;
  --bg-1: #eef2f9;
  --bg-2: #e6ecf5;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(15, 23, 42, 0.08);
  --panel-border-strong: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --text-strong: #0b1220;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent-soft: rgba(22, 163, 74, 0.12);
  --purple-soft: rgba(147, 51, 234, 0.12);
  --yellow-soft: rgba(202, 138, 4, 0.12);
  --blue-soft: rgba(37, 99, 235, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 18px -6px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 50px -12px rgba(15, 23, 42, 0.2), 0 4px 12px rgba(15, 23, 42, 0.07);
  --ring-focus: 0 0 0 3px rgba(22, 163, 74, 0.22);
  background:
    radial-gradient(1200px 800px at 10% -10%, rgba(59, 130, 246, 0.14), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, rgba(168, 85, 247, 0.12), transparent 55%),
    radial-gradient(900px 900px at 50% 110%, rgba(34, 197, 94, 0.1), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 55%, #eef2f9 100%);
}
body.light .topbar {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.85) 0%, rgba(248, 250, 252, 0.55) 60%, rgba(248, 250, 252, 0) 100%);
}
body.light .ip { background: rgba(15, 23, 42, 0.03); }
body.light .hero { box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.8); }
body.light .card { box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.7); }
body.light .item { background: rgba(15, 23, 42, 0.025); }
body.light .item:hover { background: rgba(15, 23, 42, 0.04); }
body.light .speed-item {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.35)),
    #ffffff;
}
body.light .speed-progress { background: rgba(15, 23, 42, 0.05); }
body.light .ping-only-card {
  background:
    linear-gradient(135deg, rgba(250, 204, 21, 0.12) 0%, transparent 45%),
    var(--panel);
}
body.light .flag-container { background: linear-gradient(145deg, rgba(15,23,42,0.04), rgba(15,23,42,0.01)); }
body.light .hero::before { background: radial-gradient(600px 200px at 50% -20%, rgba(34, 197, 94, 0.12), transparent 60%); }
body.light .orb { opacity: 0.35; filter: blur(90px); }
body.light .footer-inner { background: rgba(255,255,255,0.75); }

/* ===== Tablet and Up ===== */
@media (min-width: 520px) {
  .hero-inner { padding: 34px 28px 32px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 16px 18px 22px; }
  .speed-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 22px; }
  .ping-grid { grid-template-columns: 1fr; }
}

/* ===== Desktop and Up ===== */
@media (min-width: 820px) {
  .topbar { padding: calc(14px + var(--safe-top)) 26px 14px; }
  .container { padding: 18px 20px calc(60px + var(--safe-bottom)); }
  .hero-inner { padding: 44px 36px 40px; }
  .card { margin-top: 22px; }
  .card-header { padding: 18px 22px; }
  .grid { padding: 18px 22px 26px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ===== Tiny screen fallback ===== */
@media (max-width: 340px) {
  .brand-text { font-size: 14px; }
  .hero-inner { padding: 22px 16px 20px; }
  .ip { font-size: 20px; padding: 10px 12px; }
}
