:root {
  --ink: #112b2d;
  --muted: #668082;
  --paper: #f4f7f3;
  --white: #ffffff;
  --mint: #dff2e9;
  --teal: #0d6967;
  --teal-dark: #084c4d;
  --coral: #f16d5a;
  --line: #d8e2de;
  --shadow: 0 22px 70px rgba(22, 62, 62, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 9%, rgba(169, 224, 207, 0.32), transparent 23rem),
    var(--paper);
  font-family: "DM Sans", sans-serif;
  min-height: 100vh;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.topbar {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 84px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(17, 43, 45, 0.09);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.11em;
  font-size: 0.84rem;
}

.brand strong { color: var(--teal); }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 47% 53% / 61% 42% 58% 39%;
  background: var(--teal);
  position: relative;
  rotate: -18deg;
}
.brand-mark::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--mint);
  border-radius: 50%;
  top: 5px;
  right: 5px;
}

.prototype-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--teal-dark);
  background: rgba(223, 242, 233, 0.7);
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
}
.prototype-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #25a573;
  box-shadow: 0 0 0 4px rgba(37, 165, 115, 0.12);
}

main { max-width: 1280px; margin: 0 auto; padding: 62px 28px 40px; }

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 70px;
  align-items: end;
  margin-bottom: 52px;
}

