.countdown {
  text-align: right;
  font-size: var(--text-sm);
  color: var(--text-muted);
  min-height: var(--countdown-slot-height);
  margin-bottom: 0;
  line-height: var(--leading-normal);
}

.countdown.is-idle {
  display: none;
}

.stats-scroll .stat-item .value {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--primary);
  line-height: var(--leading-tight);
}

.stats-scroll .stat-item .label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
  line-height: var(--leading-tight);
}

.stat-item.highlight .value { color: var(--success); }
.stat-item.warn .value { color: var(--warning); }
.stat-item.danger .value { color: var(--danger); }

.loading-text {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-xl) var(--space-md);
  font-size: var(--text-base);
}

/* 任务列表卡片：与页面融为一体，无浮起阴影 */
.card-tasks {
  background: var(--surface);
  box-shadow: none;
}

.card-tasks .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-xs);
  margin-bottom: 0;
}

/* 任务列表滚动区域 */
.task-list-body {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb-bottom) var(--scroll-track);
  padding: 0;
  margin-top: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  box-sizing: border-box;
}

@media (min-width: 641px) {
  .task-list-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  .empty-state {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.task-list-body::-webkit-scrollbar {
  width: 10px;
}

.task-list-body::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
  margin: var(--space-sm) 0;
  box-shadow: inset 0 0 0 1px var(--scroll-track-edge);
}

.task-list-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  background: linear-gradient(180deg, var(--scroll-thumb-top), var(--scroll-thumb-bottom));
  min-height: 48px;
}

.task-list-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--scroll-thumb-hover-top), var(--scroll-thumb-hover-bottom));
}

.task-list-body::-webkit-scrollbar-thumb:active {
  background: var(--scroll-thumb-active);
}

.task-list-body::-webkit-scrollbar-corner {
  background: transparent;
}

#task-list {
  width: 100%;
  min-width: 0;
}

#task-list[data-skeleton="true"] {
  min-height: 0;
}

@media (min-width: 641px) {
  #task-list[data-skeleton="true"] {
    min-height: 100%;
  }
}

.task-list-head {
  display: grid;
  grid-template-columns: var(--task-summary-cols-mobile);
  column-gap: var(--task-list-col-gap);
  row-gap: var(--space-xs);
  align-items: center;
  padding: var(--task-row-padding-y) var(--task-list-inline-padding);
  min-height: var(--task-list-head-height);
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
}

.task-col-head {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  white-space: nowrap;
  line-height: var(--leading-normal);
  min-width: 0;
}

.task-list-head .col-id { grid-column: 1; }
.task-list-head .col-live {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-list-head .col-status {
  grid-column: 3;
  justify-self: center;
  text-align: center;
}

.task-list-head .col-type,
.task-list-head .col-progress,
.task-list-head .col-success,
.task-type,
.task-progress,
.task-success {
  display: none;
}

.task-list-head .col-time {
  grid-column: 5;
  justify-self: stretch;
  text-align: right;
  min-width: var(--task-col-time-width);
  font-variant-numeric: tabular-nums;
  padding-right: 0;
}

.task-list-body:has(#empty-tasks:not(.hidden)) .task-list-head {
  display: none;
}

.task-row {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  overflow: visible;
  background: transparent;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}

.task-row:last-child {
  border-bottom: none;
}

.task-row:not(.expanded) {
  height: var(--task-row-height-mobile);
}

.task-row.expanded {
  height: auto;
  border-bottom-color: var(--border);
}

.task-summary {
  display: grid;
  grid-template-columns: var(--task-summary-cols-mobile);
  column-gap: var(--task-list-col-gap);
  row-gap: var(--space-xs);
  align-items: center;
  padding: var(--task-row-padding-y) var(--task-list-inline-padding);
  min-height: var(--task-row-height-mobile);
  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  background: transparent;
  transition: background 0.15s ease;
}

.task-row.expanded > .task-summary {
  border-bottom: 1px solid var(--border);
  background: var(--overlay-hover);
}

.task-row.expanded > .task-summary .task-live {
  color: var(--text);
}

.task-detail {
  margin: var(--space-sm) var(--space-sm) var(--space-md);
  padding: var(--space-sm) var(--space-md);
  padding-left: calc(var(--space-md) + var(--task-detail-indent));
  background: var(--overlay-detail);
  border-left: var(--task-detail-indent) solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  box-shadow: inset 0 1px 0 var(--overlay-border);
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--divider);
  font-size: var(--text-base);
}

