:root {
  --bg: #181a1f;
  --surface: #1f2228;
  --surface-2: #282c34;
  --border: #353a44;
  --text: #c4c9d2;
  --text-muted: #7a828e;
  --primary: #6d9ae8;
  --primary-hover: #5a88d8;
  --danger: #d97070;
  --success: #5cb87a;
  --warning: #c9954a;
  --accent: #9b8fd4;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --touch-min: 44px;
  /* 间距规格：xs/sm/md/lg/xl */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  /* 圆角规格 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius: var(--radius-md);
  --shadow: none;
  --shadow-sm: none;
  /* 字体规格：xs/sm/base/md/lg/xl/2xl */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-normal: 1.5;
  /* 暗色主题辅助色 */
  --header-bg: rgba(24, 26, 31, 0.92);
  --nav-bg: rgba(24, 26, 31, 0.96);
  --overlay-subtle: transparent;
  --overlay-border: rgba(255, 255, 255, 0.06);
  --overlay-hover: rgba(255, 255, 255, 0.03);
  --overlay-active: rgba(109, 154, 232, 0.12);
  --overlay-detail: rgba(255, 255, 255, 0.025);
  --divider: rgba(255, 255, 255, 0.06);
  --surface-muted: var(--surface);
  --surface-row: transparent;
  /* 统计卡片固定高度（骨架屏与真实数据一致） */
  --stat-value-height: 22px;
  --stat-label-height: 15px;
  --stat-card-height: calc(var(--space-md) * 2 + var(--stat-value-height) + var(--space-xs) + var(--stat-label-height));
  --stat-grid-cols: 7;
  --stat-grid-rows: 2;
  /* 布局固定尺寸（防止加载跳动） */
  --layout-max: 1280px;
  --panel-create-width: 380px;
  --task-col-id-width: 3.25rem;
  --task-col-live-width: 4.75rem;
  --task-col-type-width: 2.25rem;
  --task-col-progress-width: 2.75rem;
  --task-col-success-width: 2.75rem;
  --task-col-status-width: 2rem;
  --task-col-time-width: 3.5rem;
  --task-list-inline-padding: var(--space-md);
  --task-list-col-gap: var(--space-sm);
  --task-summary-cols-mobile: var(--task-col-id-width) minmax(0, 1fr) var(--task-col-status-width);
  --task-summary-cols-desktop:
    var(--task-col-id-width)
    minmax(0, 1fr)
    var(--task-col-type-width)
    var(--task-col-progress-width)
    var(--task-col-success-width)
    var(--task-col-status-width)
    var(--task-col-time-width);
  --task-row-padding-y: 10px;
  --task-row-content-height: 22px;
  --task-row-meta-height: calc(var(--text-xs) * var(--leading-tight) + var(--space-sm));
  --task-row-height: calc(var(--task-row-padding-y) * 2 + var(--task-row-content-height));
  --task-row-height-mobile: calc(var(--task-row-height) + var(--task-row-meta-height) + var(--space-sm));
  --task-detail-indent: 3px;
  --task-list-head-height: calc(var(--task-row-padding-y) * 2 + var(--text-sm) * var(--leading-normal));
  --card-tasks-header-height: calc(var(--text-xl) * var(--leading-tight) + var(--space-xs) + var(--text-xs) * var(--leading-tight));
  --form-etc-slot-height: calc(var(--text-xs) * var(--leading-tight));
  --countdown-slot-height: calc(var(--text-sm) * var(--leading-normal) + var(--space-sm));
  /* 任务列表滚动条 */
  --scroll-track: rgba(255, 255, 255, 0.04);
  --scroll-track-edge: rgba(255, 255, 255, 0.02);
  --scroll-thumb-top: #454b58;
  --scroll-thumb-bottom: #383e4a;
  --scroll-thumb-hover-top: #525866;
  --scroll-thumb-hover-bottom: #434956;
  --scroll-thumb-active: #6d9ae8;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-base);
  min-height: 100vh;
  line-height: var(--leading-normal);
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}

@media (min-width: 641px) {
  body:has(#view-dashboard:not(.hidden)) {
    overflow: hidden;
    height: 100%;
  }
}

.hidden { display: none !important; }

#view-login {
  max-width: 420px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

.view { animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(var(--space-sm)); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-lg);
  color: var(--text);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.card-header h2 { margin-bottom: 0; }

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-sm);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn.spinning svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.btn {
  padding: var(--space-md) var(--space-lg);
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  transition: all 0.2s;
}

.btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(217, 112, 112, 0.1);
}

#toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: var(--text-base);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}

dialog:not([open]) {
  display: none;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.terminate-dialog {
  position: fixed;
  inset: 0;
  width: min(280px, calc(100vw - 2 * var(--space-xl)));
  height: fit-content;
  max-height: calc(100vh - 2 * var(--space-xl));
  margin: auto;
  overflow: auto;
}

.dialog-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
}

.dialog-message {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

.dialog-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

.dialog-actions .btn {
  flex: 0 0 auto;
  min-width: 72px;
}

.btn-sm {
  min-height: 34px;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-sm);
}

.openable {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.openable:hover { color: var(--primary-hover); }

@media (max-width: 640px) {
  .btn-block-mobile {
    flex: 1;
  }
}
