/* ==========================================================================
   虚拟生命 · 组件与布局
   规范：docs/UI_DESIGN_SPEC.md §3–§5
   约束：只用 tokens.css 变量；卡片用边框不用阴影；浮层才用阴影。
   类名前缀：结构性组件无前缀（如 .card），状态用 data-* 属性。
   ========================================================================== */

/* ───────────────────────────── AppShell ───────────────────────────── */

.app-shell {
  --shell-sidebar-w: var(--sidebar-w);
  display: grid;
  grid-template-columns: var(--shell-sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  transition: grid-template-columns var(--dur) var(--ease);
}

.app-shell[data-collapsed="true"] {
  --shell-sidebar-w: var(--sidebar-collapsed);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  background: var(--bg-elev);
  border-inline-end: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: 0 var(--sp-3) 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--primary);
  display: grid;
  place-items: center;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: 0.7;
}

.brand-mark::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: vp-breathe 3.2s var(--ease) infinite;
}

.brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: var(--fs-14);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand-sub {
  font-size: var(--fs-12);
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-3) var(--sp-2);
  scrollbar-gutter: stable;
}

.nav-group {
  margin-bottom: var(--sp-4);
}

.nav-group-title {
  padding: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-1);
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--row-h);
  padding: 0 var(--sp-3);
  border-radius: var(--radius-control);
  color: var(--text-2);
  font-size: var(--fs-14);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--primary-weak);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}

.nav-item .icon {
  font-size: 20px;
  color: inherit;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item .badge {
  margin-inline-start: auto;
}

.sidebar-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: var(--sp-2);
  border-top: 1px solid var(--border);
}

.sidebar-footer .nav-item {
  width: 100%;
}

.sidebar-toggle {
  display: none;
}

.app-shell .sidebar-toggle {
  display: none;
}

@media (min-width: 1024px) {
  .app-shell .sidebar-toggle {
    display: inline-flex;
  }
}

.sidebar-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.35;
}

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

/* 折叠态：只留图标 */
.app-shell[data-collapsed="true"] .brand-text,
.app-shell[data-collapsed="true"] .nav-label,
.app-shell[data-collapsed="true"] .nav-group-title,
.app-shell[data-collapsed="true"] .sidebar-meta,
.app-shell[data-collapsed="true"] .nav-item .badge {
  display: none;
}

.app-shell[data-collapsed="true"] .sidebar-brand {
  justify-content: center;
  padding: 0;
}

.app-shell[data-collapsed="true"] .nav-item {
  justify-content: center;
  padding: 0;
}

.app-shell[data-collapsed="true"] .sidebar-footer {
  justify-content: center;
}

.app-shell[data-collapsed="true"] .nav-group {
  margin-bottom: var(--sp-2);
}

/* 主区 */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: 0 var(--sp-6);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-title {
  font-size: var(--fs-16);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-control);
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn:disabled {
  color: var(--text-3);
  opacity: 0.6;
}

/* 全局状态条 */
.status-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 34px;
  padding: var(--sp-1) var(--sp-6);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-12);
  color: var(--text-2);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.status-strip::-webkit-scrollbar {
  display: none;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
}

.status-item .sep {
  color: var(--border);
}

.status-role {
  color: var(--text-2);
}

.status-role strong {
  color: var(--text);
  font-weight: 600;
}

/* 强制停止警示条 */
.stop-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-6);
  background: var(--danger);
  color: #14060a;
  font-size: var(--fs-13);
  font-weight: 600;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .stop-banner {
  color: #fff;
}

.stop-banner .icon {
  font-size: 20px;
}

.stop-banner-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.stop-banner-text .dim {
  color: inherit;
  opacity: 0.8;
  font-weight: 400;
}

.stop-banner-actions {
  display: flex;
  gap: var(--sp-2);
  flex: 0 0 auto;
}

.stop-banner .btn {
  border-color: rgba(0, 0, 0, 0.28);
}

/* 内容区 */
.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--page-pad-y) var(--page-pad-x) var(--sp-8);
}

.page {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  animation: vp-fade-in var(--dur) var(--ease);
}

/* 底部导航（手机） */
.bottom-nav {
  display: none;
}

