:root {
  color-scheme: light;
  --ink: #14202d;
  --ink-strong: #07121f;
  --muted: #607086;
  --soft-text: #8190a3;
  --line: #d8e2ec;
  --line-strong: #bdcad8;
  --panel: #ffffff;
  --panel-soft: #f8fbfd;
  --wash: #eef5f2;
  --nav: rgba(255, 255, 255, 0.9);
  --viewer: #101723;
  --viewer-grid: rgba(255, 255, 255, 0.055);
  --blue: #1d9bf0;
  --blue-dark: #0f6fb4;
  --green: #10b981;
  --green-dark: #087957;
  --red: #ef4444;
  --amber: #f59e0b;
  --teal: #0f766e;
  --violet: #7c3aed;
  --shadow: 0 22px 60px rgba(20, 32, 45, 0.12);
  --shadow-soft: 0 12px 34px rgba(20, 32, 45, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--wash);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #f8fbfd 0, #eef5f2 42%, #f5f8fb 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
.drop-zone:focus-within {
  outline: 3px solid rgba(29, 155, 240, 0.24);
  outline-offset: 2px;
}

button {
  border: 0;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 860px;
  margin-bottom: 0;
  color: var(--ink-strong);
  font-size: 42px;
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  color: var(--ink-strong);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  color: var(--ink-strong);
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(216, 226, 236, 0.92);
  padding: 14px 28px;
  background: var(--nav);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--ink-strong);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, #0b1724 0, #17334f 55%, #0f766e 100%);
  color: white;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
}

.brand strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(216, 226, 236, 0.8);
  border-radius: var(--radius);
  padding: 4px;
  background: rgba(248, 251, 253, 0.88);
}

.nav-links a {
  min-height: 34px;
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.nav-links a.active,
.nav-links a:hover {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(20, 32, 45, 0.08);
}

.app-shell {
  min-height: calc(100vh - 69px);
  padding: 28px;
}

.workspace,
.about-shell {
  max-width: 1480px;
  margin: 0 auto;
}

.product-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.header-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.header-chips span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(189, 202, 216, 0.75);
  border-radius: var(--radius);
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(20, 32, 45, 0.05);
}

.eyebrow,
.panel-label {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-label {
  color: var(--soft-text);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(288px, 340px) minmax(0, 1fr) minmax(290px, 340px);
  gap: 16px;
  align-items: stretch;
}

.panel {
  border: 1px solid rgba(216, 226, 236, 0.96);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 16px;
}

.section-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.section-title.compact {
  margin-top: 2px;
}

.step-badge {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: #e6f5f1;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 258px;
  place-items: center;
  gap: 10px;
  overflow: hidden;
  border: 1px dashed #9fb0c1;
  border-radius: var(--radius);
  padding: 16px;
  background:
    linear-gradient(180deg, #fbfdff 0, #f2f8fb 100%);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.drop-zone::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  pointer-events: none;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--blue);
  background: #eef8ff;
  box-shadow: inset 0 0 0 1px rgba(29, 155, 240, 0.16);
}

.drop-zone.dragover {
  transform: translateY(-1px);
}

.drop-zone input {
  display: none;
}

.drop-visual {
  position: relative;
  display: grid;
  width: min(196px, 68vw);
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid #c4d2df;
  border-radius: var(--radius);
  background: #0e1623;
  box-shadow: 0 18px 32px rgba(20, 32, 45, 0.18);
}

.drop-visual img,
.empty-state img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.08) saturate(0.82);
}

.drop-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 49%, rgba(29, 155, 240, 0.5) 50%, transparent 51%),
    linear-gradient(transparent 49%, rgba(16, 185, 129, 0.42) 50%, transparent 51%);
  opacity: 0.46;
  pointer-events: none;
}

