:root {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #151a22;
  --surface-strong: #1d2430;
  --line: #2a3442;
  --text: #eef2f7;
  --muted: #9ba7b7;
  --subtle: #6f7b8b;
  --accent: #39d98a;
  --accent-strong: #13b86f;
  --signal: #5cc8ff;
  --warning: #ffc857;
  --danger: #ff6b6b;
  --terminal: #06090d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(57, 217, 138, 0.07), transparent 36rem),
    radial-gradient(circle at top right, rgba(78, 139, 255, 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
}

.network-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.17;
  background-image:
    linear-gradient(rgba(92, 200, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 200, 255, 0.18) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.hero-copy {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  width: 53px;
  height: 48px;
  flex: none;
  display: block;
  object-fit: contain;
}

.hero-heading {
  min-width: 0;
}

.hero-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.home-link {
  color: var(--signal);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.home-link:hover {
  color: var(--text);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 680px;
  font-size: 48px;
  font-family: Bahnschrift, "DIN Alternate", "Avenir Next Condensed", sans-serif;
  line-height: 0.98;
  text-transform: uppercase;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.status-panel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 184px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 34, 0.72);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(57, 217, 138, 0.12);
}

.status-panel.is-checking .status-dot {
  background: var(--signal);
  box-shadow: 0 0 0 6px rgba(92, 200, 255, 0.12);
  animation: status-pulse 1.2s ease-in-out infinite;
}

.status-panel.is-degraded .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(255, 200, 87, 0.12);
}

.status-panel.is-offline .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.12);
}

@keyframes status-pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

.node-overview {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.node-card {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 15, 21, 0.84);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.24);
}

.node-primary {
  overflow: hidden;
  margin: 2px 0 0;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 21px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.address-list > div {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
}

.address-list dt,
.connection-label {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.address-list dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visitor-card {
  display: flex;
  flex-direction: column;
}

.visitor-ip {
  align-self: flex-start;
  max-width: 100%;
  margin-top: 12px;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--signal);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visitor-ip:disabled {
  color: var(--subtle);
  cursor: default;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
  align-self: stretch;
}

.control-panel,
.download-panel,
.result-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 34, 0.9);
  box-shadow: var(--shadow);
}

.control-panel {
  flex: 1;
  padding: 18px;
}

.download-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  margin-top: auto;
  padding: 18px;
}

.field,
.setting {
  display: grid;
  gap: 8px;
}

label,
.setting span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0f15;
  color: var(--text);
  outline: none;
  padding: 0 12px;
}

input:focus {
  border-color: rgba(57, 217, 138, 0.82);
  box-shadow: 0 0 0 3px rgba(57, 217, 138, 0.12);
}

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 18px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0f15;
}

.tool-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tool-tab.active {
  background: var(--surface-strong);
  color: var(--text);
}

.tool-tab:disabled {
  cursor: not-allowed;
  opacity: 0.35;
  text-decoration: line-through;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#hops-setting,
#speedtest-setting {
  grid-column: 1 / -1;
}

.download-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.download-option {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0f15;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.download-option:hover {
  border-color: var(--accent);
  color: var(--text);
}

.is-hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 6, 10, 0.72);
}

.modal {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.modal-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin-top: 20px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.ghost-button,
.text-button {
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.primary-button:active,
.ghost-button:active,
.text-button:active {
  transform: translateY(1px);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  background: var(--accent);
  color: #04100a;
}

.primary-button:hover {
  background: #54e59c;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.primary-button.is-cancel {
  border-color: rgba(255, 107, 107, 0.7);
  background: rgba(255, 107, 107, 0.12);
  color: #ffd9d9;
}

.primary-button.is-cancel:hover {
  background: rgba(255, 107, 107, 0.22);
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-icon {
  font-size: 12px;
}

.ghost-button {
  min-height: 44px;
  padding: 0 14px;
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--accent);
}

.compact {
  min-height: 36px;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.text-button:hover {
  color: var(--text);
}

.result-panel {
  min-width: 0;
  overflow: hidden;
}

.result-header,
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.terminal {
  min-height: 420px;
  max-height: 560px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  background: var(--terminal);
  color: #d8ffe8;
  font:
    13px/1.6 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal.error {
  color: #ffd9d9;
}

.history-panel {
  margin-top: 18px;
  overflow: hidden;
}

.history-list {
  display: grid;
  gap: 8px;
  padding: 14px 18px 18px;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151d;
  color: var(--muted);
  text-align: left;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    transform 120ms ease;
}

.history-item:hover {
  border-color: rgba(92, 200, 255, 0.58);
  background: #141b25;
  transform: translateY(-1px);
}

.history-item.is-selected {
  border-color: var(--signal);
  background: rgba(92, 200, 255, 0.08);
  box-shadow: inset 3px 0 0 var(--signal);
}

.history-item:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.history-tool {
  color: var(--accent);
  font-weight: 900;
  text-transform: uppercase;
}

.history-target {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time,
.empty-history {
  color: var(--subtle);
  font-size: 12px;
}

.history-item.has-output .history-time {
  color: #8bcff0;
}

.empty-history {
  margin: 0;
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 680px);
    padding: 22px 0;
  }

  .hero,
  .workspace {
    display: grid;
  }

  .node-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .visitor-card {
    grid-column: 1 / -1;
  }

  .hero-actions {
    justify-items: stretch;
  }

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

  .control-stack {
    min-height: auto;
  }

  .status-panel {
    width: 100%;
  }

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

  .terminal {
    min-height: 340px;
  }

  h1 {
    font-size: 34px;
  }
}

@media (max-width: 520px) {
  .brand-logo {
    width: 44px;
    height: 40px;
  }

  .tool-tabs,
  .actions,
  .download-options,
  .modal-actions,
  .history-item {
    grid-template-columns: 1fr;
  }

  .node-overview {
    grid-template-columns: 1fr;
  }

  .visitor-card {
    grid-column: auto;
  }

  .result-header,
  .history-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .ghost-button.compact {
    width: 100%;
  }
}
