/* =====================================================================
   鲸落听 · 设计系统 v3 — "墨海金声" 视觉语言 (2026-09-26 与 APP 统一)
   基调: 宣纸米白底 + 深海墨蓝 + 鲸金点缀, 大圆角, 柔和分层阴影
   令牌与 jingluoting-app/src/theme.css (.theme-day) 同源
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --jl-bg:        #f7f4ec;
  --jl-card:      #ffffff;
  --jl-ink:       #16324a;
  --jl-ink-2:     #3d5a74;
  --jl-ink-3:     #8a97a5;
  --jl-line:      #e3dcc9;
  --jl-brand:     #a8823c;
  --jl-brand-2:   #c9a24b;
  --jl-sea:       #27567a;
  --jl-violet:    #1e4666;
  /* 鲸金渐变 (主按钮/强调): 与 APP .evt/.j-btn-gold 同源 135deg 金 */
  --jl-grad:      linear-gradient(135deg, #c9a24b 0%, #a8823c 100%);
  /* 深海渐变 (Hero/横幅): 与 APP --hero 同源 */
  --jl-hero:      linear-gradient(150deg, #16324a 0%, #1e4666 60%, #27567a 100%);
  --jl-shadow-1:  0 1px 2px rgba(22,50,74,.05), 0 4px 16px -6px rgba(22,50,74,.10);
  --jl-shadow-2:  0 2px 4px rgba(22,50,74,.06), 0 12px 32px -8px rgba(22,50,74,.16);
  --jl-radius:    16px;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--jl-ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(201,162,75,.10), transparent 60%),
    radial-gradient(900px 400px at -10% 20%, rgba(39,86,122,.06), transparent 55%),
    var(--jl-bg);
  min-height: 100vh;
}

/* ---------- 滚动条 ---------- */
.scrollbar-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: #cfc6ad; border-radius: 3px; }
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background: #b3a88c; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }

/* ---------- 卡片 ---------- */
.jl-card {
  background: var(--jl-card);
  border: 1px solid var(--jl-line);
  border-radius: var(--jl-radius);
  box-shadow: var(--jl-shadow-1);
}

/* ---------- 动画 ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .25s ease-out; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .4s cubic-bezier(.16,1,.3,1) both; }

@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.scale-in { animation: scaleIn .22s cubic-bezier(.16,1,.3,1) both; }

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #efe9da 25%, #faf6ec 50%, #efe9da 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 8px;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(201,162,75,.55); }
  70% { box-shadow: 0 0 0 14px rgba(201,162,75,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,162,75,0); }
}
.pulse-ring { animation: pulse-ring 1.6s infinite; }

@keyframes floatY {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-8px); }
}
.float-y { animation: floatY 4s ease-in-out infinite; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity:.4; }
  30% { transform: translateY(-4px); opacity:1; }
}
.typing-dot { display:inline-block; width:5px; height:5px; border-radius:99px; background:currentColor; margin:0 1.5px; animation: typingDot 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay:.15s; }
.typing-dot:nth-child(3) { animation-delay:.3s; }

/* ---------- 盲盒开门动画 ---------- */
@keyframes doorLeft {
  from { transform: perspective(600px) rotateY(0deg); }
  to   { transform: perspective(600px) rotateY(-95deg); }
}
@keyframes doorRight {
  from { transform: perspective(600px) rotateY(0deg); }
  to   { transform: perspective(600px) rotateY(95deg); }
}
@keyframes lightOut {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: scale(1); }
}
.jl-door-left  { animation: doorLeft .8s cubic-bezier(.6,0,.3,1) forwards; transform-origin: left; }
.jl-door-right { animation: doorRight .8s cubic-bezier(.6,0,.3,1) forwards; transform-origin: right; }
.jl-door-light { animation: lightOut .7s .35s ease-out both; }

/* ---------- 波形 ---------- */
.wave-bar {
  display: inline-block; width: 3px; margin: 0 1px;
  background: var(--jl-brand-2); border-radius: 2px;
  animation: waveAnim 1s ease-in-out infinite;
}
@keyframes waveAnim {
  0%, 100% { height: 6px; }
  50%      { height: 22px; }
}

/* ---------- 交互 ---------- */
.lift { transition: transform .18s ease, box-shadow .18s ease; }
.lift:hover { transform: translateY(-3px); box-shadow: var(--jl-shadow-2); }

.page-enter { animation: fadeIn .2s ease-out; }

/* ---------- 按钮系统 ---------- */
.btn-primary {
  background: var(--jl-grad);
  color: #fff; border: 0; cursor: pointer;
  transition: opacity .15s ease, transform .1s ease, box-shadow .2s ease;
  box-shadow: 0 6px 16px -6px rgba(168,130,60,.55);
}
.btn-primary:hover { opacity: .92; }
.btn-primary:active { transform: scale(.98); }

button[disabled], .btn-disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
input[type=range] {
  -webkit-appearance: none; height: 4px;
  background: #e3dcc9; border-radius: 4px; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px;
  background: var(--jl-grad); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(168,130,60,.4);
  border-radius: 9999px; cursor: pointer;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201,162,75,.18);
  border-color: var(--jl-brand-2) !important;
}

