:root {
  --bg: #070b16;
  --card: #141c33;
  --card-2: #1a2440;
  --line: #243052;
  --text: #eef2ff;
  --muted: #8f9bbd;
  --accent: #6c8cff;
  --up: #3ddc97;
  --down: #ff6b6b;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(900px 520px at 12% -12%, #1b2a5c 0%, var(--bg) 58%) no-repeat,
    var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  overscroll-behavior-y: contain;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* --------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  border-bottom: 1px solid rgba(36, 48, 82, 0.6);
  background: rgba(9, 14, 27, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 5;
}

.brand {
  flex: 1;
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

h1 span {
  color: var(--accent);
}

.sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--card-2);
}

.icon-btn.spin .glyph {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------------------------------------------------------------- view */

.view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(86px + env(safe-area-inset-bottom));
}

.view:has(.frame-wrap) {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

.strip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin: 2px 2px 14px;
}

.strip .ago {
  margin-left: auto;
  font-size: 12px;
  color: #6b7697;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4a5573;
  flex: none;
}

.dot.up {
  background: var(--up);
  box-shadow: 0 0 8px rgba(61, 220, 151, 0.6);
}

.dot.down {
  background: var(--down);
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.55);
}

.grid {
  display: grid;
  gap: 11px;
}

.card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  position: relative;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(158deg, var(--card-2), var(--card));
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.card:active {
  transform: scale(0.985);
  border-color: var(--accent);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
  background: linear-gradient(140deg, hsl(var(--hue) 78% 58%), hsl(calc(var(--hue) + 32) 76% 45%));
  box-shadow: 0 8px 18px -10px hsl(var(--hue) 80% 55%);
}

.card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 26px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.desc {
  margin-top: 5px;
  font-size: 13px;
  color: #a7b2d0;
  line-height: 1.4;
}

.card-open {
  position: absolute;
  top: 10px;
  right: 8px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
}

.card-open:active {
  background: rgba(108, 140, 255, 0.18);
  color: var(--text);
}

.foot {
  margin: 18px 4px 0;
  font-size: 12px;
  color: #6b7697;
  text-align: center;
  line-height: 1.5;
}

/* -------------------------------------------------------------- service */

.svc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 2px 12px;
}

.svc-meta {
  min-width: 0;
  flex: 1;
}

.svc-meta h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.open-link {
  flex: none;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.open-link:active {
  background: var(--card-2);
}

.frame-wrap {
  position: relative;
  flex: 1;
  min-height: 60vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b1020;
}

.frame {
  width: 100%;
  height: 100%;
  min-height: 60vh;
  border: 0;
  background: #0b1020;
}

.frame-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  background: #0b1020;
  text-align: center;
  padding: 20px;
  transition: opacity 0.25s ease;
}

.frame-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(108, 140, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hint {
  margin: 12px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.hint a {
  color: var(--accent);
  text-decoration: none;
}

/* --------------------------------------------------------------- panels */

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 20px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(165deg, var(--card-2), var(--card));
  text-align: center;
}

.panel-icon {
  font-size: 30px;
  line-height: 1;
}

.panel h2 {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 650;
}

.panel p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 34ch;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 320px;
  min-height: 48px;
  padding: 12px 18px;
  margin-top: 6px;
  border-radius: 13px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(140deg, #7d99ff, #4f6cf5);
  color: #fff;
  box-shadow: 0 10px 24px -14px #6c8cff;
}

.btn.primary:active {
  filter: brightness(0.94);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:active {
  background: var(--card-2);
}

.alert {
  margin: 0 0 12px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 12px;
  background: rgba(255, 107, 107, 0.1);
  color: #ffc9c9;
  font-size: 13px;
}

/* ------------------------------------------------------------- skeleton */

.skeleton {
  height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(100deg, #131b30 30%, #1b2541 50%, #131b30 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 130% 0;
  }
  to {
    background-position: -30% 0;
  }
}

/* --------------------------------------------------------------- tabbar */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(36, 48, 82, 0.7);
  background: linear-gradient(to top, rgba(7, 11, 22, 0.98), rgba(7, 11, 22, 0.84));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 52px;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab .glyph {
  font-size: 17px;
  line-height: 1;
}

.tab:active {
  background: var(--card-2);
}

.tab[disabled] {
  opacity: 0.36;
  cursor: default;
}

@media (min-width: 700px) {
  .view {
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
  }

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

  .tabbar {
    max-width: 760px;
    margin: 0 auto;
    border-left: 1px solid rgba(36, 48, 82, 0.7);
    border-right: 1px solid rgba(36, 48, 82, 0.7);
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
