/* ==========================================================================
   小胖联机 · 我的实例（instances.html）
   设计语言与首页 / 商城 / 个人中心一致（Night Arcade：墨黑底 + 极光 + 酸性青柠）。
   结构参考同类平台 / 土豆的实例卡片：封面 + 状态 + 联机地址 + 规格 + 资源占用。
   全部使用 base.css 的语义变量，浅色主题自动跟随。
   ========================================================================== */

/* ---------------------------------------------------------------- 头部 */
.p-inst-hero {
  position: relative;
  padding-top: calc(var(--header-h) + clamp(26px, 4.6vw, 56px));
  padding-bottom: clamp(18px, 3vw, 32px);
  overflow: clip;
}

.p-inst-hero::before {
  content: "";
  position: absolute;
  inset: -22% -10% auto;
  height: 440px;
  background: var(--grad-aurora);
  pointer-events: none;
  z-index: -1;
}

.p-inst-hero-in {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(20px, 4vw, 48px);
  flex-wrap: wrap;
}

.p-inst-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  font-size: var(--fs-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.p-inst-kicker i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 12px var(--brand);
}

.p-inst-title {
  margin: 0 0 14px;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.14;
  letter-spacing: -0.02em;
}

.p-inst-lead {
  margin: 0;
  max-width: 58ch;
  color: var(--text-dim);
  line-height: 1.75;
}

.p-inst-hero-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.p-inst-count {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--ring);
}

.p-inst-count strong {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--brand-text);
}

.p-inst-count span {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

/* ---------------------------------------------------------------- 主体 */
.p-inst-body {
  padding-bottom: clamp(56px, 8vw, 104px);
}

.p-inst-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.p-inst-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.p-inst-chip {
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--fs-sm);
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

.p-inst-chip:hover {
  color: var(--text);
  background: var(--surface-2);
}

.p-inst-chip.is-on {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  border-color: color-mix(in srgb, var(--brand) 46%, transparent);
  color: var(--text);
}

.p-inst-chip b {
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.p-inst-chip.is-on b { color: var(--brand-text); }

.p-inst-refresh {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--fs-sm);
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all var(--t-fast);
}

.p-inst-refresh:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.p-inst-refresh svg { width: 14px; height: 14px; }
.p-inst-refresh.is-busy svg { animation: pi-spin 900ms linear infinite; }

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

/* ---------------------------------------------------------------- 卡片网格 */
.p-inst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: clamp(14px, 1.6vw, 20px);
}

.pi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--t-base), border-color var(--t-base), box-shadow var(--t-base);
}

.pi-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  box-shadow: var(--shadow-md), 0 0 0 1px color-mix(in srgb, var(--brand) 16%, transparent) inset;
}

.pi-card.is-dead { border-color: color-mix(in srgb, var(--rose) 34%, var(--line)); }
.pi-card.is-dead:hover { border-color: color-mix(in srgb, var(--rose) 52%, var(--line)); }

/* 封面 */
.pi-cover {
  position: relative;
  display: block;
  height: 152px;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, #10151f, #0a0e14);
}

.pi-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
  filter: saturate(1.06);
  transition: transform 500ms var(--t-base), opacity 220ms var(--t-fast);
}

.pi-card:hover .pi-cover img {
  transform: scale(1.05);
  opacity: 0.82;
}

.pi-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 7, 12, 0.1) 0%, rgba(5, 7, 12, 0.42) 48%, rgba(5, 7, 12, 0.94) 100%);
}

.pi-cover-top {
  position: absolute;
  inset: 11px 12px auto 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.pi-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, #05070c 62%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pi-tag svg { width: 11px; height: 11px; flex: 0 0 11px; }

.pi-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: color-mix(in srgb, #05070c 64%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
}

.pi-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pi-status[data-s="running"] { color: #10b981; }
.pi-status[data-s="starting"],
.pi-status[data-s="stopping"],
.pi-status[data-s="installing"] { color: var(--amber); }
.pi-status[data-s="expired"] { color: var(--rose); }

.pi-status[data-s="running"] i {
  box-shadow: 0 0 0 0 currentColor;
  animation: pi-live 2.2s infinite;
}

@keyframes pi-live {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.pi-cover-title {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  z-index: 2;
}

.pi-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}

.pi-cover-meta {
  margin: 5px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.72);
}

.pi-cover-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 卡片主体 */
.pi-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  flex: 1;
}

.pi-addr {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--bg-soft) 70%, transparent);
}

.pi-addr-k {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

.pi-addr code {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pi-copy {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--t-fast);
}

.pi-copy:hover {
  color: var(--brand-text);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}

.pi-copy svg { width: 13px; height: 13px; }
.pi-copy.is-ok { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); }

