/* css/style.css */
/* ==========================================================================
   问筊 (WenJiao) - 小型竖向 macOS 桌面工具
   一张连续宣纸：浅灰暖色纸面 + 细腻纸纹 + 墨字 + 朱砂点缀
   ========================================================================== */

:root {
  color-scheme: light;

  /* 动态全局字号比例 (0.9 ~ 1.3) */
  --font-scale: 1;

  /* 宣纸浅灰暖色体系（低饱和、略带灰度） */
  --paper: #F3F0E6;           /* 全窗唯一纸色 */
  --ink: #2B2823;             /* 焦墨（较初版深约 10%） */
  --ink-secondary: #665F55;   /* 次级墨色（深约 10%） */
  --ink-muted: #8B8378;       /* 淡墨（深约 10%） */
  --cinnabar: #A23A2D;        /* 朱砂 */
  --cinnabar-dark: #7F2D24;   /* 深朱砂 */
  --bronze: #92784E;          /* 哑光铜 */
  --line: rgba(76, 65, 52, 0.16);      /* 纸面细线 */
  --line-faint: rgba(76, 65, 52, 0.10); /* 更淡的分隔线 */
  --cinnabar-wash: rgba(162, 58, 45, 0.06); /* 极淡朱砂底 */

  /* 宋体 / 明朝体字体族 */
  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", "Songti", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html {
  width: 100%;
  height: 100%;
  background-color: var(--paper);
}

body {
  width: 100%;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   窗口即一张宣纸：整窗单一纸面，仅用留白 / 细线 / 字号 / 朱砂分层
   ========================================================================== */
.app-window {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  overflow: hidden;
}

/* 纸纤维：极淡的纵横细纤维（肉眼细看可见，第一眼几乎不可察） */
.app-paper {
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(118, 104, 82, 0.013) 0px,
      rgba(118, 104, 82, 0.013) 1px,
      rgba(118, 104, 82, 0) 1px,
      rgba(118, 104, 82, 0) 5px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(118, 104, 82, 0.007) 0px,
      rgba(118, 104, 82, 0.007) 1px,
      rgba(118, 104, 82, 0) 1px,
      rgba(118, 104, 82, 0) 11px
    );
}

/* 纸面细腻噪点（inline SVG feTurbulence，无外部图片） */
.app-paper::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='300'%20height='300'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.85'%20numOctaves='3'%20stitchTiles='stitch'/%3E%3CfeColorMatrix%20type='saturate'%20values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA%20type='linear'%20slope='0'%20intercept='1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect%20width='300'%20height='300'%20filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 300px 300px;
}

