/* ── 主题变量 ── */
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --ink: #172033;
  --muted: #64748b;
  --text-soft: #475569;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --error: #dc2626;

  --bg: #fafbfc;
  --bg-grad: linear-gradient(180deg, #fafbfc 0%, #eef1f5 100%);
  --top-glow: rgba(147, 180, 245, 0.4);
  --h1-grad: linear-gradient(135deg, #1e3a8a 0%, #2563eb 25%, #3b82f6 50%, #2563eb 75%, #1e3a8a 100%);

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.65);
  --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  --card-inset-hover: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  --card-shadow: 0 18px 45px rgba(71, 93, 125, 0.14);
  --card-shadow-hover: 0 26px 60px rgba(71, 93, 125, 0.18);

  --panel-bg: rgba(248, 250, 252, 0.55);
  --panel-border: rgba(148, 163, 184, 0.28);
  --card-bg: rgba(255, 255, 255, 0.55);
  --border-soft: rgba(148, 163, 184, 0.35);
  --pill-bg: rgba(255, 255, 255, 0.65);
  --field-bg: rgba(255, 255, 255, 0.6);
  --field-bg-focus: rgba(255, 255, 255, 0.85);
  --info-bg: rgba(239, 246, 255, 0.68);
  --info-border: rgba(147, 197, 253, 0.6);
  --key-new-bg: rgba(239, 246, 255, 0.7);
  --key-new-border: rgba(191, 219, 254, 0.9);
  --selected-card-bg: rgba(219, 234, 254, 0.5);

  --code-color: #1d4ed8;
  --code-bg: rgba(29, 78, 216, 0.07);
  --code-border: rgba(29, 78, 216, 0.14);
  --code-block-bg: rgba(248, 250, 252, 0.9);
  --code-block-ink: #1e3a8a;

  --btn2-bg: rgba(255, 255, 255, 0.8);
  --btn2-border: #cbd5e1;
  --btn2-ink: #334155;
  --btn2-bg-hover: #ffffff;
  --btn2-active-bg: #dbeafe;
  --btn2-active-border: #93c5fd;
  --btn2-active-ink: #1d4ed8;
  --btn2-active-bg-hover: #bfdbfe;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;
  --danger-ink: #dc2626;
  --danger-bg-hover: #fecaca;
  --hover-bg: rgba(59, 130, 246, 0.06);
  --list-border: rgba(148, 163, 184, 0.25);

  --modal-bg: rgba(255, 255, 255, 0.78);
  --modal-border: rgba(255, 255, 255, 0.75);
  --modal-ink: #475569;
  --overlay-bg: rgba(15, 23, 42, 0.35);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6ebf4;
  --muted: #94a3b8;
  --text-soft: #b6c2d4;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --error: #f87171;

  --bg: #0b0d10;
  --bg-grad: linear-gradient(180deg, #0b0d10 0%, #11151b 100%);
  --top-glow: rgba(59, 130, 246, 0.12);
  --h1-grad: linear-gradient(135deg, #60a5fa 0%, #93c5fd 25%, #bfdbfe 50%, #93c5fd 75%, #60a5fa 100%);

  --glass-bg: rgba(23, 32, 48, 0.6);
  --glass-border: rgba(148, 163, 184, 0.22);
  --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --card-inset-hover: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  --card-shadow: 0 18px 45px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 26px 60px rgba(0, 0, 0, 0.5);

  --panel-bg: rgba(15, 23, 42, 0.5);
  --panel-border: rgba(148, 163, 184, 0.22);
  --card-bg: rgba(30, 41, 59, 0.55);
  --border-soft: rgba(148, 163, 184, 0.3);
  --pill-bg: rgba(30, 41, 59, 0.65);
  --field-bg: rgba(15, 23, 42, 0.55);
  --field-bg-focus: rgba(15, 23, 42, 0.85);
  --info-bg: rgba(30, 58, 138, 0.35);
  --info-border: rgba(96, 165, 250, 0.4);
  --key-new-bg: rgba(30, 58, 138, 0.4);
  --key-new-border: rgba(96, 165, 250, 0.5);
  --selected-card-bg: rgba(37, 99, 235, 0.28);

  --code-color: #93c5fd;
  --code-bg: rgba(59, 130, 246, 0.16);
  --code-border: rgba(59, 130, 246, 0.3);
  --code-block-bg: rgba(15, 23, 42, 0.7);
  --code-block-ink: #bfdbfe;

  --btn2-bg: rgba(30, 41, 59, 0.7);
  --btn2-border: rgba(148, 163, 184, 0.35);
  --btn2-ink: #cbd5e1;
  --btn2-bg-hover: rgba(51, 65, 85, 0.8);
  --btn2-active-bg: rgba(37, 99, 235, 0.35);
  --btn2-active-border: rgba(96, 165, 250, 0.6);
  --btn2-active-ink: #bfdbfe;
  --btn2-active-bg-hover: rgba(37, 99, 235, 0.5);
  --danger-bg: rgba(220, 38, 38, 0.18);
  --danger-border: rgba(248, 113, 113, 0.4);
  --danger-ink: #fca5a5;
  --danger-bg-hover: rgba(220, 38, 38, 0.3);
  --hover-bg: rgba(96, 165, 250, 0.1);
  --list-border: rgba(148, 163, 184, 0.2);

  --modal-bg: rgba(23, 32, 48, 0.85);
  --modal-border: rgba(148, 163, 184, 0.25);
  --modal-ink: #cbd5e1;
  --overlay-bg: rgba(2, 6, 16, 0.6);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}
::selection { background: rgba(59, 130, 246, 0.25); }

/* ── 胶片颗粒质感 ── */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  opacity: 0.05;
  mix-blend-mode: overlay;
}
:root[data-theme="dark"] body::after { opacity: 0.08; }

/* ── 动态背景光斑 ── */
.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: var(--bg-grad);
  transition: background 0.3s ease;
}
/* 顶部细光带（单色雾灰方向） */
.bg::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 240px;
  background: linear-gradient(180deg, var(--top-glow), transparent);
}

main { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 72px; }
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
  animation: rise 0.7s var(--ease-out) both;
}
.app-header h1 { margin: 0; }
h1 {
  font-size: 32px; letter-spacing: -0.02em;
  background: var(--h1-grad);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: titleSheen 7s linear infinite;
}
@keyframes titleSheen { to { background-position: 200% 0; } }
.theme-toggle {
  padding: 8px 14px; font-size: 16px; line-height: 1;
  background: var(--btn2-bg);
  border: 1px solid var(--btn2-border);
}
h2 { margin: 0 0 8px; font-size: 20px; }
.subtitle { margin: 0; animation: rise 0.7s 0.08s var(--ease-out) both; }
.muted { color: var(--muted); }

/* ── 毛玻璃卡片 ── */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 22px;
  margin-top: 18px;
  box-shadow: var(--card-shadow), var(--card-inset);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  animation: rise 0.6s var(--ease-out) both;
  transition: box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.card:hover {
  box-shadow: var(--card-shadow-hover), var(--card-inset-hover);
}
#loginCard { animation-delay: 0.12s; }
.inner-card {
  margin-top: 16px; padding: 18px; border-radius: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  animation: fadeSlide 0.5s 0.12s var(--ease-out) both;
  transition: background 0.3s ease, border-color 0.3s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#keyPanel .row { margin-top: 14px; }

/* ── 输入控件 ── */
input, select {
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 11px;
  background: var(--field-bg);
  color: var(--ink);
  padding: 10px 14px;
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
input { min-width: 280px; flex: 1; }
select { flex: 1; min-width: 200px; cursor: pointer; }
input:focus, select:focus {
  border-color: #93c5fd;
  background: var(--field-bg-focus);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

/* ── 按钮（胶囊样式） ── */
button {
  position: relative; overflow: hidden;
  cursor: pointer;
  background: #1d4ed8;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #fff;
  padding: 10px 22px;
  font: inherit; font-weight: 600;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22);
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s ease, filter 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
button::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%);
  transform: translateX(-130%);
  transition: transform 0.55s ease;
}
button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
}
button:hover:not(:disabled)::after { transform: translateX(130%); }
button:active:not(:disabled) { transform: translateY(0) scale(0.96); }
button:disabled { opacity: 0.55; cursor: wait; }
button:not(.secondary):not(.danger):not(.copied):hover:not(:disabled) {
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.32);
}
button.secondary {
  background: var(--btn2-bg);
  border-color: var(--btn2-border);
  color: var(--btn2-ink);
  box-shadow: 0 2px 8px rgba(71, 93, 125, 0.1);
}
button.secondary:hover:not(:disabled) { background: var(--btn2-bg-hover); box-shadow: 0 6px 16px rgba(71, 93, 125, 0.18); }
button.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-ink);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.12);
}
button.danger:hover:not(:disabled) { background: var(--danger-bg-hover); box-shadow: 0 6px 16px rgba(220, 38, 38, 0.22); }
button.copied {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #059669;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}
button.copied:hover:not(:disabled) { background: #a7f3d0; box-shadow: 0 6px 16px rgba(5, 150, 105, 0.22); }

/* ── 点击火花（移植自 React Bits Click Spark） ── */
#actionsRow button { transform-origin: 50% 100%; }
.spark {
  position: fixed; z-index: 10000; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: currentColor; pointer-events: none;
  animation: sparkFly 0.6s var(--ease-out) forwards;
}
@keyframes sparkFly {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -24px)) scale(0.3); }
}