.detail-row:first-child {
  padding-top: 0;
}

.detail-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-key {
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.task-summary .openable {
  cursor: pointer;
  justify-self: start;
  pointer-events: auto;
  min-width: 0;
  max-width: 100%;
}

.task-id {
  font-family: ui-monospace, monospace;
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-live {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  grid-column: 2;
  min-width: 0;
  justify-self: start;
}

.task-type {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  grid-column: 3;
  justify-self: center;
  white-space: nowrap;
}

.task-progress {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
  grid-column: 4;
  justify-self: center;
  white-space: nowrap;
}

.task-progress.is-active {
  color: var(--accent);
  font-weight: var(--font-medium);
}

.task-success {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  text-align: center;
  grid-column: 5;
  justify-self: center;
  white-space: nowrap;
}

.task-status {
  font-size: var(--text-md);
  text-align: center;
  width: var(--task-col-status-width);
  line-height: 1;
  flex-shrink: 0;
  grid-column: 3;
  justify-self: center;
}

.task-time {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  grid-column: 5;
  justify-self: stretch;
  min-width: var(--task-col-time-width);
  width: 100%;
  box-sizing: border-box;
  padding-right: 0;
}

.task-meta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-top: 0;
  margin-top: 0;
  min-height: var(--task-row-meta-height);
  box-sizing: border-box;
  align-items: center;
  border-top: 1px solid var(--divider);
}

.detail-value {
  word-break: break-all;
  line-height: var(--leading-snug);
}

.detail-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--divider);
}

.detail-actions .btn,
.btn-terminate {
  width: auto;
  flex: 0 0 auto;
  min-height: 28px;
  padding: 2px 10px;
  font-size: var(--text-xs);
}

.footer-stats {
  color: var(--text-muted);
  opacity: 0.8;
}

