/* Illustrated Explainer — Warm Paper Atelier
 * Distilled from Stitch design (Gemini 3 Flash, 2026-04-27).
 * Vanilla CSS only — no Tailwind, no icon library, no JS framework.
 * Preserves §6a drill + §6b cross-domain + 3-tier affordance hooks.
 */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Literata:ital,wght@0,500;0,600;1,400;1,500&display=swap");

/* ── Reset ──────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* ── Tokens (from claude-DESIGN.md × Stitch distill) ─────────────────── */
:root {
  --parchment: #fdfbf6;
  --ivory: #faf9f5;
  --warm-border: #f0eee6;
  --deep-border: #e8e6dc;
  --warm-black: #2c2a26;
  --olive-gray: #5e5d59;
  --stone-gray: #87867f;
  --terracotta: #c96442;
  --terracotta-hover: #b8553a;
  --terracotta-translucent: rgba(201, 100, 66, 0.18);
  --synapse-purple: #6b4f9e;
  --synapse-purple-light: #8b6bc4;
  --synapse-purple-deep: #5a4189;
  --synapse-purple-tint: rgba(107, 79, 158, 0.30);
  --synapse-bg-from: #f4eef9;
  --synapse-bg-to: #ede4f5;
  --synapse-text: #3a2e5a;
  --analogy-blue: #3b6e8c;
  --analogy-blue-light: #5a89a8;
  --analogy-blue-deep: #2c5670;
  --analogy-blue-tint: rgba(59, 110, 140, 0.30);
  --analogy-bg-from: #eef4f8;
  --analogy-bg-to: #dde8ef;
  --analogy-text: #1f3a4d;
  --sand-hover: #f4eee0;
  --serif: "Literata", Georgia, "Songti SC", "STSong", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  background: var(--parchment);
  color: var(--warm-black);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "tnum" 1;
}

/* ── App Shell ──────────────────────────────────────────────────────── */
.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--deep-border);
  position: sticky;
  top: 0;
  background: var(--parchment);
  z-index: 50;
}
.brand {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--warm-black);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  color: var(--terracotta);
  display: inline-block;
  vertical-align: -3px;
  flex: 0 0 auto;
  transform: translateY(-1px);
}
/* R14/F57 — memory-palace tagline tucked next to the brand mark.
   Lower visual weight than the brand wordmark; serif-italic for editorial
   feel, ash-gray to recede behind the canvas. Hidden on narrow screens. */
.brand-tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  font-weight: 400;
  color: var(--stone-gray);
  letter-spacing: 0;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--deep-border);
  white-space: nowrap;
}
@media (max-width: 720px) {
  .brand-tagline { display: none; }
}
.counter {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--stone-gray);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.actions[hidden] { display: none !important; }
.actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

/* ── Buttons ────────────────────────────────────────────────────────── */
button {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--deep-border);
  background: var(--ivory);
  color: var(--warm-black);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
button:hover:not(:disabled) {
  background: var(--sand-hover);
  border-color: #c4b994;
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#gen-btn {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta-hover);
  padding: 12px 28px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
#gen-btn:hover:not(:disabled) {
  background: var(--terracotta-hover);
  border-color: var(--terracotta-hover);
}

#jump-btn {
  background: linear-gradient(135deg, var(--synapse-purple), var(--synapse-purple-light));
  color: #fff;
  border-color: var(--synapse-purple-deep);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#jump-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--synapse-purple-deep), #7a5ab3);
  border-color: var(--synapse-purple-deep);
}
#jump-btn:disabled {
  background: var(--ivory);
  color: var(--stone-gray);
  border-color: var(--deep-border);
}

#parallel-btn {
  background: linear-gradient(135deg, var(--analogy-blue), var(--analogy-blue-light));
  color: #fff;
  border-color: var(--analogy-blue-deep);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#parallel-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--analogy-blue-deep), #466e87);
  border-color: var(--analogy-blue-deep);
}
#parallel-btn:disabled {
  background: var(--ivory);
  color: var(--stone-gray);
  border-color: var(--deep-border);
}

/* R11/F37 (J3) — demote nav buttons (back/reset). Lower visual weight than
   exploration buttons (parallel/jump) so the eye lands on the canvas + the
   two exploration affordances first. Pure visual hierarchy fix. */
