:root {
  --ink: #20211d;
  --deep-ink: #11120f;
  --paper: #f5ecd9;
  --paper-deep: #dfcfaa;
  --cinnabar: #a23828;
  --jade: #3f7468;
  --malachite: #235f6b;
  --gold: #b88a45;
  --shadow: rgba(44, 34, 18, 0.18);
  --line: rgba(67, 49, 29, 0.22);
  color: var(--ink);
  font-family:
    "Noto Serif SC", "Songti SC", "SimSun", "Microsoft YaHei", serif;
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 8% 18%, rgba(162, 56, 40, 0.12), transparent 26rem),
    radial-gradient(circle at 88% 8%, rgba(35, 95, 107, 0.18), transparent 24rem),
    linear-gradient(125deg, #f9f2e5, #eadcbf 52%, #f3ead5);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  content: "";
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(68, 48, 26, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(68, 48, 26, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
}

.ink-wash {
  position: fixed;
  inset: auto -8vw -18vh -8vw;
  z-index: -2;
  height: 52vh;
  pointer-events: none;
  opacity: 0.22;
  background:
    radial-gradient(ellipse at 22% 68%, rgba(22, 42, 37, 0.62), transparent 23rem),
    radial-gradient(ellipse at 48% 46%, rgba(26, 55, 62, 0.54), transparent 26rem),
    radial-gradient(ellipse at 76% 58%, rgba(91, 80, 52, 0.42), transparent 23rem);
  filter: blur(16px);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 250, 238, 0.64);
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

button:hover,
a:hover {
  transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(162, 56, 40, 0.35);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, calc(100% - 32px));
  min-height: 74px;
  margin: 16px auto 0;
  padding: 10px 16px;
  border: 1px solid rgba(74, 52, 29, 0.18);
  border-radius: 8px;
  background: rgba(247, 238, 218, 0.82);
  box-shadow: 0 16px 38px rgba(55, 40, 20, 0.12);
  backdrop-filter: blur(18px);
}

.brand,
.topbar nav,
.hero-actions,
.canvas-toolbar,
.button-grid,
.control-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 170px;
}

.brand strong {
  display: block;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: rgba(32, 33, 29, 0.62);
  font-size: 0.78rem;
}

.seal {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(162, 56, 40, 0.82);
  color: #fff7ed;
  background: var(--cinnabar);
  box-shadow: inset 0 0 0 3px rgba(255, 246, 226, 0.18);
  font-weight: 700;
}

.seal.large {
  width: 64px;
  height: 64px;
  font-size: 1.7rem;
}

.topbar nav {
  gap: 4px;
  padding: 5px;
  border-radius: 8px;
  background: rgba(255, 249, 232, 0.56);
}

.topbar nav a {
  min-width: 58px;
  padding: 9px 12px;
  border-radius: 6px;
  text-align: center;
  color: rgba(32, 33, 29, 0.76);
}

.topbar nav a:hover {
  background: rgba(162, 56, 40, 0.1);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  min-height: calc(100vh - 94px);
  padding: clamp(2rem, 5vw, 4.5rem) 0 2rem;
}

.hero-copy {
  max-width: 590px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--cinnabar);
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 20px;
  font-size: clamp(2.65rem, 6vw, 5.45rem);
  line-height: 1.04;
  font-weight: 800;
}

.hero-copy p:not(.eyebrow) {
  max-width: 52ch;
  color: rgba(32, 33, 29, 0.74);
  font-size: 1.04rem;
  line-height: 1.9;
}

.hero-actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.primary-link,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid rgba(90, 22, 14, 0.22);
  border-radius: 8px;
  color: #fff9ec;
  background: linear-gradient(135deg, var(--cinnabar), #6f2c27);
  box-shadow: 0 12px 28px rgba(118, 40, 28, 0.25);
}

.ghost-button {
  padding: 0 18px;
}

.scroll-peek {
  position: relative;
  min-height: 470px;
  padding: clamp(1rem, 3vw, 2rem);
}

.scroll-peek::before,
.scroll-peek::after {
  position: absolute;
  top: 5%;
  bottom: 9%;
  width: 16px;
  border-radius: 999px;
  content: "";
  background: linear-gradient(#5f3c22, #c4975f 18%, #4a2e1a 72%, #22140b);
  box-shadow: 0 12px 30px var(--shadow);
}

.scroll-peek::before {
  left: 4px;
}

.scroll-peek::after {
  right: 4px;
}

#sampleCanvas {
  width: 100%;
  max-width: 660px;
  height: auto;
  border: 1px solid rgba(64, 45, 23, 0.26);
  border-radius: 8px;
  background: #f6edda;
  box-shadow: 0 26px 70px rgba(37, 30, 20, 0.22);
}

.scroll-label {
  position: absolute;
  right: 7%;
  bottom: 1.2rem;
  max-width: 330px;
  padding: 12px 14px;
  border: 1px solid rgba(67, 49, 29, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 238, 0.74);
  backdrop-filter: blur(10px);
}

