/* ==================== 宋代美学色彩体系变量 ==================== */
:root {
  /* 日间宣纸模式（天青 · 宣白 · 徽墨 · 朱砂） */
  --bg-page: #F5F2EB;
  --bg-card: #FAF8F2;
  --bg-elevated: #EFECE3;
  --bg-input: rgba(255, 253, 248, 0.82);

  --text-primary: #262421;
  --text-secondary: #5C574F;
  --text-muted: #8C8478;

  --accent-celadon: #5E7C74;       /* 汝窑天青 */
  --accent-celadon-soft: rgba(94, 124, 116, 0.14);
  --accent-cinnabar: #B8432E;      /* 印泥朱砂 */
  --accent-cinnabar-dark: #943220;
  --accent-ochre: #A68454;         /* 沉香檀褐 */

  --border-subtle: rgba(130, 120, 104, 0.22);
  --border-strong: rgba(130, 120, 104, 0.42);
  --shadow-soft: 0 10px 30px rgba(42, 37, 30, 0.06);
  --shadow-card: 0 14px 36px rgba(38, 34, 28, 0.09);

  --orb-core: radial-gradient(circle at 35% 35%, #A7C4BC 0%, #5E7C74 62%, #3E5650 100%);
  --orb-glow: rgba(94, 124, 116, 0.28);

  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif CN", "STSong", "SimSun", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 深夜护眼暗色模式（松烟墨 · 暗青釉 · 暖烛光） */
[data-theme="dark"] {
  --bg-page: #161716;
  --bg-card: #1F211F;
  --bg-elevated: #272A27;
  --bg-input: rgba(31, 33, 31, 0.9);

  --text-primary: #DFDCD4;
  --text-secondary: #A5A095;
  --text-muted: #736F66;

  --accent-celadon: #789B91;
  --accent-celadon-soft: rgba(120, 155, 145, 0.16);
  --accent-cinnabar: #C95640;
  --accent-cinnabar-dark: #A63F2B;
  --accent-ochre: #BA9868;

  --border-subtle: rgba(215, 208, 194, 0.12);
  --border-strong: rgba(215, 208, 194, 0.24);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.45);

  --orb-core: radial-gradient(circle at 35% 35%, #8CB0A6 0%, #4D6B63 62%, #2B3D38 100%);
  --orb-glow: rgba(120, 155, 145, 0.24);
}

/* ==================== 基础重置与全局布局 ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-serif);
  line-height: 1.65;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 宣纸细腻噪点纹理层 */
.paper-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(rgba(120, 110, 95, 0.08) 1px, transparent 0),
    radial-gradient(rgba(120, 110, 95, 0.05) 1px, transparent 0);
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
}

.hidden {
  display: none !important;
}

/* ==================== 顶部眉栏 ==================== */
.app-header {
  position: relative;
  z-index: 10;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 11px;
}

.seal-badge {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 38px;
  border-radius: 6px;
  background-color: var(--accent-cinnabar);
  color: #FAF7F0;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0;
  box-shadow: 0 3px 10px rgba(184, 67, 46, 0.25);
  border: 1px solid rgba(250, 247, 240, 0.45);
  user-select: none;
  flex-shrink: 0;
}

/* 印章内部极细白边线（模拟传统朱砂印框） */
.seal-badge::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(250, 247, 240, 0.35);
  border-radius: 4px;
  pointer-events: none;
}


.app-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.25;
}

.app-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 6px 12px;
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.icon-btn:hover,
.icon-btn:active {
  border-color: var(--accent-celadon);
  color: var(--text-primary);
}

/* ==================== 主内容容器 ==================== */
.app-main {
  position: relative;
  z-index: 5;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 20px calc(105px + var(--safe-bottom));
  min-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
}

.tab-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fadeSlideIn 0.35s ease;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-intro {
  text-align: center;
  margin: 6px 0 18px;
}

.section-heading {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* ==================== 通用宋式按钮 ==================== */
.action-bar {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.primary-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 176px;
  padding: 13px 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--accent-celadon);
  color: #FAF8F3;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, background-color 0.25s ease, opacity 0.25s ease;
}

.primary-btn:active {
  transform: scale(0.97);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.burn-btn {
  background: var(--accent-cinnabar);
}

.burn-btn:hover:not(:disabled) {
  background: var(--accent-cinnabar-dark);
}

.btn-seal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #FAF7F0;
  opacity: 0.85;
}

