:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --panel: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d5d9e0;
  --text: #1f2329;
  --muted: #8a9099;
  --primary: #4f6bff;
  --primary-dark: #3d55d6;
  --primary-soft: #eef1ff;
  --good: #2f9e6f;
  --good-soft: #e9f7f0;
  --bad: #e05a5a;
  --bad-soft: #fdeeee;
  --shadow: 0 12px 32px rgba(31, 35, 41, 0.07);
  --sidebar-w: 268px;
  --sidebar-collapsed: 76px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: flex;
  height: 100vh;
  min-height: 620px;
  overflow: hidden;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: #fafbfc;
  border-right: 1px solid var(--border);
  transition: width 0.22s ease, flex-basis 0.22s ease;
}

.app.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
  flex-basis: var(--sidebar-collapsed);
}

.sidebar-head {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--border);
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  background: linear-gradient(135deg, #6c86ff, #4058e6);
  box-shadow: 0 4px 10px rgba(79, 107, 255, 0.28);
}

.brand-name {
  font-weight: 650;
  font-size: 15px;
  white-space: nowrap;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: background 0.16s ease, color 0.16s ease;
}

.icon-btn:hover {
  background: #eef0f4;
  color: var(--text);
}

.app.sidebar-collapsed .brand-name,
.app.sidebar-collapsed .section-title,
.app.sidebar-collapsed .new-run span,
.app.sidebar-collapsed .history-text,
.app.sidebar-collapsed .sidebar-foot span:last-child {
  display: none;
}

.app.sidebar-collapsed .sidebar-head {
  justify-content: center;
  padding: 0;
  gap: 8px;
}

.app.sidebar-collapsed .collapse-btn {
  display: none;
}

.sidebar-section {
  padding: 18px 14px 12px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #eef0f4;
  color: #6b7280;
  display: grid;
  place-items: center;
  font-size: 11px;
  letter-spacing: 0;
}

.new-run {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 550;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.new-run:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 107, 255, 0.1);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  transition: background 0.16s ease;
  cursor: default;
}

.history-item:hover {
  background: #f0f2f6;
}

.history-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}

.history-dot.good {
  background: var(--good);
}

.history-dot.bad {
  background: var(--bad);
}

.history-text {
  min-width: 0;
}

.history-name {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app.sidebar-collapsed .history-item {
  justify-content: center;
  padding: 12px 0;
}

.app.sidebar-collapsed .history-dot {
  width: 10px;
  height: 10px;
  flex-basis: 10px;
}

.sidebar-foot {
  height: 48px;
  flex: 0 0 48px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 11px;
}

.app.sidebar-collapsed .sidebar-foot {
  justify-content: center;
  padding: 0;
}

.foot-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b8bec8;
}

/* ---------------- Main / Topbar ---------------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.menu-btn {
  display: grid;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-label {
  font-size: 12px;
  color: var(--muted);
}

.select-wrap {
  position: relative;
}

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  min-width: 210px;
  padding: 0 36px 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.select-wrap select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 107, 255, 0.12);
}

.select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.ensemble-badge {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.ensemble-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f0f2f6;
  color: #5b6270;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

/* ---------------- Content ---------------- */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 7vh 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero {
  width: 100%;
  max-width: 760px;
  text-align: center;
  margin-bottom: 28px;
}

.hero-badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.hero-title {
  margin: 14px 0 8px;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -1.4px;
  font-weight: 720;
}

.hero-sub {
  margin: 0;
  color: #606873;
  font-size: 14px;
  line-height: 1.6;
}

.hero-sub strong {
  color: var(--text);
  font-weight: 650;
}