@media (min-width: 641px) {
  .task-list-head,
  .task-summary {
    grid-template-columns: var(--task-summary-cols-desktop);
  }

  .task-list-head .col-type {
    display: block;
    grid-column: 3;
    justify-self: center;
    text-align: center;
  }

  .task-list-head .col-progress {
    display: block;
    grid-column: 4;
    justify-self: center;
    text-align: center;
  }

  .task-list-head .col-success {
    display: block;
    grid-column: 5;
    justify-self: center;
    text-align: center;
  }

  .task-list-head .col-status {
    grid-column: 6;
  }

  .task-list-head .col-time {
    grid-column: 7;
  }

  .task-list-head .col-live {
    max-width: none;
  }

  .task-type {
    display: block;
    grid-column: 3;
  }

  .task-progress {
    display: block;
    grid-column: 4;
  }

  .task-success {
    display: block;
    grid-column: 5;
  }

  .task-status {
    grid-column: 6;
  }

  .task-time {
    grid-column: 7;
  }

  .task-row:not(.expanded) {
    height: var(--task-row-height);
  }

  .task-summary {
    min-height: var(--task-row-height);
  }

  .task-meta { display: none; }

  .task-detail {
    margin-inline: var(--space-md);
  }

  .detail-row {
    flex-direction: row;
    gap: var(--space-md);
    align-items: baseline;
    padding: var(--space-sm) 0;
  }

  .detail-key {
    width: 112px;
    flex-shrink: 0;
    font-size: var(--text-sm);
  }

  .detail-actions .btn {
    width: auto;
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  :root {
    --task-list-inline-padding: 6px;
    --task-list-col-gap: 4px;
    --task-row-padding-y: 5px;
    --task-row-content-height: 16px;
    --task-row-meta-height: 0px;
    --task-row-height-mobile: calc(var(--task-row-padding-y) * 2 + var(--task-row-content-height));
    --task-list-head-height: calc(var(--task-row-padding-y) * 2 + 12px * var(--leading-normal));
    --task-col-id-width: 2.35rem;
    --task-col-type-width: 1.65rem;
    --task-col-progress-width: 2.1rem;
    --task-col-status-width: 1.5rem;
    --task-summary-cols-mobile:
      var(--task-col-id-width)
      minmax(0, 1fr)
      var(--task-col-type-width)
      var(--task-col-progress-width)
      var(--task-col-status-width);
  }

  .panel-tasks .card-tasks {
    padding: var(--space-sm);
  }

  .panel-tasks .card-header {
    padding-bottom: 2px;
    gap: var(--space-sm);
  }

  .panel-tasks .card-header h2 {
    font-size: var(--text-md);
    margin-bottom: 0;
  }

  .panel-tasks .card-header .icon-btn {
    min-width: 34px;
    min-height: 34px;
    padding: 4px;
  }

  .panel-tasks .card-header .icon-btn svg {
    width: 18px;
    height: 18px;
  }

  .panel-tasks .footer-stats.inline {
    font-size: 10px;
    min-height: 12px;
    line-height: 1.2;
  }

  .panel-tasks .countdown:not(.is-idle) {
    font-size: 10px;
    min-height: auto;
    line-height: 1.3;
    margin-bottom: 2px;
  }

  .task-list-body {
    max-height: none;
    overflow-y: auto;
    padding: 0;
    margin-top: 4px;
  }

  .task-list-body:has(#task-list[data-skeleton="true"]) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .task-list-body:has(#task-list[data-skeleton="true"]) .task-list-head {
    flex-shrink: 0;
  }

  #task-list[data-skeleton="true"] {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  #task-list[data-skeleton="true"] .skeleton-task-row {
    flex: 1 1 0;
    min-height: var(--task-row-height-mobile);
    height: auto;
  }

  .task-list-head {
    padding: var(--task-row-padding-y) var(--task-list-inline-padding);
    min-height: var(--task-list-head-height);
  }

  .task-col-head {
    font-size: 10px;
    font-weight: var(--font-medium);
  }

  .task-list-head .col-time,
  .task-list-head .col-success {
    display: none;
  }

  .task-list-head .col-type,
  .task-list-head .col-progress {
    display: block;
    justify-self: center;
    text-align: center;
  }

  .task-list-head .col-id { grid-column: 1; }
  .task-list-head .col-live { grid-column: 2; }
  .task-list-head .col-type { grid-column: 3; }
  .task-list-head .col-progress { grid-column: 4; }
  .task-list-head .col-status { grid-column: 5; }

  .task-time,
  .task-success,
  .task-meta {
    display: none !important;
  }

  .task-type,
  .task-progress {
    display: block;
  }

  .task-summary {
    row-gap: 0;
    min-height: var(--task-row-height-mobile);
  }

  .task-row:not(.expanded) {
    height: var(--task-row-height-mobile);
  }

  .task-id {
    grid-column: 1;
    font-size: 10px;
  }

  .task-live {
    grid-column: 2;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
  }

  .task-type {
    grid-column: 3;
    font-size: 10px;
    color: var(--text-muted);
  }

  .task-progress {
    grid-column: 4;
    font-size: 10px;
  }

  .task-status {
    grid-column: 5;
    font-size: var(--text-sm);
    width: auto;
  }

  .task-row.expanded {
    height: auto;
  }

  .task-row.expanded > .task-summary {
    border-bottom-color: var(--divider);
  }

  .task-detail {
    display: grid;
    grid-template-columns: 4.75rem minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 0;
    align-content: start;
    margin: 0;
    padding: 4px 5px 5px;
    padding-left: calc(5px + var(--task-detail-indent));
    border-left-width: 2px;
    background: var(--overlay-detail);
  }

  .detail-row {
    display: contents;
    padding: 0;
    border: none;
    gap: 0;
  }

  .detail-key {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    align-self: center;
    padding: 1px 0;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .detail-value {
    font-size: 10px;
    line-height: 1.25;
    word-break: break-all;
    align-self: center;
    padding: 1px 0;
    font-variant-numeric: tabular-nums;
  }

  .detail-value .openable {
    font-size: 10px;
  }

  .detail-actions {
    grid-column: 1 / -1;
    display: flex;
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px solid var(--divider);
  }

  .detail-actions .btn {
    width: auto;
    min-height: 26px;
    padding: 2px 8px;
    font-size: 10px;
  }
}