.nav-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--stone-gray);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 400;
}
.nav-ghost:hover:not(:disabled) {
  background: var(--sand-hover);
  border-color: var(--deep-border);
  color: var(--warm-black);
}
.nav-ghost:disabled {
  opacity: 0.35;
  border-color: transparent;
}

/* ── Hero Zone — Round-4 polish: serif statement above topic input ─────── */
.hero-zone {
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  padding: 8px 0 4px;
  text-align: left;
}
.hero-title {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.012em;
  color: var(--warm-black);
  margin: 0 0 10px;
  text-wrap: balance;
  animation: hero-rise 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.hero-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--olive-gray);
  margin: 0;
  letter-spacing: 0.005em;
  animation: hero-rise 720ms cubic-bezier(0.16, 1, 0.3, 1) 180ms both;
}
@keyframes hero-rise {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
/* Round-7 F13: canvas owns the hierarchy once a page is rendered */
body.has-pages .hero-zone { display: none; }

/* ── Topic Zone — Round-3 polish P-Jobs: eyebrow above input gives anchor ─ */
.topic-zone {
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.topic-eyebrow {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  font-weight: 400;
  color: var(--terracotta);
  letter-spacing: 0.02em;
  padding-left: 4px;
  margin-bottom: 2px;
}
/* Round-7 F14: compact eyebrow + tightened topic-zone in filled state */
body.has-pages .topic-zone { gap: 4px; }
body.has-pages .topic-eyebrow {
  font-family: var(--sans);
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--stone-gray);
  padding-left: 2px;
  margin-bottom: 0;
}
/* Round-8 F17: compact input row in filled state — semantics shift from "first invitation" to "ask another" */
body.has-pages .topic-row { gap: 12px; padding: 0 0 4px; }
body.has-pages input[type="text"] { padding: 8px 4px; font-size: 17px; }
body.has-pages #gen-btn {
  padding: 8px 18px;
  font-size: 13px;
  min-height: 36px;
}

/* ── Topic Input — Round-2 swarm patch C3: standalone Generate beside underline ── */
.topic-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  width: 100%;
  padding: 4px 0 8px;
}
.topic-input-wrap {
  position: relative;
  flex: 1;
}
input[type="text"] {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--deep-border);
  padding: 14px 4px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  font-weight: 400;
  color: var(--warm-black);
  outline: none;
  transition: border-color 0.18s ease;
  caret-color: var(--terracotta);
}
input[type="text"]::placeholder {
  color: var(--stone-gray);
  opacity: 0.55;
  font-style: italic;
}
input[type="text"]:focus { border-bottom-color: var(--terracotta); }
input[type="text"]:disabled {
  background: transparent;
  color: var(--olive-gray);
}
#gen-btn {
  padding: 12px 32px;
  font-size: 15px;
  letter-spacing: 0.04em;
  min-height: 48px;
  flex: 0 0 auto;
}

