.train-main {
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: stretch;
  overflow: hidden;
}

.train-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.train-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.train-head p {
  margin: 0;
  color: var(--muted);
}

.demo-note {
  margin: 4px 0 0;
  color: #b45309;
  font-size: 13px;
}

.primary-link,
.secondary-link,
.task-actions a {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 650;
}

.primary-link,
.task-actions a {
  background: var(--accent);
  color: #ffffff;
}

.primary-link:hover,
.task-actions a:hover {
  background: var(--accent-dark);
}

.secondary-link {
  border: 1px solid var(--line);
  color: var(--text);
  background: #ffffff;
}

.train-tabs,
.queue-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.train-tab,
.queue-filter a {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.train-tab:hover,
.queue-filter a:hover {
  background: #eef6ff;
  color: var(--text);
}

.train-tab.active,
.queue-filter a.active {
  border-color: var(--line);
  background: #ffffff;
  color: var(--accent);
  transform: translateY(1px);
}

.queue-filter {
  justify-content: flex-end;
  border-bottom: 0;
}

.train-tab-content {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  scroll-padding-bottom: 20px;
}

.task-list {
  display: grid;
  gap: 12px;
}

.model-list {
  display: grid;
  gap: 14px;
}

.model-card {
  break-inside: avoid;
  display: grid;
  gap: 12px;
  margin: 0 0 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.model-card-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.model-card-preview {
  grid-column: 1 / -1;
  overflow: hidden;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  background: #f8fafc;
}

.model-card-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.model-card h2 {
  margin: 0;
  font-size: 18px;
}

.model-card p {
  margin: 4px 0 0;
  color: var(--muted);
  tab-size: 4;
  white-space: pre-wrap;
}

.model-metrics {
  display: flex;
  flex-wrap: nowrap;
  gap: 28px;
  margin-top: 5px;
  color: #334e68;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  overflow: visible;
}

.model-metrics span {
  white-space: nowrap;
}

.model-metrics b {
  font-weight: 400;
}

.model-date {
  align-self: start;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.model-detail-head {
  align-items: flex-end;
}

.model-detail-head h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.model-detail-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.task-card h2 {
  margin: 0;
  font-size: 18px;
}

.task-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.status {
  align-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef6ff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.task-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.task-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-actions form {
  margin: 0;
}

.disabled-action {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 650;
  opacity: .55;
}

.empty {
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.train-dialog {
  position: static;
  width: min(760px, 100%);
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.train-dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head a {
  color: var(--muted);
  font-size: 24px;
  text-decoration: none;
}

.train-dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.train-dialog input,
.train-dialog select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #ffffff;
}

.train-dialog .readonly-field {
  color: var(--muted);
  background: #f6f8fb;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.optional-params {
  display: grid;
  gap: 12px;
  padding-top: 2px;
}

.optional-params h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--accent);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.train-task-main {
  align-content: stretch;
  grid-template-rows: auto minmax(0, 1fr);
}

.model-detail-main {
  align-content: stretch;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.model-layout {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.model-results {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.model-section {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.model-section h2 {
  margin: 0;
  font-size: 18px;
}

.model-section p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.args-output {
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: #101828;
  color: #d1fadf;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.result-file-list {
  display: grid;
  gap: 6px;
}

.result-file-list a {
  min-width: 0;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-file-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.result-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
  align-items: start;
}

.result-image-grid-fluid {
  grid-template-columns: 1fr;
}

.result-image-grid-fit {
  height: 100%;
  min-height: 0;
  grid-template-columns: 1fr;
}

.result-tabs {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.result-tab-list {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.result-tab {
  height: 34px;
  min-width: 96px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.result-tab:hover {
  background: #eef6ff;
  color: var(--text);
}

.result-tab.active {
  border-color: var(--line);
  background: #ffffff;
  color: var(--accent);
  transform: translateY(1px);
}

.result-tab-panel[hidden] {
  display: none;
}

.result-tab-panel {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 0 4px 48px 0;
  scroll-padding-bottom: 48px;
}

.args-tab-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 0;
}

.command-card {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.command-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.command-card h3 {
  margin: 0;
  font-size: 16px;
}

.command-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.copy-command-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #334e68;
  font-size: 15px;
  line-height: 1;
}

.copy-command-button:hover {
  background: #e6f0ff;
  color: #243b53;
}

.command-output {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: #f8fafc;
  color: #243b53;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.result-image-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.result-image-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  background: #ffffff;
  cursor: zoom-in;
}

.result-image-grid-fluid .result-image-card img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}

.result-image-grid-fit .result-image-card {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
}

.result-image-grid-fit .result-image-card img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.result-image-grid-曲线 .result-image-card img {
  aspect-ratio: 16 / 10;
  object-fit: contain;
}

.result-image-card span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-table-wrap {
  height: auto;
  max-height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.result-table th,
.result-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  white-space: nowrap;
}

.result-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #334e68;
  font-weight: 650;
}

.small-empty {
  padding: 16px;
}

.image-preview-dialog {
  width: min(1180px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 72px rgba(15, 23, 42, .26);
}

.image-preview-dialog::backdrop {
  background: rgba(15, 23, 42, .5);
}

.image-preview-dialog figure {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px;
}

.image-preview-dialog img {
  max-width: 100%;
  max-height: calc(100dvh - 96px);
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

.image-preview-dialog figcaption {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.image-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #334e68;
  font-size: 14px;
  line-height: 1;
  text-align: center;
}

.model-downloads {
  grid-column: auto;
  justify-content: flex-end;
}

.console-output {
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 8px;
  background: #101828;
  color: #d1fadf;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .train-head,
  .dialog-head,
  .dialog-actions {
    display: grid;
    align-items: stretch;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .result-image-grid {
    grid-template-columns: 1fr;
  }

  .model-layout {
    overflow: auto;
  }

  .model-results {
    overflow: visible;
  }
}
