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

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: #0f172a;
  background-color: #020617;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #0f172a, #020617 55%);
  color: #e5e7eb;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #facc15;
  color: #111827;
  border-radius: 999px;
  text-decoration: none;
  z-index: 20;
}

.skip-link:focus {
  left: 0.5rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  max-width: 1120px;
  margin: 0 auto;
}


.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.6);
  background: rgba(15,23,42,0.9);
  text-decoration: none;
  font-size: 0.85rem;
  color: #e5e7eb;
  white-space: nowrap;
}

.back-link:hover,
.back-link:focus-visible {
  background: rgba(15,23,42,1);
  border-color: #f97316;
}

.back-icon {
  font-size: 1rem;
  line-height: 1;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: #9ca3af;
}

.main-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
}

.main-nav a {
  color: #e5e7eb;
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 2px solid #39ff14; /* toxic green outline */
  box-shadow: 0 0 8px rgba(57, 255, 20, 0.6);
}

.main-nav a:hover,
.main-nav a:focus-visible {
  border-color: #b4ff5c; /* brighter green on hover/focus */
  background-color: rgba(15,23,42,.9);
  box-shadow: 0 0 12px rgba(57, 255, 20, 0.9);
}

.page-main {
  max-width: 1120px;
  margin: 0 auto 3rem auto;
  padding: 0 1.5rem 2rem;
}

.hero {
  margin: 1rem 0 1.5rem 0;
}

.hero h1 {
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  margin-bottom: 0.4rem;
}

.hero p {
  max-width: 48rem;
  color: #d1d5db;
}

.hero-note {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #9ca3af;
}

.card {
  background: radial-gradient(circle at top, rgba(148,163,184,0.08), rgba(15,23,42,0.95));
  border-radius: 1.25rem;
  padding: 1.5rem 1.25rem 1.75rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(148,163,184,0.2);
  box-shadow: 0 18px 45px rgba(15,23,42,0.8);
}

.card-header h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.25rem;
}

.card-header p {
  margin: 0 0 0.75rem 0;
  color: #9ca3af;
  font-size: 0.95rem;
}

.card-body {
  margin-top: 0.75rem;
}

.grid-2 {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
  }
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-inline {
  flex-direction: column;
}

.field label {
  font-size: 0.8rem;
  color: #d1d5db;
}

.field input,
.field select {
  border-radius: 0.6rem;
  border: 1px solid #4b5563;
  padding: 0.4rem 0.55rem;
  background: rgba(15,23,42,0.9);
  color: #e5e7eb;
  font-size: 0.9rem;
}

.field input::placeholder {
  color: #6b7280;
}

.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid #f97316;
  outline-offset: 1px;
  border-color: #f97316;
}

.field-group {
  border-radius: 0.9rem;
  border: 1px solid rgba(75,85,99,0.6);
  padding: 0.75rem 0.9rem 0.9rem;
}

.field-group legend {
  font-size: 0.85rem;
  color: #e5e7eb;
  padding: 0 0.25rem;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 60ms ease;
}

.btn-primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #022c22;
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(34,197,94,0.25);
}

.btn-secondary {
  background: rgba(15,23,42,0.85);
  border-color: #4b5563;
  color: #e5e7eb;
}

.btn-secondary:hover {
  background: rgba(15,23,42,1);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #9ca3af;
}

.btn-ghost:hover {
  border-color: #4b5563;
  background: rgba(15,23,42,0.75);
}

.results h3 {
  margin-top: 0;
  margin-bottom: 0.45rem;
  font-size: 1.05rem;
}

.steps {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0;
  font-size: 0.9rem;
  color: #e5e7eb;
}

.steps li {
  margin-bottom: 0.25rem;
}

.result-box {
  min-height: 3.2rem;
  border-radius: 0.9rem;
  border: 1px dashed rgba(148,163,184,0.6);
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  color: #e5e7eb;
  background: rgba(15,23,42,0.85);
  white-space: pre-line;
}

.hint {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

.hint summary {
  cursor: pointer;
}

.routes-list,
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.route-row,
.rule-row {
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: center;
}

.route-row input,
.rule-row input,
.rule-row select {
  width: 100%;
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border-radius: 0.5rem;
  border: 1px solid #4b5563;
  background: rgba(15,23,42,0.9);
  color: #e5e7eb;
}

.route-row label,
.rule-row label {
  display: none;
}

.route-row button,
.rule-row button {
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.6);
  background: transparent;
  color: #9ca3af;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}

.route-row button:hover,
.rule-row button:hover {
  background: rgba(31,41,55,0.9);
}

.page-footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem 1.75rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.page-footer a {
  color: #e5e7eb;
}

@media (max-width: 640px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .route-row,
  .rule-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 0.4rem;
  }
}


/* Extra spacing before primary action buttons inside fieldsets,
   so they don't stick to the last input row */
.field-group > .btn-primary {
  margin-top: 0.75rem;
}


/* Highlight error/stop conditions in packet path steps */
.steps li.step-error {
  color: #f97316;
  font-weight: 600;
}


/* Unified mobile-friendly layout across languages */

/* allow nav pills to wrap instead of causing horizontal scroll */
.main-nav {
  flex-wrap: wrap;
}

/* long "Back to NetLab..." labels should wrap too */
.back-link {
  white-space: normal;
}

/* guard rails: keep content inside viewport on very small screens */
@media (max-width: 640px) {
  html, body {
    overflow-x: hidden;
  }
  .page-main {
    width: 100%;
    max-width: 1120px;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}


/* Additional guard so cards & forms never overflow on narrow screens */
@media (max-width: 640px) {
  .page-main {
    max-width: 100%;
    margin: 0 auto;
  }
  .card {
    max-width: 100%;
  }
  .form,
  .field,
  .field input,
  .field select,
  .btn-primary {
    width: 100%;
  }
}
