:root {
  --paper: #f5efe3;
  --paper-strong: #fffaf0;
  --ink: #1f2f2a;
  --muted: #5e6e66;
  --board: #12372b;
  --board-deep: #0b231b;
  --line: rgba(255, 248, 220, 0.08);
  --accent: #da8a2f;
  --accent-soft: #f3c26f;
  --mint: #8ec5a4;
  --rose: #f28482;
  --chalk: #f4f1de;
  --shadow: 0 24px 60px rgba(33, 43, 38, 0.18);
  --radius-xl: 28px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(218, 138, 47, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(51, 117, 92, 0.2), transparent 36%),
    linear-gradient(180deg, #efe6d2 0%, #f7f1e4 42%, #efe8dc 100%);
}

.page-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 24px auto 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 30px;
  border-radius: var(--radius-xl);
  background: rgba(255, 250, 240, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.18em;
  font-size: 0.8rem;
  color: var(--muted);
}

.hero h1 {
  margin: 0;
  font-family: "Georgia", "Songti SC", serif;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
}

.hero-text {
  margin: 16px 0 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
}

.hero-badge {
  align-self: flex-start;
  min-width: 170px;
  padding: 18px 20px;
  border-radius: 20px;
  background: linear-gradient(160deg, #173d31, #245241);
  color: var(--chalk);
}

.hero-badge span {
  display: block;
  opacity: 0.7;
  font-size: 0.85rem;
}

.hero-badge strong {
  display: block;
  margin-top: 10px;
  font-size: 1.35rem;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
}

.panel {
  background: rgba(255, 251, 244, 0.88);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-head h2,
.result-card h3,
.stage-header h3 {
  margin: 0;
  font-family: "Georgia", "Songti SC", serif;
}

.panel-head p,
.stage-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.upload-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 28px 22px;
  margin-top: 18px;
  border: 2px dashed rgba(26, 69, 54, 0.25);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(245, 239, 227, 0.95), rgba(255, 250, 240, 0.98));
  cursor: pointer;
  overflow: hidden;
}

.upload-card::after {
  content: "";
  position: absolute;
  inset: auto -36px -36px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(218, 138, 47, 0.14);
}

.upload-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-kicker {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.preview-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  margin-top: 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(14, 41, 32, 0.95), rgba(29, 77, 59, 0.88));
  overflow: hidden;
}

#previewImage {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-empty {
  color: rgba(244, 241, 222, 0.8);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.field span {
  font-weight: 700;
}

textarea {
  width: 100%;
  border: 1px solid rgba(31, 47, 42, 0.16);
  border-radius: 16px;
  background: var(--paper-strong);
  padding: 14px 16px;
  resize: vertical;
  min-height: 120px;
  font: inherit;
  color: var(--ink);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

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

button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.primary {
  flex: 1;
  background: linear-gradient(135deg, #204d3d, #2a6550);
  color: var(--chalk);
  box-shadow: 0 12px 24px rgba(31, 69, 54, 0.22);
}

.secondary,
.ghost {
  background: rgba(255, 250, 240, 0.9);
  color: var(--ink);
  border: 1px solid rgba(31, 47, 42, 0.12);
}

.status-line {
  margin-top: 16px;
  color: var(--muted);
  min-height: 24px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.result-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.95);
  border: 1px solid rgba(31, 47, 42, 0.08);
}

.card-header-inline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.mode-tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(142, 197, 164, 0.2);
  color: #23503f;
  font-size: 0.85rem;
}

.text-block,
.analysis-text,
.answer-text {
  margin-top: 12px;
  white-space: pre-wrap;
  line-height: 1.8;
}

.placeholder {
  color: var(--muted);
}

.answer-card {
  background: linear-gradient(160deg, #173d31, #245241);
  color: var(--chalk);
}

.answer-card .placeholder,
.answer-card .answer-text {
  color: var(--chalk);
}

.animation-stage {
  margin-top: 18px;
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(18, 55, 43, 0.97), rgba(11, 35, 27, 0.98));
  color: var(--chalk);
}

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

.player-actions {
  display: flex;
  gap: 10px;
}

.player-actions .ghost {
  color: var(--chalk);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.stage-board {
  position: relative;
  margin-top: 16px;
  min-height: 420px;
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    linear-gradient(180deg, rgba(13, 43, 34, 0.96), rgba(8, 28, 21, 0.98));
  background-size: 44px 44px, 44px 44px, auto;
}

#sceneSvg {
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.annotation-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.annotation-bubble {
  position: absolute;
  transform: translate(-50%, -50%);
  max-width: 240px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 248, 220, 0.16);
  border: 1px solid rgba(255, 248, 220, 0.24);
  color: var(--chalk);
  font-size: 0.92rem;
  line-height: 1.5;
  opacity: 0;
  animation: bubble-in 220ms ease forwards;
}

.step-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.step-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0.7;
}

.step-card.active {
  opacity: 1;
  background: rgba(218, 138, 47, 0.16);
  border-color: rgba(243, 194, 111, 0.45);
}

.step-card strong {
  display: block;
  margin-bottom: 6px;
}

.shape-hidden {
  opacity: 0;
}

.shape-visible {
  opacity: 1;
  transition: opacity 240ms ease;
}

.shape-drawing {
  transition: stroke-dashoffset 700ms ease, opacity 240ms ease;
}

.shape-highlighted {
  filter: drop-shadow(0 0 14px rgba(255, 209, 102, 0.82));
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 12px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100vw - 18px, 1380px);
    margin: 10px auto 24px;
  }

  .hero {
    flex-direction: column;
    padding: 22px;
  }

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

  .stage-header {
    flex-direction: column;
  }

  .actions {
    flex-direction: column;
  }
}
