/* ============================================================
   MIHOMO BUILDER — BASE
   ============================================================ */

:root {
  --mihomo-border: rgba(229, 231, 235, 0.92);
  --mihomo-border-soft: rgba(229, 231, 235, 0.72);
  --mihomo-bg-card: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.95) 100%);
  --mihomo-bg-soft: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.92) 100%);
  --mihomo-text: #111827;
  --mihomo-text-soft: #6b7280;
  --mihomo-blue: #3b82f6;
  --mihomo-blue-soft: rgba(63, 167, 255, 0.12);
  --mihomo-shadow: 0 14px 36px rgba(17, 24, 39, 0.08);

  --mihomo-navbar-offset: 132px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: var(--mihomo-navbar-offset);
  scrollbar-gutter: stable;
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.05), transparent 34%),
    linear-gradient(180deg, #f8fafc 0%, #f3f6fa 100%);
  background-attachment: fixed;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.05), transparent 34%),
    linear-gradient(180deg, #f8fafc 0%, #f3f6fa 100%);
  background-attachment: fixed;
  color: var(--mihomo-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-flex;
}

.mihomo-page {
  padding-top: 105px;
  padding-bottom: 2rem;
  min-height: 100vh;
  background: transparent;
}

.mihomo-container {
  width: min(100%, 1520px);
  margin: 0 auto;
  padding: 0 1rem;
}

.mihomo-hero {
  margin-bottom: 1rem;
}

.mihomo-grid {
  display: grid;
  grid-template-columns: minmax(380px, 720px) minmax(420px, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.mihomo-left-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mihomo-disabled-card {
  opacity: 0.58;
  pointer-events: none;
  filter: grayscale(0.08);
}

/* ============================================================
   CARD SYSTEM
   ============================================================ */

.card.shadow {
  border: 1px solid var(--mihomo-border);
  border-radius: 24px;
  overflow: visible;
  background: var(--mihomo-bg-card);
  box-shadow: var(--mihomo-shadow) !important;
}

.card.shadow > .card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--mihomo-border);
  background: transparent;
}

.card.shadow > .card-body {
  padding: 18px 22px 20px;
}

.connections-head-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.connections-head-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mihomo-blue-soft);
  color: var(--mihomo-blue);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.connections-head-icon i,
.connections-head-icon .material-icons {
  font-size: 1.45rem;
  line-height: 1;
}

.connections-head-text {
  min-width: 0;
  text-align: left;
}

.card.shadow > .card-header .connections-head-text h6 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--mihomo-text);
}

.connections-head-subtitle {
  margin-top: 3px;
  color: var(--mihomo-text-soft);
  font-size: 0.88rem;
  line-height: 1.45;
}

.connections-head-subtitle code,
.info-banner code {
  font-family: inherit;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  padding: 0.08rem 0.38rem;
}

/* ============================================================
   HERO TOOLTIP
   ============================================================ */

.mihomo-hero-title-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  position: relative;
}

.mihomo-hero-tooltip {
  position: relative;
  flex: 0 0 auto;
  z-index: 20;
}

.mihomo-hero-tooltip__summary {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.mihomo-hero-tooltip__summary::-webkit-details-marker {
  display: none;
}

.mihomo-hero-tooltip__summary:hover,
.mihomo-hero-tooltip__summary:focus,
.mihomo-hero-tooltip[open] .mihomo-hero-tooltip__summary {
  background: rgba(37, 99, 235, 0.16);
  color: #1d4ed8;
  transform: translateY(-1px);
}

.mihomo-hero-tooltip__summary i {
  font-size: 0.78rem;
  line-height: 1;
}

.mihomo-hero-tooltip__panel {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 100;
  width: min(380px, calc(100vw - 32px));
  padding: 0.76rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(31, 41, 55, 0.18);
  background: rgba(17, 24, 39, 0.97);
  color: #f9fafb;
  font-size: 0.82rem;
  line-height: 1.5;
  font-weight: 500;
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.22);
}

.mihomo-hero-tooltip__panel::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 14px;
  width: 12px;
  height: 12px;
  background: rgba(17, 24, 39, 0.97);
  transform: rotate(45deg);
  border-left: 1px solid rgba(31, 41, 55, 0.18);
  border-top: 1px solid rgba(31, 41, 55, 0.18);
}

/* ============================================================
   INFO BANNERS
   ============================================================ */

.info-banner {
  --banner-accent: #60a5fa;
  --banner-bg: rgba(59, 130, 246, 0.07);
  --banner-text: #243447;

  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--banner-bg), rgba(59, 130, 246, 0.03));
  color: var(--banner-text);
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  font-weight: 500;
  margin-bottom: 10px;
}

.info-banner i.fa-solid {
  color: var(--banner-accent);
  font-size: 1.05rem;
  margin-top: 0.1rem;
  flex-shrink: 0;
}

.info-banner strong {
  font-weight: 700;
  color: inherit;
}

.info-banner--success {
  --banner-accent: #22c55e;
  --banner-bg: rgba(34, 197, 94, 0.08);
  --banner-text: #184b31;
  border-color: rgba(34, 197, 94, 0.22);
}

.info-banner--danger {
  --banner-accent: #ef4444;
  --banner-bg: rgba(239, 68, 68, 0.07);
  --banner-text: #6b2020;
  border-color: rgba(239, 68, 68, 0.2);
}

/* ============================================================
   COMMON META
   ============================================================ */

.mihomo-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid var(--mihomo-border);
  font-size: 0.82rem;
  padding: 0.28rem 0.62rem;
  line-height: 1.1;
  white-space: nowrap;
  color: #374151;
  font-weight: 600;
}

.meta-pill i {
  font-size: 0.8rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1200px) {
  .mihomo-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 1199.98px) {
  :root {
    --mihomo-navbar-offset: 128px;
  }
}

@media (max-width: 991.98px) {
  :root {
    --mihomo-navbar-offset: 124px;
  }

  .card.shadow > .card-header {
    padding: 16px 18px 12px;
  }

  .card.shadow > .card-body {
    padding: 16px 18px 18px;
  }
}

@media (max-width: 767.98px) {
  :root {
    --mihomo-navbar-offset: 118px;
  }
}

@media (max-width: 576px) {
  :root {
    --mihomo-navbar-offset: 112px;
  }

  .mihomo-page {
    padding-top: 92px;
  }

  .mihomo-container {
    padding: 0 0.8rem;
  }

  .card.shadow {
    border-radius: 20px;
  }

  .card.shadow > .card-header {
    padding: 15px 16px 12px;
  }

  .card.shadow > .card-body {
    padding: 14px 16px 16px;
  }

  .connections-head-main {
    align-items: flex-start;
    gap: 12px;
  }

  .connections-head-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .connections-head-subtitle {
    font-size: 0.84rem;
  }

  .mihomo-hero-title-row {
    align-items: flex-start;
  }

  .mihomo-hero-tooltip__panel {
    left: auto;
    right: 0;
    width: min(320px, calc(100vw - 32px));
  }

  .mihomo-hero-tooltip__panel::before {
    left: auto;
    right: 16px;
  }

  .info-banner {
    flex-direction: column;
    gap: 10px;
    padding: 0.85rem 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card.shadow,
  .info-banner,
  .mihomo-hero-tooltip__summary {
    transition: none !important;
  }
}