:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #111113;
  --text-muted: #666872;
  --border: #e6e6ea;
  --shadow: 0 6px 16px rgba(0,0,0,0.06);
  --radius: 14px;

  --badge-bg: #f0f0f2;
  --badge-text: #111113;

  --tag-bg: #f2f3f5;
  --tag-text: #3a3c42;

  --input-bg: #ffffff;
  --input-border: #e6e6ea;
  --input-text: #111113;
}



/* base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1100px;
  padding: 24px 20px;
  margin: 0 auto;
}

/* header */
.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.title-wrap { display: grid; gap: 4px; }
.app-title {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.2px;
}
.subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* radar status indicator */
.radar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #23c55e; /* 绿色核心点 */
  position: relative;
  box-shadow: 0 0 0 2px rgba(35, 197, 94, 0.24), 0 0 10px rgba(35, 197, 94, 0.55);
}
.radar::before, .radar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(35, 197, 94, 0.35);
  animation: radar-pulse 2s ease-out infinite;
}
.radar::after { animation-delay: 1s; }

/* down: 红色告警 */
.radar.down { background: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.24), 0 0 10px rgba(239, 68, 68, 0.55); }
.radar.down::before, .radar.down::after { border-color: rgba(239, 68, 68, 0.38); }
@keyframes radar-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  70% { transform: scale(2.3); opacity: 0; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin: 16px 0 8px;
  flex-wrap: wrap;
}
.search, .select {
  appearance: none;
  outline: none;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--input-text);
  padding: 10px 12px;
  min-height: 40px;
  font-size: 16px; /* 防止 iOS 输入时自动放大 */
}
.search { flex: 1 1 260px; }
.select { flex: 0 0 160px; }

/* states */
.state { padding: 24px 0; }
.state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  margin: 8px 0;
}
.state-title { font-weight: 600; }
.state-desc { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* grid and cards */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}
.card {
  grid-column: span 12;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
@media (min-width: 640px) { .card { grid-column: span 6; } }
@media (min-width: 980px) { .card { grid-column: span 4; } }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-title {
  font-size: 16px;
  margin: 0;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}
.card-head .card-title { margin-left: 6px; flex: 1; }

.card-desc {
  color: var(--text-muted);
  margin: 8px 0 10px;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Microsoft YaHei Mono", monospace;
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
  line-height: 1.4;
}
.link { color: inherit; text-decoration: underline; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  line-height: 0;
}
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn:hover { filter: brightness(0.98); }
.icon { font-size: 13px; }



/* footer */
.footer {
  display: flex; align-items: center; justify-content: center;
  padding-top: 8px; padding-bottom: 40px;
}
.muted { color: var(--text-muted); font-size: 12px; }

/* skeleton */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}
.skeleton-card {
  grid-column: span 12;
  height: 140px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--bg) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: shimmer 1.4s ease-in-out infinite;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) { .skeleton-card { grid-column: span 6; } }
@media (min-width: 980px) { .skeleton-card { grid-column: span 4; } }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}



/* buttons */
.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { filter: brightness(0.98); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 120; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.25); }
.modal-dialog { position: absolute; top: 10vh; left: 50%; transform: translateX(-50%); width: 720px; max-width: calc(100vw - 40px); }
.modal-body { padding: 12px; }
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.form-item { display: grid; gap: 6px; }
.form-col-2 { grid-column: span 2; }
.form-label { color: var(--text-muted); font-size: 12px; }

/* 展开/详情/统计样式 */
.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.stat .label { color: var(--text-muted); font-size: 12px; }
.stat .value { font-weight: 700; font-variant-numeric: tabular-nums; }

.expand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  margin-top: 10px;
}
.expand .chev { transition: transform .2s ease; }
.expand.open .chev { transform: rotate(90deg); }