@media (max-width: 719.98px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .topbar {
    min-height: var(--topbar-h-mobile);
    padding: 0 var(--sp-3);
  }

  .status-strip {
    padding: var(--sp-1) var(--sp-3);
    gap: var(--sp-3);
  }

  .content {
    padding: var(--sp-4) var(--sp-4) calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + var(--sp-6));
  }

  .bottom-nav {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: var(--z-bottomnav);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    color: var(--text-3);
    font-size: var(--fs-12);
    text-decoration: none;
    background: none;
    border: 0;
    padding: 0;
  }

  .bottom-nav-item .icon {
    font-size: 22px;
  }

  .bottom-nav-item.active {
    color: var(--primary);
  }

  .bottom-nav-item.active .bottom-nav-label {
    font-weight: 600;
  }

  .bottom-nav-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stop-banner {
    padding: var(--sp-2) var(--sp-3);
    flex-wrap: wrap;
  }

  .stop-banner-actions {
    width: 100%;
  }

  .stop-banner-actions .btn {
    flex: 1 1 auto;
  }
}

@media (min-width: 720px) and (max-width: 1023.98px) {
  .content {
    padding: var(--sp-5) var(--sp-5) var(--sp-8);
  }

  .topbar {
    padding: 0 var(--sp-5);
  }

  .status-strip {
    padding-inline: var(--sp-5);
  }
}

/* ───────────────────────────── 页头 ───────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.page-header-main {
  min-width: 0;
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.page-title {
  font-size: var(--fs-24);
  font-weight: 650;
  line-height: var(--lh-tight);
  letter-spacing: 0.01em;
}

.page-subtitle {
  color: var(--text-2);
  font-size: var(--fs-13);
  line-height: var(--lh-normal);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.page-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-3);
  font-size: var(--fs-12);
  flex-wrap: wrap;
}

/* ───────────────────────────── 卡片 / 指标 ───────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  min-width: 0;
  overflow: hidden;
}

.card-pad {
  padding: var(--sp-4);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) 0;
  flex-wrap: wrap;
}

.card-head + .card-body {
  padding-top: var(--sp-3);
}

.card-title {
  font-size: var(--fs-16);
  font-weight: 600;
  line-height: var(--lh-tight);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.card-title .icon {
  font-size: 20px;
  color: var(--text-2);
}

.card-subtitle {
  color: var(--text-2);
  font-size: var(--fs-12);
  margin-top: var(--sp-1);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: auto;
  flex-wrap: wrap;
}

.card-body {
  padding: var(--sp-4);
}

.card-body.flush {
  padding: 0;
}

.card-foot {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  color: var(--text-2);
  font-size: var(--fs-12);
}

.card--danger {
  border-color: var(--danger);
}

.card--warn {
  border-color: var(--warn);
}

.card--accent {
  border-color: var(--accent);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  min-width: 0;
}

.stat-top {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-2);
  font-size: var(--fs-12);
}

.stat-top .icon {
  font-size: 18px;
}

.stat-value-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  min-width: 0;
}

.stat-value {
  font-size: var(--fs-32);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-value.sm {
  font-size: var(--fs-24);
}

.stat-unit {
  font-size: var(--fs-12);
  color: var(--text-3);
}

.stat-hint {
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.4;
}

.stat-trend {
  font-size: var(--fs-12);
  color: var(--text-2);
}

.stat[data-tone="success"] .stat-value {
  color: var(--success);
}
.stat[data-tone="warn"] .stat-value {
  color: var(--warn);
}
.stat[data-tone="danger"] .stat-value {
  color: var(--danger);
}
.stat[data-tone="primary"] .stat-value {
  color: var(--primary);
}

/* ───────────────────────────── 状态点 / 徽标 ───────────────────────────── */

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-13);
  color: var(--text-2);
  white-space: nowrap;
}

.status-dot .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px transparent;
}

.status-dot[data-state="online"] .dot,
.status-dot[data-state="success"] .dot {
  background: var(--success);
}

.status-dot[data-state="warn"] .dot {
  background: var(--warn);
}

.status-dot[data-state="error"] .dot,
.status-dot[data-state="danger"] .dot {
  background: var(--danger);
}

