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

:root {
  /* Theme: navy base + cyan accent */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.12);

  --navy-1: #0b1b2b;
  --navy-2: #122a42;

  --accent: #00bfe6;
  --accent-2: #008bb8;

  --primary-1: #0b63c6;
  --primary-2: #094b98;

  --shadow-1: 0 4px 20px rgba(2, 6, 23, 0.08);
  --shadow-2: 0 10px 26px rgba(2, 6, 23, 0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--navy-1) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 2rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  text-align: center;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
}

/* Title "pop/burst" animation on initial page load */
header h1.hero-title {
  display: inline-block;
  position: relative;
}

header h1.hero-title .hero-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(-8px) scale(0.9);
  filter: blur(7px);
  transform-origin: 50% 60%;
  animation: hero-pop 980ms cubic-bezier(0.2, 1, 0.22, 1) both;
  will-change: transform, opacity, filter;
}

header h1.hero-title .hero-word-1 {
  animation-delay: 40ms;
}

header h1.hero-title .hero-word-2 {
  animation-delay: 140ms;
}

header h1.hero-title .hero-word-2.highlight {
  position: relative;
}

header h1.hero-title .hero-word-2.highlight::before {
  content: "";
  position: absolute;
  left: -0.25em;
  right: -0.25em;
  top: -0.35em;
  bottom: -0.35em;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 55%, rgba(0, 191, 230, 0.42) 0%, rgba(0, 191, 230, 0.0) 66%);
  opacity: 0;
  transform: scale(0.7);
  animation: hero-burst 900ms cubic-bezier(0.18, 1, 0.22, 1) both;
  animation-delay: 240ms;
  pointer-events: none;
  z-index: -1;
  filter: blur(0.2px);
}

@keyframes hero-pop {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.88);
    filter: blur(9px);
  }
  58% {
    opacity: 1;
    transform: translateY(0) scale(1.035);
    filter: blur(0px);
  }
  78% {
    opacity: 1;
    transform: translateY(0) scale(0.995);
    filter: blur(0px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

@keyframes hero-burst {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  40% {
    opacity: 0.55;
    transform: scale(1.25);
  }
  100% {
    opacity: 0;
    transform: scale(1.55);
  }
}

header .highlight {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(0, 191, 230, 0.28);
}

@media (prefers-reduced-motion: reduce) {
  header h1.hero-title .hero-word,
  header h1.hero-title .hero-word-2.highlight::before {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}

header .header-contact {
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header .header-contact a {
  color: rgba(226, 232, 240, 0.78);
  text-decoration: none;
  transition: color 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

header .header-contact a:hover {
  color: var(--accent);
}

/* Main Content */
main {
  flex: 1;
  max-width: 1200px;
  margin: 2rem auto;
  width: 100%;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-1);
  padding: 2rem;
}

/* Section Styles */
section {
  margin-bottom: 2rem;
}

.info {
  background: linear-gradient(
    135deg,
    rgba(0, 191, 230, 0.09) 0%,
    rgba(0, 191, 230, 0.03) 70%,
    rgba(15, 23, 42, 0.02) 100%
  );
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 191, 230, 0.16);
  border-left: 4px solid var(--accent);
}

.info h2 {
  margin-top: 0;
  color: var(--navy-2);
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

#server-info {
  line-height: 1.8;
  color: var(--text);
}

#user-ip {
  line-height: 1.8;
  color: var(--text);
}

#server-info strong {
  color: #1a2332;
  font-weight: 600;
}

/* Key/Value rows for homepage info blocks */
.kv-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.kv-row {
  display: grid;
  grid-template-columns: 1.25rem minmax(160px, 230px) 1fr;
  gap: 0.6rem;
  align-items: start;
}

.kv-row i {
  color: var(--primary-1);
  margin-top: 0.2rem;
}

.kv-key {
  font-weight: 700;
  color: var(--navy-2);
}

.kv-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
}

/* Info Grid Layout */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  align-items: stretch;
}

.info-grid > .info {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Tools Section */
.tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.tools h2 {
  grid-column: 1 / -1;
  color: var(--navy-2);
  font-size: 1.5rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.8rem;
  margin: 0 0 1.5rem 0;
}

/* Tool Menu */
.tool-menu {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  margin: 0 auto 1.5rem auto;
  border-bottom: 2px solid rgba(15, 23, 42, 0.1);
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  row-gap: 0.25rem;
  padding: 0 0.25rem 0.6rem;
}

.tool-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.8rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', 'Helvetica Neue', sans-serif;
  flex: 0 0 auto;
  white-space: nowrap;
}

