* { box-sizing: border-box; }

:root {
  --pink: #F4A0A0;
  --pink-dark: #c97878;
  --pink-deep: #b8585e;
  --pink-hover: #e98e8e;
  --cream: #FFF0C0;
  --paper: #fffaf0;
  --ink: #2a2620;
  --ink-soft: #3a3328;
  --muted: #8a6a4a;
  --muted-soft: #9c8568;
  --tan-border: #ead7c8;
  --tan-bg: #f4ead8;
}

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  font-weight: 400;
  letter-spacing: 0.01em;
}

h1, h2, h3, .modal-title, .canvas-title {
  font-family: 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', serif;
  font-weight: 700;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Resume button */
.resume-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.2;
  box-shadow: 0 4px 0 var(--pink-dark), 0 6px 12px rgba(0,0,0,0.1);
  border: 2px solid #fff;
  z-index: 100;
  transition: transform 0.2s ease;
}
.resume-btn:hover { transform: scale(1.1); }
.resume-btn span { display: block; }

/* Stage */
.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 600px;
  overflow: hidden;
}

.wave {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Nodes */
.node {
  position: absolute;
  width: var(--size);
  height: var(--size);
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--pink);
  border: 3px solid #fff;
  box-shadow:
    0 4px 0 var(--pink-dark),
    0 6px 14px rgba(0,0,0,0.12),
    inset 0 -4px 8px rgba(0,0,0,0.08);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: inherit;
  padding: 4px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 5;
}
.node:hover {
  transform: translate(-50%, -50%) scale(1.08);
}
.node-label {
  font-size: 30px;
  font-weight: bold;
  line-height: 1.2;
}
.node-5 .node-label { font-size: 44px; }
.node-date {
  font-size: 15px;
  opacity: 0.85;
  margin-top: 6px;
}

.node.glow {
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% {
    box-shadow:
      0 4px 0 var(--pink-dark),
      0 6px 14px rgba(0,0,0,0.12),
      0 0 0 0 rgba(244,160,160,0.6),
      inset 0 -4px 8px rgba(0,0,0,0.08);
  }
  50% {
    box-shadow:
      0 4px 0 var(--pink-dark),
      0 6px 14px rgba(0,0,0,0.12),
      0 0 0 18px rgba(244,160,160,0),
      inset 0 -4px 8px rgba(0,0,0,0.08);
  }
}

.caption {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 1px;
  margin: 0;
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.2s ease;
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(1000px, 92vw);
  height: min(620px, 88vh);
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  position: relative;
  display: flex;
  padding: 28px;
  gap: 28px;
  animation: pop-in 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}
@keyframes pop-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--muted);
}
.modal-close:hover { background: #f4eada; }

.modal-left {
  flex: 0 0 45%;
  background: #f5f5f5;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}
.modal-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Swiper image slides */
.swiper, .swiper-wrapper {
  width: 100%;
  height: 100%;
}
.swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tan-bg);
  color: var(--muted);
  font-size: 18px;
  overflow: hidden;
}
.swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.swiper-slide.slide-empty {
  font-family: 'Noto Serif SC', serif;
  font-size: 24px;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #f4dcc8, var(--tan-border));
}
.swiper-pagination-bullet { background: #fff; opacity: 0.7; }
.swiper-pagination-bullet-active { background: var(--pink); opacity: 1; }
.swiper-button-prev, .swiper-button-next {
  color: #fff;
  --swiper-navigation-size: 24px;
}
/* Vertical pagination on the right edge */
.swiper-pagination-vertical.swiper-pagination-bullets,
.swiper-vertical > .swiper-pagination-bullets {
  right: 8px;
  left: auto;
  top: 50%;
  transform: translateY(-50%);
}
.swiper-vertical > .swiper-pagination-bullets .swiper-pagination-bullet {
  margin: 6px 0;
}

.modal-title {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: var(--ink);
  line-height: 1.3;
}
.modal-timeline {
  margin: 0 0 18px 0;
  font-size: 13px;
  color: var(--muted-soft);
  letter-spacing: 0.5px;
  white-space: pre-line;
  font-weight: 300;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.9;
  white-space: pre-line;
  padding-right: 8px;
  font-weight: 400;
  color: var(--ink-soft);
}
.modal-body strong, .card-a strong {
  font-weight: 700;
  color: var(--pink-deep);
}
.modal-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted-soft);
  font-style: italic;
}

/* Floating chat FAB */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
}
.chat-fab {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 6px 0 var(--pink-dark), 0 8px 18px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: inherit;
  animation: fab-bob 3s ease-in-out infinite;
  transition: transform 0.2s ease;
}
.chat-fab:hover { transform: scale(1.06); }
.fab-icon { font-size: 22px; line-height: 1; }
.fab-text {
  font-size: 12px;
  line-height: 1.2;
  font-weight: bold;
  text-align: center;
}
@keyframes fab-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Canvas modal (chat) */
.canvas-mask {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  animation: fade-in 0.2s ease;
}