.status-dot[data-state="offline"] .dot {
  background: var(--text-3);
}

.status-dot[data-state="info"] .dot {
  background: var(--info);
}

.status-dot[data-state="accent"] .dot {
  background: var(--accent);
}

.status-dot[data-state="online"] .dot,
.status-dot[data-state="success"] .dot {
  animation: vp-pulse 2.4s var(--ease) infinite;
}

.status-dot .dot-label {
  color: var(--text-2);
}

.status-dot[data-state="online"] .dot-label,
.status-dot[data-state="success"] .dot-label {
  color: var(--success);
}

.status-dot[data-state="warn"] .dot-label {
  color: var(--warn);
}

.status-dot[data-state="error"] .dot-label,
.status-dot[data-state="danger"] .dot-label {
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px var(--sp-2);
  min-height: 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge .icon {
  font-size: 14px;
}

.badge--primary {
  background: var(--primary-weak);
  border-color: transparent;
  color: var(--primary);
}

.badge--success {
  background: var(--success-weak);
  border-color: transparent;
  color: var(--success);
}

.badge--warn {
  background: var(--warn-weak);
  border-color: transparent;
  color: var(--warn);
}

.badge--danger {
  background: var(--danger-weak);
  border-color: transparent;
  color: var(--danger);
}

.badge--info {
  background: var(--info-weak);
  border-color: transparent;
  color: var(--info);
}

.badge--accent {
  background: var(--accent-weak);
  border-color: transparent;
  color: var(--accent);
}

.badge--outline {
  background: transparent;
}

.badge--sm {
  min-height: 18px;
  font-size: 11px;
  padding: 0 6px;
}

/* ───────────────────────────── 按钮 ───────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 36px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-13);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--text-3);
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
}

.btn .icon {
  font-size: 18px;
}

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: #6f9aff;
  border-color: #6f9aff;
}

[data-theme="light"] .btn--primary:hover:not(:disabled) {
  background: #4a7bf0;
  border-color: #4a7bf0;
}

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

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

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

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #1a0507;
}

[data-theme="light"] .btn--danger {
  color: #fff;
}

.btn--danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

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

.btn--danger-ghost:hover:not(:disabled) {
  background: var(--danger-weak);
}

.btn--sm {
  min-height: 28px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-12);
}

.btn--sm .icon {
  font-size: 16px;
}

.btn--lg {
  min-height: 44px;
  padding: 0 var(--sp-5);
  font-size: var(--fs-14);
}

.btn--block {
  width: 100%;
}

.btn--icon {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.btn--icon.btn--sm {
  width: 28px;
  min-height: 28px;
}

.btn[aria-busy="true"] {
  cursor: progress;
  opacity: 0.8;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: vp-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

/* ───────────────────────────── 表单控件 ───────────────────────────── */

.input,
.textarea,
.select {
  width: 100%;
  min-height: 36px;
  padding: 6px var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  color: var(--text);
  font-size: var(--fs-14);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:hover:not(:disabled),
.textarea:hover:not(:disabled),
.select:hover:not(:disabled) {
  border-color: var(--text-3);
}

.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.textarea {
  min-height: 88px;
  resize: vertical;
  line-height: var(--lh-normal);
  padding: var(--sp-2) var(--sp-3);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: var(--sp-7);
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

[data-theme="light"] .select {
  background-color: var(--surface-2);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search > .icon {
  position: absolute;
  inset-inline-start: var(--sp-2);
  color: var(--text-3);
  font-size: 18px;
  pointer-events: none;
}

.search > .input {
  padding-inline-start: 36px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-row.inline {
  flex-direction: row;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.form-label {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-label .req {
  color: var(--danger);
}

.form-hint {
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.45;
}

.form-error {
  font-size: var(--fs-12);
  color: var(--danger);
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
}

.input-group {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  min-width: 0;
}

.input-group > .input {
  flex: 1 1 auto;
}

/* 开关 */
.switch {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--sp-3);
  cursor: pointer;
  min-height: var(--touch);
  padding: var(--sp-2) 0;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  margin-top: 2px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--primary);
  border-color: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
  background: #fff;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.switch input:disabled + .switch-track {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.switch-label {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.switch-hint {
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.4;
}

.switch.disabled {
  cursor: not-allowed;
}

/* ───────────────────────────── Tabs / Segmented / Chips ───────────────────────────── */

.tabs {
  display: flex;
  align-items: stretch;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: 600;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-count {
  font-size: var(--fs-12);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
  display: none;
}

.seg-btn {
  min-height: 30px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 600;
  white-space: nowrap;
  border: 0;
  background: none;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.chips {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 32px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 600;
  white-space: nowrap;
}

.chip:hover:not(:disabled) {
  border-color: var(--text-3);
  color: var(--text);
}

.chip.active {
  background: var(--primary-weak);
  border-color: var(--primary);
  color: var(--primary);
}

.chip:disabled {
  opacity: 0.5;
}

.chip .icon {
  font-size: 16px;
}

/* ───────────────────────────── 表格 / 列表 ───────────────────────────── */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: auto;
  background: var(--surface);
}

.table {
  width: 100%;
  font-size: var(--fs-13);
  min-width: 520px;
}

.table th {
  text-align: start;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-3);
  padding: 0 var(--sp-4);
  height: 38px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table td {
  padding: var(--sp-2) var(--sp-4);
  height: var(--row-h);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr[data-clickable="true"] {
  cursor: pointer;
}

.table tbody tr[data-clickable="true"]:hover td {
  background: var(--surface-2);
}

.table .cell-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  white-space: nowrap;
}

.table .cell-muted {
  color: var(--text-2);
}

.list {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--row-h);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row[data-clickable="true"] {
  cursor: pointer;
}

.list-row[data-clickable="true"]:hover {
  background: var(--surface-2);
}

.list-row-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-row-title {
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.list-row-sub {
  font-size: var(--fs-12);
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.list-row-side {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-2);
  font-size: var(--fs-12);
  white-space: nowrap;
}

.list-row-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-control);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--text-2);
}

.list-row-icon .icon {
  font-size: 20px;
}

@media (max-width: 719.98px) {
  .list-row {
    min-height: var(--row-h-mobile);
    padding: var(--sp-2) var(--sp-3);
  }

  .list-row-side {
    font-size: var(--fs-12);
  }
}

/* ───────────────────────────── 空态 / 错误 / 骨架 ───────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-2);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

.empty-icon .icon {
  font-size: 26px;
}

.empty-title {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--text);
}

.empty-text {
  font-size: var(--fs-13);
  color: var(--text-2);
  max-width: 46ch;
  line-height: var(--lh-normal);
  overflow-wrap: anywhere;
}

.empty-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-2);
  justify-content: center;
}

.empty--error .empty-icon {
  background: var(--danger-weak);
  color: var(--danger);
}

.empty--error .empty-title {
  color: var(--danger);
}

.empty--sm {
  padding: var(--sp-4);
}

.skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.sk-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: vp-shimmer 1.4s ease infinite;
}

.sk-line.w-40 {
  width: 40%;
}
.sk-line.w-60 {
  width: 60%;
}
.sk-line.w-80 {
  width: 80%;
}
.sk-line.h-20 {
  height: 20px;
}

.sk-card {
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.sk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
}

/* ───────────────────────────── 时间线 ───────────────────────────── */

.timeline {
  display: flex;
  flex-direction: column;
}

.tl-item {
  position: relative;
  display: flex;
  gap: var(--sp-3);
  padding: 0 0 var(--sp-4);
  min-width: 0;
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-item::before {
  content: "";
  position: absolute;
  inset-inline-start: 5px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.tl-item:last-child::before {
  display: none;
}

.tl-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}

.tl-item[data-tone="info"] .tl-dot {
  background: var(--info);
  box-shadow: 0 0 0 1px var(--info);
}
.tl-item[data-tone="success"] .tl-dot {
  background: var(--success);
  box-shadow: 0 0 0 1px var(--success);
}
.tl-item[data-tone="warn"] .tl-dot {
  background: var(--warn);
  box-shadow: 0 0 0 1px var(--warn);
}
.tl-item[data-tone="danger"] .tl-dot {
  background: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}
.tl-item[data-tone="accent"] .tl-dot {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.tl-body {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tl-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.tl-title {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.tl-time {
  font-size: var(--fs-12);
  color: var(--text-3);
  margin-inline-start: auto;
  white-space: nowrap;
}

.tl-detail {
  font-size: var(--fs-12);
  color: var(--text-2);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* ───────────────────────────── 代码块 ───────────────────────────── */

.code-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 34px;
  padding: 0 var(--sp-2) 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-12);
  color: var(--text-3);
}

.code-title {
  font-weight: 600;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-copy {
  margin-inline-start: auto;
}

.code-body {
  margin: 0;
  padding: var(--sp-3);
  max-height: 360px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

/* ───────────────────────────── 对话框 / 浮层 ───────────────────────────── */

.dialog-backdrop,
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: var(--overlay);
  animation: vp-fade-in var(--dur) var(--ease);
}

.sheet-backdrop {
  z-index: var(--z-sheet);
  align-items: flex-end;
}

.dialog {
  width: min(520px, 100%);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-overlay);
  animation: vp-pop-in var(--dur) var(--ease);
  overflow: hidden;
}

.dialog--wide {
  width: min(680px, 100%);
}

.dialog--danger {
  border-color: var(--danger);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) 0;
}

.dialog-title {
  font-size: var(--fs-16);
  font-weight: 650;
  line-height: var(--lh-tight);
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 6px;
}

.dialog--danger .dialog-title {
  color: var(--danger);
}

.dialog-body {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  font-size: var(--fs-13);
  color: var(--text-2);
  line-height: var(--lh-normal);
}

.dialog-body p {
  font-size: var(--fs-13);
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.dialog-message {
  color: var(--text-2);
  font-size: var(--fs-13);
  white-space: pre-line;
}

.dialog-consequences {
  border: 1px solid var(--danger);
  border-radius: var(--radius-control);
  padding: var(--sp-3);
  background: var(--danger-weak);
  color: var(--text);
  font-size: var(--fs-13);
}

.dialog-consequences ul {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
}

.dialog-consequences li {
  padding-inline-start: var(--sp-4);
  position: relative;
  font-size: var(--fs-13);
  line-height: 1.5;
}

.dialog-consequences li::before {
  content: "•";
  position: absolute;
  inset-inline-start: var(--sp-1);
  color: var(--danger);
}

.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  box-shadow: var(--shadow-overlay);
  animation: vp-slide-up var(--dur) var(--ease);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.sheet-title {
  font-size: var(--fs-16);
  font-weight: 650;
  flex: 1 1 auto;
}

.sheet-body {
  padding: var(--sp-4);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 720px) {
  .sheet-backdrop {
    align-items: center;
  }
  .sheet {
    border-radius: var(--radius-card);
  }
}

/* ───────────────────────────── Toast ───────────────────────────── */

.toast-root {
  position: fixed;
  z-index: var(--z-toast);
  inset-inline-end: var(--sp-4);
  top: calc(var(--topbar-h) + 34px + var(--sp-3));
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(380px, calc(100vw - var(--sp-6)));
  pointer-events: none;
}

@media (max-width: 719.98px) {
  .toast-root {
    inset-inline: var(--sp-3);
    top: calc(var(--topbar-h-mobile) + 34px + var(--sp-2));
    width: auto;
  }
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--toast-bg);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--info);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-overlay);
  color: var(--text);
  font-size: var(--fs-13);
  line-height: 1.45;
  pointer-events: auto;
  animation: vp-toast-in var(--dur) var(--ease);
}

.toast--success {
  border-inline-start-color: var(--success);
}

.toast--warn {
  border-inline-start-color: var(--warn);
}

.toast--danger {
  border-inline-start-color: var(--danger);
}

.toast--info {
  border-inline-start-color: var(--info);
}

.toast-icon {
  color: var(--info);
  flex: 0 0 auto;
}

.toast--success .toast-icon {
  color: var(--success);
}
.toast--warn .toast-icon {
  color: var(--warn);
}
.toast--danger .toast-icon {
  color: var(--danger);
}

.toast-text {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 2px;
}

/* ───────────────────────────── 键值 / 进度 / 标签 ───────────────────────────── */

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3) var(--sp-4);
}

.kv-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kv-key {
  font-size: var(--fs-12);
  color: var(--text-3);
}

.kv-val {
  font-size: var(--fs-13);
  color: var(--text);
  overflow-wrap: anywhere;
}

.kv-val.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
}

.meter {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

.meter-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  color: var(--text-2);
}

.meter-head .meter-value {
  margin-inline-start: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.meter-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
  transition: width var(--dur) var(--ease);
}

.meter[data-tone="warn"] .meter-fill {
  background: var(--warn);
}
.meter[data-tone="danger"] .meter-fill {
  background: var(--danger);
}
.meter[data-tone="success"] .meter-fill {
  background: var(--success);
}

/* ───────────────────────────── 告警条 ───────────────────────────── */

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-13);
  color: var(--text-2);
  line-height: 1.5;
}