.scroll-label span,
.scroll-label strong {
  display: block;
}

.scroll-label span {
  color: rgba(32, 33, 29, 0.62);
  font-size: 0.78rem;
}

.scroll-label strong {
  margin-top: 4px;
}

.workspace,
.insight-grid,
.pipeline {
  padding: 64px 0;
}

.section-heading {
  margin-bottom: 22px;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3.2vw, 2.8rem);
}

.tool-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.side-panel,
.canvas-panel,
.insight-grid article,
.pipeline li {
  border: 1px solid rgba(67, 49, 29, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 249, 235, 0.84), rgba(235, 220, 186, 0.78)),
    radial-gradient(circle at 18% 0, rgba(162, 56, 40, 0.08), transparent 16rem);
  box-shadow: 0 18px 44px rgba(55, 40, 20, 0.12);
}

.side-panel {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 18px;
  border: 1px dashed rgba(67, 49, 29, 0.38);
  border-radius: 8px;
  text-align: center;
  background: rgba(255, 253, 244, 0.5);
  cursor: pointer;
}

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

.upload-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 8px;
  border: 1px solid rgba(162, 56, 40, 0.32);
  border-radius: 50%;
  color: var(--cinnabar);
  font-size: 1.8rem;
}

.upload-box small,
.control-row output,
.canvas-toolbar span,
.insight-grid p,
.pipeline span,
footer {
  color: rgba(32, 33, 29, 0.66);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(67, 49, 29, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 238, 0.62);
}

.segmented button {
  min-height: 38px;
  border: 0;
  background: transparent;
}

.segmented button.active {
  color: #fff9ec;
  background: var(--jade);
  box-shadow: 0 8px 18px rgba(63, 116, 104, 0.24);
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
}

.control-row input {
  grid-column: 1 / -1;
  accent-color: var(--cinnabar);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-grid .primary-button {
  grid-column: 1 / -1;
}

.canvas-panel {
  min-width: 0;
  padding: 14px;
}

.canvas-toolbar {
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
  padding: 0 4px 10px;
}

.canvas-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(184, 138, 69, 0.18);
}

.canvas-shell {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 1px solid rgba(67, 49, 29, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(122, 82, 39, 0.13), transparent 18%, transparent 82%, rgba(122, 82, 39, 0.13)),
    #f6edda;
}

.canvas-shell canvas,
#compareMask,
.empty-state {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.canvas-shell canvas {
  object-fit: contain;
}

#originalCanvas {
  z-index: 1;
}

#restoredCanvas {
  z-index: 2;
  clip-path: inset(0 50% 0 0);
}

#compareMask {
  z-index: 3;
  width: 2px;
  margin-left: 50%;
  background: rgba(162, 56, 40, 0.82);
  box-shadow: 0 0 0 9999px transparent;
  pointer-events: none;
}

.empty-state {
  z-index: 4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(255, 249, 235, 0.9), rgba(255, 249, 235, 0.64)),
    linear-gradient(135deg, rgba(63, 116, 104, 0.08), rgba(162, 56, 40, 0.08));
}

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

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

.insight-grid .section-heading {
  grid-column: 1 / -1;
}

.insight-grid article {
  min-height: 220px;
  padding: 22px;
}

.insight-grid article span {
  color: var(--cinnabar);
  font-weight: 800;
}

.insight-grid h3 {
  margin: 18px 0 12px;
  font-size: 1.18rem;
}

.insight-grid p,
.pipeline span {
  line-height: 1.75;
}

.pipeline ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.pipeline li {
  position: relative;
  min-height: 190px;
  padding: 54px 18px 18px;
  overflow: hidden;
}

.pipeline li::before {
  position: absolute;
  top: 14px;
  left: 18px;
  color: rgba(162, 56, 40, 0.23);
  content: counter(step, decimal-leading-zero);
  counter-increment: step;
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}

.pipeline strong,
.pipeline span {
  display: block;
}

.pipeline strong {
  margin-bottom: 10px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 38px;
  padding-top: 18px;
  border-top: 1px solid rgba(67, 49, 29, 0.2);
  font-size: 0.9rem;
}

@media (max-width: 980px) {
  .hero,
  .tool-layout,
  .pipeline ol {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .scroll-peek {
    min-height: auto;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-box,
  .button-grid {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar nav {
    width: 100%;
  }

  .topbar nav a {
    flex: 1;
  }

  h1 {
    font-size: 2.65rem;
  }

  .side-panel,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .insight-grid .section-heading {
    grid-column: auto;
  }

  .canvas-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  footer {
    flex-direction: column;
  }
}

@media (max-width: 470px) {
  main,
  .topbar,
  footer {
    width: min(100% - 20px, 1180px);
  }

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

  .primary-button {
    grid-column: auto;
  }
}