.secondary-btn {
  appearance: none;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:active {
  transform: scale(0.97);
  background: var(--bg-elevated);
}

.text-link-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  padding: 4px 6px;
}

.text-link-btn:hover {
  color: var(--accent-cinnabar);
}

/* ==================== TAB 1：焚心炉 ==================== */
.furnace-stage {
  position: relative;
  flex: 1;
  min-height: 310px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.fire-canvas {
  position: absolute;
  inset: -16px;
  width: calc(100% + 32px);
  height: calc(100% + 32px);
  pointer-events: none;
  z-index: 8;
}

.letter-paper {
  position: relative;
  z-index: 4;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: opacity 1.6s ease, transform 1.6s ease, filter 1.6s ease;
}

/* 焚烧消散状态（由 app.js 触发） */
.letter-paper.burning {
  opacity: 0;
  transform: translateY(-18px) scale(0.97);
  filter: blur(4px) sepia(0.6);
  pointer-events: none;
}

.letter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.worry-textarea {
  flex: 1;
  width: 100%;
  min-height: 210px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.9;
  letter-spacing: 0.8px;
  /* 宋式淡淡信笺横格线 */
  background-image: linear-gradient(to bottom, transparent 96%, var(--border-subtle) 97%);
  background-size: 100% 30.4px;
}

.worry-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.letter-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

/* 焚尽后的安抚浮层 */
.ash-comfort-card {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 32px 26px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: fadeSlideIn 0.8s ease;
}

.smoke-mark {
  font-size: 28px;
  color: var(--accent-celadon);
  opacity: 0.75;
  margin-bottom: 14px;
}

.comfort-quote {
  font-size: 17px;
  line-height: 1.9;
  color: var(--text-primary);
  letter-spacing: 1px;
  max-width: 340px;
  margin-bottom: 26px;
}

/* ==================== TAB 2：宋式解忧签 ==================== */
.lot-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 340px;
}

.lot-vessel-wrapper {
  position: relative;
  width: 196px;
  height: 196px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.hold-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.hold-ring-bg {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 3;
}

.hold-ring-progress {
  fill: none;
  stroke: var(--accent-cinnabar);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 515.22;
  stroke-dashoffset: 515.22;
  transition: stroke-dashoffset 0.05s linear;
}

.lot-vessel-btn {
  appearance: none;
  position: relative;
  width: 156px;
  height: 156px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  user-select: none;
  -webkit-user-select: none;
}

.lot-vessel-btn.pressing {
  transform: scale(0.95);
  box-shadow: 0 0 0 8px var(--accent-celadon-soft);
}

.vessel-bamboo-sticks {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 26px;
  margin-bottom: 6px;
}

.vessel-bamboo-sticks span {
  display: block;
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: var(--accent-ochre);
  opacity: 0.8;
}

.vessel-bamboo-sticks span:nth-child(2) {
  height: 25px;
  transform: rotate(-4deg);
}

.vessel-bamboo-sticks span:nth-child(3) {
  height: 27px;
  background: var(--accent-cinnabar);
}

.vessel-bamboo-sticks span:nth-child(4) {
  height: 24px;
  transform: rotate(5deg);
}

.vessel-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.vessel-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-primary);
}

.vessel-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* 抽出的宋式签文卡片 */
.lot-card {
  width: 100%;
  animation: fadeSlideIn 0.55s ease;
}

.lot-card-inner {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 24px 22px 20px;
  box-shadow: var(--shadow-card);
  position: relative;
}

.lot-card-inner::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  pointer-events: none;
}

.lot-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.lot-number {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 2px;
}

.lot-tag {
  font-size: 12px;
  color: var(--accent-celadon);
  background: var(--accent-celadon-soft);
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 1px;
}

.lot-verse {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.65;
  letter-spacing: 2px;
  color: var(--text-primary);
  text-align: center;
  padding: 8px 6px;
}

.lot-divider {
  width: 44px;
  height: 1px;
  background: var(--accent-ochre);
  opacity: 0.5;
  margin: 16px auto;
}

.lot-insight {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-secondary);
  letter-spacing: 0.6px;
  text-align: justify;
}