.drop-title {
  position: relative;
  z-index: 1;
  max-width: 100%;
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.drop-meta {
  position: relative;
  z-index: 1;
  max-width: 100%;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.field-note {
  margin: -1px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 38px 0 12px;
  background:
    linear-gradient(180deg, #ffffff, #f8fbfd);
  color: var(--ink);
  cursor: pointer;
}

.anatomy-grid {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.anatomy-card {
  position: relative;
  display: grid;
  width: 100%;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 12px 14px;
  background: #fbfdff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.anatomy-card::before {
  content: "";
  position: absolute;
  inset: 12px auto 12px 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

.anatomy-card:hover {
  border-color: #b9c8d7;
  transform: translateY(-1px);
}

.anatomy-card strong {
  font-size: 14px;
  line-height: 1.25;
}

.anatomy-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.anatomy-card.active {
  border-color: rgba(15, 118, 110, 0.38);
  background: #effaf7;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.09);
}

.anatomy-card.active::before {
  background: var(--teal);
}

.primary-button,
.ghost-button,
.download-link,
.status-pill {
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
}

.primary-button,
.ghost-button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  min-height: 52px;
  background:
    linear-gradient(135deg, #111d2b 0, #17334f 58%, #0f766e 100%);
  color: white;
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.2);
}

.primary-button:hover {
  filter: brightness(1.04);
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(0.18);
  opacity: 0.72;
}

.ghost-button,
.download-link,
.status-pill {
  min-height: 42px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
}

.ghost-button,
.download-link {
  padding: 0 12px;
}

.ghost-button:hover,
.download-link:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: 0 9px 24px rgba(20, 32, 45, 0.07);
}

.status-pill {
  display: grid;
  min-width: 96px;
  place-items: center;
  padding: 0 12px;
}

.status-pill.busy {
  border-color: rgba(29, 155, 240, 0.35);
  background: #edf8ff;
  color: var(--blue-dark);
}

.status-pill.error {
  border-color: rgba(239, 68, 68, 0.36);
  background: #fff1f1;
  color: var(--red);
}

.button-glyph {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  color: currentColor;
  font-size: 11px;
  font-weight: 900;
}

.ghost-button .button-glyph {
  background: #eef5f2;
  color: var(--teal);
}

.progress-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
  padding: 2px 0 0;
  list-style: none;
}

.progress-list li {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.35;
}

.progress-list li::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border: 2px solid #b8c6d6;
  border-radius: 999px;
  background: #fff;
}

.progress-list li.active {
  color: var(--blue-dark);
}

.progress-list li.active::before {
  border-color: var(--blue);
  background: var(--blue);
}

.progress-list li.done {
  color: var(--green-dark);
}

.progress-list li.done::before {
  border-color: var(--green);
  background: var(--green);
}

.viewer {
  display: grid;
  grid-template-rows: auto auto minmax(530px, calc(100vh - 310px));
  min-width: 0;
  overflow: hidden;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  background: #ffffff;
}

.viewer-tabs {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f4f7fa;
}

.tab {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.tab.active {
  border-color: #cfdae4;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 7px 18px rgba(20, 32, 45, 0.08);
}

.legend-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  background: #f8fbfd;
  color: var(--ink);
}

.legend-bar span {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(216, 226, 236, 0.78);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
}

.swatch {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid rgba(20, 32, 45, 0.14);
  border-radius: 5px;
  box-shadow: 0 6px 14px rgba(20, 32, 45, 0.12);
}

.swatch.soft {
  background: var(--blue);
}

.swatch.dense {
  background: var(--green);
}

.swatch.bone {
  background: var(--violet);
}

.swatch.edge {
  background: var(--amber);
}

.canvas-wrap {
  position: relative;
  display: grid;
  min-height: 530px;
  place-items: center;
  overflow: auto;
  padding: 22px;
  background:
    linear-gradient(90deg, var(--viewer-grid) 1px, transparent 1px),
    linear-gradient(var(--viewer-grid) 1px, transparent 1px),
    var(--viewer);
  background-size: 34px 34px, 34px 34px, auto;
}

.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  pointer-events: none;
}

#resultImage {
  position: relative;
  z-index: 1;
  display: none;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  image-rendering: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

#resultImage.visible {
  display: block;
}

.empty-state {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(440px, 86%);
  place-items: center;
  gap: 16px;
  color: #d8e2ec;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state img {
  max-width: 330px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.28);
}

.empty-state p {
  margin-bottom: 0;
  color: #d8e2ec;
  font-size: 14px;
  font-weight: 800;
}

.metrics {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px;
}

