:root {
  --bg: #08110f;
  --panel: #0d1815;
  --panel-2: #11201c;
  --line: rgba(201, 232, 221, 0.12);
  --line-strong: rgba(201, 232, 221, 0.22);
  --text: #eff8f4;
  --muted: #90a79f;
  --mint: #6ee7ba;
  --mint-strong: #33d39b;
  --mint-soft: rgba(110, 231, 186, 0.12);
  --red: #ff6d7a;
  --red-soft: rgba(255, 109, 122, 0.14);
  --amber: #ffc66d;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 48% 0%, rgba(57, 143, 111, 0.12), transparent 35%),
    var(--bg);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.hidden { display: none !important; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 17, 15, 0.88);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  overflow: hidden;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(110, 231, 186, 0.28), 0 8px 24px rgba(0, 0, 0, 0.22);
}

.brand-logo img {
  position: absolute;
  top: -21.5px;
  left: -74.5px;
  width: 186px;
  height: auto;
  max-width: none;
  display: block;
}

.brand strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.12em;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 14px var(--mint);
}

.divider {
  width: 1px;
  height: 16px;
  background: var(--line-strong);
  margin: 0 5px;
}

.workspace {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 302px minmax(420px, 1fr) 294px;
}

.sidebar, .result-panel {
  min-height: 0;
  background: rgba(13, 24, 21, 0.84);
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.new-case {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--line);
}

.section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.source-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 14px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
}

.source-tab {
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.source-tab.active {
  color: var(--text);
  background: var(--panel-2);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
}

.source-panel { display: none; }
.source-panel.active { display: block; }

.drop-zone {
  min-height: 154px;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px dashed rgba(110, 231, 186, 0.32);
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(110, 231, 186, 0.06), rgba(110, 231, 186, 0.015));
  text-align: center;
  cursor: pointer;
  transition: 160ms ease;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--mint);
  background: var(--mint-soft);
}

.drop-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--bg);
  background: var(--mint);
  font-size: 22px;
  line-height: 1;
}

.drop-zone strong { font-size: 13px; }
.drop-zone span:not(.drop-icon) { color: var(--muted); font-size: 11px; }
.drop-zone .file-limit { opacity: 0.7; }

