:root {
  --bg: #f3ede4;
  --bg-deep: #e2d7c7;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --panel-muted: rgba(246, 240, 232, 0.78);
  --line: rgba(16, 33, 44, 0.1);
  --line-strong: rgba(16, 33, 44, 0.16);
  --text: #17222d;
  --muted: #60707a;
  --accent: #0b6464;
  --accent-strong: #0a4553;
  --accent-soft: rgba(11, 100, 100, 0.12);
  --warm: #a56440;
  --warm-soft: rgba(165, 100, 64, 0.14);
  --success: #1d6a52;
  --success-soft: rgba(29, 106, 82, 0.14);
  --danger: #a94f43;
  --danger-soft: rgba(169, 79, 67, 0.14);
  --font-display:
    "Iowan Old Style",
    "Palatino Linotype",
    "Noto Serif SC",
    "Source Han Serif SC",
    serif;
  --font-body:
    "Avenir Next",
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans GB",
    sans-serif;
  --shadow-lg: 0 24px 64px rgba(20, 28, 36, 0.14);
  --shadow-md: 0 16px 36px rgba(20, 28, 36, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(11, 100, 100, 0.18), transparent 24rem),
    radial-gradient(circle at 100% 0%, rgba(165, 100, 64, 0.16), transparent 22rem),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 42%, var(--bg-deep) 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(36px);
  opacity: 0.4;
}

body::before {
  top: -6rem;
  left: -8rem;
  background: rgba(11, 100, 100, 0.18);
}

body::after {
  right: -8rem;
  bottom: -8rem;
  background: rgba(165, 100, 64, 0.18);
}

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

.page {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.95fr);
  gap: 20px;
  margin-bottom: 18px;
}

.hero-main,
.hero-status,
.setup-panel,
.viewport-panel,
.sidebar > .panel {
  animation: fade-up 0.7s ease both;
}

.hero-status {
  animation-delay: 0.08s;
}

.setup-panel {
  animation-delay: 0.18s;
}

.viewport-panel {
  animation-delay: 0.24s;
}

.sidebar > .panel:nth-child(1) {
  animation-delay: 0.3s;
}

.sidebar > .panel:nth-child(2) {
  animation-delay: 0.36s;
}

.sidebar > .panel:nth-child(3) {
  animation-delay: 0.42s;
}

.hero-main {
  min-height: 240px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.2), transparent 32%),
    linear-gradient(135deg, rgba(8, 49, 58, 0.98) 0%, rgba(13, 85, 94, 0.94) 52%, rgba(165, 100, 64, 0.84) 100%);
  color: #f8f2e8;
}

.hero-main::after {
  content: "";
  position: absolute;
  right: -3rem;
  bottom: -7rem;
  width: 18rem;
  height: 18rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
}

.hero-brand,
.hero-tags {
  position: relative;
  z-index: 1;
}

.eyebrow,
.section-kicker,
.status-label,
.overview-label {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 14px;
  color: rgba(248, 242, 232, 0.72);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(3.8rem, 7vw, 6.8rem);
  line-height: 0.9;
  letter-spacing: 0.08em;
  font-weight: 600;
  text-transform: uppercase;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(248, 242, 232, 0.16);
  border-radius: 999px;
  background: rgba(248, 242, 232, 0.08);
  color: rgba(248, 242, 232, 0.92);
  font-size: 0.92rem;
  line-height: 1;
}

.hero-status {
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 242, 234, 0.82));
}

.status-label {
  color: var(--muted);
}

#statusText {
  display: inline-flex;
  align-self: flex-start;
  padding: 10px 16px;
  border: 1px solid rgba(47, 91, 109, 0.18);
  border-radius: 999px;
  background: rgba(47, 91, 109, 0.12);
  color: #24475a;
  font-size: 0.98rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

#statusText[data-status="initializing"],
#statusText[data-status="rendering"] {
  border-color: rgba(165, 100, 64, 0.2);
  background: var(--warm-soft);
  color: #84512f;
}

#statusText[data-status="ready"] {
  border-color: rgba(29, 106, 82, 0.22);
  background: var(--success-soft);
  color: var(--success);
}

#statusText[data-status="out_of_bounds"] {
  border-color: rgba(165, 100, 64, 0.24);
  background: rgba(165, 100, 64, 0.18);
  color: #8a552f;
}

#statusText[data-status="error"] {
  border-color: rgba(169, 79, 67, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
}

#messageText {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.overview-card {
  min-height: 116px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 242, 234, 0.78));
  box-shadow: var(--shadow-md);
  animation: fade-up 0.7s ease both;
}

.overview-card:nth-child(1) {
  animation-delay: 0.1s;
}

.overview-card:nth-child(2) {
  animation-delay: 0.14s;
}

.overview-card:nth-child(3) {
  animation-delay: 0.18s;
}

.overview-label {
  color: var(--muted);
}

.overview-value {
  font-family: var(--font-display);
  font-size: clamp(1.24rem, 2vw, 1.72rem);
  line-height: 1.25;
  font-weight: 600;
}

.setup-panel,
.viewport-panel,
.info-panel {
  padding: 28px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.compact-heading {
  margin-bottom: 18px;
}

.section-kicker {
  margin-bottom: 8px;
  color: var(--accent);
}

.section-heading h2 {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.2vw, 1.96rem);
  line-height: 1.1;
  font-weight: 600;
}

.section-note {
  display: inline-flex;
  align-self: flex-start;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.2;
}

.setup-panel {
  margin-bottom: 24px;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: stretch;
}