/* ── 消息 & 加载 ── */
.msg-line {
  min-height: 24px; margin-top: 14px;
  display: flex; align-items: center;
  font-size: 14px; color: var(--accent);
}
.msg-line.busy { color: var(--text-soft); }
.msg-line.error { color: var(--error); }
.msg-line .msg-text { animation: fadeSlide 0.3s ease both; }
.spinner {
  width: 14px; height: 14px; margin-right: 8px; flex: none;
  border: 2px solid rgba(37, 99, 235, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
.msg-line.error .spinner { border-color: rgba(220, 38, 38, 0.25); border-top-color: var(--error); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.shake { animation: shake 0.3s ease; }

/* ── 状态指示 ── */
#statusLine { margin-top: 16px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 16px; border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--border-soft);
  font-weight: 700; font-size: 13px;
  animation: fadeSlide 0.4s var(--ease-out) both;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; flex: none; }
.dot.running { background: #32d583; animation: pulseGreen 1.8s ease-out infinite; }
.dot.starting { background: #f5bf42; animation: pulseAmber 1.2s ease-out infinite; }
@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(50, 213, 131, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(50, 213, 131, 0); }
  100% { box-shadow: 0 0 0 0 rgba(50, 213, 131, 0); }
}
@keyframes pulseAmber {
  0% { box-shadow: 0 0 0 0 rgba(245, 191, 66, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(245, 191, 66, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 191, 66, 0); }
}

/* ── 启动进度 ── */
.startup-progress {
  margin-top: 16px; padding: 16px 18px; border-radius: 14px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  transition: background 0.3s ease, border-color 0.3s ease;
}
.progress-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.progress-heading strong { font-size: 14px; }
.progress-percent { color: var(--accent); font-size: 13px; font-weight: 700; }
.progress-track {
  height: 7px; margin-top: 12px; overflow: hidden; border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
}
.progress-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, #2563eb, #1d4ed8);
  transition: width 0.35s var(--ease-out);
}
.progress-steps { display: grid; gap: 9px; margin-top: 14px; }
.progress-step {
  display: grid; grid-template-columns: 20px 1fr auto; gap: 9px; align-items: center;
  color: var(--muted); font-size: 13px;
}
.progress-step .step-dot {
  position: relative;
  width: 11px; height: 11px; border-radius: 50%;
  background: #cbd5e1; border: 2px solid rgba(100, 116, 139, 0.2);
}
.progress-step.done .step-dot::after {
  content: ""; position: absolute; left: 50%; top: 42%;
  width: 3px; height: 6px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg) scale(0);
  animation: checkPop 0.35s var(--ease-spring) 0.08s forwards;
}
@keyframes checkPop { to { transform: translate(-50%, -60%) rotate(45deg) scale(1); } }
.progress-step .step-state { font-size: 12px; }
.progress-step.active { color: var(--accent-strong); font-weight: 700; }
.progress-step.active .step-dot { background: #f5bf42; border-color: #f5bf42; animation: pulseAmber 1.2s ease-out infinite; }
.progress-step.done { color: #047857; font-weight: 700; }
:root[data-theme="dark"] .progress-step.done { color: #34d399; }
.progress-step.done .step-dot { background: #10b981; border-color: #10b981; }
.progress-step.error { color: var(--error); font-weight: 700; }
.progress-step.error .step-dot { background: #ef4444; border-color: #ef4444; }

/* ── 实例卡片 ── */
.instance-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.instance-card {
  position: relative;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1.5px solid var(--border-soft);
  box-shadow: 0 2px 10px rgba(71, 93, 125, 0.06);
  cursor: pointer;
  animation: fadeSlide 0.45s var(--ease-out) both;
  transition: transform 0.15s ease-out, box-shadow 0.25s ease, border-color 0.2s ease, background 0.2s ease;
}
/* Spotlight 光晕：边框跟随鼠标（移植自 React Bits Spotlight Card） */
.instance-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), rgba(96, 165, 250, 0.75), transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0; transition: opacity 0.3s ease;
}
.instance-card:hover::before { opacity: 1; }
.instance-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(71, 93, 125, 0.14); }
.instance-card:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25); }
.instance-card.selected {
  border-color: #60a5fa;
  background: var(--selected-card-bg);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.18);
}
.instance-card.empty { cursor: default; }
.instance-card.empty:hover { transform: none; box-shadow: 0 2px 10px rgba(71, 93, 125, 0.06); }
.instance-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.instance-card-top .status-pill { padding: 4px 12px; font-size: 12px; animation: none; }
.instance-card b { display: block; margin-top: 9px; font-size: 15px; word-break: break-all; }
.instance-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

/* ── 健康状态 ── */
.health-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 14px; font-size: 13px;
}
.health-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--border-soft);
  font-weight: 700; font-size: 13px;
}
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; flex: none; }
.health-dot.ready { background: #32d583; animation: pulseGreen 1.8s ease-out infinite; }
.health-dot.starting { background: #f5bf42; animation: pulseAmber 1.2s ease-out infinite; }
.health-dot.error { background: #ef4444; }
.health-time { font-size: 12px; }

/* ── 启动事件 ── */
.startup-log {
  margin-top: 14px; padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  max-height: 170px; overflow-y: auto;
}
.startup-log-title {
  color: #64748b; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 6px;
}
.startup-log-line { display: flex; gap: 10px; padding: 2px 0; line-height: 1.55; }
.startup-log-line time { color: #64748b; flex: none; font-variant-numeric: tabular-nums; }
.startup-log-line.ok span { color: #34d399; }
.startup-log-line.error span { color: #f87171; }

/* ── 代码行 + 复制 ── */
.code-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.code-row .code-line { flex: 1; min-width: 200px; margin-bottom: 0; }
.code-row button { flex: none; }
.code-block {
  margin: 8px 0 0; padding: 12px 14px;
  border-radius: 10px;
  background: var(--code-block-bg);
  border: 1px solid var(--border-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; color: var(--code-block-ink);
  white-space: pre; overflow-x: auto;
}

/* ── 开关状态按钮 ── */
button.secondary.active {
  background: var(--btn2-active-bg);
  border-color: var(--btn2-active-border);
  color: var(--btn2-active-ink);
}
button.secondary.active:hover:not(:disabled) { background: var(--btn2-active-bg-hover); }

/* ── 空闲自动关机 ── */
.idle-shutdown-card .row { margin-top: 0; flex-wrap: wrap; }
.idle-shutdown-card input { width: 90px; min-width: 0; flex: none; }
.idle-label { font-weight: 700; font-size: 14px; }
.idle-status { margin-top: 10px; font-size: 13px; line-height: 1.6; }
.health-pill.muted { color: var(--muted); font-weight: 400; }

/* ── 指标卡 ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-top: 16px;
}
.metric {
  padding: 14px 16px; border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  box-shadow: 0 2px 10px rgba(71, 93, 125, 0.06);
  animation: fadeSlide 0.45s var(--ease-out) both;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease, background 0.3s ease;
}
.metric:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(71, 93, 125, 0.14); }
.metric b { display: block; margin-top: 5px; font-size: 15px; word-break: break-all; }

code {
  display: inline-block;
  color: var(--code-color);
  word-break: break-all;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 9px;
  border-radius: 8px;
  font-size: 13px;
  transition: background 0.2s ease;
}
.code-line { margin: 6px 0 14px; }
.code-line:last-child { margin-bottom: 0; }

/* ── API Keys ── */
.key-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--list-border);
  border-radius: 10px;
  animation: fadeSlide 0.4s ease both;
  transition: background 0.2s ease;
}
.key-item:hover { background: var(--hover-bg); }
.key-item:last-child { border-bottom: 0; }
.key-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
@property --spin { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
#newKey {
  position: relative;
  margin-top: 14px; padding: 14px; border-radius: 14px;
  background: var(--key-new-bg);
  border: 1px solid var(--key-new-border);
  animation: pop 0.5s var(--ease-spring) both;
}
/* Star Border：新 Key 卡片旋转星弧（移植自 React Bits Star Border） */
#newKey::before {
  content: ""; position: absolute; inset: -1px; border-radius: 15px; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--spin), transparent 0%, transparent 32%, #60a5fa 46%, #93c5fd 55%, transparent 70%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: spinBorder 2.8s linear infinite;
}
:root[data-theme="dark"] #newKey::before {
  background: conic-gradient(from var(--spin), transparent 0%, transparent 32%, #93c5fd 46%, #bfdbfe 55%, transparent 70%, transparent 100%);
}
@keyframes spinBorder { to { --spin: 360deg; } }
#newKeyValue { animation: keyGlow 1.8s ease-out 2; }
@keyframes pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes keyGlow {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.35); }
  100% { box-shadow: 0 0 0 16px rgba(37, 99, 235, 0); }
}
#keyList { margin-top: 14px; }

/* ── 确认弹窗 ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.modal-overlay.show { opacity: 1; }
.modal {
  width: min(420px, 100%);
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  transition: transform 0.32s var(--ease-spring), opacity 0.22s ease;
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); opacity: 1; }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0; color: var(--modal-ink); line-height: 1.65; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media (max-width: 600px) {
  main { padding-top: 24px; }
  input, select { min-width: 0; width: 100%; flex: 1 1 100%; }
  h1 { font-size: 26px; }
  .instance-list { grid-template-columns: 1fr; }
  .code-row .code-line { flex-basis: 100%; }
  .idle-shutdown-card input { width: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