.upload-card {
  width: 100%;
  max-width: 760px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  box-shadow: var(--shadow);
  padding: 40px 32px 34px;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.upload-card.dragover {
  border-color: var(--primary);
  background: #f7f9ff;
  transform: translateY(-2px);
}

.upload-icon {
  margin-bottom: 14px;
}

.upload-title {
  font-size: 17px;
  font-weight: 650;
}

.upload-sub {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12.5px;
}

.browse-btn {
  margin-top: 20px;
  height: 36px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  transition: border-color 0.16s ease, color 0.16s ease;
}

.browse-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.pipeline {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  padding: 5px 9px;
  border-radius: 7px;
  background: #f1f3f7;
  color: #626a76;
  font-size: 11px;
  font-weight: 550;
}

.chip.accent {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.arrow,
.plus {
  color: #aeb4bd;
  font-size: 12px;
}

.selected-file {
  margin: 20px auto 0;
  max-width: 460px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.file-icon {
  display: grid;
  place-items: center;
}

.file-name {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clear-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
}

.clear-btn:hover {
  color: var(--bad);
}

.run-btn {
  margin-top: 18px;
  height: 40px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(79, 107, 255, 0.24);
  transition: background 0.16s ease, transform 0.16s ease;
}

.run-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ---------------- Result ---------------- */

.result-card {
  width: 100%;
  max-width: 760px;
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.result-head {
  height: 44px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-tag {
  padding: 2px 7px;
  border-radius: 5px;
  background: #f1f3f7;
  color: #868d97;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-model {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary-dark);
}

.result-body {
  padding: 22px 20px 20px;
}

.verdict {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.verdict.good {
  color: var(--good);
}

.verdict.bad {
  color: var(--bad);
}

.confidence {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.confidence-bar {
  margin-top: 14px;
  height: 6px;
  border-radius: 999px;
  background: #eef0f4;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.5s ease;
}

.vote-summary {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
}

.verdict-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.feedback-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-feedback {
  margin-top: 14px;
}

.feedback-hint {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.fb-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: var(--panel);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fb-correct {
  color: var(--good);
}

.fb-wrong {
  color: var(--bad);
}

.fb-btn:hover {
  border-color: currentColor;
}

.fb-btn.active.fb-correct {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

.fb-btn.active.fb-wrong {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.result-meta {
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
}

/* ---------------- Assets / Preview modal ---------------- */

.asset-row {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.asset {
  flex: 1;
  min-width: 150px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.asset-label {
  flex: 1;
  font-size: 11.5px;
  font-weight: 650;
  color: #5b6270;
}

.asset-preview-btn,
.asset-download-btn {
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  color: #5b6270;
  padding: 4px 8px;
  font-size: 10.5px;
}

.asset-preview-btn:hover,
.asset-download-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.history-item.clickable {
  cursor: pointer;
}

.history-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.history-detail-title {
  font-size: 15px;
  font-weight: 650;
  word-break: break-all;
}

.history-detail-meta {
  color: var(--muted);
  font-size: 11.5px;
  margin-bottom: 14px;
}

.history-detail-image {
  display: block;
  max-width: 100%;
  max-height: 54vh;
  margin: 0 auto 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

#previewModal {
  z-index: 60;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 35, 41, 0.42);
}

.modal-panel {
  position: relative;
  width: min(900px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(31, 35, 41, 0.22);
  overflow: hidden;
}

.modal-head {
  height: 50px;
  flex: 0 0 50px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 650;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover {
  background: #f0f2f6;
  color: var(--text);
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background: #fafbfc;
}

.modal-body img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.modal-body pre {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #3b4250;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 68vh;
  overflow: auto;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 980px) {
  .sidebar {
    width: var(--sidebar-collapsed);
    flex-basis: var(--sidebar-collapsed);
  }
  .brand-name,
  .section-title,
  .new-run span,
  .history-text,
  .sidebar-foot span:last-child {
    display: none;
  }
  .sidebar-head {
    justify-content: center;
    padding: 0;
  }
  .collapse-btn {
    display: none;
  }
  .history-item {
    justify-content: center;
    padding: 12px 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 14px;
  }
  .model-label {
    display: none;
  }
  .select-wrap select {
    min-width: 150px;
  }
  .content {
    padding: 5vh 16px 40px;
  }
  .hero-title {
    font-size: 36px;
  }
  .upload-card {
    padding: 32px 18px 28px;
  }
}
