:root {
  --bg: #0a0a0a;
  --paper: #c4a47c;
  --ink: #1a1a1a;
  --cinnabar: #a61b1b;
  --gold: #b89b72;
  --ink-read: #3d2b1a;
  --ink-unread: rgba(26, 26, 26, 0.35);
  --char-size: clamp(32px, 5vw, 48px);
  --gap-col: clamp(30px, 5vw, 55px);
  --scroll-padding: clamp(20px, 4vw, 40px);
  --taiji-size: clamp(180px, 40vw, 55vh);
  --axis-width: clamp(36px, 5.5vw, 50px);
  --chapter-size: clamp(24px, 3vw, 34px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body, html {
  height: 100%; width: 100%; overflow: hidden;
  background: radial-gradient(ellipse at center, #0a1525 0%, #02050d 100%);
  font-family: "STSong", "Songti SC", "Noto Serif SC", "KaiTi", "SimSun", serif;
}

.stars-container { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.star {
  position: absolute; background: white; border-radius: 50%;
  animation: twinkle var(--duration) ease-in-out infinite;
  animation-delay: var(--delay); opacity: 0;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.4); box-shadow: 0 0 8px 2px rgba(255,255,255,0.5); }
}
.nebula {
  position: fixed; border-radius: 50%; filter: blur(90px);
  opacity: 0.1; pointer-events: none; z-index: 0;
}
.nebula1 { width: 50vw; height: 50vw; top: -5%; left: -5%; background: radial-gradient(circle, #3a2060, transparent); }
.nebula2 { width: 60vw; height: 60vw; bottom: -15%; right: -10%; background: radial-gradient(circle, #1a3050, transparent); }

.taiji-bg {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: var(--taiji-size); height: var(--taiji-size);
  z-index: 1; pointer-events: none;
  animation: taiji-spin 30s linear infinite;
  border-radius: 50%;
  box-shadow: 0 0 50px rgba(180,150,110,0.15);
}
.taiji-bg svg { width: 100%; height: 100%; display: block; }
@keyframes taiji-spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.header {
  position: fixed; top: 0; width: 100%; height: 60px;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(14px);
  display: flex; justify-content: center; align-items: center; gap: 12px;
  z-index: 100; border-bottom: 1px solid var(--gold);
  flex-wrap: wrap; padding: 0 10px;
}

button {
  background: transparent; border: 1px solid var(--gold); color: var(--gold);
  padding: 6px 12px; cursor: pointer; font-weight: bold;
  font-family: inherit; font-size: clamp(12px, 1.6vw, 15px);
  letter-spacing: 1px; border-radius: 3px; transition: all 0.3s;
  user-select: none; white-space: nowrap;
}
button:hover {
  background: rgba(184,155,114,0.15); border-color: #d4b87a; color: #d4b87a;
}
button:active { transform: scale(0.96); }
button.active {
  background: rgba(166,27,27,0.3); border-color: var(--cinnabar); color: var(--cinnabar);
}

#playBtn.playing {
  border-color: var(--cinnabar); color: var(--cinnabar);
  animation: pulse-btn 1.6s infinite;
}
@keyframes pulse-btn {
  0%,100% { box-shadow: 0 0 6px rgba(166,27,27,0.2); }
  50% { box-shadow: 0 0 22px rgba(166,27,27,0.55); }
}

.music-controls {
  display: flex; align-items: center; gap: 6px;
  color: var(--gold); font-size: 13px;
}

/* 顶部音乐控制按钮 */
.music-controls-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid rgba(184, 155, 114, 0.3);
}

.music-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  transition: all 0.3s;
  padding: 0;
}

.music-header-btn.on {
  border-color: #5a9e6f;
  color: #5a9e6f;
}

.music-header-btn.off {
  border-color: #8b5555;
  color: #8b5555;
  opacity: 0.7;
}

.music-settings-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid rgba(212, 175, 55, 0.5);
  background: transparent;
  color: var(--gold);
  transition: all 0.3s;
  padding: 0;
  opacity: 0.8;
}

.music-settings-btn:hover {
  opacity: 1;
  border-color: var(--gold);
}

/* 顶部音乐设置面板 */
.music-panel-header {
  position: fixed;
  top: 60px;
  right: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-size: 13px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--gold);
  z-index: 99;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.music-panel-header.expanded {
  max-height: 200px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 旧样式兼容 - 保留 */
.music-controls-collapsed {
  display: none;
}

.music-main-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border: 1px solid var(--gold);
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(10px);
  color: var(--gold);
  transition: all 0.3s;
  flex-shrink: 0;
  padding: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.music-main-btn.on {
  border-color: #5a9e6f;
  color: #5a9e6f;
  box-shadow: 0 0 12px rgba(90,158,111,0.4);
}

.music-main-btn.off {
  border-color: #8b5555;
  color: #8b5555;
  opacity: 0.8;
}

.music-main-btn:hover {
  transform: scale(1.1);
}

.music-expand-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid rgba(212, 175, 55, 0.5);
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  color: var(--gold);
  transition: all 0.3s;
  flex-shrink: 0;
  padding: 0;
  opacity: 0.7;
}

.music-expand-btn:hover {
  opacity: 1;
  transform: scale(1.1);
  border-color: var(--gold);
}

.music-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-size: 13px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 25px;
  border: 1px solid var(--gold);
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateX(-20px);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.music-panel.expanded {
  max-width: 400px;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* 旧样式兼容 - 保留 */
.music-toggle-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; border: 1px solid var(--gold);
  background: transparent; color: var(--gold);
  transition: all 0.3s; flex-shrink: 0; padding: 0;
}
.music-toggle-btn.on {
  border-color: #5a9e6f; color: #5a9e6f;
  box-shadow: 0 0 10px rgba(90,158,111,0.3);
}
.music-toggle-btn.off {
  border-color: #8b5555; color: #8b5555; opacity: 0.7;
}
.music-label {
  white-space: nowrap;
  font-size: clamp(10px, 1.3vw, 13px);
  letter-spacing: 1px;
}
.volume-slider {
  width: 60px;
  accent-color: var(--gold);
  cursor: pointer;
}

.music-selector {
  display: flex;
  gap: 6px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid rgba(212, 175, 55, 0.3);
}

.music-track-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-family: "STKaiti", "KaiTi", serif;
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: rgba(212, 175, 55, 0.7);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 1px;
}

.music-track-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.music-track-btn.active {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

/* 章节按钮区域 */
.chapter-nav {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.9);
  border-bottom: 1px solid var(--gold);
  z-index: 99;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.chapter-nav.open {
  max-height: 200px;
  overflow-y: auto;
}
.chapter-nav::-webkit-scrollbar {
  width: 6px;
}
.chapter-nav::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 3px;
}
.chapter-buttons {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  gap: 4px;
  padding: 10px;
  min-height: 50px;
}
.chapter-btn {
  width: 36px;
  height: 32px;
  padding: 0;
  font-size: 12px;
}
.chapter-btn.current {
  background: rgba(184,155,114,0.3);
  border-color: #d4b87a;
}

/* 版本切换和繁简切换按钮 */
.version-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.container {
  display: flex; justify-content: center; align-items: center;
  height: 100vh; width: 100vw; padding-top: 60px;
  position: relative; z-index: 2;
}

.axis {
  width: var(--axis-width);
  height: calc(100vh - 140px);
  background: linear-gradient(to right,
    #1a0a04 0%, #2e1508 12%, #5a2d14 28%, #8b4a22 48%,
    #a06030 55%, #8b4a22 62%, #5a2d14 78%, #2e1508 92%, #1a0a04 100%);
  border-radius: 14px;
  box-shadow: inset 0 0 25px rgba(0,0,0,0.8), 0 0 25px rgba(0,0,0,0.6);
  position: relative; flex-shrink: 0;
  display: flex; justify-content: center; align-items: center;
  overflow: hidden; z-index: 3;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.axis:hover {
  transform: scale(1.02);
  box-shadow: 
    inset 0 0 25px rgba(0,0,0,0.8), 
    0 0 35px rgba(0,0,0,0.7);
}

.axis-text {
  position: absolute;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 14px;
  color: #f5e6c8;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 4px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
  pointer-events: none;
  user-select: none;
}

.prev-chapter {
  left: 50%;
  transform: translateX(-50%);
}

.next-chapter {
  right: 50%;
  transform: translateX(50%);
}
.axis::before, .axis::after {
  content: ''; position: absolute; left: -3px; right: -3px;
  height: 18px;
  background: linear-gradient(to bottom, #1a0a03, #7a4a22, #d4a373, #7a4a22, #1a0a03);
  border-radius: 8px;
  box-shadow: 0 0 14px rgba(0,0,0,0.8);
  z-index: 5;
}
.axis::before { top: -5px; }
.axis::after { bottom: -5px; }
.axis-decor {
  position: absolute; width: 85%; height: 88%;
  top: 6%; left: 7.5%; z-index: 4; opacity: 0.55;
}

.silk-scroll {
  background: rgba(196, 164, 124, 0.8);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  background-image:
    radial-gradient(ellipse at 15% 25%, rgba(180,150,110,0.5) 0%, transparent 50%),
    radial-gradient(ellipse at 78% 60%, rgba(160,130,90,0.4) 0%, transparent 45%),
    radial-gradient(ellipse at 40% 80%, rgba(190,160,120,0.45) 0%, transparent 40%),
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.08"/></svg>');
  background-repeat: repeat, repeat, repeat, repeat;
  background-size: 100% 100%, 100% 100%, 100% 100%, 200px 200px;
  padding: var(--scroll-padding) var(--scroll-padding);
  box-shadow: 0 0 60px rgba(0,0,0,0.6), inset 0 0 30px rgba(0,0,0,0.15);
  height: calc(100vh - 140px);
  width: 72vw; max-width: 950px;
  flex-grow: 1;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: reverse;
  -webkit-flex-direction: row-reverse;
  flex-direction: row-reverse;
  -webkit-box-align: start;
  -webkit-align-items: flex-start;
  align-items: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-radius: 4px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 2;
  margin: 0 10px;
}
.silk-scroll::-webkit-scrollbar { display: none; }

.chapter-fixed {
  position: sticky;
  left: 0; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 clamp(25px, 3vw, 45px);
  margin-right: clamp(20px, 2vw, 35px);
  flex-shrink: 0; z-index: 5;
  background: transparent;
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: var(--chapter-size);
  color: #3d2510; letter-spacing: 6px;
  text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.5);
  font-weight: bold; user-select: none;
  pointer-events: none; white-space: nowrap;
}

.scroll-content-inner {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: reverse;
  -webkit-flex-direction: row-reverse;
  flex-direction: row-reverse;
  -webkit-box-align: start;
  -webkit-align-items: flex-start;
  align-items: flex-start;
  gap: var(--gap-col);
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  min-height: 100%;
}

.paragraph-col {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0;
}

.char-unit {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: clamp(14px, 2.2vw, 22px);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.pinyin {
  font-family: "Georgia", serif;
  font-size: clamp(10px, 1.6vw, 14px); height: 1.2em; line-height: 1;
  color: #5d4a37; opacity: 0.7; margin-bottom: 2px; transition: all 0.3s;
}
.word {
  font-size: var(--char-size); line-height: 1; font-weight: 900;
  color: var(--ink-unread); transition: all 0.25s;
}
.char-unit.read .word {
  color: var(--ink-read); opacity: 0.85;
  text-shadow: 0 1px 2px rgba(61,43,26,0.3);
}
.char-unit.read .pinyin { color: #5d4030; opacity: 0.8; }
.char-unit.reading .word {
  color: var(--cinnabar) !important; opacity: 1 !important;
  transform: scale(1.15);
  text-shadow: 0 0 14px rgba(166,27,27,0.55);
  animation: ktv-glow 0.55s infinite alternate;
}
.char-unit.reading .pinyin {
  color: var(--cinnabar); opacity: 1; font-weight: bold;
}
@keyframes ktv-glow {
  0% { transform: scale(1.12); text-shadow: 0 0 10px rgba(166,27,27,0.45); }
  100% { transform: scale(1.18); text-shadow: 0 0 25px rgba(166,27,27,0.7); }
}
.char-unit.all-read .word { animation: settled-ink 2.2s infinite; }
@keyframes settled-ink {
  0%,100% { text-shadow: 0 1px 3px rgba(61,43,26,0.3); }
  50% { text-shadow: 0 1px 6px rgba(61,43,26,0.5); }
}

/* 导航栏展开时的容器调整 */
.container.nav-open {
  padding-top: 260px;
}
.container.nav-open .axis,
.container.nav-open .silk-scroll {
  height: calc(100vh - 340px);
}

@media (max-width: 640px) {
  .axis { height: calc(100vh - 95px); }
  .silk-scroll { 
    height: calc(100vh - 95px); 
    width: 66vw;
    padding-top: 60px;
  }
  .scroll-content-inner {
    padding-bottom: 120px;
  }
  .header { gap: 6px; padding: 0 6px; }
  button { padding: 5px 8px; letter-spacing: 0.5px; font-size: 11px; }
  .music-toggle-btn { width: 28px; height: 28px; font-size: 14px; }
  .volume-slider { width: 40px; }
  .chapter-btn { width: 30px; height: 28px; font-size: 10px; }
  .container.nav-open {
    padding-top: 240px;
  }
  .container.nav-open .axis,
  .container.nav-open .silk-scroll {
    height: calc(100vh - 290px);
  }
  
  /* 移动端音乐控制面板适配 */
  .music-controls-collapsed {
    bottom: 10px;
    left: 10px;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .music-main-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
  .music-expand-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
    position: static;
  }
  .music-panel {
    padding: 10px 12px;
    gap: 8px;
    flex-direction: column;
    align-items: flex-start;
    border-radius: 12px;
    transform: translateY(10px);
    margin-top: 4px;
    max-width: 180px;
  }
  .music-panel.expanded {
    max-width: 180px;
    transform: translateY(0);
  }
  .music-label {
    font-size: 11px;
    white-space: nowrap;
  }
  .volume-slider {
    width: 100%;
  }
  .music-selector {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
    justify-content: space-between;
  }
  .music-track-btn {
    padding: 4px 10px;
    font-size: 11px;
    flex: 1;
  }
}

/* 二维码区域 - 古风样式 */
.qrcode-section {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
  pointer-events: auto;
}

.qrcode-close-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #8b6914;
  background: linear-gradient(145deg, #f5f0e6 0%, #e8e0d0 100%);
  color: #5d4a37;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: all 0.2s;
  z-index: 11;
}

.qrcode-close-btn:hover {
  background: #8b6914;
  color: #f5f0e6;
  transform: scale(1.1);
}

.qrcode-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px 8px;
  background: linear-gradient(145deg, #f5f0e6 0%, #e8e0d0 100%);
  border: 2px solid #8b6914;
  border-radius: 8px;
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.8),
    0 2px 8px rgba(139,105,20,0.25),
    0 0 0 1px rgba(139,105,20,0.1);
}

.qrcode-img {
  width: 70px;
  height: 70px;
  border-radius: 4px;
  opacity: 0.9;
  filter: sepia(20%) contrast(1.1);
}

.qrcode-placeholder {
  width: 70px;
  height: 70px;
  border-radius: 4px;
  background: linear-gradient(145deg, #f5f0e6 0%, #e8e0d0 100%);
  border: 1px dashed #8b6914;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.qrcode-domain {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 10px;
  color: #8b6914;
  text-align: center;
  line-height: 1.3;
  word-break: break-all;
  padding: 4px;
}

.qrcode-text {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 11px;
  color: #5d4a37;
  margin-top: 6px;
  letter-spacing: 1px;
  writing-mode: horizontal-tb;
}

.credits {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 12px;
  color: #6b4a1e;
  letter-spacing: 2px;
  text-shadow: 
    0 1px 2px rgba(255,255,255,0.9),
    0 0 8px rgba(255,255,255,0.6);
  opacity: 1;
  writing-mode: horizontal-tb;
  white-space: nowrap;
  background: linear-gradient(135deg, rgba(245,240,230,0.85) 0%, rgba(232,224,208,0.9) 100%);
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid rgba(139,105,20,0.3);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

@media (max-width: 640px) {
  .qrcode-section {
    display: none;
  }
  
  /* 手机端音乐按钮去掉外圆 */
  .music-header-btn {
    border: none;
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
  .music-header-btn.on {
    border: none;
    color: #5a9e6f;
  }
  .music-header-btn.off {
    border: none;
    color: #8b5555;
  }
  .music-settings-btn {
    border: none;
    width: 24px;
    height: 24px;
    font-size: 14px;
    opacity: 0.9;
  }
}