.eyebrow, .step, .card-kicker {
  margin: 0 0 12px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

h1 {
  max-width: 820px;
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2.6rem, 5.4vw, 5.2rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
  font-weight: 600;
}
h1 em { color: var(--teal); font-style: normal; }
.hero-copy {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.7;
  margin: 26px 0 0;
}

.model-summary { border-left: 1px solid var(--line); padding-left: 28px; }
.model-summary > div { display: flex; align-items: center; gap: 17px; padding: 15px 0; }
.model-summary > div + div { border-top: 1px solid var(--line); }
.model-summary span { color: var(--coral); font-family: "Fraunces", serif; font-size: 1.45rem; }
.model-summary p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 0.89rem; }
.model-summary strong { color: var(--ink); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  background: var(--white);
  border: 1px solid rgba(20, 70, 70, 0.08);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.upload-panel, .results-panel { padding: clamp(28px, 4vw, 52px); min-width: 0; }
.results-panel { background: #f8faf8; border-left: 1px solid var(--line); }
.section-heading { margin-bottom: 28px; }
.section-heading h2 { margin: 0; font-family: "Fraunces", serif; font-size: 1.75rem; }

.drop-zone {
  min-height: 360px;
  border: 1.5px dashed #a9c2bd;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(223, 242, 233, 0.35), rgba(255, 255, 255, 0.6));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--teal); background: var(--mint); transform: translateY(-2px); }
.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  font-size: 1.7rem;
}
.drop-title { font-weight: 700; font-size: 1.05rem; }
.drop-help { margin-top: 8px; color: var(--muted); font-size: 0.82rem; text-align: center; }

.preview-wrap { position: relative; border-radius: 18px; overflow: hidden; background: #071a1b; }
.preview-wrap img { width: 100%; height: 360px; display: block; object-fit: contain; }
.remove-image {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: rgba(0, 0, 0, 0.58);
  cursor: pointer;
  font-size: 1.35rem;
}
.file-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 18px 14px;
  color: white;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  font-size: 0.78rem;
}

.analyze-button {
  width: 100%;
  margin-top: 18px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  border: 0;
  border-radius: 12px;
  background: var(--teal);
  color: white;
  cursor: pointer;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}
.analyze-button:hover:not(:disabled) { background: var(--teal-dark); transform: translateY(-1px); }
.analyze-button:disabled { opacity: 0.38; cursor: not-allowed; }
.privacy-note { margin: 14px 4px 0; color: var(--muted); font-size: 0.72rem; line-height: 1.5; }

.empty-state, .loading-state {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}
.scan-illustration {
  width: 120px;
  height: 120px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: repeating-radial-gradient(circle, transparent 0 13px, rgba(13, 105, 103, 0.06) 14px 15px);
}
.scan-illustration span { width: 35px; height: 48px; border: 2px solid #80aaa2; border-radius: 53% 47% 50% 50%; rotate: 22deg; }
.empty-state p { max-width: 260px; font-size: 0.87rem; }

.loader { display: flex; gap: 8px; margin-bottom: 18px; }
.loader span { width: 11px; height: 11px; border-radius: 50%; background: var(--teal); animation: pulse 1s infinite alternate; }
.loader span:nth-child(2) { animation-delay: 180ms; }
.loader span:nth-child(3) { animation-delay: 360ms; }
@keyframes pulse { to { opacity: 0.25; transform: translateY(-8px); } }
.loading-state p { color: var(--ink); font-weight: 700; margin: 0 0 8px; }
.loading-state small { max-width: 330px; line-height: 1.5; }

.error-state { padding: 22px; border: 1px solid #f1b4aa; border-radius: 14px; background: #fff0ec; color: #833428; }
.error-state p { margin: 8px 0 0; font-size: 0.88rem; line-height: 1.5; }

.classification-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.classification-card h3, .segmentation-card h3 { margin: 0; font-family: "Fraunces", serif; font-size: 2rem; }
.confidence-ring {
  --confidence: 0deg;
  width: 92px;
  height: 92px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background: radial-gradient(circle closest-side, #f8faf8 78%, transparent 80% 99%), conic-gradient(var(--coral) var(--confidence), #dbe5e1 0);
}
.confidence-ring span { font-weight: 700; font-size: 1.08rem; }
.confidence-ring small { color: var(--muted); font-size: 0.64rem; }

.probability-list { margin: 28px 0 34px; display: grid; gap: 13px; }
.probability-row > div:first-child { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.77rem; }
.probability-row strong { color: var(--teal); }
.probability-track { height: 6px; background: #dfe7e4; border-radius: 99px; overflow: hidden; }
.probability-track span { display: block; height: 100%; background: var(--teal); border-radius: inherit; transition: width 500ms ease; }

.segmentation-card { padding-top: 30px; border-top: 1px solid var(--line); }
.card-title-row { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 17px; }
.card-title-row > p { text-align: right; margin: 0; font-size: 0.8rem; color: var(--muted); }
.card-title-row > p strong { color: var(--coral); font-size: 1.3rem; }
.segmentation-card > img { width: 100%; max-height: 380px; display: block; object-fit: contain; border-radius: 13px; background: #071a1b; }
.image-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.view-toggle, .image-actions a { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; background: transparent; color: var(--ink); text-decoration: none; cursor: pointer; font-size: 0.72rem; }
.view-toggle.active { color: white; background: var(--teal); border-color: var(--teal); }
.image-actions a { margin-left: auto; color: var(--teal); font-weight: 700; }
.inference-meta { margin: 18px 0 0; color: var(--muted); font-size: 0.7rem; text-align: right; }

.medical-warning {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 880px;
  margin: 28px auto 0;
  color: #785249;
}
.medical-warning > span { display: grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; background: #fee6df; font-weight: 700; }
.medical-warning p { margin: 0; font-size: 0.75rem; line-height: 1.55; }

footer { padding: 28px; color: var(--muted); text-align: center; font-size: 0.68rem; letter-spacing: 0.04em; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .model-summary { display: grid; grid-template-columns: 1fr 1fr; border-left: 0; padding-left: 0; }
  .model-summary > div { border-top: 1px solid var(--line); }
  .workspace { grid-template-columns: 1fr; }
  .results-panel { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .topbar { min-height: 70px; padding: 0 18px; }
  .prototype-badge { font-size: 0; padding: 10px; }
  main { padding: 40px 14px 24px; }
  h1 { font-size: 2.7rem; }
  .hero-copy { font-size: 0.92rem; }
  .model-summary { grid-template-columns: 1fr; }
  .workspace { border-radius: 18px; }
  .upload-panel, .results-panel { padding: 26px 20px; }
  .drop-zone, .preview-wrap img { min-height: 270px; height: 270px; }
  .classification-card h3, .segmentation-card h3 { font-size: 1.6rem; }
  .image-actions a { width: 100%; margin: 4px 0 0; text-align: center; }
}

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