.setup-section {
  padding: 22px;
  border: 1px solid rgba(16, 33, 44, 0.08);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(246, 240, 232, 0.82), rgba(255, 255, 255, 0.64));
}

.upload-section {
  display: flex;
  flex-direction: column;
}

.subsection-heading {
  margin-bottom: 16px;
}

.subsection-heading h3 {
  margin-bottom: 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.subsection-heading p {
  color: var(--muted);
  line-height: 1.65;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.preset-card {
  padding: 0;
  min-height: 100%;
  border: 1px solid rgba(16, 33, 44, 0.12);
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  color: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(20, 28, 36, 0.08);
  transition:
    transform 0.24s ease,
    box-shadow 0.24s ease,
    border-color 0.24s ease,
    opacity 0.24s ease;
}

.preset-card:hover:not(:disabled) {
  transform: translateY(-4px);
  border-color: rgba(11, 100, 100, 0.34);
  box-shadow: 0 20px 38px rgba(20, 28, 36, 0.12);
}

.preset-card.is-selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px rgba(11, 100, 100, 0.16),
    0 18px 32px rgba(20, 28, 36, 0.12);
}

.preset-card:disabled {
  opacity: 0.7;
  cursor: wait;
}

.preset-card:focus-visible,
.primary-button:focus-visible,
.upload-box:focus-within {
  outline: 2px solid rgba(11, 100, 100, 0.42);
  outline-offset: 3px;
}

.preset-card-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: linear-gradient(135deg, rgba(11, 100, 100, 0.18), rgba(23, 34, 45, 0.08));
}

.preset-card-title {
  display: block;
  padding: 14px 16px 16px;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 600;
}

.preset-empty {
  margin: 0;
  padding: 24px;
  border: 1px dashed rgba(11, 100, 100, 0.24);
  border-radius: 22px;
  background: rgba(11, 100, 100, 0.05);
  color: var(--muted);
  line-height: 1.7;
}

.upload-box {
  flex: 1;
  min-height: 220px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  border: 1.5px dashed rgba(11, 100, 100, 0.32);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(11, 100, 100, 0.08), rgba(165, 100, 64, 0.1));
  color: var(--accent-strong);
  cursor: pointer;
  transition:
    transform 0.24s ease,
    border-color 0.24s ease,
    box-shadow 0.24s ease;
}

.upload-box:hover {
  transform: translateY(-2px);
  border-color: rgba(11, 100, 100, 0.42);
  box-shadow: 0 18px 34px rgba(20, 28, 36, 0.1);
}

.upload-label {
  font-family: var(--font-display);
  font-size: 1.48rem;
  line-height: 1.2;
  font-weight: 600;
}

.upload-caption {
  max-width: 28rem;
  color: var(--muted);
  line-height: 1.75;
}

.upload-box input {
  display: none;
}

.source-hint {
  margin: 16px 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(16, 33, 44, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  line-height: 1.6;
}

.primary-button {
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #0b6464 0%, #0c5060 46%, #a56440 100%);
  color: #f8f4ed;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 20px 38px rgba(11, 100, 100, 0.24);
  transition:
    transform 0.24s ease,
    opacity 0.24s ease,
    box-shadow 0.24s ease;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 24px 44px rgba(11, 100, 100, 0.28);
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.95fr);
  gap: 20px;
}

.viewport-panel {
  display: flex;
  flex-direction: column;
}

.viewport-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(16, 33, 44, 0.14);
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(11, 100, 100, 0.32), rgba(23, 34, 45, 0.14) 52%, rgba(165, 100, 64, 0.26)),
    #d9d3c7;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    0 16px 36px rgba(20, 28, 36, 0.1);
}

.viewport-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0) 16%, rgba(255, 255, 255, 0.04) 32%, rgba(255, 255, 255, 0) 48%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

#frameImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.frame-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.placeholder-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 28px;
  border: 1px solid rgba(16, 33, 44, 0.08);
  border-radius: 22px;
  background: rgba(248, 244, 237, 0.76);
  box-shadow: 0 18px 36px rgba(20, 28, 36, 0.1);
  text-align: center;
}

.placeholder-copy strong {
  font-family: var(--font-display);
  font-size: 1.48rem;
  line-height: 1.2;
  font-weight: 600;
}

.placeholder-copy span {
  color: var(--muted);
  line-height: 1.6;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pose-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pose-grid div {
  padding: 16px 18px;
  border: 1px solid rgba(16, 33, 44, 0.08);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(246, 240, 232, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.pose-grid dt {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pose-grid dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.1;
  font-weight: 600;
}

.control-list,
.limit-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.control-list li,
.limit-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(16, 33, 44, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
}

.control-list li {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.limit-list li {
  justify-content: space-between;
}

.help-text {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.75;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.22rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .hero,
  .setup-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-main {
    min-height: 220px;
  }
}

@media (max-width: 860px) {
  .page {
    padding: 20px 16px 40px;
  }

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

  .setup-panel,
  .viewport-panel,
  .info-panel {
    padding: 22px;
  }

  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .preset-grid,
  .pose-grid {
    grid-template-columns: 1fr;
  }

  .upload-box {
    min-height: 180px;
  }
}

@media (max-width: 640px) {
  .hero-main {
    padding: 24px;
    min-height: 200px;
  }

  .hero-tags {
    gap: 10px;
  }

  .hero-tag,
  .section-note {
    font-size: 0.84rem;
  }

  .control-list li,
  .limit-list li {
    align-items: flex-start;
    flex-direction: column;
  }

  .placeholder-copy {
    width: 100%;
  }
}