.metrics-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.download-link.disabled {
  pointer-events: none;
  color: var(--soft-text);
  opacity: 0.55;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.metric-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background:
    linear-gradient(180deg, #ffffff 0, #f9fbfd 100%);
  box-shadow: 0 8px 20px rgba(20, 32, 45, 0.04);
}

dt {
  color: var(--soft-text);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.28;
}

.result-card {
  display: grid;
  gap: 5px;
  border: 1px solid #bce7d8;
  border-radius: var(--radius);
  padding: 13px;
  background:
    linear-gradient(180deg, #f1fbf6 0, #ebf8f5 100%);
  color: #07563e;
}

.result-card strong {
  color: #063f31;
}

.result-card span {
  color: #23765b;
  font-size: 13px;
  line-height: 1.35;
}

.warnings {
  display: grid;
  gap: 8px;
}

.warning {
  border: 1px solid #f7d99d;
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  padding: 10px 11px;
  background: #fff9ec;
  color: #734700;
  font-size: 13px;
  line-height: 1.42;
}

.about-shell {
  padding: 28px;
}

.about-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

.about-hero p {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.62;
}

.about-visual {
  overflow: hidden;
  border: 1px solid rgba(216, 226, 236, 0.96);
  border-radius: var(--radius);
  background: var(--viewer);
  box-shadow: var(--shadow);
}

.about-visual img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  opacity: 0.9;
  filter: contrast(1.08) saturate(0.86);
}

.about-grid,
.pipeline-grid,
.tech-grid {
  display: grid;
  gap: 16px;
}

.about-grid {
  grid-template-columns: 1.08fr 0.92fr;
}

.pipeline-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tech-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.info-panel,
.pipeline-step,
.tech-card {
  border: 1px solid rgba(216, 226, 236, 0.96);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.info-panel {
  padding: 20px;
}

.info-panel p,
.info-panel li,
.pipeline-step p,
.tech-card p {
  color: var(--muted);
  line-height: 1.58;
}

.info-panel ul {
  margin: 12px 0 0;
  padding-left: 18px;
}

.pipeline-step,
.tech-card {
  padding: 16px;
}

.pipeline-step strong {
  display: grid;
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: var(--radius);
  background: #e6f5f1;
  color: var(--teal);
}

.code-block {
  overflow: auto;
  border-radius: var(--radius);
  padding: 14px;
  background: #111827;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.6;
}

.about-section {
  margin-top: 24px;
}

@media (max-width: 1240px) {
  h1 {
    font-size: 36px;
  }

  .tool-grid {
    grid-template-columns: minmax(284px, 330px) minmax(0, 1fr);
  }

  .metrics {
    grid-column: 1 / -1;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .about-visual {
    max-width: 420px;
  }
}

@media (max-width: 920px) {
  h1 {
    font-size: 32px;
  }

  .site-nav,
  .product-header,
  .viewer-toolbar,
  .metrics-header {
    align-items: stretch;
    flex-direction: column;
  }

  .product-header {
    display: flex;
  }

  .nav-links,
  .header-actions,
  .viewer-tabs {
    width: 100%;
  }

  .nav-links a,
  .ghost-button,
  .status-pill,
  .tab {
    flex: 1;
  }

  .tool-grid,
  .pipeline-grid,
  .tech-grid {
    grid-template-columns: 1fr;
  }

  .viewer {
    grid-template-rows: auto auto minmax(460px, 60vh);
  }

  .canvas-wrap {
    min-height: 460px;
  }

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

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

@media (max-width: 620px) {
  h1 {
    font-size: 28px;
    line-height: 1.08;
  }

  .site-nav,
  .app-shell,
  .about-shell {
    padding: 12px;
  }

  .site-nav {
    position: static;
    gap: 12px;
  }

  .brand {
    width: 100%;
  }

  .brand strong {
    white-space: normal;
  }

  .nav-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .product-header {
    margin-top: 6px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .header-chips {
    display: grid;
    grid-template-columns: 1fr;
  }

  .controls,
  .metrics {
    padding: 14px;
  }

  .viewer-toolbar {
    padding: 14px;
  }

  .viewer-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .tab {
    padding: 0 8px;
    font-size: 12px;
  }

  .legend-bar,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .legend-bar {
    padding: 12px;
  }

  .viewer {
    grid-template-rows: auto auto minmax(380px, 56vh);
  }

  .canvas-wrap {
    min-height: 380px;
    padding: 14px;
  }

  .empty-state {
    width: 92%;
  }

  .empty-state img {
    max-width: 260px;
  }
}