.banner .icon {
  font-size: 20px;
  color: var(--info);
  flex: 0 0 auto;
}

.banner--warn {
  background: var(--warn-weak);
  border-color: transparent;
  color: var(--text);
}
.banner--warn .icon {
  color: var(--warn);
}

.banner--danger {
  background: var(--danger-weak);
  border-color: transparent;
  color: var(--text);
}
.banner--danger .icon {
  color: var(--danger);
}

.banner--success {
  background: var(--success-weak);
  border-color: transparent;
  color: var(--text);
}
.banner--success .icon {
  color: var(--success);
}

.banner--info {
  background: var(--info-weak);
  border-color: transparent;
  color: var(--text);
}

.banner-body {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.banner-title {
  font-weight: 600;
  color: var(--text);
  font-size: var(--fs-13);
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-1);
}

/* ───────────────────────────── 生命核 ───────────────────────────── */

.life-core {
  position: relative;
  width: 136px;
  height: 136px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.life-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.life-ring.r1 {
  inset: 0;
  border-color: var(--primary-weak);
  border-width: 1px;
}

.life-ring.r2 {
  inset: 16px;
  border-color: var(--primary);
  opacity: 0.45;
}

.life-ring.r3 {
  inset: 32px;
  border-color: var(--accent);
  opacity: 0.35;
  animation: vp-breathe-ring 4.2s var(--ease) infinite;
}

.life-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #dcd4ff, var(--accent) 60%, #6d4fd8);
  box-shadow: 0 0 24px var(--accent-weak), 0 0 0 8px var(--primary-weak);
  animation: vp-breathe 3.2s var(--ease) infinite;
}