/* 纸面之上的所有内容 */
.app-window > * {
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   毛玻璃：极薄一层磨砂琉璃，压在宣纸之上（宣纸纹理仍隐约透出）
   只用于少数组件制造层级：不做整页玻璃化，且不使用强折射 / 高光边 / 大面积白
   ========================================================================== */
.paper-glass {
  background-color: rgba(255, 255, 255, 0.20);
  border: 1px solid rgba(255, 255, 255, 0.30);
  border-radius: 7px;
  box-shadow:
    0 4px 14px rgba(55, 45, 34, 0.045),
    inset 0 1px 0 rgba(255, 255, 255, 0.20);
}

.paper-glass,
.modal-box {
  -webkit-backdrop-filter: blur(6px) saturate(1.03);
  backdrop-filter: blur(6px) saturate(1.03);
}

/* 引擎不支持 backdrop-filter 时，自动退化为半透明白（不影响排版与可读性） */
@supports (not (backdrop-filter: blur(1px))) and (not (-webkit-backdrop-filter: blur(1px))) {
  .paper-glass {
    background-color: rgba(255, 255, 255, 0.34);
  }
}

/* 顶部：标题与工具 */
.app-header {
  flex: 0 0 auto;
  height: 54px;
  padding: 0 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
}

.title-group {
  display: flex;
  align-items: center;
}

.app-title {
  font-family: var(--font-serif);
  font-size: calc((18px) * var(--font-scale, 1));
  font-weight: 600;
  letter-spacing: 5px;
  color: var(--ink);
  transition: font-size 0.2s ease;
}

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

/* 顶部工具：极轻一层玻璃 + 淡墨图标，hover 极淡朱砂 */
.icon-btn {
  background-color: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.20);
  color: var(--ink-muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  -webkit-backdrop-filter: blur(4px) saturate(1.02);
  backdrop-filter: blur(4px) saturate(1.02);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.icon-btn:hover {
  color: var(--cinnabar);
  background-color: var(--cinnabar-wash);
}

.icon-btn.active {
  color: var(--ink-secondary);
}

.svg-icon {
  display: block;
}

/* 主工作区：单列纵向 */
.main-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ==========================================================================
   模式选择：轻文字页签（朱砂标题 + 短下划线 + 极淡朱砂 tint）
   整体承载一层极薄毛玻璃，无大卡片无槽体
   ========================================================================== */
.mode-selector-wrap {
  flex: 0 0 auto;
  margin: 2px 22px 0;
  padding: 6px 12px 5px;
}

.mode-selector {
  display: flex;
  align-items: flex-start;
}

.mode-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 2px 10px 4px;
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  font-family: var(--font-serif);
  text-align: left;
  transition: background-color 0.2s ease;
}

.mode-tab + .mode-tab {
  padding-left: 18px;
  border-left: 1px solid var(--line-faint);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* 选中的模式：只给极淡朱砂 tint，不做独立粗边框 */
.mode-tab.active {
  background-color: rgba(162, 58, 45, 0.035);
}

.mode-name {
  position: relative;
  font-size: calc((15px) * var(--font-scale, 1));
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--ink-muted);
  padding-bottom: 7px;
  transition: color 0.2s ease;
}

.mode-name::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 22px;
  height: 2px;
  background-color: var(--cinnabar);
  opacity: 0;
  transform: scaleX(0.35);
  transform-origin: left center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.mode-tab:hover .mode-name {
  color: var(--ink-secondary);
}

.mode-tab.active .mode-name {
  color: var(--cinnabar);
}

.mode-tab.active .mode-name::after {
  opacity: 1;
  transform: scaleX(1);
}

.mode-sub {
  font-size: calc((12px) * var(--font-scale, 1));
  line-height: 1.55;
  color: var(--ink-muted);
  font-family: var(--font-serif);
  letter-spacing: 0.4px;
}

.mode-tab.active .mode-sub {
  color: var(--ink-secondary);
}

/* 传统模式下的连续三圣配置行 */
.triple-option-bar {
  flex: 0 0 auto;
  padding: 2px 22px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc((13px) * var(--font-scale, 1));
  color: var(--ink-secondary);
}

.triple-option-bar.hidden {
  display: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--cinnabar);
  width: 13px;
  height: 13px;
}

.bias-tag {
  color: var(--ink-muted);
  font-size: calc((12px) * var(--font-scale, 1));
  letter-spacing: 0.5px;
}

/* ==========================================================================
   甲乙选项：两块极薄毛玻璃纸签（存在感仅比纸面高一点，不做成表单框）
   ========================================================================== */
.options-panel {
  flex: 0 0 auto;
  padding: 5px 22px 2px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: transparent;
}

.input-card {
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

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

/* 朱砂小印章「甲」「乙」 */
.seal-tag {
  font-family: var(--font-serif);
  font-size: calc((11px) * var(--font-scale, 1));
  font-weight: 600;
  color: #F7F3E8;
  background: var(--cinnabar);
  border-radius: 2px;
  padding: 1px 5px 2px;
  line-height: 1.3;
  letter-spacing: 1px;
}

.input-desc {
  font-size: calc((12px) * var(--font-scale, 1));
  color: var(--ink-muted);
  letter-spacing: 1px;
  transition: color 0.2s ease;
}

.option-input {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--line);
  outline: none;
  font-family: var(--font-serif);
  color: var(--ink);
  font-size: calc((15px) * var(--font-scale, 1));
  letter-spacing: 0.5px;
  width: 100%;
  padding: 0 0 2px;
  transition: border-color 0.2s ease;
}

