﻿:root {
  --bg-a: #fefbf5;
  --bg-b: #f1f6ff;
  --card: #ffffffcc;
  --stroke: #d9e2f2;
  --text: #1f2a44;
  --muted: #5a6477;
  --accent: #0f7c9c;
  --accent-2: #27b8a5;
  --shadow: 0 16px 40px rgba(16, 55, 88, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 15%, #ffe8cc 0%, #ffe8cc00 28%),
    radial-gradient(circle at 92% 8%, #dff4ff 0%, #dff4ff00 33%),
    linear-gradient(150deg, var(--bg-a), var(--bg-b));
}

.mini-nav,
.viewer-card,
.server-card,
.info-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(3px);
}

.page-shell {
  width: min(1080px, 100% - 24px);
  margin: 18px auto 28px;
  display: grid;
  gap: 14px;
}

.mini-nav {
  min-height: 46px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mini-nav-brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.mini-nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-nav-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #c8daeb;
  color: #1f4f69;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  background: #f6fbff;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.mini-nav-links a:hover {
  border-color: #89adca;
  transform: translateY(-1px);
}

.viewer-card {
  padding: 14px;
}

.compare-stage {
  position: relative;
  width: min(100%, 720px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  overflow: hidden;
  background: #e8eef8;
}

.compare-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.new-mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(100% - 1px);
  width: 2px;
  transform: translateX(-1px);
  background: linear-gradient(180deg, #fff, #d8ecff);
  box-shadow: 0 0 0 1px #0b5a72aa, 0 0 14px #11a8c099;
}

.tag {
  position: absolute;
  top: 12px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-transform: uppercase;
}

.tag.old {
  left: 12px;
  background: #3f5368d0;
}

.tag.new {
  right: 12px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.control-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.control-row label {
  font-size: 13px;
  color: var(--muted);
}

#revealRange {
  width: 100%;
  accent-color: var(--accent);
  height: 30px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

#revealRange::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d6e8f7, #c6ddf1);
}

#revealRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 8px rgba(15, 124, 156, 0.35);
  cursor: pointer;
}

#revealRange::-moz-range-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d6e8f7, #c6ddf1);
}

#revealRange::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 8px rgba(15, 124, 156, 0.35);
  cursor: pointer;
}

#revealValue {
  min-width: 52px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
}

.mode-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
}

.segmented {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  overflow: hidden;
  background: #fff;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.seg-btn.is-active {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.ghost-btn {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ghost-btn.is-running {
  border-color: #0f7c9c6b;
  background: #eaf9ff;
  color: #0f7c9c;
}

.speed-control {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.speed-control input {
  width: 100%;
  accent-color: var(--accent);
}

.divider.is-vertical {
  left: 0;
  right: 0;
  top: auto;
  bottom: calc(100% - 1px);
  width: auto;
  height: 2px;
  transform: translateY(1px);
  background: linear-gradient(90deg, #fff, #d8ecff);
}

.server-card {
  padding: 12px;
}

.server-box {
  border: 1px solid #cfe0f2;
  border-radius: 14px;
  background: #f4fbff;
  padding: 10px;
}

.server-box h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.server-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px);
  gap: 8px;
  align-items: end;
}

.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.core-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(148px, 1fr));
  gap: 10px;
  max-width: 680px;
}

.core-btn {
  position: relative;
  --pulse-rgb: 40, 95, 132;
  aspect-ratio: 4 / 1;
  border-radius: 16px;
  border: 1px solid #bfcfdf;
  min-height: 0;
  padding: 4px 10px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.core-btn:hover {
  transform: translateY(-2px);
}

.core-btn.pulse-glow::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 2px solid rgba(var(--pulse-rgb), 0.34);
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
  animation: core-halo 1.9s ease-in-out infinite;
}

.core-btn.pulse-glow::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 25%;
  width: clamp(30px, 4.6vw, 42px);
  height: clamp(30px, 4.6vw, 42px);
  background: url("./assets/icons/hand-point.svg") center / contain no-repeat;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(28, 66, 98, 0.26));
  z-index: 3;
  transform: translate(-50%, -50%) rotate(90deg);
  animation: pointer-mid-left 1.1s ease-in-out infinite;
}

.core-title {
  font-size: clamp(14px, 1.9vw, 22px);
  line-height: 1.1;
}

.core-icon {
  width: clamp(24px, 4.3vw, 40px);
  height: clamp(24px, 4.3vw, 40px);
  margin-bottom: 0;
  flex: 0 0 auto;
}

.core-sub {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 2px;
  margin-top: 0;
  max-width: 100%;
  font-size: clamp(9px, 1vw, 11px);
  line-height: 1;
  font-weight: 600;
  color: #4b5d73;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.core-upload {
  color: #1f3347;
  background: #f2f7fc;
  box-shadow: 0 8px 18px rgba(44, 87, 125, 0.12);
}

#pickImageBtn.pulse-glow {
  --pulse-rgb: 40, 95, 132;
  animation: breathe-upload 1.9s ease-in-out infinite;
}

.core-generate {
  border: 1px solid #195d77;
  color: #fff;
  background: #1f6f8d;
  box-shadow: 0 12px 24px rgba(21, 79, 102, 0.32);
  font-size: clamp(18px, 2.2vw, 28px);
}

