:root {
  --blue-900: #163b66;
  --blue-800: #174ea6;
  --blue-700: #1f6feb;
  --blue-600: #2f7df1;
  --blue-100: #eaf2ff;
  --blue-050: #f4f8fd;
  --ink: #172235;
  --text: #1f2d3d;
  --muted: #60748c;
  --border: #cfdced;
  --border-strong: #b8c9e2;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --warning-bg: #fff3cd;
  --warning-text: #765400;
  --danger: #9d3b00;
  --shadow: 0 10px 28px rgba(31, 111, 235, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(31, 111, 235, 0.10), transparent 320px),
    var(--blue-050);
  font-family: Arial, "Noto Sans CJK SC", sans-serif;
  letter-spacing: 0;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 30px;
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 18px;
  background:
    radial-gradient(circle at 8% 12%, rgba(255, 255, 255, 0.24), transparent 28%),
    linear-gradient(135deg, #0f3b68 0%, #1769a6 48%, #14a6a6 100%);
  box-shadow: 0 18px 42px rgba(15, 59, 104, 0.22);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto -80px -120px auto;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  border: 34px solid rgba(255, 255, 255, 0.10);
}

.topbar > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1 {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.2;
}

.topbar h1 {
  color: white;
  font-size: 36px;
  letter-spacing: -0.02em;
}

.topbar-subtitle {
  max-width: 680px;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
  line-height: 1.55;
}

.status-pill,
.button,
button {
  border: 0;
  border-radius: 7px;
  background: var(--blue-700);
  color: white;
  min-height: 44px;
  padding: 11px 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.button:hover,
button:hover {
  background: var(--blue-600);
  box-shadow: 0 8px 18px rgba(31, 111, 235, 0.22);
}

.button:active,
button:active {
  transform: translateY(1px);
}

.button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.22);
  outline-offset: 2px;
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.16);
  color: white;
  backdrop-filter: blur(10px);
  cursor: default;
  box-shadow: none;
}

.status-pill:hover {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.button {
  display: inline-block;
  text-align: center;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.panel.compact {
  padding: 14px 18px;
}

.panel-title {
  color: var(--blue-800);
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
}

.panel-subtitle {
  color: var(--blue-800);
  font-size: 16px;
  font-weight: 800;
  margin: 18px 0 10px;
}

.seg-preview {
  margin-top: 16px;
  padding-top: 4px;
}

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

.analysis-card {
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #101516;
}

.analysis-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.analysis-card img {
  display: block;
  width: 100%;
  height: 330px;
  object-fit: contain;
  background: white;
}

.batch-overview-gallery {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.batch-overview-gallery .analysis-card {
  display: flex;
  flex-direction: column;
  background: white;
}

.batch-overview-gallery .analysis-card:first-child,
.batch-overview-gallery .analysis-card:last-child:nth-child(odd) {
  grid-column: auto;
}

.batch-overview-gallery .analysis-card img {
  height: clamp(260px, 24vw, 340px);
  object-fit: contain;
  background: white;
}

.batch-overview-gallery .analysis-card figcaption {
  margin-top: auto;
  min-height: 104px;
}

.analysis-card figcaption {
  display: grid;
  gap: 4px;
  min-height: 72px;
}

.analysis-card figcaption strong,
.analysis-card figcaption span {
  display: block;
}

.analysis-card figcaption span {
  color: #d8e5f5;
  line-height: 1.4;
}

.analysis-note {
  margin-top: 12px;
  border-left: 4px solid #e1ae25;
  border-radius: 6px;
  padding: 11px 13px;
  color: #624b0d;
  background: #fff8df;
  line-height: 1.55;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric-strip div {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 11px;
  background: var(--surface-soft);
}

.metric-strip span,
.metric-strip strong {
  display: block;
}

.metric-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-strip strong {
  margin-top: 5px;
  color: var(--ink);
}

.probability-panel {
  margin-top: 18px;
  padding: 2px 0 4px;
}

.probability-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(180px, 2fr) 64px;
  gap: 12px;
  align-items: center;
  margin: 9px 0;
}

.probability-row > span {
  color: var(--ink);
  font-weight: 700;
}

.probability-row > strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.probability-track {
  height: 16px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #edf3fb;
}

.probability-track i {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--blue-700);
}

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

label {
  display: grid;
  gap: 6px;
  color: #4d637c;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  font: inherit;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #9bb5d8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.10);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.file-upload {
  cursor: pointer;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker {
  display: grid;
  gap: 4px;
  min-height: 56px;
  border: 1px dashed var(--blue-700);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f7fbff;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.file-upload:hover .file-picker {
  border-color: var(--blue-600);
  background: #eef6ff;
  box-shadow: 0 8px 18px rgba(31, 111, 235, 0.10);
}

.file-picker-title {
  color: var(--blue-800);
  font-size: 15px;
  font-weight: 800;
}

.file-picker-hint,
.selected-file-summary,
.selected-file-list {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.selected-file-summary {
  margin-top: 2px;
}

.selected-file-list {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.wide {
  grid-column: span 3;
}

.sample-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.preview {
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #101516;
}

.preview img {
  display: block;
  width: 100%;
  height: 300px;
  object-fit: contain;
}

figcaption {
  padding: 9px 11px;
  color: white;
  font-size: 13px;
  overflow-wrap: anywhere;
  background: rgba(8, 15, 24, 0.92);
}

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

.facts div {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px;
  min-height: 72px;
  background: var(--surface-soft);
}

.facts span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.facts strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.batch-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.batch-summary div {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px;
  background: var(--surface-soft);
}

.batch-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.batch-summary strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
}

.batch-table {
  font-size: 14px;
}

.mini-link {
  display: inline-block;
  margin: 2px 4px 2px 0;
  color: var(--blue-800);
  font-weight: 700;
  text-decoration: none;
}

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

.key-preview-card {
  margin: 12px 0 18px;
}

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

.warn {
  color: var(--danger);
}

table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  border: 1px solid var(--border);
  padding: 9px 11px;
  text-align: left;
}

th {
  background: var(--blue-100);
  color: var(--blue-900);
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.error {
  border: 1px solid #efb4b4;
  border-left: 4px solid #c74444;
  border-radius: 7px;
  background: #fff3f3;
  color: #8b2323;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-weight: 700;
}

@media (max-width: 760px) {
  main {
    padding: 16px 14px 28px;
  }

  .topbar,
  .split,
  .grid-form,
  .sample-form,
  .facts,
  .batch-summary,
  .preview-pair,
  .analysis-gallery,
  .metric-strip {
    grid-template-columns: 1fr;
    display: grid;
  }

  .analysis-card img {
    height: 260px;
  }

  .analysis-card:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .probability-row {
    grid-template-columns: 1fr 56px;
  }

  .probability-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .wide {
    grid-column: span 1;
  }

  h1 {
    font-size: 24px;
  }

  .status-pill,
  .button,
  button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
