:root {
  --bg: #030308;
  --surface: rgba(11, 13, 24, 0.84);
  --surface-strong: rgba(14, 17, 31, 0.94);
  --border: rgba(160, 185, 255, 0.14);
  --border-strong: rgba(180, 210, 255, 0.28);
  --text: #eef1fa;
  --text-muted: #8b93ad;
  --text-dim: #5e667e;
  --accent: #90d5ff;
  --accent-violet: #c59bff;
  --accent-glow: rgba(144, 213, 255, 0.35);
  --danger: #ff7a8a;
  --success: #6ee7b7;
  --warning: #fcd34d;
  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse 75% 60% at 50% 42%, rgba(28, 34, 72, 0.28) 0%, rgba(10, 10, 22, 0.14) 48%, rgba(3, 3, 8, 1) 100%),
    #030308;
}

/* --- Canvas FX Layers --- */
.fx-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fx-layer--back {
  z-index: 1;
}

.fx-layer--front {
  z-index: 15;
}

/* --- Hero Stage --- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4.5rem 1.5rem 2.5rem;
}

.hero-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 960px;
  width: 100%;
  text-align: center;
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3rem, 11.5vw, 7.8rem);
  letter-spacing: 0.12em;
  line-height: 1.05;
  color: #f3f5fc;
  text-shadow:
    0 0 28px rgba(155, 190, 255, 0.14),
    0 0 70px rgba(120, 110, 255, 0.08);
  user-select: none;
}

.links-nav {
  margin-top: 2.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 2.2rem;
  justify-content: center;
  align-items: center;
  padding: 0 1rem;
}

.service-link {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  color: #848ba0;
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.35rem 0.2rem;
  transition: color 0.22s ease, text-shadow 0.22s ease, transform 0.22s ease;
}

.service-link::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(160, 220, 255, 0.75), rgba(197, 155, 255, 0.75), transparent);
  opacity: 0;
  transform: scaleX(0.35);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.service-link:hover,
.service-link:focus-visible,
.service-link.is-hovered {
  color: #ffffff;
  text-shadow: 0 0 14px rgba(160, 220, 255, 0.55);
  outline: none;
}

.service-link:hover::after,
.service-link:focus-visible::after,
.service-link.is-hovered::after {
  opacity: 1;
  transform: scaleX(1);
}

.service-link__sub {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: none;
  color: var(--text-dim);
  transition: color 0.22s ease;
}

.service-link:hover .service-link__sub,
.service-link.is-hovered .service-link__sub {
  color: rgba(195, 220, 255, 0.82);
}

.empty-state {
  margin-top: 2.2rem;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  max-width: 440px;
  line-height: 1.6;
}

.svg-defs {
  position: fixed;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* --- Magnifying Optical Bubble Portal --- */
.lens-portal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 0.22s ease;
  box-shadow:
    inset 0 0 10px rgba(160, 210, 255, 0.05),
    0 0 16px rgba(120, 175, 255, 0.04);
  background: transparent;
}

.lens-portal.is-visible {
  opacity: 1;
}

.lens-distort-layer {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
  filter: url(#spherical-lens-filter);
  will-change: filter;
}

.stage--magnified {
  position: absolute;
  inset: auto;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
}

.stage--magnified .brand-title {
  color: #ff2e3d;
  text-shadow:
    0 0 16px rgba(255, 38, 56, 0.45),
    0 0 34px rgba(200, 16, 36, 0.28);
}

.stage--magnified .service-link {
  color: #ff3e4e;
  text-shadow:
    0 0 10px rgba(255, 42, 60, 0.35);
}

.stage--magnified .service-link::after {
  background: linear-gradient(90deg, transparent, rgba(255, 72, 88, 0.85), rgba(255, 130, 140, 0.85), transparent);
}

.stage--magnified .service-link__sub {
  color: rgba(255, 118, 130, 0.88);
}

.stage--magnified .service-link.is-hovered {
  color: #ff6270;
  text-shadow:
    0 0 14px rgba(255, 45, 65, 0.72),
    0 0 28px rgba(255, 28, 48, 0.42);
}

.stage--magnified .empty-state {
  color: rgba(255, 96, 110, 0.9);
}

.lens-glass-sheen {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.015) 20%, transparent 45%),
    radial-gradient(circle at 50% 50%, transparent 78%, rgba(8, 12, 30, 0.08) 100%);
}