#sendToServerBtn.pulse-glow {
  --pulse-rgb: 38, 184, 165;
  animation: breathe-generate 1.9s ease-in-out infinite;
}

.core-generate:disabled {
  opacity: 0.68;
  cursor: not-allowed;
  transform: none;
}

.core-sub-light {
  color: #d9eef7;
}

@keyframes breathe-upload {
  0%,
  100% {
    border-color: #bfcfdf;
    box-shadow: 0 8px 18px rgba(44, 87, 125, 0.12);
  }
  50% {
    border-color: #7d9db8;
    box-shadow:
      0 0 0 6px rgba(40, 95, 132, 0.16),
      0 12px 26px rgba(44, 87, 125, 0.24);
  }
}

@keyframes breathe-generate {
  0%,
  100% {
    border-color: #195d77;
    box-shadow: 0 12px 24px rgba(21, 79, 102, 0.32);
  }
  50% {
    border-color: #51aec6;
    box-shadow:
      0 0 0 8px rgba(38, 184, 165, 0.22),
      0 16px 28px rgba(21, 79, 102, 0.4);
  }
}

@keyframes core-halo {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.03);
  }
}

@keyframes pointer-mid-left {
  0%,
  100% {
    opacity: 0.9;
    transform: translate(-50%, -50%) translateX(0) rotate(90deg) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) translateX(8px) rotate(90deg) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .core-btn.pulse-glow,
  .core-btn.pulse-glow::before,
  .core-btn.pulse-glow::after {
    animation: none !important;
  }
}

.template-panel {
  margin-top: 10px;
  border: 1px solid #dbe8f5;
  border-radius: 12px;
  background: #ffffffb8;
  padding: 6px;
}

.template-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.template-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 16px) / 3);
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto;
  scrollbar-color: #7ea6c4 #dce8f4;
  touch-action: pan-x;
  cursor: grab;
  user-select: none;
  max-width: 100%;
}

.template-list::-webkit-scrollbar {
  height: 16px;
}

.template-list::-webkit-scrollbar-track {
  background: #dce8f4;
  border-radius: 999px;
}

.template-list::-webkit-scrollbar-thumb {
  background: linear-gradient(120deg, #5e8dad, #7ea6c4);
  border-radius: 999px;
  border: 3px solid #dce8f4;
}

.template-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(120deg, #4f7e9f, #6f98b8);
}

.template-list:active {
  cursor: grabbing;
}

.template-item {
  border: 1px solid #d5e2ef;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
  min-height: 44px;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.template-item:hover {
  transform: translateY(-1px);
}

.template-item.is-selected {
  border-color: #0f7c9c;
  box-shadow: 0 0 0 2px #0f7c9c2a;
}

.template-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5edf7;
  display: block;
}

.template-name {
  margin-top: 4px;
  display: block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.endpoint-box {
  margin-top: 8px;
}

.endpoint-box summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.endpoint-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px;
}

.upload-field {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.upload-field input {
  width: 100%;
  border: 1px solid #cadced;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.primary-btn {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 12px;
}

.server-status,
.current-meta {
  margin: 8px 0 0;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.server-status.is-error {
  color: #b23b3b;
}

.server-status.is-ok {
  color: #0f7c9c;
}

.current-meta {
  font-weight: 600;
}

.info-card {
  padding: 10px 12px;
}

.info-card h2 {
  margin: 0 0 6px;
  font-size: 14px;
}

.info-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.faq-item + .faq-item {
  margin-top: 8px;
}

.faq-item h3 {
  margin: 0 0 3px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .page-shell {
    width: 100%;
    margin: 0;
    padding: 10px;
    gap: 10px;
  }

  .mini-nav,
  .viewer-card,
  .server-card,
  .info-card {
    border-radius: 16px;
  }

  .mini-nav {
    min-height: 42px;
    padding: 6px 8px;
  }

  .mini-nav-brand {
    font-size: 12px;
  }

  .mini-nav-links {
    gap: 6px;
  }

  .mini-nav-links a {
    min-height: 26px;
    padding: 0 8px;
    font-size: 11px;
  }

  .viewer-card {
    padding: 10px;
  }

  .compare-stage {
    width: 100%;
  }

  .mode-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .ghost-btn {
    justify-self: start;
  }

  .speed-control {
    grid-template-columns: 36px 1fr;
  }

  .server-grid,
  .endpoint-grid {
    grid-template-columns: 1fr;
  }

  .core-actions {
    grid-template-columns: repeat(2, minmax(116px, 1fr));
    gap: 8px;
    max-width: 100%;
  }

  .core-btn {
    border-radius: 12px;
    padding: 3px 8px;
    gap: 6px;
  }

  .core-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 0;
  }

  .core-sub {
    left: 6px;
    right: 6px;
    bottom: 1px;
    margin-top: 0;
    font-size: 9px;
  }

  .template-list {
    grid-auto-columns: calc((100% - 16px) / 3);
    gap: 8px;
  }

  .template-item {
    border-radius: 10px;
    padding: 6px;
  }

  .template-thumb {
    border-radius: 8px;
  }

  .template-name {
    margin-top: 6px;
    font-size: 11px;
  }

  .primary-btn {
    height: 36px;
  }

  .info-card {
    padding: 9px 10px;
  }

  .info-card h2 {
    font-size: 13px;
  }

  .info-card p {
    font-size: 11px;
  }
}