.details {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.detail-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: start;
  padding: 4px 0;
}
.detail-key { color: var(--text-muted); font-size: 12px; }
.detail-val { font-size: 13px; word-break: break-all; }
.params {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.params table { width: 100%; border-collapse: collapse; font-size: 12px; }
.params th, .params td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.params th { color: var(--text-muted); font-weight: 600; background: var(--surface); }
.params tr:last-child td { border-bottom: none; }

/* 参数说明列：长英文/URL自动换行 */
.params td.desc-col {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
/* 参数说明内的链接：颜色同正文，仅显示下划线 */
.params td.desc-col a {
  color: inherit;
  text-decoration: underline;
}

/* Toast */
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 99;
  font-size: 13px;
}

/* Floating Nav (FAB) */
.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
}
.fab-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,0.88);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08), 0 1px 0 rgba(0,0,0,0.02);
  cursor: pointer;
  -webkit-backdrop-filter: saturate(1.1) blur(6px);
  backdrop-filter: saturate(1.1) blur(6px);
  transition: transform .22s ease, box-shadow .22s ease, background-color .2s ease, border-color .2s ease;
  will-change: transform;
  position: relative;
  outline: none;
}
.fab-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(0,0,0,0.10), 0 1px 0 rgba(0,0,0,0.03); }
.fab-btn:active { transform: translateY(-1px) scale(0.98); }
.fab-btn:focus-visible { box-shadow: 0 0 0 3px rgba(138,180,255,.25), 0 10px 24px rgba(0,0,0,0.08); border-color: #cdd8ff; }
.fab-btn.open { background: #fff; border-color: #e1e2e6; }
.fab-btn svg { width: 22px; height: 22px; transition: transform .28s ease; }
.fab-btn.open svg { transform: rotate(45deg); }
/* click feedback pulse */
.fab-btn::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,0.06), rgba(0,0,0,0));
  opacity: 0; transform: scale(0.2); transition: opacity .28s ease, transform .28s ease;
  pointer-events: none;
}
.fab-btn.pressed::after { opacity: 1; transform: scale(1); }

.fab-panel-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.18);
  z-index: 110; opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.fab-panel-mask.show { opacity: 1; pointer-events: auto; }

.fab-panel {
  position: fixed; right: 20px; bottom: 88px; z-index: 121;
  width: 280px; max-width: calc(100vw - 28px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  transform: translateY(10px); opacity: 0; pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
}
.fab-panel.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.fab-list { padding: 10px; display: grid; gap: 6px; }
.fab-item {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.fab-item:hover { background: var(--bg); transform: translateY(-1px); box-shadow: var(--shadow); }
.fab-item .icon { width: 18px; height: 18px; }
.fab-item .title { font-weight: 600; font-size: 13px; }
.fab-item .desc { font-size: 12px; color: var(--text-muted); }
.fab-item .go { font-size: 12px; color: var(--text-muted); }

/* Friends page */
.link-section { display: grid; gap: 16px; }
.link-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.link-group-title { margin: 0 0 6px 0; font-size: 16px; }
.link-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.link-card {
  grid-column: span 12;
  display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center;
  padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; cursor: pointer;
}
.link-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #dcdde2; }
.link-logo { width: 36px; height: 36px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-weight: 700; }
.link-meta { display: grid; gap: 2px; }
.link-name { font-size: 14px; font-weight: 600; margin: 0; }
.link-desc { font-size: 12px; color: var(--text-muted); margin: 0; }
@media (min-width: 640px) { .link-card { grid-column: span 6; } }
@media (min-width: 980px) { .link-card { grid-column: span 4; } }

/* Params area: independent scroll and better touch usability */
.modal .params {
  max-height: 52vh;               /* 独立可滚动区域高度 */
  overflow: auto;
  overscroll-behavior: contain;   /* 阻断滚动链，避免带动窗口 */
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 480px) {
  .modal .params { max-height: 56vh; }
}
/* 增大“删除”触控区与输入框命中面积 */
.params td:last-child .btn {
  padding: 8px 12px;
  font-size: 13px;
}
.params td input.search { min-height: 42px; }

/* 进一步保证点击穿透不受遮挡 */
.modal .params, .modal .params * { pointer-events: auto; }

/* modal usability enhancements */
.modal-dialog {
  position: fixed;
  top: 4vh;
  left: 50%;
  transform: translateX(-50%);
  width: 760px;
  max-width: calc(100vw - 24px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 保持圆角与阴影 */
}
@media (max-width: 480px) {
  .modal-dialog { top: 3vh; width: 100%; max-width: calc(100vw - 16px); }
}
.modal-body {
  padding: 12px;
  overflow: auto;                 /* 内容滚动 */
  -webkit-overflow-scrolling: touch;
}
.modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}
.actions-inner {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn { padding: 10px 14px; font-size: 15px; } /* 提升触控可点性 */

/* login input interactions */
.field .search {
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.field.is-focused .search,
.search:focus {
  border-color: #8ab4ff;
  box-shadow: 0 0 0 3px rgba(138,180,255,.25);
  background: #fff;
  outline: none;
}
.field { cursor: text; }