/* --- Top-Right Minimal HUD --- */
.hud {
  position: fixed;
  top: 1.15rem;
  right: 1.25rem;
  z-index: 30;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hud-pill,
.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  height: 2rem;
  padding: 0 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(9, 11, 20, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.hud-btn {
  cursor: pointer;
}

.hud-btn:hover,
.hud-btn:focus-visible {
  color: #ffffff;
  border-color: var(--border-strong);
  background: rgba(20, 25, 45, 0.8);
  outline: none;
}

.hud-btn--icon {
  padding: 0;
  width: 2rem;
  justify-content: center;
  font-size: 0.9rem;
}

.hud-btn--icon[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(144, 213, 255, 0.34);
  text-shadow: 0 0 10px rgba(144, 213, 255, 0.6);
}

.hud-btn--accent {
  color: #dff4ff;
  border-color: rgba(144, 213, 255, 0.36);
  background: rgba(34, 52, 92, 0.45);
}

.hud-btn--accent:hover {
  border-color: rgba(144, 213, 255, 0.7);
  box-shadow: 0 0 16px rgba(144, 213, 255, 0.22);
}

.hud-pill--preview {
  cursor: pointer;
  color: var(--warning);
  border-color: rgba(252, 211, 77, 0.38);
  background: rgba(66, 48, 12, 0.55);
}

.hud-pill--preview:hover {
  border-color: rgba(252, 211, 77, 0.75);
  color: #fff6d6;
}

.status-dot {
  width: 0.44rem;
  height: 0.44rem;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 8px currentColor;
}

.hud-pill--network[data-net="local"] .status-dot {
  background: var(--success);
  color: var(--success);
}

.hud-pill--network[data-net="tailscale"] .status-dot {
  background: var(--warning);
  color: var(--warning);
}

.hud-pill--network[data-net="external"] .status-dot {
  background: var(--accent-violet);
  color: var(--accent-violet);
}

/* --- Modals & Drawers --- */
.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 3, 10, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-backdrop[hidden],
.drawer-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 410px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75), 0 0 40px rgba(110, 150, 255, 0.12);
  padding: 1.5rem;
}

.modal-header,
.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-title,
.drawer-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  color: #f6f8ff;
}

.modal-subtitle,
.drawer-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.icon-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-close:hover {
  color: #fff;
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

.icon-close--sm {
  width: 1.65rem;
  height: 1.65rem;
  font-size: 1rem;
}

/* --- Drawer --- */
.drawer-backdrop {
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: min(520px, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface-strong);
  border-left: 1px solid var(--border-strong);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.72);
}

.drawer-header {
  padding: 1.35rem 1.4rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1.4rem 2.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.panel-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(18, 22, 40, 0.56);
  padding: 1rem;
}