.life-core[data-state="stopped"] .life-dot {
  background: var(--danger);
  box-shadow: 0 0 24px var(--danger-weak), 0 0 0 8px var(--danger-weak);
  animation: none;
}

.life-core[data-state="stopped"] .life-ring.r3 {
  border-color: var(--danger);
  animation: none;
}

.life-meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

.life-name {
  font-size: var(--fs-20);
  font-weight: 650;
  line-height: 1.25;
}

.life-id {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--text-3);
  letter-spacing: 0.04em;
}

.life-hero {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex-wrap: wrap;
}

/* ───────────────────────────── 网格 / 卡片入口 ───────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--sp-4);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--sp-4);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-2);
}

.link-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  min-height: var(--row-h-mobile);
  justify-content: center;
}

.link-card:hover {
  border-color: var(--primary);
  text-decoration: none;
  background: var(--surface-2);
}

.link-card-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-13);
  font-weight: 600;
  min-width: 0;
}

.link-card-title .icon {
  font-size: 18px;
  color: var(--text-2);
}

.link-card-desc {
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.4;
}

/* 更多（手机） */
.more-group {
  margin-bottom: var(--sp-4);
}

.more-group:last-child {
  margin-bottom: 0;
}

.more-group-title {
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: var(--sp-2);
}