.canvas {
  width: min(92vw, 1100px);
  height: min(86vh, 680px);
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop-in 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

.canvas-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: var(--pink);
  color: #fff;
}
.canvas-title { font-size: 18px; font-weight: bold; }
.canvas-head-right { display: flex; align-items: center; gap: 14px; }
.canvas-close {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
}
.canvas-close:hover { background: rgba(255,255,255,0.35); }

/* The board: horizontal scrolling card canvas */
.canvas-board {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 28px 24px;
  display: flex;
  gap: 22px;
  align-items: stretch;
  background:
    radial-gradient(circle, #e8dcc5 1.5px, transparent 1.5px) 0 0 / 24px 24px,
    var(--paper);
  scroll-behavior: smooth;
}
.canvas-board::-webkit-scrollbar { height: 8px; }
.canvas-board::-webkit-scrollbar-thumb { background: #e0d0b8; border-radius: 4px; }

.card {
  flex: 0 0 300px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--tan-border);
  box-shadow: 0 4px 0 var(--tan-border), 0 6px 14px rgba(0,0,0,0.06);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  animation: card-in 0.3s cubic-bezier(0.2, 0.8, 0.3, 1.2);
  transform-origin: bottom center;
}
@keyframes card-in {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.card:nth-child(odd) { transform: rotate(-0.4deg); }
.card:nth-child(even) { transform: rotate(0.4deg); }
.card-q {
  font-size: 14px;
  color: var(--muted-soft);
  border-left: 3px solid var(--pink);
  padding: 2px 0 2px 10px;
  line-height: 1.5;
}
.card-a {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.card-intro {
  flex: 0 0 340px;
  background: #fff5e0;
  border-color: #f4d8a0;
  box-shadow: 0 4px 0 #f4d8a0, 0 6px 14px rgba(0,0,0,0.06);
}

.card-loading .dots span {
  display: inline-block;
  animation: blink 1.2s infinite;
  font-size: 18px;
  color: var(--muted-soft);
}
.card-loading .dots span:nth-child(2) { animation-delay: 0.2s; }
.card-loading .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.card-download-badge {
  margin-top: auto;
  background: var(--pink);
  color: #fff;
  text-align: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  display: block;
}
.card-download-badge:hover { background: var(--pink-hover); }

/* Footer */
.canvas-footer {
  padding: 14px 22px 18px;
  background: var(--paper);
  border-top: 1px solid #f0e6d8;
}
.canvas-input-row {
  display: flex;
  gap: 10px;
}
#chatInput {
  flex: 1;
  padding: 12px 18px;
  border-radius: 24px;
  border: 1.5px solid #e0d0b8;
  font-family: inherit;
  font-size: 15px;
  background: #fff;
  outline: none;
  transition: background 0.2s ease, color 0.2s ease;
}
#chatInput:focus { border-color: var(--pink); }
#chatInput:disabled {
  background: #ece5d8;
  color: #b0a89a;
  border-color: #d8cdb8;
  cursor: not-allowed;
}
#chatSend {
  border: none;
  background: var(--pink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 15px;
  box-shadow: 0 3px 0 var(--pink-dark);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
#chatSend:disabled {
  background: #d8cdb8;
  color: #fff;
  box-shadow: 0 3px 0 #b8ad98;
  cursor: not-allowed;
}

.turn-dots {
  display: inline-flex;
  gap: 5px;
  font-size: 12px;
  color: #fff;
  opacity: 0.9;
  align-items: center;
}
.turn-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  background: transparent;
}
.turn-dots .dot.used { background: #fff; }

.chat-end {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

/* Mobile */
@media (max-width: 768px) {
  .modal {
    width: 92vw;
    height: 88vh;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
  }
  .modal-left {
    flex: 0 0 38%;
    width: 100%;
  }
  .modal-right { flex: 1; }
  .stage { height: 100vh; min-height: 560px; }
  .node-label { font-size: 13px; }
  .node-5 .node-label { font-size: 16px; }
  .node-date { font-size: 10px; }
  .caption { font-size: 13px; bottom: 16px; }

  .chat-widget {
    bottom: 16px;
    right: 16px;
  }
  .chat-fab { width: 64px; height: 64px; }
  .fab-icon { font-size: 18px; }
  .fab-text { font-size: 10px; }
  .canvas {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  .canvas-board { padding: 18px 14px; gap: 14px; }
  .card { flex: 0 0 260px; padding: 14px 16px; }
  .card-intro { flex: 0 0 280px; }

  /* Mobile: hide pixel-positioned wave, stack nodes vertically */
  .wave { display: none; }
  .node { --size: 96px !important; }
  .node-5 { --size: 130px !important; }
  .node-1 { --x: 22% !important; --y: 14% !important; }
  .node-2 { --x: 72% !important; --y: 28% !important; }
  .node-3 { --x: 22% !important; --y: 46% !important; }
  .node-4 { --x: 72% !important; --y: 62% !important; }
  .node-5 { --x: 50% !important; --y: 82% !important; }
}