.panel-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-kicker {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.muted-note {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.preview-block {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
  background: rgba(5, 7, 15, 0.65);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.22rem;
}

.seg-btn {
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.42rem 0.25rem;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.seg-btn:hover {
  color: #fff;
}

.seg-btn.is-active {
  background: rgba(144, 213, 255, 0.18);
  color: #eaf6ff;
  box-shadow: inset 0 0 0 1px rgba(144, 213, 255, 0.34);
}

/* --- Forms --- */
.form-stack {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.link-form {
  margin-bottom: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  border-color: rgba(144, 213, 255, 0.28);
  background: rgba(20, 26, 48, 0.72);
}

.link-form[hidden] {
  display: none;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

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

.field[hidden] {
  display: none;
}

.field-label {
  font-size: 0.74rem;
  font-weight: 500;
  color: #b7c0d8;
  letter-spacing: 0.04em;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(5, 7, 14, 0.8);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  padding: 0.56rem 0.72rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(144, 213, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(144, 213, 255, 0.12);
}

.field-hint {
  font-size: 0.73rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.checkbox-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-top: 0.15rem;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: #c7d0e6;
  cursor: pointer;
}

.check-label input {
  accent-color: var(--accent);
}

.form-error {
  margin: 0;
  font-size: 0.8rem;
  color: var(--danger);
  line-height: 1.4;
}

.form-error.is-success {
  color: var(--success);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

/* --- Buttons --- */
.btn {
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.btn--sm {
  font-size: 0.75rem;
  padding: 0.42rem 0.78rem;
}

.btn--primary {
  background: linear-gradient(135deg, rgba(112, 186, 255, 0.28), rgba(168, 128, 255, 0.28));
  border-color: rgba(154, 212, 255, 0.52);
  color: #ffffff;
}

.btn--primary:hover {
  background: linear-gradient(135deg, rgba(112, 186, 255, 0.4), rgba(168, 128, 255, 0.4));
  border-color: rgba(176, 224, 255, 0.82);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
  color: #c5cde2;
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: var(--border-strong);
}

/* --- Managed Links List --- */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-heading {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #dbe3f7;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.count-pill {
  font-size: 0.72rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(144, 213, 255, 0.14);
  color: var(--accent);
}

.admin-links-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.admin-link-card {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(14, 18, 34, 0.64);
  padding: 0.78rem 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: border-color 0.16s ease, opacity 0.16s ease;
}

.admin-link-card:hover {
  border-color: var(--border-strong);
}

.admin-link-card.is-disabled {
  opacity: 0.52;
}

.admin-link-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
}

.admin-link-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f3f6ff;
}

.admin-link-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.14rem;
}

.admin-link-target {
  font-size: 0.73rem;
  color: #8f9bb8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

.admin-link-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(160, 185, 255, 0.08);
}

.action-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.mini-btn {
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: #b7c2dc;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  padding: 0.25rem 0.52rem;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.mini-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  border-color: var(--border-strong);
}

.mini-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.mini-btn--danger:hover:not(:disabled) {
  color: #ffd0d6;
  border-color: rgba(255, 122, 138, 0.55);
  background: rgba(255, 122, 138, 0.16);
}

/* --- Visibility Badges --- */
.vis-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.vis-badge--public {
  color: #a7f3d0;
  border-color: rgba(110, 231, 183, 0.34);
  background: rgba(16, 85, 62, 0.32);
}

.vis-badge--local {
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.34);
  background: rgba(30, 58, 138, 0.32);
}

.vis-badge--local_or_auth {
  color: #bae6fd;
  border-color: rgba(144, 213, 255, 0.38);
  background: rgba(24, 65, 96, 0.36);
}

.vis-badge--auth {
  color: #e9d5ff;
  border-color: rgba(197, 155, 255, 0.38);
  background: rgba(76, 29, 149, 0.32);
}

.vis-badge--external {
  color: #fde68a;
  border-color: rgba(252, 211, 77, 0.38);
  background: rgba(113, 63, 18, 0.34);
}

/* --- Security Details --- */
.security-details {
  padding: 0.85rem 1rem;
}

.security-summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b7c2dc;
  list-style: none;
}

.security-summary::-webkit-details-marker {
  display: none;
}

.security-form {
  margin-top: 0.9rem;
}

/* --- Toast Notifications --- */
.toast-region {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.58rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(13, 17, 32, 0.92);
  backdrop-filter: blur(12px);
  color: #eef4ff;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.22s ease;
}

.toast--error {
  border-color: rgba(255, 122, 138, 0.5);
  color: #ffd5da;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive --- */
@media (max-width: 560px) {
  .hud {
    top: 0.8rem;
    right: 0.8rem;
    left: 0.8rem;
  }

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

  .segmented {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lens-portal,
  .fx-layer--front {
    display: none !important;
  }
}