.tool-tab:hover {
  color: var(--navy-2);
  background: rgba(0, 191, 230, 0.06);
}

.tool-tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent);
}

/* Download Test Buttons */
.download-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-top: 1rem;
}

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, var(--primary-1) 0%, var(--primary-2) 100%);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', 'Helvetica Neue', sans-serif;
}

.btn-download:hover {
  background: linear-gradient(135deg, var(--primary-2) 0%, #063a74 100%);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(11, 99, 198, 0.28);
}

/* Speedtest Buttons */
.speedtest-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
  margin-top: 1rem;
}

.btn-speedtest {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.2rem;
  background: rgba(11, 99, 198, 0.06);
  color: var(--primary-1);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  border: 2px solid rgba(11, 99, 198, 0.32);
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', 'Helvetica Neue', sans-serif;
}

.btn-speedtest:hover {
  background: var(--primary-1);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(11, 99, 198, 0.25);
}

.btn-speedtest.primary {
  background: linear-gradient(135deg, var(--primary-1) 0%, var(--primary-2) 100%);
  color: #fff;
  border-color: transparent;
}

.btn-speedtest.primary:hover {
  background: linear-gradient(135deg, var(--primary-2) 0%, #063a74 100%);
  color: #fff;
}

/* Tool Item */
.tool-item {
  background: var(--surface-2);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  grid-column: 1 / -1;
  display: none;
}

.tool-item.active {
  display: block;
}

.tool-item:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 191, 230, 0.38);
}

/* Avoid double borders/backgrounds when an .info section is inside a tool panel */
.tool-item .info {
  background: transparent;
  border: none;
  border-left: none;
  padding: 0;
}

.tool-item .info h2 {
  margin-bottom: 0.9rem;
}

.tool-item label {
  display: block;
  font-weight: 600;
  color: var(--navy-2);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.tool-item form {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.captcha-wrap {
  flex-basis: 100%;
  width: 100%;
  display: grid;
  /* Keep question close to label, and make input span full width */
  grid-template-columns: auto auto 1fr auto;
  grid-template-areas:
    "label question . refresh"
    "input input input refresh";
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px dashed rgba(0, 191, 230, 0.32);
  background: rgba(0, 191, 230, 0.06);
}

.captcha-label {
  font-weight: 800;
  color: var(--navy-2);
  grid-area: label;
}

.captcha-question {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  color: var(--text);
  font-weight: 800;
  grid-area: question;
  white-space: nowrap;
  justify-self: start;
}

.captcha-input {
  grid-area: input;
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
}

.captcha-input:focus {
  outline: none;
  border-color: rgba(0, 191, 230, 0.65);
  box-shadow: 0 0 0 4px rgba(0, 191, 230, 0.14);
}

.captcha-refresh {
  grid-area: refresh;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 191, 230, 0.35);
  background: rgba(0, 191, 230, 0.12);
  color: var(--accent-2);
  cursor: pointer;
  justify-self: end;
}

.captcha-refresh:hover {
  background: rgba(0, 191, 230, 0.18);
}

/* IPv4 Calculator */
.ipcalc-output {
  margin-top: 1rem;
}

.ipcalc-output.hidden {
  display: none;
}

.ipcalc-error {
  display: none;
  margin-bottom: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.06);
  color: #991b1b;
  font-weight: 700;
}

.ipcalc-error.active {
  display: block;
}

.ipcalc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.10);
}

.ipcalc-table th,
.ipcalc-table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  vertical-align: top;
}

.ipcalc-table tr:last-child th,
.ipcalc-table tr:last-child td {
  border-bottom: none;
}

.ipcalc-table th {
  width: 38%;
  text-align: left;
  font-weight: 800;
  color: var(--navy-2);
  background: rgba(15, 23, 42, 0.02);
}

.ipcalc-table td {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ipcalc-reset {
  padding: 0.7rem 1.1rem;
  background: rgba(15, 23, 42, 0.06);
  color: var(--navy-2);
  border: 1px solid rgba(15, 23, 42, 0.14);
}

.ipcalc-reset:hover {
  background: rgba(15, 23, 42, 0.10);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.10);
}

