/* 移植自 EchoShelf web 的 public/style.css：只保留画廊墙需要的部分（舞台、卡片标签、顶栏、详情面板、提示），
   详情面板换成「对比图 + 完整 prompt + 署名」。 */

:root {
  --bg: #090a0c;
  --surface: rgba(18, 19, 24, 0.66);
  --surface-strong: rgba(14, 15, 19, 0.88);
  --hairline: rgba(255, 255, 255, 0.1);
  --hairline-strong: rgba(255, 255, 255, 0.2);
  --text: #f4f4f6;
  --text-secondary: rgba(244, 244, 246, 0.66);
  --text-tertiary: rgba(244, 244, 246, 0.42);
  --accent: #22c55e;
  --accent-ink: #052e14;
  --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: 20px;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, "PingFang SC", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

/* ---------- 3D 舞台 ---------- */

.stage {
  position: fixed;
  inset: 0;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
  cursor: default;
  touch-action: none;
}

.stage canvas.is-pointing {
  cursor: pointer;
}

.stage canvas.is-dragging {
  cursor: grabbing;
}

/* ---------- 画廊墙：卡片下方的文字标签（跟随 3D 投影定位） ---------- */

.tile-labels {
  position: fixed;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.tile-label {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  gap: 2px;
  padding-top: 10px;
  opacity: 0;
  will-change: transform, opacity;
}

.tile-label p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-title {
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
}

.tile-artist {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-tertiary);
}

.gallery-fade {
  position: fixed;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(9, 10, 12, 0), rgba(9, 10, 12, 0.78));
  pointer-events: none;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 20px
    max(var(--gutter), env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(9, 10, 12, 0.84) 0%, rgba(9, 10, 12, 0.36) 55%, rgba(9, 10, 12, 0) 100%);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid rgba(34, 197, 94, 0.7);
  outline-offset: 2px;
}

/* ---------- 空状态 ---------- */

.empty {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: min(460px, calc(100% - 2 * var(--gutter)));
  transform: translate(-50%, -58%);
  text-align: center;
}

.empty h1 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 650;
}

.empty p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

kbd {
  padding: 1px 6px;
  border: 1px solid var(--hairline-strong);
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
}

/* ---------- 详情面板 ---------- */
/* 上半部分：原图 / 生成图左右并排的大图（占满剩余高度）；下半部分：紧凑的文字区。 */

.detail-scrim {
  position: fixed;
  z-index: 3;
  inset: 0;
  background: rgba(4, 5, 7, 0.55);
  opacity: 0;
  transition: opacity 0.28s var(--ease-out-expo);
}

.detail-scrim.is-open {
  opacity: 1;
}

.detail {
  position: fixed;
  z-index: 4;
  top: 12px;
  bottom: 12px;
  left: 50%;
  width: min(1320px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  background: var(--surface-strong);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 24px 80px rgba(0, 0, 0, 0.62);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition:
    opacity 0.28s var(--ease-out-expo),
    transform 0.32s var(--ease-out-expo);
}

.detail.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.detail::-webkit-scrollbar {
  width: 6px;
}

.detail::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

/* 标题栏：来源 + 标题，右侧 上一张 / 下一张 / 关闭 */
.detail-head {
  position: sticky;
  z-index: 2;
  top: 0;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 6px;
  background: var(--surface-strong);
}

.detail-heading {
  min-width: 0;
}

.detail-nav {
  flex: none;
  display: flex;
  gap: 6px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.18s var(--ease-out-expo),
    transform 0.18s var(--ease-out-expo),
    opacity 0.18s var(--ease-out-expo);
}

.icon-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  transform: scale(1.06);
}

.icon-button:active:not(:disabled) {
  transform: scale(0.92);
}

.icon-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-source {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.detail-source.is-derived {
  color: #fbbf24;
}

.detail-title {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

/* 对比图：左原图、右生成图，占满剩余宽高，各自完整显示（墙上的卡片会裁切，这里不裁），点开看原尺寸 */
.detail-compare {
  flex: 1 1 0;
  min-height: 220px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.detail-compare figure {
  min-width: 0;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-frame {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.detail-frame a {
  position: absolute;
  inset: 0;
  display: block;
  cursor: zoom-in;
}

.detail-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail-frame img:not([src]) {
  visibility: hidden;
}

.detail-compare figcaption {
  flex: none;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-tertiary);
  overflow-wrap: anywhere;
}

/* 文字区：左 prompt 代码块，右 技法 + 紧凑元信息 */
.detail-info {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 16px;
}

.detail-prompt-block {
  min-width: 0;
}

.detail-prompt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.detail-prompt-head h3 {
  margin: 0 auto 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.detail-lang {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.chip {
  padding: 4px 12px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.16s var(--ease-out-expo),
    border-color 0.16s var(--ease-out-expo),
    transform 0.14s var(--ease-out-expo);
}

.chip[hidden] {
  display: none;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--hairline-strong);
}

.chip:active {
  transform: scale(0.96);
}

.chip-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.chip-primary:hover {
  background: #2fd56b;
}

.chip-primary.is-done {
  background: #bbf7d0;
}

.detail-prompt {
  max-height: 7.2em;
  margin: 0;
  padding: 9px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.32);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.detail.is-prompt-expanded .detail-prompt {
  max-height: 38dvh;
}

.detail-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(7.2em + 40px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.detail.is-prompt-expanded .detail-side {
  max-height: none;
}

.detail-technique {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.detail-technique[hidden] {
  display: none;
}

.detail-meta p {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.detail-meta a,
.detail-more a {
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 3px;
}

.detail-meta a:hover {
  color: var(--text);
}

.detail-more {
  font-size: 12px;
  color: var(--text-secondary);
}

.detail-more summary {
  cursor: pointer;
  color: var(--text-tertiary);
}

.detail-more p {
  margin: 6px 0 0;
  line-height: 1.6;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.detail-more p[hidden],
.detail-more dl[hidden] {
  display: none;
}

.detail-placeholders {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 6px 0 0;
  line-height: 1.5;
}

.detail-placeholders dt {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.detail-placeholders dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  z-index: 5;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 10px 16px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-size: 13px;
  line-height: 1.45;
  transform: translateX(-50%);
  animation: toast-in 0.25s ease-out;
}

.toast.is-error {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

/* ---------- 窄屏 ---------- */

@media (max-width: 720px) {
  .tile-title {
    font-size: 13px;
  }

  .tile-artist {
    font-size: 11.5px;
  }

  .toast {
    border-radius: var(--radius);
    text-align: center;
  }

  /* 手机：近全屏抽屉。两张图改为左右滑动（scroll-snap），文字区仍在下方且保持紧凑 */
  .detail {
    top: 8px;
    bottom: 8px;
    width: calc(100% - 16px);
    gap: 8px;
    padding: 0 12px 12px;
  }

  .detail-title {
    font-size: 17px;
  }

  .detail-compare {
    display: flex;
    gap: 10px;
    min-height: 200px;
    margin: 0 -12px;
    padding: 0 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 12px;
    scrollbar-width: none;
  }

  .detail-compare::-webkit-scrollbar {
    display: none;
  }

  .detail-compare figure {
    flex: 0 0 86%;
    scroll-snap-align: center;
  }

  .detail-info {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .detail-prompt {
    max-height: 5.6em;
  }

  .detail.is-prompt-expanded .detail-prompt {
    max-height: 30dvh;
  }

  .detail-side {
    max-height: none;
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .detail,
  .detail-scrim,
  .icon-button,
  .chip,
  .toast {
    transition: none;
    animation: none;
  }
}