/* ── Gallery Section: 思考起点 · 今日邀请 ─────────────────────────────── */
.gallery-section {
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  padding: 36px 0 32px;
  border-top: 1px solid var(--warm-border);
  border-bottom: 1px solid var(--warm-border);
}
.gallery-section.hidden { display: none; }
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
  gap: 16px;
}
.gallery-label {
  font-family: var(--serif);
  font-style: normal;
  font-size: 22px;
  font-weight: 600;
  color: var(--warm-black);
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.25;
}
.gallery-helper {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--olive-gray);
  margin-top: 6px;
  letter-spacing: 0;
  line-height: 1.5;
}
.gallery-refresh {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--olive-gray);
  text-decoration: none;
  border: 1px solid var(--deep-border);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  background: var(--ivory);
  letter-spacing: 0.04em;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.gallery-refresh .refresh-icon {
  font-size: 13px;
  line-height: 1;
  color: var(--terracotta);
  display: inline-block;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.gallery-refresh:hover .refresh-icon {
  transform: rotate(180deg);
}
.gallery-refresh:hover {
  color: var(--terracotta);
  border-color: var(--terracotta);
  background: var(--parchment);
}
.gallery-refresh.spinning {
  opacity: 0.5;
  pointer-events: none;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--ivory);
  border: 1px solid var(--deep-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  font-style: normal;
  font-size: 15px;
  font-weight: 600;
  color: var(--warm-black);
  letter-spacing: -0.005em;
  word-break: keep-all;
  overflow-wrap: break-word;
  min-width: 0;
  transition: border-color 0.22s ease, transform 0.12s ease, box-shadow 0.22s ease, background 0.22s ease;
  width: 100%;
}
.chip:hover:not(:disabled) {
  border-color: var(--terracotta);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 4px rgba(44, 42, 38, 0.03),
    0 4px 12px rgba(201, 100, 66, 0.10);
  background: var(--parchment);
}
.chip:active:not(:disabled) {
  transform: translateY(0);
}
.chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* Round-5 F9: first chip gets a subtle terracotta ring as "today's first card".
 * Outer box-shadow keeps the existing border + layout intact; hover/selected
 * states still win because they redefine box-shadow / background. */
.gallery-grid > .chip:first-child:not(.selected):not(:hover) {
  box-shadow: 0 0 0 2px var(--terracotta-translucent);
}
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--stone-gray);
}
.chip-dot.biology    { background: #2f8f5e; }
.chip-dot.physics    { background: #1e3a8a; }
.chip-dot.finance    { background: #b87333; }
.chip-dot.arts       { background: #8e2b6b; }
.chip-dot.philosophy { background: #4338ca; }
.chip-dot.law        { background: #64748b; }
.chip-dot.math       { background: #8b6bc4; }
.chip-dot.music      { background: #a23a78; }
.chip-dot.psychology { background: #4338ca; }
.chip-dot.linguistics { background: #0d9488; }
.chip-dot.computing  { background: #475569; }
.chip-dot.chemistry  { background: #92400e; }
.chip-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Round-2 swarm R2-B: chip selected pulse on click */
.chip.selected {
  border-color: var(--terracotta);
  background: rgba(201, 100, 66, 0.08);
  transform: translateY(-1px);
  animation: chip-selected-pulse 380ms ease-out;
  pointer-events: none;
}
@keyframes chip-selected-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(201, 100, 66, 0.45); }
  60%  { box-shadow: 0 0 0 10px rgba(201, 100, 66, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 100, 66, 0); }
}

/* Round-2 swarm R2-A: domain-color legend strip
 * R14g (2026-04-28): hidden per Round 4 cold-start swarm consensus
 * (Hara + Jobs convergent #1 kill — friction without conversion on landing).
 * Reverse by changing `display: none` to `display: flex` if a11y/discovery
 * concern outweighs landing focus. Keep all sub-rules intact for fast revert. */
.gallery-legend {
  display: none;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--warm-border);
  justify-content: flex-start;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--stone-gray);
  letter-spacing: 0.04em;
}
.legend-item .chip-dot {
  width: 8px;
  height: 8px;
}
.gallery-legend {
  justify-content: center;
}
.gallery-legend::before {
  content: "色彩对应学科";
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--stone-gray);
  letter-spacing: 0.04em;
  margin-right: 6px;
  align-self: center;
}
.legend-label {
  font-weight: 400;
}

/* ── Bridge Banner (§6b cross-domain reveal) ────────────────────────── */
.bridge-banner[hidden] { display: none !important; }
.bridge-banner {
  background: linear-gradient(135deg, var(--synapse-bg-from) 0%, var(--synapse-bg-to) 100%);
  border: 1px solid #c4b3dc;
  border-left: 4px solid var(--synapse-purple);
  border-radius: 10px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  animation: bridge-reveal 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.bridge-label {
  order: 1;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--synapse-purple);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}
.bridge-headline {
  order: 2;
  font-family: var(--serif);
  font-style: normal;
  font-size: 22px;
  font-weight: 600;
  color: var(--synapse-text);
  letter-spacing: -0.005em;
  width: 100%;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: balance;
}
.bridge-text {
  order: 3;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--synapse-text);
  width: 100%;
  letter-spacing: 0;
  border-top: 1px solid rgba(107, 79, 158, 0.20);
  padding-top: 14px;
  margin-top: 8px;
  opacity: 0;
  transform: translateY(6px);
  animation: bridge-text-reveal 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.7s forwards;
}
@keyframes bridge-reveal {
  0%   { opacity: 0; transform: translateY(-6px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes bridge-text-reveal {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .bridge-text,
  .hero-title,
  .hero-sub {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

/* ── Analogy Banner (§6c structural isomorphism reveal) ─────────────────── */
.analogy-banner[hidden] { display: none !important; }
.analogy-banner {
  background: linear-gradient(135deg, var(--analogy-bg-from) 0%, var(--analogy-bg-to) 100%);
  border: 1px solid #b3c7d6;
  border-left: 4px solid var(--analogy-blue);
  border-radius: 10px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  animation: bridge-reveal 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.analogy-label {
  order: 1;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--analogy-blue);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}
.analogy-pair-meta {
  order: 2;
  font-family: var(--serif);
  font-style: normal;
  font-size: 22px;
  font-weight: 600;
  color: var(--analogy-text);
  letter-spacing: -0.005em;
  width: 100%;
  line-height: 1.3;
}
.analogy-text {
  order: 3;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--analogy-text);
  width: 100%;
  letter-spacing: 0;
  border-top: 1px solid rgba(59, 110, 140, 0.20);
  padding-top: 10px;
  margin-top: 4px;
}

/* ── Canvas Pair (§6c side-by-side analog comparison) ─────────────────── */
.canvas-area:has(#canvas-pair:not([hidden])) {
  align-items: stretch;
}
.canvas-pair[hidden] { display: none !important; }
.canvas-pair {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}
.canvas-pane {
  flex: 1 1 50%;
  position: relative;
  overflow: hidden;
  background: var(--ivory);
}
.canvas-pane img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.canvas-pane-label {
  position: absolute;
  left: 14px;
  bottom: 14px;
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  font-weight: 500;
  color: #fff;
  background: rgba(31, 58, 77, 0.85);
  padding: 6px 14px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(2px);
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}
.canvas-pane.left .canvas-pane-label {
  background: rgba(94, 93, 89, 0.78);
}
.canvas-pane-divider {
  flex: 0 0 1px;
  background: var(--deep-border);
  position: relative;
  /* R11/F39 (J5) — divider line fades in slowly, glyph follows */
  opacity: 0;
  animation: divider-line-reveal 600ms ease-out 100ms forwards;
}
.canvas-pane-divider::after {
  content: "◆";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  width: auto;
  height: auto;
  background: transparent;
  color: var(--analogy-blue);
  font-size: 18px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ivory);
  /* R11/F39 (J5) — ◆ glyph blooms after the line settles, signaling the
     structural-isomorphism connection between the two panes */
  opacity: 0;
  animation: divider-glyph-bloom 700ms cubic-bezier(0.34, 1.4, 0.64, 1) 500ms forwards;
}
@keyframes divider-line-reveal {
  from { opacity: 0; transform: scaleY(0.2); }
  to   { opacity: 1; transform: scaleY(1); }
}
@keyframes divider-glyph-bloom {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── Canvas Hero ────────────────────────────────────────────────────── */
.canvas-area {
  position: relative;
  background: var(--ivory);
  border: 1px solid var(--deep-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  max-height: 720px;
  margin: 0 auto;
  width: 100%;
}
.canvas-area:has(.placeholder:not(.hidden)):not(:has(#page-img.shown)) {
  aspect-ratio: auto;
  min-height: 420px;
  max-height: 480px;
  background: var(--parchment);
}
.placeholder {
  color: var(--stone-gray);
  font-size: 15px;
  padding: 220px 32px 36px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  line-height: 1.7;
  max-width: 720px;
  background-image: url("/atlas-illustration.png");
  background-repeat: no-repeat;
  background-position: center 16px;
  background-size: 320px auto;
  opacity: 1;
}
.placeholder.hidden { display: none; }
.placeholder strong {
  display: block;
  font-style: normal;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--warm-black);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.placeholder em {
  font-style: italic;
  color: var(--terracotta);
  opacity: 0.85;
}

#page-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  cursor: crosshair;
  position: relative;
  z-index: 1;
}
#page-img.shown { display: block; }

/* Tier 1 affordance — canvas breathe (Stitch's improved blur version) */
.canvas-area:has(#page-img.shown)::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 12px;
  animation: canvas-breathe 3.2s ease-in-out infinite;
  z-index: 2;
}
@keyframes canvas-breathe {
  0%, 100% { box-shadow: inset 0 0 12px rgba(201, 100, 66, 0.05); }
  50%      { box-shadow: inset 0 0 24px var(--terracotta-translucent); }
}

/* Tier 2 affordance — spotlight follows cursor */
.spotlight {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle,
    rgba(201, 100, 66, 0.22) 0%,
    rgba(201, 100, 66, 0.10) 40%,
    rgba(201, 100, 66, 0)   70%);
  transform: translate(-50%, -50%);
  z-index: 3;
  opacity: 0;
  transition: opacity 0.18s ease;
  mix-blend-mode: multiply;
}
.spotlight.active { opacity: 1; }

/* Tier 3 affordance — idle pulse + tooltip */
.idle-pulse {
  position: absolute;
  width: 56px;
  height: 56px;
  border: 2px solid var(--terracotta);
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  animation: idle-pulse 1.6s ease-out infinite;
  box-shadow: 0 0 24px rgba(201, 100, 66, 0.5);
}
.idle-pulse::after {
  content: "点击下钻";
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warm-black);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.06em;
  opacity: 0.92;
  pointer-events: none;
}
@keyframes idle-pulse {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.85; }
  70%  { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

/* Click ripple (drill confirm) */
.click-ripple {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 2px solid var(--terracotta);
  border-radius: 50%;
  pointer-events: none;
  animation: ripple 0.7s ease-out forwards;
  z-index: 4;
}
@keyframes ripple {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
}

/* R11/F38 (J4) — permanent canvas hint. Floats bottom-center, fades in
   after first page loads, persists. Hotspots remain clickable through it
   (pointer-events: none). Jobs critique: the canvas is a deep affordance
   (any pixel is clickable) but invisible — this nudge teaches the gesture
   without dimming the artwork. Tucked just above the foot, soft type. */
.canvas-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(253, 251, 246, 0.86);
  border: 1px solid var(--deep-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--stone-gray);
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 600ms ease-out;
  backdrop-filter: blur(1px);
  white-space: nowrap;
}
.canvas-hint:not([hidden]) {
  opacity: 1;
}

/* ── Loading Overlay ────────────────────────────────────────────────── */
.loading {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(253, 251, 246, 0.94);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 10;
  backdrop-filter: blur(2px);
}
.loading.shown { display: flex; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--deep-border);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  color: var(--olive-gray);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ── Error Banner ───────────────────────────────────────────────────── */
.error-banner {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 18px;
  background: #fff0f0;
  color: #b53333;
  border-bottom: 1px solid #f5c6c6;
  font-size: 13px;
  z-index: 11;
}
.error-banner.shown { display: block; }

/* ── Thumbnails (book-spine row) ────────────────────────────────────── */
.thumbnails-wrap { min-height: 64px; position: relative; }
.thumbnails {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--deep-border) transparent;
  justify-content: center;
  flex-wrap: nowrap;
  align-items: center;
}
/* R14/F58 — concept-trail transition glyph between thumbnails.
   Tells the user HOW they moved from room to room: → drill, ◆ parallel,
   ✦ jump. Without these the thumbnails read as a flat strip; with these
   they read as a path. */
.trail-transition {
  flex: 0 0 auto;
  width: 18px;
  text-align: center;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1;
  color: var(--stone-gray);
  user-select: none;
  cursor: help;
}
.trail-transition[data-kind="parallel"] { color: var(--analogy-blue); font-size: 13px; }
.trail-transition[data-kind="jump"]     { color: var(--synapse-purple); font-size: 13px; }
.trail-transition[data-kind="drill"]    { color: var(--stone-gray); }

/* R14/F59 — share button for the concept trail. Sits centered under the
   thumbnail strip; only appears once the trail has at least 2 rooms. */
.trail-share {
  display: block;
  margin: 4px auto 0;
  background: transparent;
  border: 1px solid var(--deep-border);
  color: var(--stone-gray);
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--sans);
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.trail-share:hover {
  background: var(--sand-hover);
  color: var(--warm-black);
  border-color: #c4b994;
}
.trail-share.copied {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}

/* R14/F62 — spaced-repetition recall banner. Soft warm-paper strip above
   the hero zone; only fires when localStorage holds a room-visit whose age
   matches one of the SR intervals (3d / 7d / 30d) within ±12h. Two actions:
   回房间 (re-enter that room) or 改天 (snooze 1 day). Persists ZH typography
   from the main editorial voice. */
.recall-banner {
  max-width: 920px;
  margin: 0 auto 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.08), rgba(217, 119, 6, 0.02));
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-left: 3px solid var(--terracotta);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.recall-text {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--warm-black);
  line-height: 1.5;
  flex: 1 1 auto;
}
.recall-actions {
  display: inline-flex;
  gap: 8px;
  flex: 0 0 auto;
}
.recall-back, .recall-snooze {
  font-family: var(--sans);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--deep-border);
  background: var(--ivory);
  color: var(--warm-black);
  transition: background 0.15s, border-color 0.15s;
}
.recall-back {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}
.recall-back:hover { background: var(--terracotta-hover); border-color: var(--terracotta-hover); }
.recall-snooze:hover { background: var(--sand-hover); border-color: #c4b994; }
.thumbnails::-webkit-scrollbar { height: 4px; }
.thumbnails::-webkit-scrollbar-thumb { background: var(--deep-border); border-radius: 2px; }
/* Round-7 F15: lone thumb wears its query as a context caption */
.thumbnails:not(:has(.thumb:nth-child(2))) {
  padding-bottom: 28px;
}
.thumbnails:not(:has(.thumb:nth-child(2))) .thumb {
  position: relative;
  overflow: visible;
}
.thumbnails:not(:has(.thumb:nth-child(2))) .thumb[data-label]::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--olive-gray);
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
}

.thumb {
  flex: 0 0 auto;
  width: 96px;
  height: 54px;
  border: 2px solid var(--deep-border);
  border-radius: 6px;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  background-color: var(--ivory);
  position: relative;
  transition: border-color 0.18s ease, transform 0.12s ease;
}
.thumb:hover:not(.active) {
  border-color: var(--stone-gray);
  transform: translateY(-1px);
}
.thumb.active {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 1px rgba(201, 100, 66, 0.18);
}
.thumb.cross-domain {
  border-color: var(--synapse-purple-light);
}
.thumb.cross-domain.active {
  border-color: var(--synapse-purple);
  box-shadow: 0 0 0 2px var(--synapse-purple-tint);
}
.thumb.cross-domain::before {
  content: "✦";
  position: absolute;
  top: 1px;
  right: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 4px rgba(107, 79, 158, 0.95);
  pointer-events: none;
}
.thumb.parallel {
  border-color: var(--analogy-blue-light);
}
.thumb.parallel.active {
  border-color: var(--analogy-blue);
  box-shadow: 0 0 0 2px var(--analogy-blue-tint);
}
.thumb.parallel::before {
  content: "◆";
  position: absolute;
  top: 1px;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 4px rgba(31, 58, 77, 0.95);
  pointer-events: none;
}
.thumb-num {
  position: absolute;
  top: 2px;
  left: 6px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.02em;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--stone-gray);
  padding-top: 16px;
  margin-top: auto;
  border-top: 1px solid var(--warm-border);
  letter-spacing: 0.02em;
  text-align: center;
}
.foot a {
  color: var(--stone-gray);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.foot a:hover { color: var(--terracotta); }
.foot-brand {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--olive-gray);
}
.foot-attribution {
  font-family: var(--sans);
  font-style: normal;
  font-size: 11px;
  color: var(--stone-gray);
  letter-spacing: 0.04em;
  margin-left: 4px;
}

/* Round-8 F18: mobile topbar — collapse parallel/jump to glyph squares ≤480px */
@media (max-width: 480px) {
  .actions { gap: 6px; }
  .actions #parallel-btn,
  .actions #jump-btn {
    width: 38px;
    padding: 8px 0;
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .actions #parallel-btn::before { content: '◆'; font-size: 14px; }
  .actions #jump-btn::before { content: '✦'; font-size: 14px; }
  .actions #back-btn,
  .actions #reset-btn { padding: 8px 12px; font-size: 13px; }
}

/* ── Responsive shrink ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  .app { padding: 0 16px 16px; gap: 16px; }
  .hero-zone { padding: 4px 0 0; }
  .hero-title { font-size: 28px; line-height: 1.2; margin-bottom: 8px; }
  .hero-sub { font-size: 15px; line-height: 1.5; }
  .topbar { height: auto; flex-wrap: wrap; padding: 12px 0; }
  .actions { width: 100%; justify-content: flex-end; }
  .canvas-area { max-height: 480px; }
  .canvas-area:has(.placeholder:not(.hidden)):not(:has(#page-img.shown)) {
    min-height: 420px;
    max-height: 480px;
  }
  .placeholder {
    padding: 200px 20px 36px;
    background-size: 280px auto;
    background-position: center 20px;
    font-size: 14px;
    max-width: 100%;
  }
  .placeholder strong { font-size: 19px; }
  input[type="text"] { font-size: 18px; padding-right: 0; }
  #gen-btn { padding: 7px 14px; font-size: 13px; }
  .bridge-text { font-size: 14px; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gallery-section { padding: 20px 0; }
  .gallery-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .gallery-refresh { align-self: flex-end; }
  .chip { font-size: 14px; padding: 12px 14px; }
  .gallery-legend { justify-content: center; gap: 10px 12px; }
  .legend-item { font-size: 11px; }
  .foot {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    padding-top: 20px;
  }
  .foot-attribution { margin-left: 0; display: block; margin-top: 2px; }
}

/* ── §6d Hotspot Overlay — ink-annotation pattern (no pill, native to illustration) ───── */
.hotspot-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
.hotspot-overlay[hidden] { display: none !important; }
.hotspot {
  position: absolute;
  pointer-events: auto;
  transform: translate(-50%, 0);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  font-weight: 500;
  color: rgba(60, 45, 30, 0.78);
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease, color 0.2s ease, transform 0.2s ease;
}
.hotspot.shown { opacity: 0.85; }
.hotspot:hover {
  opacity: 1;
  color: var(--synapse-purple, #6b4f9e);
  transform: translate(-50%, 0) scale(1.06);
}
.hotspot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--synapse-purple, #6b4f9e);
  box-shadow: 0 0 0 3px rgba(255, 250, 240, 0.55), 0 0 0 4px rgba(107, 79, 158, 0.18);
  flex: 0 0 8px;
}
.hotspot-label {
  display: inline-block;
  max-width: 10em;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(255, 250, 240, 0.85);
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s ease;
}
.hotspot:hover .hotspot-label {
  border-bottom-color: rgba(107, 79, 158, 0.55);
}

/* ── §6d Exploration Zone (联想启发 + 进一步思考) ───────────────────────── */
.exploration-zone {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 24px 4px;
  width: 100%;
  box-sizing: border-box;
}
.exploration-zone[hidden] { display: none !important; }
.explore-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.explore-block-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.explore-eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terracotta, #b85c38);
  white-space: nowrap;
}
.thinking-block .explore-eyebrow {
  color: var(--synapse-purple, #6b4f9e);
}
.explore-helper {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--stone-gray, #8a8580);
  letter-spacing: 0;
}

/* Inspiration row: ghost-pill chips, terracotta accent */
.inspirations-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.inspiration-chip {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink, #2c2520);
  background: rgba(184, 92, 56, 0.06);
  border: 1px solid rgba(184, 92, 56, 0.28);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, color 0.2s ease;
  letter-spacing: 0.01em;
}
.inspiration-chip:hover {
  background: rgba(184, 92, 56, 0.12);
  border-color: var(--terracotta, #b85c38);
  color: var(--terracotta, #b85c38);
}
.inspiration-chip:active {
  transform: translateY(1px);
}
.inspiration-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Thinking prompts: italic serif card list */
.thinking-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.thinking-prompt {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink, #2c2520);
  background: rgba(107, 79, 158, 0.04);
  border: 1px solid rgba(107, 79, 158, 0.18);
  border-left: 3px solid var(--synapse-purple, #6b4f9e);
  border-radius: 6px;
  padding: 10px 14px 10px 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.thinking-prompt:hover {
  background: rgba(107, 79, 158, 0.09);
  border-left-color: var(--synapse-purple, #6b4f9e);
  color: var(--synapse-text, #4d3c75);
}
.thinking-prompt::before {
  content: '↗ ';
  font-style: normal;
  color: var(--synapse-purple, #6b4f9e);
  font-weight: 600;
  margin-right: 4px;
  letter-spacing: 0;
}
.thinking-prompt:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile: tighten the exploration zone, allow horizontal scroll for chips */
@media (max-width: 720px) {
  .exploration-zone { padding: 16px 16px 4px; gap: 14px; }
  .explore-block-header { gap: 8px; }
  .explore-helper { font-size: 11px; }
  .inspirations-row { gap: 6px 8px; }
  .inspiration-chip { font-size: 12px; padding: 5px 12px; }
  .thinking-prompt { font-size: 14px; padding: 9px 12px 9px 14px; }
  .hotspot { font-size: 11px; padding: 3px 8px 3px 5px; }
  .hotspot::before { width: 6px; height: 6px; flex: 0 0 6px; box-shadow: 0 0 0 2px rgba(107, 79, 158, 0.16); }
  .hotspot-label { max-width: 7em; }
}
@media (prefers-reduced-motion: reduce) {
  .hotspot { transition: none; }
  .hotspot:hover { transform: translate(-50%, -50%); }
  .inspiration-chip, .thinking-prompt { transition: none; }
}