/* IP Calculator version selector */
.ipcalc-version {
  flex: 0 0 140px;
  min-width: 140px;
}

.ipcalc-input {
  flex: 1 1 320px;
  min-width: 260px;
}

/* Netplan Generator */
.netplan-form [hidden] {
  display: none !important;
}

#netplan-tool input[type="text"],
#netplan-tool input[type="number"],
#netplan-tool select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  /* Override global `.tool-item input/select { flex: 1; }` which makes inputs look too tall in columns */
  flex: 0 0 auto;
}

.netplan-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.netplan-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.netplan-check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  color: var(--navy-2);
  margin-top: 0.2rem;
}

.netplan-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.netplan-actions {
  width: 100%;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.netplan-help {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: -0.2rem;
}

.netplan-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-weight: 800;
  color: var(--navy-2);
}

@media (max-width: 720px) {
  .netplan-grid {
    grid-template-columns: 1fr;
  }
}

/* MikroTik Burst Limit Generator */
.burst-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.burst-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  box-shadow: 0 6px 14px rgba(2, 6, 23, 0.04);
}

.burst-card-title {
  font-weight: 900;
  color: var(--navy-2);
  margin-bottom: 0.55rem;
}

.burst-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* Make burst inputs/selects fill cards (avoid tiny default widths) */
.burst-grid input,
.burst-grid select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.burst-output {
  margin-top: 1rem;
}

.burst-output.hidden {
  display: none;
}

.burst-error {
  display: none;
  margin-bottom: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.06);
  color: #991b1b;
  font-weight: 800;
}

.burst-error.active {
  display: block;
}

.burst-error.warning {
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.10);
  color: #92400e;
}

.burst-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.burst-code {
  background: #0b1220;
  color: #d1fae5;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.burst-result {
  background: linear-gradient(135deg, rgba(11, 99, 198, 0.18) 0%, rgba(0, 191, 230, 0.10) 100%);
  border: 1px solid rgba(0, 191, 230, 0.25);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.75rem;
}

.burst-result-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  color: var(--navy-2);
  margin-bottom: 0.75rem;
}

.burst-result-line {
  background: rgba(2, 6, 23, 0.82);
  color: #d1fae5;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 4px solid rgba(34, 197, 94, 0.9);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  margin: 0;
  white-space: pre-wrap;
}

.burst-copy {
  margin-top: 0.8rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.16);
  color: #14532d;
  cursor: pointer;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.burst-copy:hover {
  background: rgba(34, 197, 94, 0.22);
  transform: translateY(-1px);
}

.burst-explain {
  background: rgba(11, 99, 198, 0.10);
  border: 1px solid rgba(11, 99, 198, 0.18);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.9rem;
}

.burst-explain-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  color: #0b4aa0;
  margin-bottom: 0.75rem;
}

.burst-explain-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.burst-explain-row:first-of-type {
  border-top: none;
}

.burst-explain-row .k {
  color: var(--navy-2);
  font-weight: 900;
}

.burst-explain-row .v {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  overflow-wrap: anywhere;
}

.burst-emoji {
  font-size: 1.05rem;
}

.burst-reset {
  padding: 0.7rem 1.1rem;
  background: rgba(15, 23, 42, 0.06);
  color: var(--navy-2);
  border: 1px solid rgba(15, 23, 42, 0.14);
}

.burst-reset:hover {
  background: rgba(15, 23, 42, 0.10);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.10);
}

.tool-item input[type="text"],
.tool-item input[type="number"],
.tool-item select {
  flex: 1;
  min-width: 200px;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 6px;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  background: #ffffff;
  color: var(--text);
}

.tool-item input[type="text"]:focus,
.tool-item input[type="number"]:focus,
.tool-item select:focus {
  outline: none;
  border-color: rgba(0, 191, 230, 0.65);
  box-shadow: 0 0 0 4px rgba(0, 191, 230, 0.14);
  background: #ffffff;
}

/* PON Calculator */
#pon-tool .pon-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  align-items: stretch;
}

#pon-tool [hidden] {
  display: none !important;
}

#pon-tool .pon-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  color: var(--navy-2);
  margin-bottom: 0.2rem;
}

#pon-tool input,
#pon-tool select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#pon-tool .pon-help {
  margin-top: -0.3rem;
  color: var(--muted);
  font-size: 0.9rem;
}