.selected-file {
  margin-top: 10px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button, .secondary-button {
  width: 100%;
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  transition: 150ms ease;
}

.primary-button {
  margin-top: 12px;
  border: 1px solid var(--mint-strong);
  color: #06120e;
  background: var(--mint-strong);
  font-weight: 700;
  font-size: 12px;
}

.primary-button:hover:not(:disabled) { filter: brightness(1.08); }
.primary-button:disabled { cursor: not-allowed; opacity: 0.35; }

.secondary-button {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(255,255,255,0.025);
  font-size: 12px;
}

.secondary-button:hover { border-color: var(--mint); }

.server-list {
  max-height: 198px;
  margin: 10px 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.server-slide {
  width: 100%;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.server-slide:last-child { border-bottom: 0; }
.server-slide:hover, .server-slide.selected { background: var(--mint-soft); }
.server-slide strong, .server-slide span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-slide strong { font-size: 11px; }
.server-slide span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.server-slide .server-analysis {
  display: inline-block;
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  line-height: 1;
}
.server-slide .server-analysis.ready { color: var(--mint); border-color: rgba(97, 226, 178, .3); background: var(--mint-soft); }
.server-slide .server-analysis.processing,
.server-slide .server-analysis.queued { color: var(--amber); border-color: rgba(245, 188, 95, .3); }
.server-slide .server-analysis.failed { color: var(--red); border-color: rgba(255, 109, 122, .3); }
.server-slide .server-analysis.outdated { color: var(--amber); }

.empty-hint { padding: 8px 12px; color: var(--muted); font-size: 11px; text-align: center; }

.recent-section {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.job-list {
  min-height: 0;
  overflow: auto;
}

.job-item {
  width: 100%;
  margin-bottom: 6px;
  padding: 11px;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 9px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.job-item:hover, .job-item.active {
  border-color: var(--line);
  background: rgba(255,255,255,0.025);
}

.job-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.job-indicator.completed { background: var(--mint); }
.job-indicator.running, .job-indicator.queued { background: var(--amber); }
.job-indicator.failed { background: var(--red); }

.job-copy { min-width: 0; }
.job-copy strong, .job-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-copy strong { font-size: 11px; }
.job-copy span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.job-time { color: var(--muted); font-size: 9px; }

.viewer-shell {
  min-width: 0;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 44px 44px;
}

.empty-state, .progress-state {
  width: min(620px, 82%);
  height: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.eyebrow {
  color: var(--mint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.empty-state h1 {
  margin: 18px 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: -0.035em;
}

.empty-state p {
  max-width: 550px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.microscope-motif {
  width: 150px;
  height: 100px;
  margin-bottom: 25px;
  position: relative;
}

.cell {
  position: absolute;
  border: 1px solid rgba(110, 231, 186, 0.45);
  border-radius: 44% 56% 58% 42%;
  background: rgba(110, 231, 186, 0.06);
}

.cell::after {
  content: "";
  width: 8px;
  height: 8px;
  position: absolute;
  left: 45%;
  top: 42%;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 16px rgba(110, 231, 186, 0.7);
}

.cell-a { width: 66px; height: 56px; left: 16px; top: 24px; transform: rotate(-18deg); }
.cell-b { width: 48px; height: 44px; right: 10px; top: 7px; transform: rotate(28deg); }
.cell-c { width: 38px; height: 34px; right: 34px; bottom: 0; transform: rotate(-8deg); }

.focus-ring {
  width: 106px;
  height: 106px;
  position: absolute;
  left: 22px;
  top: -3px;
  border: 1px solid rgba(110, 231, 186, 0.16);
  border-radius: 50%;
  box-shadow: inset 0 0 50px rgba(110, 231, 186, 0.035);
}

.capability-row {
  margin-top: 34px;
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
}

.capability-row span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
}

.progress-state h2 { margin: 20px 0 8px; font-size: 24px; font-weight: 500; }
.progress-state p { max-width: 80%; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { width: min(460px, 90%); height: 5px; margin-top: 28px; overflow: hidden; border-radius: 5px; background: rgba(255,255,255,0.08); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--mint); box-shadow: 0 0 18px var(--mint); transition: width 400ms ease; }
.progress-meta { width: min(560px, 90%); margin-top: 10px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; color: var(--muted); font-size: 10px; }

.viewer-state { width: 100%; height: 100%; }

.viewer-toolbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 17, 15, 0.82);
}

.viewer-toolbar strong, .viewer-toolbar span { display: block; }
.viewer-toolbar strong { max-width: 360px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.viewer-toolbar span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.toolbar-actions { display: flex; gap: 5px; }
.toolbar-actions button {
  min-width: 32px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255,255,255,0.025);
  cursor: pointer;
  font-size: 10px;
}
.toolbar-actions button:hover, .toolbar-actions button.active { border-color: rgba(110,231,186,.4); color: var(--mint); background: var(--mint-soft); }

.slide-viewport {
  height: calc(100% - 58px);
  position: relative;
  overflow: hidden;
  background: #050807;
  touch-action: none;
}

#slide-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#slide-canvas.dragging { cursor: grabbing; }
.zoom-readout, .viewer-help {
  position: absolute;
  bottom: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(5,8,7,.76);
  font-size: 9px;
  pointer-events: none;
}
.zoom-readout { left: 13px; }
.viewer-help { right: 13px; }

.result-panel {
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  overflow: auto;
}

.result-empty { margin: auto 0; text-align: center; color: var(--muted); }
.result-placeholder {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--mint);
  font-family: Georgia, serif;
  font-size: 19px;
}
.result-empty p { font-size: 11px; line-height: 1.7; }

.result-content { margin-top: 18px; }
.result-provenance {
  margin-top: 10px;
  padding: 9px 10px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 9px;
}
.result-provenance strong { color: var(--text); font-size: 10px; }
.diagnosis-card {
  padding: 18px;
  border: 1px solid rgba(110, 231, 186, 0.24);
  border-radius: 12px;
  background: linear-gradient(145deg, var(--mint-soft), rgba(110, 231, 186, 0.025));
}
.diagnosis-card.malignant { border-color: rgba(255,109,122,.34); background: linear-gradient(145deg, var(--red-soft), rgba(255,109,122,.025)); }
.diagnosis-kicker, .diagnosis-card strong, .diagnosis-card span { display: block; }
.diagnosis-kicker { color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.diagnosis-card strong { margin-top: 10px; color: var(--mint); font-family: Georgia, "Noto Serif SC", serif; font-size: 29px; font-weight: 400; }
.diagnosis-card.malignant strong { color: var(--red); }
.diagnosis-card > span:last-child { margin-top: 5px; color: var(--muted); font-size: 10px; }

.metric-grid { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { min-height: 86px; padding: 13px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.018); }
.metric-wide { grid-column: 1 / -1; min-height: 72px; }
.metric span { color: var(--muted); font-size: 10px; }
.metric strong { font-family: Georgia, serif; font-size: 23px; font-weight: 400; }

.legend { margin: 18px 0; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 2; }
.legend-swatch { width: 10px; height: 10px; margin-right: 8px; display: inline-block; vertical-align: -1px; border-radius: 2px; }
.legend-swatch.malignant { background: rgba(255, 77, 94, .34); }
.legend-swatch.boundary { border: 1px solid #ff5262; }

.download-button { display: grid; place-items: center; text-decoration: none; }

.clinical-note {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.clinical-note strong { color: var(--amber); font-size: 10px; }
.clinical-note p { margin: 6px 0 0; font-size: 9px; line-height: 1.6; }

.toast {
  max-width: min(420px, calc(100vw - 40px));
  padding: 11px 15px;
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #14231f;
  box-shadow: var(--shadow);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { border-radius: 6px; background: rgba(144,167,159,.24); }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 270px 1fr; }
  .result-panel {
    width: 280px;
    height: calc(100vh - 126px);
    position: fixed;
    right: 12px;
    top: 80px;
    z-index: 8;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
  }
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .topbar-status span:not(.status-dot):not(#clock) { display: none; }
  .workspace { height: auto; min-height: calc(100vh - 68px); display: block; }
  .sidebar { min-height: auto; border-right: 0; }
  .recent-section { max-height: 260px; }
  .viewer-shell { height: 70vh; min-height: 520px; border-top: 1px solid var(--line); }
  .result-panel { width: auto; height: auto; position: static; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; }
  .viewer-help { display: none; }
  .empty-state h1 { font-size: 35px; }
}
