:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #647087;
  --border: #dfe4ec;
  --accent: #2857a4;
  --accent-soft: #eaf1ff;
  --danger-bg: #fff5e8;
  --danger-border: #f0c98a;
  --danger-text: #6b4500;
  --bar-bg: #e8ecf2;
  --shadow: 0 10px 30px rgba(25, 42, 70, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --panel: #151e2c;
    --text: #edf2fa;
    --muted: #a8b3c5;
    --border: #2a3649;
    --accent: #8db6ff;
    --accent-soft: #1d3154;
    --danger-bg: #332919;
    --danger-border: #695126;
    --danger-text: #ffd993;
    --bar-bg: #273247;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

/*
 * Important:
 * elements carrying the HTML `hidden`
 * attribute must remain hidden even if
 * another class sets display:grid/flex.
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.06;
}

h2 {
  margin: 0 0 18px;
  font-size: 1.05rem;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.status {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--panel);
}

.status-ready {
  color: #167047;
  border-color: #77c8a4;
}

.status-error {
  color: #b23b3b;
  border-color: #d99090;
}

.notice,
.deployment-note {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.notice {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}

.deployment-note {
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.grid {
  display: grid;
  grid-template-columns:
    minmax(0, 0.95fr)
    minmax(0, 1.05fr);
  gap: 18px;
  margin-top: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 310px;
  overflow: hidden;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: var(--bg);
}

.dropzone:hover {
  border-color: var(--accent);
}

.dropzone input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.dropzone img {
  width: 100%;
  height: 310px;
  object-fit: contain;
}

#dropPrompt {
  text-align: center;
  padding: 28px;
}

.upload-title {
  display: block;
  font-weight: 750;
  margin-bottom: 6px;
}

.upload-copy {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

button {
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

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

.small-status {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 10px 2px 0;
}

.empty-result {
  min-height: 310px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.prediction-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.muted-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 5px;
}

.predicted-class {
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  font-weight: 800;
}

.confidence-box {
  text-align: right;
}

.confidence {
  font-size: 1.55rem;
  font-weight: 800;
}

.probabilities {
  margin-top: 16px;
  display: grid;
  gap: 11px;
}

.prob-row {
  display: grid;
  grid-template-columns: 128px 1fr 58px;
  gap: 10px;
  align-items: center;
}

.prob-name {
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.prob-track {
  height: 9px;
  border-radius: 999px;
  background: var(--bar-bg);
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.prob-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.branch-card,
.technical-card {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.formula {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.branch {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px;
}

.branch strong {
  display: block;
  font-size: 1rem;
}

.branch-confidence {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 5px;
}

details summary {
  cursor: pointer;
  font-weight: 750;
}

.technical-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns:
    repeat(3, 1fr);
  gap: 10px;
}

.technical-grid > div {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.technical-grid span,
.technical-grid strong {
  display: block;
}

.technical-grid span {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.technical-grid strong {
  font-size: 0.87rem;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1080px);
    padding-top: 22px;
  }

  .hero {
    flex-direction: column;
  }

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

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

  .section-heading {
    display: block;
  }

  .formula {
    display: block;
    margin: -9px 0 16px;
  }

  .prob-row {
    grid-template-columns: 108px 1fr 52px;
  }
}