#pon-tool .pon-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

#pon-tool .pon-reset {
  background: rgba(15, 23, 42, 0.06);
  color: var(--navy-2);
  border: 1px solid rgba(15, 23, 42, 0.14);
}

#pon-tool .pon-reset:hover {
  background: rgba(15, 23, 42, 0.10);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.10);
}

.tool-item button {
  padding: 0.7rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-2) 0%, #006a8a 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 0.95rem;
  white-space: nowrap;
}

.tool-item button:hover {
  background: linear-gradient(135deg, #006a8a 0%, #004c63 100%);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 139, 184, 0.25);
}

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

.result-label {
  display: block;
  font-weight: 600;
  color: #1a2332;
  margin: 1rem 0 0.5rem 0;
  font-size: 0.9rem;
}

/* Result Container */
.result-container {
  margin-top: 1rem;
  transition: all 0.3s ease;
  width: 100%;
  overflow: hidden;
}

.result-container.hidden {
  display: none;
}

.result-container.active {
  display: block;
}

/* Toggle Result Button */
.toggle-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-2);
  color: #fff;
  border: none;
  padding: 0.7rem 1.2rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 0.8rem;
  font-family: -apple-system, BlinkMacSystemFont, 'San Francisco', 'Segoe UI', 'Helvetica Neue', sans-serif;
}

.toggle-result:hover {
  background: #006a8a;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 139, 184, 0.25);
}

.toggle-result i {
  font-size: 0.7rem;
  transition: transform 0.3s ease;
}

.toggle-result.collapsed i {
  transform: rotate(-90deg);
}

/* Terminal Output */
pre {
  background: #1e1e1e;
  color: #00ff00;
  padding: 1.2rem;
  border-radius: 6px;
  min-height: 80px;
  max-height: 300px;
  overflow: auto;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  word-wrap: break-word;
  border: 1px solid #333;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

pre::-webkit-scrollbar {
  width: 8px;
}

pre::-webkit-scrollbar-track {
  background: #2d2d2d;
}

pre::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
  background: #777;
}

/* IP & UserAgent Table */
.ipua-alert {
  background: rgba(0, 191, 230, 0.08);
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  color: var(--accent-2);
  border: 1px solid rgba(0, 191, 230, 0.22);
}

.ipua-table-container {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 191, 230, 0.22);
  border-radius: 10px;
  padding: 0.65rem;
}

.ipua-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.ipua-item {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  box-shadow: 0 6px 14px rgba(2, 6, 23, 0.04);
}

/* Items outside the grid (User Agent, Your IP & Useragent) need explicit spacing */
.ipua-table-container > .ipua-item {
  margin-top: 0.6rem;
}

.ipua-item.ipua-item-wide {
  grid-column: 1 / -1;
}

.ipua-item-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--navy-2);
  font-weight: 800;
}

.ipua-item-head i {
  width: 1.25rem;
  text-align: center;
  color: var(--primary-1);
}

.ipua-item-label {
  font-size: 0.92rem;
}

