/* ============================================================
   Anatomask — 腹部解剖结构智能分割平台
   Light clinical theme
   ============================================================ */

:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface-dim: #f7f9fc;
  --border:      #e2e8f0;
  --border-mid:  #cbd5e1;
  --ink:         #0f172a;
  --ink-mid:     #334155;
  --ink-soft:    #64748b;
  --ink-faint:   #94a3b8;
  --accent:      #1d6fce;
  --accent-dark: #1558a8;
  --accent-soft: #eff6ff;
  --accent-mid:  #bfdbfe;
  --green:       #16a34a;
  --green-soft:  #f0fdf4;
  --amber:       #b45309;
  --amber-soft:  #fffbeb;
  --shadow-sm:   0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.05);
  --shadow-md:   0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:   0 10px 32px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.05);
  --radius:      10px;
  --radius-lg:   14px;
  --radius-xl:   18px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ─────────────────────────────────────────────── */

.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar__logo-img {
  height: 56px;
  width: auto;
  display: block;
  object-fit: contain;
}

.topbar__brand-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.2;
}

.topbar__name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.topbar__tagline {
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: background 150ms, color 150ms;
}

.github-link:hover {
  background: var(--surface-dim);
  color: var(--ink);
}

.github-link__icon {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  opacity: 0.7;
}

.github-link:hover .github-link__icon {
  opacity: 1;
}

.github-link__label {
  line-height: 1;
}

.topbar__indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,.2);
}

.status-label {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 500;
}

/* ── Workspace ───────────────────────────────────────────── */

.workspace {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Guide banner ────────────────────────────────────────── */

.guide-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.guide-steps {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.guide-step {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
  min-width: 120px;
}

.guide-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.guide-step__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.guide-step__text strong {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.guide-step__text span {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.guide-arrow {
  color: var(--border-mid);
  font-size: 1rem;
  flex-shrink: 0;
  padding: 0 0.1rem;
}

/* ── Step row ────────────────────────────────────────────── */

.step-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ── Panel ───────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.panel--full { width: 100%; }

.panel__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem 0;
}

.panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.panel__body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel__body--result {
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* ── Token row ───────────────────────────────────────────── */

.token-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.token-row__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-mid);
}

.token-row__controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

/* ── Token input ─────────────────────────────────────────── */

.token-input {
  height: 38px;
  padding: 0 0.75rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 150ms, box-shadow 150ms;
  width: 100%;
}

.token-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,111,206,.12);
}

.token-input::placeholder { color: var(--ink-faint); }

/* ── Dropzone ────────────────────────────────────────────── */

.dropzone {
  position: relative;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--radius-lg);
  background: var(--surface-dim);
  cursor: pointer;
  transition: border-color 150ms, background 150ms, box-shadow 150ms;
  text-align: center;
  padding: 1.5rem;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(29,111,206,.08);
}

.dropzone__icon { color: var(--ink-faint); transition: color 150ms; }
.dropzone:hover .dropzone__icon,
.dropzone.dragover .dropzone__icon { color: var(--accent); }

.dropzone__text {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-mid);
}

.dropzone__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* ── Buttons ─────────────────────────────────────────────── */

.primary-action,
.secondary-action,
.download-btn {
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 150ms, transform 120ms, box-shadow 150ms, opacity 150ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-action {
  width: 100%;
  height: 40px;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  box-shadow: 0 1px 3px rgba(29,111,206,.3);
}

.primary-action:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(29,111,206,.35);
}

.primary-action:disabled {
  background: var(--border);
  color: var(--ink-faint);
  box-shadow: none;
  cursor: not-allowed;
}

.secondary-action {
  height: 38px;
  padding: 0 0.875rem;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.8rem;
  border: 1px solid var(--accent-mid);
  white-space: nowrap;
}

.secondary-action:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.download-btn {
  height: 44px;
  padding: 0 1.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(29,111,206,.3);
  flex-shrink: 0;
}

.download-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(29,111,206,.4);
}

/* ── Job table ───────────────────────────────────────────── */

.job-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.job-table th,
.job-table td {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.job-table tr:last-child th,
.job-table tr:last-child td { border-bottom: none; }

.job-table th {
  width: 80px;
  color: var(--ink-soft);
  font-weight: 500;
  white-space: nowrap;
  padding-right: 1rem;
}

.job-table td {
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ── Progress bar ────────────────────────────────────────── */

.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 300ms ease;
}

/* ── Status message ──────────────────────────────────────── */

.status-message {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ── Stats grid ──────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.stat-card {
  background: var(--surface-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-card__label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card__value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}

/* ── Restore hint ────────────────────────────────────────── */

.restore-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ── Download stage ──────────────────────────────────────── */

.download-stage { flex: 1; min-width: 0; }

.download-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex-shrink: 0;
}

.result-stage__title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.result-stage__body {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 72ch;
}

/* ── Scope card ──────────────────────────────────────────── */

.scope-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.scope-card__inner {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0;
}

.scope-card__left {
  padding: 1.5rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  justify-content: center;
}

.scope-card__eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.scope-card__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.scope-card__body {
  margin: 0;
  font-size: 0.83rem;
  color: var(--ink-soft);
  line-height: 1.65;
}

.scope-card__right {
  padding: 1.5rem;
}

.scope-card__structures-label {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.scope-card__structures {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.4rem 0.75rem;
}

.scope-card__structures li {
  font-size: 0.83rem;
  color: var(--ink-mid);
  padding: 0.3rem 0.6rem;
  background: var(--surface-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 500;
}

/* ── Modal ───────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.modal--open {
  display: grid;
  place-items: center;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(4px);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 2rem), 440px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 0;
}

.modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 150ms, color 150ms;
  flex-shrink: 0;
}

.modal__close:hover { background: var(--surface-dim); color: var(--ink); }

.modal__body {
  padding: 1rem 1.25rem 1.5rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.7;
}

.modal__body p { margin: 0 0 0.75rem; }
.modal__body p:last-child { margin-bottom: 0; }
.modal__body a { color: var(--accent); font-weight: 600; text-decoration: none; }
.modal__body a:hover { text-decoration: underline; }

/* ── Focus ───────────────────────────────────────────────── */

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 860px) {
  .scope-card__inner {
    grid-template-columns: 1fr;
  }
  .scope-card__left {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 768px) {
  .step-row { grid-template-columns: 1fr; }

  .panel__body--result {
    flex-direction: column;
    align-items: flex-start;
  }

  .guide-steps { gap: 0.4rem; }
  .guide-arrow { display: none; }
  .guide-step { min-width: calc(50% - 0.4rem); }

  .topbar__tagline { display: none; }
  .github-link__label { display: none; }
}

@media (max-width: 480px) {
  .workspace { padding: 1rem 1rem 2rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .token-row__controls { grid-template-columns: 1fr; }
  .guide-step { min-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
