:root {
  --bg: #0b1020;
  --bg-soft: #131a30;
  --card: #182142;
  --line: #263259;
  --text: #e8ecf7;
  --muted: #9aa6c7;
  --accent: #4f8cff;
  --accent-2: #28d39a;
  --danger: #ff5c7a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2550 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(11, 16, 32, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; font-size: 20px; letter-spacing: 0.3px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.port-input, .name-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
}
.port-input { width: 100px; }
.name-input { width: 170px; }
@media (max-width: 620px) {
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .name-input { width: 130px; }
}

.btn-primary {
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #6aa0ff);
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.container { max-width: 760px; margin: 0 auto; padding: 28px 22px 80px; }

.muted { color: var(--muted); }
.empty-hint { text-align: center; margin-top: 56px; font-size: 15px; }
code {
  background: #0e1530;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.92em;
}

/* ---- Tunnel badge ---- */
.badge {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #16203f, #131a30);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.badge:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 30px rgba(79, 140, 255, 0.18);
}
.badge-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.status-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--muted); flex: none;
}
.status-dot.online { background: var(--accent-2); box-shadow: 0 0 0 4px rgba(40,211,154,0.18); }
.status-dot.waiting { background: #f5c542; box-shadow: 0 0 0 4px rgba(245,197,66,0.18); }
.badge-titles { min-width: 0; }
.badge-name { display: block; font-weight: 700; font-size: 15px; }
.badge-url { font-weight: 600; font-size: 15px; word-break: break-all; color: var(--accent); }
.badge-name + .badge-url { font-weight: 500; font-size: 13px; }
.badge-status-text { margin-left: auto; font-size: 13px; color: var(--muted); flex: none; white-space: nowrap; }
.close-x {
  flex: none; border: 0; background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.close-x:hover { color: var(--danger); background: rgba(255,92,122,0.12); }

.badge-preview { display: flex; gap: 14px; padding: 16px 18px; }
.preview-img {
  width: 120px; height: 80px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); flex: none; background: #0e1530;
}
.preview-text { min-width: 0; }
.preview-title { font-weight: 600; margin: 0 0 4px; }
.preview-desc { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.preview-site { color: var(--accent); font-size: 12px; margin: 6px 0 0; }

/* ---- Bootstrap command box ---- */
.cmd-box {
  background: #0c1330;
  padding: 12px 16px 14px;
}
.cmd-hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.os-label { font-size: 12px; color: var(--text); margin: 10px 0 4px; font-weight: 600; }
.os-label:first-of-type { margin-top: 0; }
.cmd-sublabel { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.cmd-line {
  display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px;
}
.cmd-line:last-child { margin-bottom: 0; }
.cmd-line pre {
  margin: 0; flex: 1; overflow-x: auto;
  background: #060b1f; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; color: #cfe0ff;
}
.copy-btn {
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  border-radius: 8px; padding: 0 12px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.copy-btn:hover { border-color: var(--accent); }

.bg-details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.bg-details summary {
  cursor: pointer; font-size: 13px; color: var(--accent); list-style: none;
  -webkit-user-select: none; user-select: none;
}
.bg-details summary::before { content: "▸ "; }
.bg-details[open] summary::before { content: "▾ "; }

/* ---- Public directory ---- */
.public-area { margin-top: 40px; }
.public-title { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 0 12px; }
.public-list { display: flex; flex-direction: column; gap: 8px; }
.public-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); text-decoration: none; color: var(--text);
  transition: border-color 0.15s ease;
}
.public-item:hover { border-color: var(--accent); }
.public-img {
  width: 64px; height: 48px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); flex: none; background: #0e1530;
}
.public-dot { flex: none; }
.public-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.public-name { font-weight: 600; }
.public-desc {
  color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px;
}
.public-url { color: var(--accent); font-size: 12px; word-break: break-all; }