.ipua-item-value {
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ipua-item-value.ipua-item-value-small {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* legacy .ipua-details styles removed (no longer using <details>) */

.ipua-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.ipua-table tr:nth-child(even) {
  background: rgba(0, 191, 230, 0.04);
}

.ipua-table th,
.ipua-table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  vertical-align: top;
}

.ipua-table tr:last-child th,
.ipua-table tr:last-child td {
  border-bottom: none;
}

.ipua-table th.ipua-label {
  width: 38%;
  min-width: 220px;
  text-align: left;
  font-weight: 700;
  color: var(--navy-2);
  background: rgba(26, 35, 50, 0.02);
}

.ipua-table th.ipua-label i {
  width: 1.25rem;
  text-align: center;
  margin-right: 0.55rem;
  color: var(--primary-1);
}

.ipua-table td.ipua-value {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
}

.ipua-table td.ipua-value-ua {
  font-size: 0.85rem;
}

.ipua-refresh {
  margin-top: 0.7rem;
  padding: 0.65rem 1.1rem;
  background: linear-gradient(135deg, var(--primary-1) 0%, var(--primary-2) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.ipua-refresh:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(25, 118, 210, 0.22);
  filter: brightness(1.02);
}

.ipua-refresh:active {
  transform: translateY(0);
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--navy-1) 0%, var(--navy-2) 100%);
  color: rgba(226, 232, 240, 0.78);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer p {
  margin: 0;
  font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  header {
    padding: 1rem 1rem 1.2rem 1rem;
  }

  header h1 {
    font-size: 1.8rem;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
  }

  header .header-contact {
    font-size: 0.75rem;
    gap: 0.3rem;
    margin-bottom: 0.8rem;
  }

  header .header-contact a {
    gap: 0.2rem;
  }

  main {
    margin: 1.5rem 1rem;
    padding: 1.5rem 1rem;
    border-radius: 8px;
  }

  .info-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .info {
    padding: 1.2rem;
    margin-bottom: 1.5rem;
  }

  .info h2 {
    font-size: 1.2rem;
  }

  .kv-row {
    grid-template-columns: 1.25rem 1fr;
  }

  .kv-row .kv-val {
    grid-column: 2;
  }

  .tools h2 {
    font-size: 1.3rem;
  }

  .tool-menu {
    gap: 0.3rem;
    margin: 0 0 1.2rem 0;
  }

  .tool-tab {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    gap: 0.4rem;
  }

  .tool-item {
    padding: 1.2rem;
  }

  .tool-item label {
    font-size: 0.9rem;
  }

  .tool-item form {
    flex-direction: column;
    gap: 0.6rem;
  }

  .tool-item input[type="text"],
  .tool-item input[type="number"],
  .tool-item select,
  .tool-item button {
    width: 100%;
  }

  .tool-item input[type="text"],
  .tool-item input[type="number"],
  .tool-item select {
    padding: 0.8rem;
    font-size: 16px;
  }

  .tool-item button {
    padding: 0.8rem;
    font-size: 1rem;
  }

  .download-buttons {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
  }

  .btn-download {
    padding: 0.7rem 0.8rem;
    font-size: 0.85rem;
  }

  .speedtest-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .btn-speedtest {
    padding: 0.8rem 1rem;
    font-size: 0.8rem;
  }

  pre {
    font-size: 0.85rem;
    padding: 1rem;
    max-height: 250px;
    word-break: break-word;
    overflow-x: auto;
  }

  .ipua-table th.ipua-label {
    width: auto;
    min-width: 0;
    display: block;
    border-bottom: none;
    padding-bottom: 0.25rem;
    background: transparent;
  }

  .ipua-table td.ipua-value {
    display: block;
    padding-top: 0;
  }

  .ipua-grid {
    grid-template-columns: 1fr;
  }

  .ipcalc-table th {
    width: auto;
    display: block;
    border-bottom: none;
    padding-bottom: 0.25rem;
    background: transparent;
  }

  .ipcalc-table td {
    display: block;
    padding-top: 0;
  }
}

@media (max-width: 600px) {
  body {
    background: var(--bg);
  }

  header {
    padding: 1.5rem 1rem;
  }

  header h1 {
    font-size: 1.5rem;
    font-weight: 600;
  }

  header .header-contact {
    font-size: 0.7rem;
    margin-bottom: 0.8rem;
    gap: 0.4rem;
  }

  header .header-contact a {
    gap: 0.2rem;
  }

  main {
    margin: 1rem;
    padding: 1.2rem;
    border-radius: 8px;
    max-width: calc(100% - 2rem);
  }

  section {
    margin-bottom: 1.5rem;
  }

  .info {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 6px;
  }

  .info h2 {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
  }

  #server-info {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  #user-ip {
    font-size: 0.9rem;
  }

  .tools {
    gap: 1.2rem;
  }

  .tools h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }

  .info-grid {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }

  .download-buttons {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .btn-download {
    padding: 0.6rem 0.6rem;
    font-size: 0.8rem;
  }

  .speedtest-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .btn-speedtest {
    padding: 0.7rem 0.9rem;
    font-size: 0.75rem;
    gap: 0.3rem;
  }
  /* Tool tabs: wrap + centered (prevents awkward single overflow row) */
  .tool-menu {
    display: flex !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    justify-content: center;
    gap: 0.4rem;
    margin: 0 0 1rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid rgba(15, 23, 42, 0.1);
  }

  .tool-tab {
    flex: 0 0 auto !important;
    width: auto !important;
    justify-content: center;
    white-space: nowrap;
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
    gap: 0.35rem;
    margin-bottom: 0;
  }

  /* Captcha: 2-row layout so it doesn't squeeze */
  .captcha-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "label question refresh"
      "input input refresh";
    align-items: center;
    gap: 0.55rem;
  }

  .captcha-label {
    grid-area: label;
    justify-self: start;
  }

  .captcha-question {
    grid-area: question;
    min-width: 0;
    justify-self: start;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .captcha-input {
    grid-area: input;
    width: 100%;
    min-width: 0;
    justify-self: stretch;
  }

  .captcha-refresh {
    grid-area: refresh;
    height: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: end;
  }


  .tool-item {
    padding: 1rem;
    border-radius: 6px;
  }

  .tool-item label {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
  }

  .tool-item form {
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
    align-items: stretch;
  }

  .burst-grid {
    grid-template-columns: 1fr;
  }

  .burst-2col {
    grid-template-columns: 1fr;
  }

  .burst-explain-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .tool-item input[type="text"],
  .tool-item input[type="number"],
  .tool-item select {
    width: 100%;
    padding: 0.8rem;
    font-size: 16px;
    border-radius: 4px;
  }

  .tool-item button {
    width: 100%;
    padding: 0.9rem;
    font-size: 0.95rem;
    border-radius: 4px;
  }

  .toggle-result {
    width: 100%;
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
  }

  .result-label {
    font-size: 0.85rem;
    margin: 0.8rem 0 0.4rem 0;
  }

  pre {
    font-size: 0.8rem;
    padding: 0.8rem;
    min-height: 100px;
    max-height: 200px;
    border-radius: 4px;
    line-height: 1.4;
    word-break: break-word;
    overflow-x: auto;
  }

  footer {
    padding: 1rem;
  }

  footer p {
    font-size: 0.8rem;
  }
}