/* ---------- 阅读页主题 ---------- */
.read-theme-paper  { background: #faf6ec !important; }
.read-theme-paper p { color: #433722 !important; }
.read-theme-night  { background: #1a2233 !important; }
.read-theme-night p { color: #c3cfe2 !important; }

/* ---------- 杂项 ---------- */
.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }

/* 打字光标(正文流式生成时) */
.caret::after {
  content: '';
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--jl-brand-2);
  margin-left: 2px;
  vertical-align: -0.15em;
  animation: caretBlink 1s step-end infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

/* 渐变文字 */
.grad-text {
  background: var(--jl-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Hero 内的发光渐变标题 (深色底上用): 白→鲸金 */
.grad-text-glow {
  background: linear-gradient(90deg, #ffffff 0%, #f4ead0 45%, #ddc078 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(201, 162, 75, .35));
}

/* 主按钮: 悬浮微光 + 按下回弹 */
.btn-primary {
  background: var(--jl-grad);
  background-size: 160% 160%;
  background-position: 0% 50%;
  transition: background-position .35s ease, transform .1s ease, box-shadow .25s ease;
  box-shadow: 0 8px 20px -6px rgba(168, 130, 60, .55);
}
.btn-primary:hover { background-position: 90% 50%; opacity: 1; }

/* 卡片悬浮光晕 (作品封面卡等) */
.jl-card.lift { position: relative; }
.jl-card.lift::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
  box-shadow: 0 0 0 1.5px rgba(201, 162, 75, .25), 0 10px 30px -8px rgba(201, 162, 75, .35);
}
.jl-card.lift:hover::after { opacity: 1; }

/* 区块标题: 渐变小竖条 */
.sec-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--jl-ink);
}
.sec-title::before {
  content: '';
  width: 4px; height: 16px; border-radius: 2px;
  background: var(--jl-grad);
}

/* 榜单前三名徽章 */
.rank-top { color: #c9a24b; text-shadow: 0 0 12px rgba(201,162,75,.3); }

/* 减少动画(系统偏好) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 阶段B/C/D (#298-#303) ---------- */
/* 段评气泡 (#300): 段落右侧悬浮按钮 */
#reader p[data-pidx] { padding-right: 44px; }
.pc-badge {
  position: absolute; right: 0; top: 0;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--jl-grad);
  color: #fff; opacity: .85; cursor: pointer; border: none;
  box-shadow: 0 2px 8px rgba(168,130,60,.35);
  transition: opacity .15s ease, transform .15s ease;
}
.pc-badge:hover { opacity: 1; transform: scale(1.08); }

/* 作者中心 KPI 渐变数字 */
.grad-text {
  background: var(--jl-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* 渐变底工具类 (阶段B/C/D 新页面用): 深海墨蓝 (与 APP Hero 同源) */
.grad { background: var(--jl-hero); }

/* ==================== 移动端适配 (2026-09-12 APP 全功能版, ≤768px) ====================
 * 侧边栏 → 抽屉 + 底部 TabBar + 全局栅格降列。
 * 桌面端 (≥769px) 完全不受影响 —— 所有规则都在 media query 内。 */
.mobile-backdrop { display: none; }
.mobile-tabbar { display: none; }

@media (max-width: 768px) {
  /* -- 桌面专属控件隐藏 -- */
  .hide-mobile { display: none !important; }

  /* -- 侧边栏 → 左滑抽屉 -- */
  #sidebar {
    position: fixed !important;
    top: 0; bottom: 0; left: 0;
    width: 17rem; z-index: 60;
    margin-left: 0 !important;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  body.sb-open #sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,.35);
  }
  .mobile-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 55;
    background: rgba(2,6,23,.5);
  }
  body.sb-open .mobile-backdrop { display: block; }

  /* -- 底部 TabBar -- */
  .mobile-tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(22,50,74,.10);
    height: calc(3.4rem + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabbar a {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    font-size: 10px; color: #8a97a5; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-tabbar a.active { color: #a8823c; font-weight: 600; }
  .mobile-tabbar svg { width: 22px; height: 22px; }
  /* 内容底部留白, 防 TabBar 遮挡 */
  #app { padding-bottom: calc(3.4rem + env(safe-area-inset-bottom)); }

  /* -- 全局兜底布局 -- */
  main { padding: .75rem !important; }
  /* 任意值栅格模板 (studio 210/1fr/310 三栏、dubbing 250/1fr/320 等) → 单列纵排 */
  [class*="grid-cols-["] {
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto !important;
    max-height: none !important;
  }
  /* 常规多列栅格降为 2 列 (书封卡片/榜单等) */
  main .grid-cols-3, main .grid-cols-4, main .grid-cols-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  main .grid-cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* 桌面固定视高的工作区 (studio/dubbing 中栏 h-[calc(...)]) 放开成自然高度 */
  [class*="h-[calc(100vh"] { height: auto !important; min-height: 60vh; }
  /* 横向工具条允许换行 */
  main .flex.items-center.gap-2, main .flex.items-center.gap-3 { flex-wrap: wrap; }
  /* 弹窗/模态全宽 */
  #modal-wrap > * { max-width: 94vw !important; }
  /* 触控目标加大 */
  main button { min-height: 30px; }
  /* 表格容器横滚 (作者中心/充值记录等) */
  main .overflow-x-auto { -webkit-overflow-scrolling: touch; }
  /* 悬浮控件 (阅读器迷你播放条/配音连配面板/全局播放器) 避让底部 TabBar */
  #player, #player-fab, .fixed.bottom-5, .fixed.bottom-6 {
    bottom: calc(4rem + env(safe-area-inset-bottom)) !important;
  }
}
