:root {
  --bg: #ffffff;
  --surface: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-hover: #0d6460;
  --accent-light: #f0fdf9;
  --accent-bar: #14b8a6;
  --error: #dc2626;
  --font: "Figtree", sans-serif;
  --mono: "JetBrains Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */

.header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.brand-sep {
  color: var(--border);
  font-weight: 300;
  font-size: 1rem;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  line-height: 1;
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.meta-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.05);
  transform: translateY(-0.5px);
}

.meta-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Main layout ── */

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 3rem;
  display: grid;
  gap: 1rem;
}

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

/* ── Card ── */

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

.card-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details.card>summary.card-header--toggle {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

details.card>summary.card-header--toggle::-webkit-details-marker {
  display: none;
}

.toggle-chevron {
  color: var(--muted);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

details.card[open]>summary .toggle-chevron {
  transform: rotate(0deg);
}

details.card:not([open])>summary .toggle-chevron {
  transform: rotate(-90deg);
}

details.card:not([open])>summary.card-header--toggle {
  border-bottom: none;
}

h2 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ── Form ── */

.form {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
}

select,
input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

select:focus,
input[type="number"]:focus {
  border-color: var(--accent);
}

/* ── Dropzone ── */

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  cursor: pointer;
  text-align: center;
  padding: 1.25rem;
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  outline: none;
}

.dropzone-icon {
  color: #d1d5db;
  margin-bottom: 0.1rem;
}

.dropzone p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text);
}

.dropzone-link {
  color: var(--accent);
  font-weight: 600;
}

.dropzone small {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Preview ── */

.preview-wrap {
  display: inline-block;
  align-self: flex-start;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

#upload-preview {
  width: auto;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  background: #fff;
}

#file-name {
  margin: 0;
  padding: 0.45rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ── Button ── */

button {
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: scale(0.99);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Latency ── */

.latency {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.18rem 0.5rem;
}

/* ── Result ── */

.result {
  position: relative;
  padding: 1.25rem;
  min-height: 280px;
  display: flex;
  flex-direction: column;
}

.result-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.result-empty p {
  margin: 0;
}

.result-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.result-top {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.result-class {
  margin: 0 0 0.2rem;
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.1;
  text-transform: capitalize;
  letter-spacing: -0.02em;
}

.result-confidence {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.result-loading {
  position: absolute;
  inset: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  justify-content: center;
}

.result--loading .result-empty,
.result--loading .result-content,
.result--loading .error {
  visibility: hidden;
}

.skeleton {
  background: linear-gradient(100deg, #e5e7eb 12%, #f3f4f6 35%, #e5e7eb 60%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s linear infinite;
  border-radius: 5px;
}

.result-skeleton-title {
  width: 48%;
  height: 28px;
}

.result-skeleton-subtitle {
  width: 65%;
  height: 12px;
  margin-bottom: 0.45rem;
}

.result-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.result-skeleton-row {
  display: flex;
  justify-content: space-between;
}

.result-skeleton-label {
  width: 28%;
  height: 11px;
}

.result-skeleton-value {
  width: 20%;
  height: 11px;
}

.result-skeleton-bar {
  width: 100%;
  height: 3px;
  border-radius: 2px;
}

@keyframes skeleton-shimmer {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* ── Top-K bars ── */

.topk-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.topk-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.topk-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.topk-name {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: capitalize;
  color: var(--text);
}

.topk-pct {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.topk-bar-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.topk-bar {
  height: 100%;
  background: var(--accent-bar);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Error ── */

.error {
  margin: 0.75rem 0 0;
  color: var(--error);
  font-family: var(--mono);
  font-size: 0.78rem;
}

/* ── Reports ── */

.reports-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
}

.reports-col {
  padding: 1.25rem;
}

.reports-col+.reports-col {
  border-left: 1px solid var(--border);
}

.col-label {
  margin: 0 0 0.65rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: var(--mono);
}

.metrics-container {
  overflow: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.75rem 1rem;
}

.metrics-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.metrics-table thead th {
  padding: 0.55rem 0.85rem;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: right;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
}

.metrics-table thead th:first-child {
  text-align: left;
  border-radius: 6px 0 0 0;
}

.metrics-table thead th:last-child {
  border-radius: 0 6px 0 0;
}

.metrics-table tbody td {
  padding: 0.65rem 0.85rem;
  font-size: 0.78rem;
  text-align: right;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.metrics-table tbody td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.metrics-table tbody tr:last-child td {
  border-bottom: none;
}

.metrics-table tbody tr:hover td {
  background: var(--accent-light);
}

.metrics-table .model-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.metrics-table .model-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.metrics-table .model-dot--best {
  background: var(--accent);
}

.metrics-table .model-dot--other {
  background: var(--border);
}

.metrics-table .metric-val {
  font-size: 0.8rem;
  font-weight: 500;
}

.metrics-table .metric-val--best {
  color: var(--accent);
  font-weight: 700;
}

.metrics-table .metric-unit {
  font-size: 0.65rem;
  color: var(--muted);
  margin-left: 0.1rem;
}

.report-figure {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  display: block;
}

.figure-caption {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Info section ── */

.info-card {
  overflow: visible;
}

.info-body {
  padding: 1rem 1.25rem 1.2rem;
}

.info-body p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.info-lead {
  font-weight: 500;
}

.info-list {
  margin: 0.65rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.4rem;
}

.info-list li {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
}

.info-list strong {
  font-family: var(--mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.info-tip {
  margin-top: 0.8rem !important;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border);
}

.info-tip a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.info-tip a:hover {
  text-decoration: underline;
}

/* ── Stagger animation ── */

.stagger {
  opacity: 0;
  animation: fadein 350ms ease forwards;
}

.stagger:nth-child(1) {
  animation-delay: 0ms;
}

.stagger:nth-child(2) {
  animation-delay: 70ms;
}

@keyframes fadein {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive ── */

@media (max-width: 860px) {

  .grid,
  .reports-grid {
    grid-template-columns: 1fr;
  }

  .reports-col+.reports-col {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .main {
    padding: 1rem 1rem 2rem;
  }

  .header-meta {
    display: none;
  }
}