.more-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 72px;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-12);
  text-align: center;
  text-decoration: none;
}

.more-link:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.more-link .icon {
  font-size: 22px;
  color: var(--text-2);
}

.more-link.active {
  border-color: var(--primary);
  background: var(--primary-weak);
}

.more-link.active .icon {
  color: var(--primary);
}

/* ───────────────────────────── 对话 ───────────────────────────── */

.chat-page {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: calc(100vh - var(--topbar-h) - var(--page-pad-y) - 120px);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-1) 0;
  overflow-y: auto;
  max-height: min(58vh, 680px);
  padding-inline-end: 4px;
  scroll-behavior: smooth;
}

@media (max-width: 719.98px) {
  .chat-log {
    max-height: none;
  }

  .chat-page {
    padding-bottom: 190px;
  }
}

@media (max-width: 719.98px) {
  .life-core {
    width: 104px;
    height: 104px;
  }

  .life-core .life-dot {
    width: 28px;
    height: 28px;
  }

  .life-hero {
    gap: var(--sp-4);
  }
}

@media (max-width: 719.98px) {
  .chat-msg {
    scroll-margin-bottom: 200px;
  }
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(760px, 100%);
  min-width: 0;
}

.chat-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg--system {
  align-self: center;
  align-items: center;
  max-width: 100%;
}