.lot-card-bottom {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lot-brand {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.lot-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border: 1.5px solid var(--accent-cinnabar);
  color: var(--accent-cinnabar);
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 1px;
}

.lot-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* 壁纸预览弹窗 */
.poster-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.poster-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 18, 17, 0.72);
  backdrop-filter: blur(4px);
}

.poster-modal-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.poster-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.poster-modal-header h3 {
  font-size: 15px;
  letter-spacing: 1.5px;
}

.close-modal-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.poster-preview-box {
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 10px;
  max-height: 55vh;
  overflow-y: auto;
}

.poster-preview-box img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

.poster-save-tip {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.poster-modal-actions {
  margin-top: 12px;
}

/* ==================== TAB 3：4-7-8 呼吸光球 ==================== */
.rounds-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.round-chip {
  appearance: none;
  padding: 6px 15px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.round-chip.active {
  border-color: var(--accent-celadon);
  background: var(--accent-celadon-soft);
  color: var(--text-primary);
  font-weight: 600;
}

.breath-stage {
  position: relative;
  flex: 1;
  min-height: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
}

.breath-halo-outer,
.breath-halo-mid {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transition: transform 1s ease, opacity 1s ease;
}

.breath-halo-outer {
  width: 246px;
  height: 246px;
  border: 1px solid var(--border-subtle);
  opacity: 0.55;
}

.breath-halo-mid {
  width: 204px;
  height: 204px;
  background: var(--orb-glow);
  filter: blur(12px);
  opacity: 0.6;
}

.breath-orb {
  position: relative;
  z-index: 3;
  width: 158px;
  height: 158px;
  border-radius: 50%;
  background: var(--orb-core);
  box-shadow: 0 12px 35px var(--orb-glow), inset 0 0 24px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FAF9F5;
  text-align: center;
  will-change: transform;
}

/* 4秒吸气：柔和膨胀 */
.breath-orb.inhale {
  transition: transform 4s cubic-bezier(0.25, 0.1, 0.25, 1);
  transform: scale(1.42);
}

/* 7秒屏息：保持饱满并微颤 */
.breath-orb.hold {
  transform: scale(1.42);
  animation: orbHoldPulse 1.75s ease-in-out infinite;
}

/* 8秒呼气：缓慢沉降收缩 */
.breath-orb.exhale {
  transition: transform 8s cubic-bezier(0.22, 0.61, 0.36, 1);
  transform: scale(1);
}

.breath-orb.idle {
  transition: transform 0.8s ease;
  transform: scale(1);
}

@keyframes orbHoldPulse {
  0%, 100% {
    transform: scale(1.42);
  }
  50% {
    transform: scale(1.46);
  }
}

.orb-core-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

.breath-phase-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
}

.breath-timer-num {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 2px;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}

.breath-guide-sub {
  font-size: 11px;
  opacity: 0.88;
  letter-spacing: 1px;
}

.breath-status-bar {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
}

/* ==================== 底部宋式三栏导航 ==================== */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 40;
  width: calc(100% - 40px);
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  box-shadow: var(--shadow-card);
}

.nav-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-serif);
  cursor: pointer;
  transition: all 0.25s ease;
}

.nav-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 700;
}

.nav-label {
  font-size: 13px;
  letter-spacing: 1.5px;
}

.nav-tab.active {
  background: var(--accent-celadon);
  color: #FAF8F3;
}

.nav-tab.active .nav-glyph {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.14);
}

/* ==================== 页脚 ==================== */
.app-footer {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 4px 0 calc(86px + var(--safe-bottom));
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  opacity: 0.7;
}

/* ==================== 移动端一屏零遮挡精准适配 ==================== */
.app-main {
  min-height: calc(100dvh - 68px);
  padding: 4px 20px calc(106px + var(--safe-bottom));
  justify-content: space-between;
}

.panel-intro {
  margin: 2px 0 12px;
}

/* 焚心炉紧凑自适应高度 */
.furnace-stage {
  min-height: 190px;
}

.worry-textarea {
  min-height: 130px;
}

/* 调息球紧凑自适应高度 */
.breath-stage {
  min-height: 205px;
  margin: 4px 0;
}

.action-bar {
  margin-top: 14px;
}

/* 隐藏主界面多余的页脚占位（顶部“行者”竖印已可直接点击回主站） */
.app-footer {
  display: none;
}

/* 保持标签切换隐藏规则 */
.tab-panel[hidden],
.tab-panel:not(.active) {
  display: none !important;
}

