:root {
  --bg: #0e1117;
  --panel: #171b24;
  --panel-alt: #1d2330;
  --border: #2a3142;
  --text: #f3f4f6;
  --muted: #9aa4b2;
  --accent: #6567c9;
  --accent-strong: #7c7ff0;
  --success: #2da66d;
  --warn: #c98a1c;
  --danger: #ca5050;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

html {
  font-size: 14px;
}

body.app-body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(101, 103, 201, 0.2), transparent 26%),
    radial-gradient(circle at top right, rgba(45, 166, 109, 0.16), transparent 24%),
    linear-gradient(180deg, #0b0f14 0%, #10141c 100%);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans KR", sans-serif;
}

a {
  color: inherit;
}

.logout-form {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(10, 14, 21, 0.82);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(16px);
}

.logout-user {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.logout-button {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background:
    radial-gradient(circle at top right, rgba(101, 103, 201, 0.22), transparent 35%),
    linear-gradient(180deg, rgba(28, 34, 46, 0.98) 0%, rgba(18, 23, 32, 0.98) 100%);
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-title {
  margin: 12px 0 0;
  font-size: 2rem;
  font-weight: 800;
}

.login-caption {
  margin: 10px 0 24px;
  color: var(--muted);
  line-height: 1.65;
}

.login-form {
  display: block;
}

.login-input {
  min-height: 46px;
  border-radius: 14px;
}

.login-button {
  width: 100%;
  min-height: 48px;
  margin-top: 24px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  font-weight: 800;
}

.login-validation {
  display: block;
  margin-top: 8px;
  color: #ffb1b1;
  font-size: 0.9rem;
}

.hunyuan-page {
  max-width: 1680px;
  margin: 0 auto;
  padding: 26px 18px 12px;
}

.hero-panel {
  margin-bottom: 18px;
  text-align: center;
}

.hero-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hero-subtitle {
  margin: 6px 0 0;
  color: #d4d7de;
  font-size: 1rem;
}

.hero-caption {
  margin: 10px 0 0;
  color: var(--muted);
}

.status-banner {
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition: all 0.2s ease;
}

.status-banner--busy {
  border-color: rgba(101, 103, 201, 0.5);
  background: rgba(101, 103, 201, 0.12);
}

.status-banner--success {
  border-color: rgba(45, 166, 109, 0.45);
  background: rgba(45, 166, 109, 0.12);
}

.status-banner--error {
  border-color: rgba(202, 80, 80, 0.5);
  background: rgba(202, 80, 80, 0.14);
}

.hunyuan-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr) minmax(260px, 320px);
  gap: 18px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(28, 34, 46, 0.98) 0%, rgba(20, 24, 34, 0.98) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.control-panel,
.gallery-panel {
  padding: 18px;
}

.viewer-panel {
  overflow: hidden;
}

.panel-section + .panel-section {
  margin-top: 18px;
}

.section-title {
  margin-bottom: 12px;
  color: #f7f8fb;
  font-size: 1rem;
  font-weight: 700;
}

.image-drop {
  position: relative;
  min-height: 290px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.image-preview {
  width: 100%;
  height: 290px;
  object-fit: contain;
  background: #fff;
}

.image-placeholder {
  display: flex;
  height: 290px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

.placeholder-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.placeholder-caption {
  margin-top: 8px;
  max-width: 180px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.action-button {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 700;
}

.action-button.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.action-button--secondary {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.option-check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.field-block {
  margin-top: 14px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: #dce2eb;
  font-weight: 600;
}

.range-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.range-value {
  color: var(--muted);
  font-weight: 600;
}

.form-control,
.form-select {
  border-color: rgba(255, 255, 255, 0.14);
  background-color: rgba(5, 8, 14, 0.42);
  color: var(--text);
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(124, 127, 240, 0.6);
  box-shadow: 0 0 0 0.2rem rgba(124, 127, 240, 0.18);
  background-color: rgba(5, 8, 14, 0.58);
  color: var(--text);
}

.form-range::-webkit-slider-thumb {
  background: var(--accent-strong);
}

.form-range::-moz-range-thumb {
  background: var(--accent-strong);
}

.viewer-tabs {
  padding: 16px 16px 0;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.viewer-tabs .nav-link {
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  font-weight: 700;
}

.viewer-tabs .nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent-strong);
  background: transparent;
}

.viewer-tab-content {
  padding: 16px;
}

.viewer-shell {
  min-height: 720px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.viewer-shell--empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-placeholder {
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}

.viewer-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 12px 0;
}

.viewer-toggle {
  min-width: 110px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

.viewer-toggle.is-active {
  border-color: transparent;
  background: var(--accent);
}

.model-viewer-frame {
  min-height: 680px;
  padding: 10px 12px 12px;
}

.model-viewer-frame model-viewer {
  width: 100%;
  height: 680px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0.12) 100%);
}

.stats-output {
  min-height: 720px;
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  background: rgba(6, 10, 16, 0.65);
  color: #d7deea;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.example-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 880px;
  overflow: auto;
  padding-right: 4px;
}

.example-card {
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.example-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 127, 240, 0.6);
  background: rgba(124, 127, 240, 0.08);
}

.example-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  background: #fff;
}

.example-name {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.gallery-placeholder {
  grid-column: 1 / -1;
  padding: 22px 10px;
  color: var(--muted);
  text-align: center;
}

.disabled,
.btn.disabled {
  pointer-events: none;
  opacity: 0.45;
}

@media (max-width: 1280px) {
  .hunyuan-grid {
    grid-template-columns: minmax(280px, 360px) 1fr;
  }

  .gallery-panel {
    grid-column: 1 / -1;
  }

  .example-gallery {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    max-height: none;
  }
}

@media (max-width: 900px) {
  .hunyuan-page {
    padding-inline: 10px;
  }

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

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

  .action-row,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .viewer-shell,
  .stats-output {
    min-height: 560px;
  }

  .model-viewer-frame,
  .model-viewer-frame model-viewer {
    min-height: 520px;
    height: 520px;
  }
}