.option-input:focus {
  border-bottom-color: var(--cinnabar);
}

.option-input::placeholder {
  color: var(--ink-muted);
}

.input-card:focus-within .input-desc {
  color: var(--cinnabar);
}

/* ==========================================================================
   筊杯舞台：与宣纸连续（无底色、无边框），仅中心微亮
   —— 3D 几何、材质、阴影、动画关键帧一律保持原样 ——
   ========================================================================== */
.stage-wrapper {
  position: relative;
  flex: 0 1 auto;
  width: 100%;
  height: 246px;
  min-height: 186px;
  margin-top: 2px;
  background-color: transparent;
  background-image: radial-gradient(ellipse 62% 52% at 50% 50%, rgba(255, 253, 247, 0.72) 0%, rgba(255, 253, 247, 0) 72%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.stage-3d-scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1100px;
}

.table-plane {
  position: absolute;
  width: 320px;
  height: 160px;
  bottom: 15px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(152, 122, 78, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
}

.cups-group {
  position: relative;
  width: 250px;
  height: 130px;
  transform-style: preserve-3d;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cup-wrapper {
  position: relative;
  width: 100px;
  height: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
  transform-style: preserve-3d;
}

/* 桌面柔和漫反射投影 */
.cup-shadow {
  position: absolute;
  bottom: 4px;
  width: 78px;
  height: 24px;
  border-radius: 50%;
  background: rgba(48, 39, 31, 0.24);
  filter: blur(5px);
  transform: scale(1);
  transition: transform 0.05s linear, opacity 0.05s linear, filter 0.05s linear;
}

/* 3D 筊杯几何新月体 */
.cup-3d {
  position: absolute;
  width: 80px;
  height: 110px;
  transform-style: preserve-3d;
  will-change: transform;
}

.cup-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  clip-path: path("M 40,5 C 75,5 82,45 74,90 C 70,105 60,108 55,95 C 50,75 35,55 20,62 C 10,67 5,55 10,35 C 16,15 28,5 40,5 Z");
}

/* 阴面 (深木平面) */
.cup-face.yin {
  background: linear-gradient(135deg, #381810 0%, #4a2217 50%, #29100a 100%);
  border: 1px solid rgba(216, 199, 165, 0.4);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8), inset 0 -1px 3px rgba(250, 243, 223, 0.15);
  transform: rotateX(0deg) translateZ(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cup-face.yin::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(226, 212, 186, 0.35);
  transform: translate(5px, -3px);
}

/* 阳面 (朱红圆拱凸面) */
.cup-face.yang {
  background: radial-gradient(ellipse at 38% 34%, #be3c2e 0%, #902c21 45%, #5a170f 85%, #3c0e08 100%);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.3), 0 3px 10px rgba(73, 51, 38, 0.35);
  transform: rotateX(180deg) translateZ(6px);
}

.cup-face.yang::before {
  content: "";
  position: absolute;
  top: 14%;
  left: 26%;
  width: 42%;
  height: 52%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 235, 205, 0.5) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
  filter: blur(2px);
}

.cup-rim {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #2a0c07;
  clip-path: path("M 40,5 C 75,5 82,45 74,90 C 70,105 60,108 55,95 C 50,75 35,55 20,62 C 10,67 5,55 10,35 C 16,15 28,5 40,5 Z");
  transform: translateZ(0px);
}

/* 案上：三圣进度（上缘）与状态墨字（下缘），直接写在纸面 */
.stage-overlay {
  position: absolute;
  inset: 0;
  padding: 15px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.progress-dots {
  display: flex;
  gap: 10px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bronze);
  background: transparent;
  transition: all 0.25s ease;
}

.dot.active {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  transform: scale(1.15);
}

/* 状态墨字：无方框、无底色 */
.status-badge {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  font-size: calc((13px) * var(--font-scale, 1));
  font-family: var(--font-serif);
  color: var(--ink-secondary);
  letter-spacing: 1.5px;
  transition: color 0.25s ease;
}

.status-badge.highlight {
  color: var(--cinnabar);
}

/* ==========================================================================
   掷杯：全页唯一大色块（朱砂实体按钮，微内高光，无发光）
   ========================================================================== */
.controls-panel {
  flex: 0 0 auto;
  padding: 6px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  background: transparent;
}

.btn-primary {
  display: block;
  width: 74%;
  max-width: 360px;
  height: 48px;
  padding: 0 18px;
  font-family: var(--font-serif);
  font-size: calc((16px) * var(--font-scale, 1));
  font-weight: 600;
  letter-spacing: 6px;
  text-indent: 6px;
  background: var(--cinnabar);
  color: #F7F3E8;
  border: 1px solid var(--cinnabar-dark);
  border-radius: 3px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 2px 6px rgba(48, 44, 39, 0.10);
  transition: background-color 0.18s ease, transform 0.12s ease;
}

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

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

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

/* 「开始下一轮」：低视觉权重居中小按钮 */
.btn-secondary-action {
  display: block;
  width: 58%;
  max-width: 260px;
  height: 44px;
  font-family: var(--font-serif);
  font-size: calc((14px) * var(--font-scale, 1));
  letter-spacing: 3px;
  text-indent: 3px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.btn-secondary-action:hover {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.btn-secondary-action.hidden {
  display: none;
}

.btn-tip {
  font-size: calc((12px) * var(--font-scale, 1));
  color: var(--ink-muted);
  letter-spacing: 0.8px;
}

.btn-tip.hidden {
  display: none;
}

/* ==========================================================================
   定案区：固定高度 + 稍明显一层毛玻璃（页面不跳动）
   ========================================================================== */
.result-area {
  position: relative;
  flex: 0 0 auto;
  height: 52px;
  margin: 6px 22px 0;
  /* 定案区允许比其它玻璃稍微明显一点，边框带一丝朱砂 */
  background-color: rgba(255, 255, 255, 0.26);
  border-color: rgba(162, 58, 45, 0.16);
  -webkit-backdrop-filter: blur(9px) saturate(1.04);
  backdrop-filter: blur(9px) saturate(1.04);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 投掷前：极淡的未定空状态 */
.result-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.55;
}

/* 投掷后：定案判词出现时，淡空状态让位（纯 CSS 联动，无需 JS 参与） */
.decision-banner.win-a + .result-placeholder,
.decision-banner.win-b + .result-placeholder,
.decision-banner[style*="flex"] + .result-placeholder {
  display: none;
}

.ghost-seal {
  width: 30px;
  height: 30px;
  border: 1px dashed var(--line);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc((16px) * var(--font-scale, 1));
  font-weight: 600;
  color: var(--ink-muted);
}

.ghost-text {
  font-size: calc((12px) * var(--font-scale, 1));
  color: var(--ink-muted);
  letter-spacing: 2px;
}

/* 投掷后：朱砂定印与判词（玻璃纸面上的定案） */
.decision-banner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  animation: fadeIn 0.25s ease-out;
}

.banner-seal {
  width: 32px;
  height: 32px;
  border: 2px solid var(--cinnabar);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(162, 58, 45, 0.28);
  flex-shrink: 0;
}

.seal-char {
  font-family: var(--font-serif);
  font-size: calc((19px) * var(--font-scale, 1));
  font-weight: 700;
  color: var(--cinnabar);
  line-height: 1;
}

.banner-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.banner-reason {
  font-size: calc((12px) * var(--font-scale, 1));
  color: var(--cinnabar);
  letter-spacing: 1.5px;
}

.banner-result {
  font-size: calc((15px) * var(--font-scale, 1));
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.5px;
}

/* ==========================================================================
   筊册记录：占据窗口剩余高度，仅列表内部滚动
   ========================================================================== */
.history-drawer {
  flex: 1 1 0%;
  min-height: 96px;
  margin-top: 2px;
  padding: 8px 22px 10px;
  border-top: 1px solid var(--line-faint);
  display: flex;
  flex-direction: column;
  background: transparent;
}

.history-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 7px 5px;
  margin-bottom: 4px;
  border-radius: 5px;
  /* 只给「筊册记录 / 导出 / 清空」这一行极轻的半透明底，正文列表不卡片化 */
  background-color: rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid var(--line-faint);
}

.history-title {
  font-size: calc((13px) * var(--font-scale, 1));
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--ink-secondary);
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: var(--font-serif);
  font-size: calc((12px) * var(--font-scale, 1));
  letter-spacing: 0.8px;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.18s;
}

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

/* 簿册为空时，导出与清空不可用（避免浏览器原生对话框） */
.text-btn:disabled,
.text-btn:disabled:hover {
  color: var(--ink-muted);
  opacity: 0.42;
  cursor: default;
}

.sep-dot {
  color: var(--line);
  font-size: 12px;
}

.history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-right: 4px;
}

.history-list::-webkit-scrollbar {
  width: 3px;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.history-row {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 3px 2px;
  font-size: calc((12px) * var(--font-scale, 1));
  border-bottom: 1px dashed var(--line-faint);
  color: var(--ink-secondary);
  font-family: var(--font-serif);
}

.history-row:last-child {
  border-bottom: none;
}

.history-col-time {
  width: 44px;
  flex: 0 0 auto;
  font-family: var(--font-sans);
  color: var(--ink-muted);
  font-size: calc((11px) * var(--font-scale, 1));
}

.history-col-desc {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-col-badge {
  flex: 0 0 auto;
  color: var(--bronze);
  font-size: calc((11px) * var(--font-scale, 1));
  font-family: var(--font-sans);
}

.history-row.final-decision {
  color: var(--ink);
  background: var(--cinnabar-wash);
  padding: 3px 4px;
  margin: 1px 0;
  border-bottom: 1px solid rgba(162, 58, 45, 0.18);
}

.history-col-desc.final-text {
  font-weight: 600;
  color: var(--ink);
}

.seal-mini {
  display: inline-block;
  border: 1px solid var(--cinnabar);
  color: var(--cinnabar);
  font-size: 11px;
  padding: 0 3px;
  border-radius: 2px;
  margin-right: 5px;
  line-height: 1.2;
}

.history-empty {
  margin: auto;
  text-align: center;
  padding: 8px 0;
  color: var(--ink-muted);
  font-size: calc((13px) * var(--font-scale, 1));
  letter-spacing: 1.5px;
  opacity: 0.85;
}

/* ==========================================================================
   浮层：纸面文书（无玻璃、无模糊，仅墨色压暗）
   ========================================================================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(48, 44, 39, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background-color: rgba(255, 255, 255, 0.60);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 7px;
  padding: 18px 20px;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(48, 44, 39, 0.20);
  -webkit-backdrop-filter: blur(12px) saturate(1.03);
  backdrop-filter: blur(12px) saturate(1.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-box::-webkit-scrollbar {
  width: 3px;
}

.modal-box::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: calc((17px) * var(--font-scale, 1));
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--ink);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-faint);
}

.modal-body {
  font-size: calc((14px) * var(--font-scale, 1));
  color: var(--ink-secondary);
  line-height: 1.65;
}

.intro-p {
  margin-bottom: 8px;
  color: var(--ink);
}

.rule-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 8px 0;
  padding: 2px 0 2px 10px;
  border-left: 2px solid var(--line);
  background: transparent;
}

.rule-row {
  display: flex;
  gap: 8px;
  font-size: calc((13px) * var(--font-scale, 1));
}

.rule-name {
  color: var(--cinnabar);
  font-weight: 600;
  width: 40px;
  flex: 0 0 auto;
}

.rule-detail {
  color: var(--ink);
}

/* 完整概率与数学原理 (仅在说明弹窗展示) */
.rule-math-section {
  margin-top: 10px;
  padding: 8px 0 4px;
  border-top: 1px solid var(--line-faint);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.math-mode-title {
  font-family: var(--font-serif);
  font-size: calc((14px) * var(--font-scale, 1));
  font-weight: 600;
  color: var(--cinnabar);
  letter-spacing: 0.5px;
}

.math-p {
  font-size: calc((13px) * var(--font-scale, 1));
  color: var(--ink);
  line-height: 1.6;
}

.math-formula {
  font-size: calc((13px) * var(--font-scale, 1));
  font-weight: 600;
  color: var(--ink);
  padding: 2px 0 2px 10px;
  border-left: 2px solid var(--cinnabar);
  margin: 3px 0;
}

.math-sub {
  font-size: calc((13px) * var(--font-scale, 1));
  color: var(--ink-muted);
}

/* ==========================================================================
   案台设置浮层
   ========================================================================== */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line-faint);
}

.setting-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.setting-item.setting-row-inline {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.setting-label-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-name {
  font-family: var(--font-serif);
  font-size: calc((15px) * var(--font-scale, 1));
  font-weight: 600;
  color: var(--ink);
}

.setting-desc {
  font-size: calc((13px) * var(--font-scale, 1));
  color: var(--ink-muted);
}

/* 字号步进 */
.font-size-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: 1px solid var(--line-faint);
  border-radius: 3px;
  padding: 3px 6px;
}

.font-btn {
  background: transparent;
  border: 1px solid var(--line-faint);
  border-radius: 2px;
  color: var(--ink-secondary);
  font-family: var(--font-serif);
  font-size: calc((13px) * var(--font-scale, 1));
  font-weight: 600;
  width: 36px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.font-btn:hover:not(:disabled) {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.font-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.font-scale-tag {
  font-family: var(--font-serif);
  font-size: calc((13px) * var(--font-scale, 1));
  font-weight: 600;
  color: var(--ink-secondary);
}

/* 设置分段文字页签 */
.setting-segmented {
  display: flex;
  background: transparent;
  border: 1px solid var(--line-faint);
  border-radius: 3px;
  padding: 3px;
  gap: 3px;
}

.setting-tab {
  flex: 1;
  padding: 5px 8px;
  background: transparent;
  border: none;
  border-radius: 2px;
  color: var(--ink-muted);
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: calc((13px) * var(--font-scale, 1));
  transition: color 0.18s ease, background-color 0.18s ease;
  text-align: center;
}

.setting-tab:hover {
  color: var(--ink);
}

.setting-tab.active {
  color: var(--cinnabar);
  font-weight: 600;
  background-color: var(--cinnabar-wash);
}

/* 开关 */
.setting-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.setting-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--line);
  border-radius: 12px;
  transition: .3s;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--paper);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(48, 44, 39, 0.25);
  transition: .3s;
}

.setting-switch input:checked + .switch-slider {
  background-color: var(--cinnabar);
}

.setting-switch input:checked + .switch-slider:before {
  transform: translateX(16px);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn-modal-cancel {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-secondary);
  font-family: var(--font-serif);
  font-size: calc((14px) * var(--font-scale, 1));
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.btn-modal-cancel:hover {
  color: var(--cinnabar);
  border-color: var(--cinnabar);
}

.btn-modal-confirm {
  padding: 6px 16px;
  background: var(--cinnabar);
  border: 1px solid var(--cinnabar-dark);
  border-radius: 3px;
  color: #F7F3E8;
  font-family: var(--font-serif);
  font-size: calc((14px) * var(--font-scale, 1));
  letter-spacing: 1px;
  cursor: pointer;
}

.btn-modal-confirm:hover {
  background: var(--cinnabar-dark);
}

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

/* ==========================================================================
   极矮窗口（浏览器预览等非标准场景）下的收敛
   ========================================================================== */
@media (max-height: 700px) {
  .app-header { height: 46px; }
  .stage-wrapper { height: 208px; }
  .result-area { height: 52px; }
}

@media (max-width: 520px) {
  .app-header,
  .mode-selector-wrap,
  .options-panel,
  .controls-panel,
  .history-drawer { padding-inline: 16px; }

  .result-area { margin-inline: 16px; }
}
