:root {
  color-scheme: light;
  --bg: #edf1f3;
  --surface: #ffffff;
  --surface-soft: #f5f7f8;
  --surface-strong: #e8eff1;
  --text: #172327;
  --muted: #65767d;
  --line: #d5dee2;
  --primary: #0b6b68;
  --primary-strong: #084f4d;
  --primary-soft: #dff2ef;
  --accent: #365f8f;
  --accent-soft: #e7eef7;
  --warn: #a76300;
  --warn-soft: #fff2d9;
  --danger: #b42318;
  --danger-soft: #fde7e4;
  --ok: #117a41;
  --ok-soft: #ddf3e6;
  --shadow: 0 14px 36px rgba(23, 35, 39, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f6faf9 100%);
}

.app-header h1,
.panel-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 24px;
  line-height: 1.25;
}

.app-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 138px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.status-pill.ready {
  border-color: #a8dbc7;
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill.error {
  border-color: #efb5ad;
  background: var(--danger-soft);
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(540px, 1.05fr);
  gap: 18px;
  align-items: start;
  padding: 18px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.image-panel {
  position: sticky;
  top: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  font-size: 18px;
}

.panel-header span {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.drop-zone {
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 76px;
  align-content: center;
  border: 1.5px dashed #8bb7b4;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--primary);
  background: #d3eeeb;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  font-size: 16px;
  font-weight: 700;
}

.drop-meta {
  color: var(--muted);
  font-size: 13px;
}

.primary-button {
  min-width: 0;
  min-height: 76px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.primary-button:disabled {
  background: #9aabaa;
  cursor: not-allowed;
}

.image-workbench {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
}

.preview-box {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 360px;
  max-height: 56vh;
  overflow: hidden;
  border: 1px solid #1c2a2f;
  border-radius: 8px;
  background: #101719;
}

.preview-box img {
  display: block;
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
}

.preview-empty {
  color: #9dafb5;
  font-size: 15px;
}

.image-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 2px;
}

.image-list-empty {
  display: grid;
  place-items: center;
  min-height: 84px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
}

.image-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.image-item:hover {
  border-color: #8fb6c7;
  background: #f8fbfc;
}

.image-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.thumb {
  display: block;
  width: 76px;
  height: 64px;
  overflow: hidden;
  border-radius: 6px;
  background: #101719;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-meta {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.image-meta strong {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-meta span {
  color: var(--muted);
  font-size: 12px;
}

.image-status {
  max-width: 150px;
  border-radius: 999px;
  padding: 5px 9px;
  overflow: hidden;
  background: #e8eef0;
  color: #34464d;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-status.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.image-status.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.image-status.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.results-panel {
  min-height: 640px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 520px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.result-detail {
  padding: 16px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.file-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  word-break: break-all;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  background: #e8eef0;
  color: #34464d;
  font-size: 13px;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
}

.metric span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.25;
}

.section {
  padding: 0 14px 14px;
}

.section h3 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: 0;
}

.recommendation {
  margin: 0;
  border-left: 4px solid var(--primary);
  border-radius: 4px;
  padding: 10px 12px;
  background: var(--primary-soft);
  line-height: 1.55;
}

.state-card .section {
  padding-top: 14px;
}

.state-message {
  margin: 0;
  color: var(--muted);
}

.disease-list,
.evidence-list {
  display: grid;
  gap: 8px;
}

.disease-row,
.evidence-row {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

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

.disease-row-head strong,
.evidence-row-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.probability-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe4e7;
}

.probability-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.error-box {
  border: 1px solid #efb5ad;
  border-radius: 8px;
  padding: 14px;
  background: var(--danger-soft);
  color: var(--danger);
}

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

  .image-panel {
    position: static;
  }

  .preview-box {
    min-height: 300px;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 16px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }

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

  .primary-button {
    min-height: 44px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-item {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .thumb {
    width: 68px;
    height: 58px;
  }

  .image-status {
    grid-column: 2;
    width: fit-content;
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .result-top,
  .disease-row-head,
  .evidence-row-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .badges {
    justify-content: flex-start;
  }
}