/* 四项信息 */
.pi-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pi-fact {
  padding: 8px 10px;
  border-radius: var(--r-xs);
  background: color-mix(in srgb, #fff 2.4%, transparent);
  border: 1px solid var(--line-soft);
  min-width: 0;
}

.pi-fact-k {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.pi-fact-v {
  display: block;
  margin-top: 3px;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  /* 到期这类「日期 + 剩余天数」允许折成两行，别把关键信息截掉 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.pi-fact-v.is-warn { color: var(--amber); }
.pi-fact-v.is-dead { color: var(--rose); }
.pi-fact-v.is-ok { color: var(--brand-text); }

/* 资源占用 */
.pi-rings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 2px;
}

.pi-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
}

.pi-ring-svg { position: relative; width: 54px; height: 54px; }
.pi-ring-svg svg { width: 54px; height: 54px; transform: rotate(-90deg); }
.pi-ring-svg .track { fill: none; stroke: var(--line); stroke-width: 3.6; }

.pi-ring-svg .bar {
  fill: none;
  stroke: var(--brand);
  stroke-width: 3.6;
  stroke-linecap: round;
  transition: stroke-dasharray 420ms ease;
}

/* CPU 青柠 / 内存 水青 / 在线 天蓝 —— 和站点的三色体系对齐 */
.pi-ring[data-kind="mem"] .bar { stroke: var(--aqua); }
.pi-ring[data-kind="online"] .bar { stroke: var(--azure); }
.pi-ring[data-kind="disk"] .bar { stroke: var(--amber, #f5b73d); }

.pi-ring[data-tone="warn"] .bar { stroke: var(--amber); }
.pi-ring[data-tone="dead"] .bar { stroke: var(--rose); }

.pi-ring-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.pi-ring-k {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.pi-ring-v {
  font-size: 0.68rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

/* 过期提示 */
.pi-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--r-xs);
  border: 1px solid color-mix(in srgb, var(--rose) 36%, transparent);
  background: color-mix(in srgb, var(--rose) 10%, transparent);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: color-mix(in srgb, var(--rose) 82%, #fff);
}

.pi-alert-ico {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: color-mix(in srgb, var(--rose) 24%, transparent);
}

/* 底部 */
.pi-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.pi-foot .pi-node {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
  font-size: var(--fs-xs);
  color: var(--brand-text);
}

.pi-enter {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: var(--r-full);
  background: var(--brand);
  color: var(--brand-ink) !important;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  transition: filter var(--t-fast), box-shadow var(--t-fast);
}

.pi-enter:hover {
  filter: brightness(1.06);
  box-shadow: var(--shadow-glow);
}

.pi-enter svg { width: 13px; height: 13px; }

.pi-card.is-dead .pi-enter {
  background: color-mix(in srgb, var(--rose) 88%, #fff);
  color: #1a0d10 !important;
}

.pi-card.is-dead .pi-enter:hover { box-shadow: 0 18px 44px -24px rgba(255, 122, 138, 0.55); }

/* ---------------------------------------------------------------- 骨架 / 空态 */
.pi-skel {
  height: 372px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background:
    linear-gradient(100deg, transparent 20%, color-mix(in srgb, #fff 5%, transparent) 40%, transparent 60%)
      0 0 / 220% 100%,
    var(--surface);
  animation: pi-shimmer 1.5s infinite linear;
}

@keyframes pi-shimmer {
  to { background-position: -120% 0, 0 0; }
}

.pi-state {
  padding: 44px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: var(--fs-sm);
}

.pi-blank {
  max-width: 520px;
  margin: 34px auto 0;
  padding: clamp(26px, 4vw, 40px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.pi-blank svg { color: var(--brand-text); opacity: 0.75; }

.pi-blank h2 {
  margin: 0;
  font-size: clamp(1.16rem, 2.4vw, 1.42rem);
  letter-spacing: -0.01em;
}

.pi-blank p {
  margin: 0;
  max-width: 44ch;
  font-size: var(--fs-sm);
  line-height: 1.75;
  color: var(--text-dim);
}

.pi-blank-acts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

.pi-btn {
  height: 40px;
  padding: 0 20px;
  border-radius: var(--r-full);
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: filter var(--t-fast), box-shadow var(--t-fast);
}

.pi-btn:hover { filter: brightness(1.06); box-shadow: var(--shadow-glow); }

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

.pi-btn--ghost:hover {
  filter: none;
  box-shadow: none;
  background: var(--surface-2);
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 900px) {
  .p-inst-hero { padding-top: calc(var(--header-h) + 22px); }
  .p-inst-hero-in { align-items: flex-start; }
  .p-inst-hero-side { width: 100%; }
  .p-inst-count { flex: 1; justify-content: center; }
  .p-inst-grid { grid-template-columns: 1fr; gap: 14px; }
  .pi-cover { height: 138px; }
}

@media (max-width: 360px) {
  .pi-facts { grid-template-columns: 1fr; }
  .pi-rings { gap: 4px; }
}

/* 窄屏：筛选条竖排，避免四个胶囊挤在一行被裁掉 */
@media (max-width: 640px) {
  .p-inst-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .p-inst-chips {
    min-width: 0;
    gap: 6px;
  }
  .p-inst-refresh {
    align-self: flex-start;
  }
}

/* ══ 内存超限（OOM）提示 ═══════════════════════════════════════ */
.p-inst-alert {
  display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 14px 16px; border-radius: 12px;
  background: color-mix(in srgb, #f0a020 12%, transparent);
  border: 1px solid color-mix(in srgb, #f0a020 34%, transparent);
}
.p-inst-alert-body { flex: 1; min-width: 220px; }
.p-inst-alert-body strong { display: block; font-size: 14px; margin-bottom: 4px; }
.p-inst-alert-body p { margin: 0; font-size: 13px; line-height: 1.6; opacity: .82; }
.p-inst-alert .btn { flex: none; }