@media (max-width: 400px) {
  header {
    padding: 0.8rem 0.5rem;
  }

  header h1 {
    font-size: 1.2rem;
    margin-top: 0.5rem;
  }

  header .header-contact {
    font-size: 0.6rem;
    gap: 0.15rem;
    margin-bottom: 0.5rem;
  }

  header .header-contact a {
    gap: 0.1rem;
  }

  main {
    margin: 0.5rem;
    padding: 0.8rem;
    max-width: calc(100% - 1rem);
  }

  .info {
    padding: 0.8rem;
    margin-bottom: 1rem;
    border-left-width: 3px;
  }

  .info h2 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
  }

  .info-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  #user-ip {
    font-size: 0.8rem;
  }

  #user-ip > div {
    margin: 0.4rem 0;
  }

  .tools h2 {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .download-buttons {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .btn-download {
    padding: 0.5rem 0.6rem;
    font-size: 0.7rem;
  }

  .speedtest-buttons {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .btn-speedtest {
    padding: 0.6rem 0.8rem;
    font-size: 0.7rem;
    gap: 0.2rem;
  }

  .tool-menu {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
    justify-content: center;
    gap: 0.4rem;
    margin: 0 0 0.8rem 0;
    padding-bottom: 0.35rem;
  }

  .tool-tab {
    flex: 0 0 auto;
    padding: 0.5rem 0.8rem;
    font-size: 0.75rem;
    gap: 0.2rem;
    justify-content: center;
    white-space: nowrap;
  }

  .tool-tab i {
    font-size: 0.7rem;
  }


  .tool-item {
    padding: 0.8rem;
    margin-bottom: 1rem;
    max-width: 100%;
    overflow: hidden;
  }

  .tool-item label {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
  }

  .tool-item input[type="text"],
  .tool-item input[type="number"],
  .tool-item select {
    padding: 0.6rem;
    font-size: 16px;
    margin-bottom: 0.5rem;
  }

  .tool-item button {
    padding: 0.7rem;
    font-size: 0.85rem;
  }

  .toggle-result {
    width: 100%;
    font-size: 0.75rem;
    padding: 0.6rem 0.8rem;
    gap: 0.4rem;
  }

  .result-label {
    font-size: 0.75rem;
    margin: 0.6rem 0 0.3rem 0;
  }

  pre {
    font-size: 0.7rem;
    padding: 0.8rem;
    min-height: 80px;
    max-height: 180px;
    line-height: 1.35;
    word-break: break-word;
    overflow-x: auto;
    border-radius: 4px;
  }

  footer {
    padding: 0.8rem 0.5rem;
  }

  footer p {
    font-size: 0.7rem;
  }
}