.chat-bubble {
  padding: var(--sp-3);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-14);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.chat-msg--user .chat-bubble {
  background: var(--primary-weak);
  border-color: transparent;
}

.chat-msg--system .chat-bubble {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-12);
  padding: var(--sp-2) var(--sp-3);
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  color: var(--text-3);
  flex-wrap: wrap;
}

.chat-meta .badge {
  font-size: 11px;
}

.composer {
  position: sticky;
  bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

@media (max-width: 719.98px) {
  .composer {
    position: fixed;
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + var(--sp-2));
    z-index: 15;
    box-shadow: var(--shadow-overlay);
  }
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  min-width: 0;
}

.composer-input {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  color: var(--text);
  font-size: var(--fs-14);
  line-height: 1.5;
}

.composer-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}

.composer-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.composer-hint {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  color: var(--text-3);
  flex-wrap: wrap;
}

.composer-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-12);
  color: var(--text-2);
}

/* 可折叠区块 */
details.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  overflow: hidden;
}

details.disclosure > summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

details.disclosure > summary::-webkit-details-marker {
  display: none;
}

details.disclosure > summary .icon.chev {
  margin-inline-start: auto;
  transition: transform var(--dur) var(--ease);
  color: var(--text-3);
}

details.disclosure[open] > summary .icon.chev {
  transform: rotate(90deg);
}

details.disclosure .disclosure-body {
  padding: 0 var(--sp-3) var(--sp-3);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}

/* 分区标题 */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}

.section-title .icon {
  font-size: 18px;
}

/* ───────────────────────────── 动画 ───────────────────────────── */

@keyframes vp-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.92;
  }
  50% {
    transform: scale(1.16);
    opacity: 1;
  }
}

@keyframes vp-breathe-ring {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.28;
  }
  50% {
    transform: scale(1.04);
    opacity: 0.5;
  }
}

@keyframes vp-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
  50% {
    box-shadow: 0 0 0 3px var(--success-weak);
  }
}

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

@keyframes vp-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@keyframes vp-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes vp-pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes vp-slide-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes vp-toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 登录/配对待机页 */
.boot-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background:
    radial-gradient(1200px 600px at 20% -10%, var(--primary-weak), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, var(--accent-weak), transparent 55%),
    var(--bg);
}

.boot-card {
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.boot-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.boot-title {
  font-size: var(--fs-24);
  font-weight: 650;
}

.boot-sub {
  color: var(--text-2);
  font-size: var(--fs-13);
}

.boot-hint {
  font-size: var(--fs-12);
  color: var(--text-3);
  line-height: 1.5;
}

.boot-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  color: var(--text-3);
  font-size: var(--fs-12);
}

.boot-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-3);
  font-size: var(--fs-12);
}

.boot-divider::before,
.boot-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

/* 停止状态：Agent 相关操作不可用（真实禁用由 JS 设置 disabled，这里只做视觉提示） */
.app-shell[data-stopped="true"] [data-agent-action] {
  opacity: 0.55;
}

.app-shell[data-stopped="true"] [data-agent-action] .icon {
  color: var(--danger);
}

/* 打印：只保留内容 */
@media print {
  .sidebar,
  .topbar,
  .status-strip,
  .bottom-nav,
  .stop-banner,
  .toast-root {
    display: none !important;
  }
  .app-shell {
    display: block;
  }
  .content {
    padding: 0;
    max-width: none;
  }
}
