/* 周易起卦 · 样式表（从 index.html 拆分） */
:root {
    --bg: #f3ead6;
    --card: #fbf6ea;
    --ink: #3a2a1e;
    --ink-soft: #7a6753;
    --cinnabar: #a63d2f;   /* 朱砂 */
    --cinnabar-deep: #8c2f25;
    --gold: #d9a441;       /* 铜币金 */
    --gold-deep: #b9822c;
    --line-ink: #4a3826;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  [hidden] { display: none !important; }
  html, body { height: 100%; }
  body {
    background:
      radial-gradient(circle at 20% 10%, rgba(166,61,47,.05), transparent 45%),
      var(--bg);
    color: var(--ink);
    font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
    line-height: 1.6;
  }
  .wrap { max-width: 720px; margin: 0 auto; padding: 28px 16px 60px; }

  header { text-align: center; padding: 18px 0 8px; position: relative; }
  header h1 {
    font-size: 34px; letter-spacing: 10px; font-weight: 700;
    color: var(--cinnabar-deep);
  }
  header p { color: var(--ink-soft); font-size: 15px; letter-spacing: 3px; margin-top: 6px; }

  .card {
    position: relative;   /* 供右上角角标按钮定位 */
    background: var(--card);
    border: 1px solid rgba(166,61,47,.15);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(90,60,30,.08);
    padding: 22px 20px;
    margin-top: 22px;
  }
  /* 重新起卦：卡片右上角小号弱化按钮（与主操作区分） */
  .btn-reset-corner {
    position: absolute; top: 20px; right: 18px;
    padding: 3px 12px;
    font-family: inherit; font-size: 12px; letter-spacing: 2px;
    color: var(--ink-soft);
    background: transparent;
    border: 1px dashed rgba(58,42,30,.35);
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s ease;
  }
  .btn-reset-corner:hover {
    color: var(--cinnabar-deep);
    border-color: var(--cinnabar);
    background: rgba(166,61,47,.05);
  }
  .card h2 {
    font-size: 17px; color: var(--cinnabar-deep); letter-spacing: 4px;
    padding-bottom: 10px; margin-bottom: 14px;
    border-bottom: 1px solid rgba(166,61,47,.18);
  }

  /* ---- 起卦方式选择 ---- */
  .method-wrap { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; }
  .method-opt {
    font-family: inherit; font-size: 13px; letter-spacing: 2px;
    padding: 5px 18px; border-radius: 20px; cursor: pointer;
    border: 1px solid rgba(58,42,30,.25); background: transparent; color: var(--ink-soft);
    transition: all .12s ease;
  }
  .method-opt:hover { border-color: var(--cinnabar); color: var(--cinnabar-deep); }
  .method-opt.active {
    background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-deep));
    border-color: var(--cinnabar-deep); color: #fdf3e0; font-weight: 700;
    box-shadow: 0 2px 6px rgba(140,47,37,.4);
  }

  /* ---- 蓍草法展示 ---- */
  .shicao-box { text-align: center; padding: 10px 0 6px; }
  .sc-stage { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 128px; justify-content: flex-end; }
  .sc-slot { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--gold-deep); letter-spacing: 2px; min-height: 26px; }
  .sc-piles { display: flex; justify-content: center; gap: 30px; align-items: flex-end; min-height: 38px; }
  .sc-pile { display: flex; align-items: flex-end; gap: 2px; animation: scFade .3s ease; }
  .sc-stalk { width: 3px; height: 34px; border-radius: 1px; background: linear-gradient(180deg, #d4af6a, #8a6a2f); }
  .sc-stalk.grp { margin-right: 6px; }
  .sc-stalk.gua { background: linear-gradient(180deg, #e0b257, var(--gold-deep)); }
  @keyframes scFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
  .sc-step { margin-top: 8px; font-size: 13px; color: var(--ink); letter-spacing: 1px; min-height: 20px; }
  .sc-log-bar { margin-top: 10px; }
  .sc-log-bar .btn-save { padding: 4px 14px; font-size: 12px; }
  .sc-log-list { list-style: none; }
  .sc-log-item { padding: 7px 4px; border-bottom: 1px dashed rgba(58,42,30,.12); font-size: 13px; line-height: 1.7; color: var(--ink); }
  .sc-log-item:last-child { border-bottom: none; }
  .sc-log-empty { text-align: center; color: #b9ab92; font-size: 13px; letter-spacing: 2px; padding: 30px 0; }
  .shicao-value {
    display: inline-block; font-size: 20px; font-weight: 700; letter-spacing: 3px;
    padding: 8px 26px; border-radius: 10px;
    border: 1px dashed rgba(58,42,30,.3); color: var(--ink-soft);
  }
  .shicao-value.yang { color: var(--cinnabar-deep); border-color: var(--cinnabar); }
  .shicao-value.yin { color: #3f6d5c; border-color: #3f6d5c; }
  .shicao-value.moving { animation: movingPulse 1.6s ease-in-out infinite; }
  .shicao-tip { margin-top: 8px; font-size: 12px; color: #b9ab92; letter-spacing: 1px; }

  /* ---- 硬币区 ---- */
  .coins { display: flex; justify-content: center; gap: 40px; padding: 10px 0 6px; }
  /* 古钱币：圆形方孔，铜质铸造质感（外圆内方、外郭内郭、钱文直读） */
  .coin {
    width: 94px; height: 94px; border-radius: 50%;
    position: relative;
    background: radial-gradient(circle at 33% 27%, #f8e6b0 0%, #e9cd7e 20%, #cba04a 46%, #a87d2f 72%, #86621f 100%);
    border: 1px solid #6b4d1c;
    box-shadow:
      inset 0 0 0 3px rgba(255,244,214,.30),      /* 外郭内高光 */
      inset 0 0 0 5px rgba(120,86,34,.35),        /* 外郭暗环 */
      inset 0 0 0 7px rgba(255,242,205,.22),      /* 外郭亮沿 */
      inset 0 2px 3px rgba(255,240,200,.5),       /* 顶部内高光 */
      inset 0 -7px 14px rgba(60,38,8,.55),        /* 底部内阴影（厚度） */
      0 5px 12px rgba(90,60,30,.35);              /* 投影 */
  }
  /* 中心方孔（天圆地方）：内郭凸沿 + 铸造斜壁 + 微偏转模拟铸造不规整 */
  .coin::before {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: 20px; height: 20px;
    transform: translate(-50%, -50%) rotate(0.6deg);
    background: linear-gradient(160deg, #1a1208, #3a2a14 45%, #0b0805);
    border-radius: 2px 3px 2px 3px;               /* 铸孔边缘不齐 */
    box-shadow:
      inset 0 2px 3px rgba(0,0,0,.9),             /* 孔内深度 */
      inset -1px -1px 2px rgba(255,230,180,.12),  /* 孔内远侧微光 */
      0 0 0 3px rgba(240,215,160,.28),            /* 内郭：凸起方沿亮边 */
      0 0 0 4px rgba(90,62,20,.55),               /* 内郭暗边（铸造斜壁） */
      0 1px 1px rgba(255,238,200,.35);            /* 孔沿受光 */
  }
  /* 包浆锈蚀 + 磨光露铜：青绿锈斑 + 边缘高光磨损 */
  .coin::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    background:
      radial-gradient(circle at 70% 78%, rgba(82,120,92,.28) 0 18%, transparent 40%),
      radial-gradient(circle at 12% 84%, rgba(96,132,100,.18) 0 12%, transparent 26%),
      radial-gradient(circle at 60% 8%, rgba(74,112,82,.12) 0 10%, transparent 20%),
      radial-gradient(circle at 30% 30%, rgba(255,240,205,.25) 0 6%, transparent 12%),
      radial-gradient(circle at 85% 35%, rgba(255,235,190,.18) 0 5%, transparent 10%);
    pointer-events: none;
  }
  /* 阳/阴大字：方孔上方（钱文直读位置） */
  .coin .mark {
    position: absolute; left: 50%; top: 7%;
    transform: translateX(-50%);
    font-size: 24px; font-weight: 700; line-height: 1;
    font-family: "KaiTi", "楷体", "STKaiti", "SimSun", serif;
    text-shadow: 0 1px 0 rgba(255,240,205,.5), 0 -1px 1px rgba(60,40,10,.45);
  }
  /* 正面/反面小注：隐藏，改用钱币颜色区分（正面古铜、反面银灰） */
  .coin .sub { display: none; }
  .coin.tails .mark { color: #33404a; }   /* 反：墨青 */
  .coin.heads .mark { color: var(--cinnabar-deep); } /* 正：朱砂 */

  /* 反面：银灰色古钱（整体银灰金属质感，含方孔/外郭/污渍全套适配） */
  .coin.tails {
    background: radial-gradient(circle at 33% 27%, #f7f7f9 0%, #e3e3e7 20%, #bdbdc3 46%, #9a9aa1 72%, #76767d 100%);
    border: 1px solid #56565c;
    box-shadow:
      inset 0 0 0 3px rgba(255,255,255,.5),       /* 外郭内高光 */
      inset 0 0 0 5px rgba(120,120,128,.35),      /* 外郭暗环 */
      inset 0 0 0 7px rgba(255,255,255,.25),      /* 外郭亮沿 */
      inset 0 2px 3px rgba(255,255,255,.6),       /* 顶部内高光 */
      inset 0 -7px 14px rgba(38,38,44,.5),        /* 底部内阴影 */
      0 5px 12px rgba(90,90,100,.35);             /* 投影 */
  }
  .coin.tails::before {
    background: linear-gradient(160deg, #202024, #3c3c44 45%, #101014);
    box-shadow:
      inset 0 2px 3px rgba(0,0,0,.9),
      inset -1px -1px 2px rgba(255,255,255,.1),
      0 0 0 3px rgba(230,230,235,.3),             /* 内郭亮边 */
      0 0 0 4px rgba(70,70,78,.55),               /* 内郭暗边 */
      0 1px 1px rgba(255,255,255,.4);
  }
  .coin.tails::after {
    background:
      radial-gradient(circle at 70% 78%, rgba(110,110,120,.30) 0 18%, transparent 40%),
      radial-gradient(circle at 12% 84%, rgba(90,90,100,.20) 0 12%, transparent 26%),
      radial-gradient(circle at 60% 8%, rgba(120,120,130,.14) 0 10%, transparent 20%),
      radial-gradient(circle at 30% 30%, rgba(255,255,255,.35) 0 6%, transparent 12%),
      radial-gradient(circle at 85% 35%, rgba(255,255,255,.25) 0 5%, transparent 10%);
  }

  @keyframes coinToss {
    0%   { transform: translateY(0)     rotate(0deg)   scale(1); }
    22%  { transform: translateY(-32px) rotate(140deg) scale(1.06); }
    48%  { transform: translateY(0)     rotate(280deg) scale(1); }
    72%  { transform: translateY(-20px) rotate(380deg) scale(1.09); }
    100% { transform: translateY(0)     rotate(360deg) scale(1); }
  }
  .coin.tossing { animation: coinToss .9s ease-in-out forwards; }

  .actions { display: flex; justify-content: center; gap: 16px; margin-top: 18px; }
  /* ---- 手动录入爻象 ---- */
  .manual-wrap {
    margin-top: 18px; padding: 16px 14px;
    background: #faf4e4; border: 1px dashed rgba(166,61,47,.3);
    border-radius: 10px;
  }
  .manual-tip { font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; text-align: center; margin-bottom: 14px; }
  .manual-list { list-style: none; }
  .manual-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 4px; border-bottom: 1px dashed rgba(58,42,30,.12);
  }
  .manual-list li:last-child { border-bottom: none; }
  .manual-list .pos { width: 56px; font-weight: 700; color: var(--ink); letter-spacing: 2px; font-size: 14px; }
  .manual-opts { display: flex; gap: 8px; margin-left: auto; }
  .manual-opt {
    padding: 4px 14px; border-radius: 20px; cursor: pointer;
    font-size: 13px; letter-spacing: 2px; border: 1px solid rgba(58,42,30,.25);
    background: transparent; color: var(--ink-soft); font-family: inherit;
    transition: all .12s ease;
  }
  .manual-opt:hover { border-color: var(--cinnabar); color: var(--cinnabar-deep); }
  /* 爻象选中态：实底 + 白字 + 发光（阳=朱砂、阴=青绿） */
  .manual-opt.sel-yang {
    background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-deep));
    border-color: var(--cinnabar-deep);
    color: #fdf3e0; font-weight: 700;
    box-shadow: 0 2px 6px rgba(140,47,37,.4);
  }
  .manual-opt.sel-yin {
    background: linear-gradient(180deg, #4a7a66, #37503f);
    border-color: #2f4538;
    color: #f3efe2; font-weight: 700;
    box-shadow: 0 2px 6px rgba(55,80,63,.4);
  }
  button {
    font-family: inherit; font-size: 17px; letter-spacing: 4px;
    padding: 10px 30px; border-radius: 8px; cursor: pointer;
    transition: all .15s ease;
  }
  .btn-primary {
    background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-deep));
    color: #fdf3e0; border: 1px solid var(--cinnabar-deep);
    box-shadow: 0 3px 8px rgba(140,47,37,.3);
  }
  .btn-primary:hover { filter: brightness(1.1); }
  .btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
  /* 连抛六次：金色渐变（区别于主操作红、辅助透明） */
  .btn-auto {
    background: linear-gradient(180deg, #e0b257, var(--gold-deep));
    color: #3a2a1e;
    border: 1px solid #a5782a;
    box-shadow: 0 3px 8px rgba(160,120,40,.3);
  }
  .btn-auto:hover { filter: brightness(1.08); }
  .btn-auto:disabled { opacity: .5; cursor: not-allowed; filter: none; }
  .btn-ghost {
    background: transparent; color: var(--ink-soft);
    border: 1px solid rgba(58,42,30,.35);
  }
  .btn-ghost:hover { color: var(--ink); border-color: var(--ink); }
  /* 手动录入按钮：激活态（进入手动模式时实底高亮） */
  .btn-ghost.active {
    background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-deep));
    color: #fdf3e0; border-color: var(--cinnabar-deep);
    box-shadow: 0 2px 8px rgba(140,47,37,.35);
  }

  .status {
    text-align: center; margin-top: 16px; font-size: 15px;
    color: var(--ink-soft); letter-spacing: 2px;
  }
  .status b { color: var(--cinnabar-deep); font-size: 16px; }

  /* ---- 记录区 ---- */
  .throws { list-style: none; }
  .throws li {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 6px; border-bottom: 1px dashed rgba(58,42,30,.14);
    font-size: 15px;
  }
  .throws li:last-child { border-bottom: none; }
  .throws .pos { width: 64px; font-weight: 700; color: var(--ink); letter-spacing: 2px; }
  .throws .coins-text { width: 90px; color: var(--ink-soft); letter-spacing: 6px; }
  .throws .coins-text .h { color: var(--cinnabar-deep); }
  .throws .coins-text .t { color: #4a4a52; }
  .throws .coins-text .manual-mark { color: #b9ab92; letter-spacing: 2px; }
  .throws .verdict { margin-left: auto; }
  .throws .empty { color: #b9ab92; letter-spacing: 2px; }
  .badge {
    display: inline-block; padding: 2px 12px; border-radius: 20px;
    font-size: 13px; letter-spacing: 2px; border: 1px solid;
  }
  .badge.yang { color: var(--cinnabar-deep); border-color: var(--cinnabar); background: rgba(166,61,47,.06); }
  .badge.yin  { color: #3f6d5c;  border-color: #3f6d5c;  background: rgba(63,109,92,.06); }
  .badge .dot { color: var(--cinnabar); }
  .badge.moving {
    background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-deep));
    color: #fdf3e0;
    border-color: var(--cinnabar-deep);
    font-weight: 700;
    animation: movingPulse 1.6s ease-in-out infinite;
  }

  /* ---- 卦象区 ---- */
  .hexagrams { display: flex; justify-content: center; gap: 40px; flex-wrap: wrap; }
  .hex { width: 240px; text-align: center; }
  .hex .tag {
    font-size: 13px; color: var(--ink-soft); letter-spacing: 4px; margin-bottom: 6px;
  }
  .hex .name { font-size: 26px; font-weight: 700; color: var(--cinnabar-deep); letter-spacing: 6px; margin-top: 10px; }
  .hex .sub-names { margin-top: 6px; font-size: 14px; color: var(--ink-soft); letter-spacing: 3px; }
  .hex.lines-right { border-right: 1px dashed rgba(58,42,30,.18); padding-right: 30px; }
  .hex.lines-left  { border-left: 1px dashed rgba(58,42,30,.18);  padding-left: 30px; }
  .hex-lines { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; }
  .line { width: 150px; height: 18px; display: flex; align-items: center; position: relative; }
  .line .bar {
    height: 14px; background: linear-gradient(180deg, #5c4630, var(--line-ink));
    border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  }
  .line.yang .bar { width: 100%; }
  .line.yin  { gap: 12px; }
  .line.yin  .bar { width: calc(50% - 6px); }
  .line.moving .bar {
    background: linear-gradient(180deg, #e2604f, var(--cinnabar-deep));
    box-shadow: 0 0 8px rgba(166,61,47,.55);
    animation: linePulse 1.6s ease-in-out infinite;
  }

  @keyframes movingPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(166,61,47,.35), 0 2px 6px rgba(140,47,37,.3); }
    50%      { box-shadow: 0 0 0 4px rgba(166,61,47,.6),  0 2px 10px rgba(140,47,37,.5); }
  }
  @keyframes linePulse {
    0%, 100% { box-shadow: 0 0 6px rgba(166,61,47,.4); }
    50%      { box-shadow: 0 0 14px rgba(166,61,47,.85); }
  }
  .line .flag {
    position: absolute; right: -26px; font-size: 12px;
    color: var(--cinnabar-deep); letter-spacing: 1px; font-weight: 700;
  }
  .note { text-align: center; margin-top: 16px; color: var(--ink-soft); font-size: 14px; letter-spacing: 2px; }
  /* ---- 卦辞爻辞原文展示 ---- */
  .hex-orig {
    margin-top: 16px; padding: 12px 16px;
    background: #faf4e4; border: 1px solid rgba(166,61,47,.16);
    border-left: 3px solid var(--gold-deep); border-radius: 8px;
    font-size: 14px; line-height: 1.9; color: var(--ink);
  }
  .hex-orig .row { margin: 3px 0; }
  .hex-orig .lbl { color: var(--cinnabar-deep); font-weight: 700; letter-spacing: 1px; margin-right: 6px; }
  .hex-orig .hl { background: rgba(166,61,47,.08); padding: 1px 6px; border-radius: 4px; }
  .hex-orig .miss { color: #b9ab92; }
  .note .divider { display: block; margin-top: 8px; color: var(--cinnabar-deep); }
  .methods { list-style: none; margin-top: 4px; }
  .methods li {
    padding: 8px 4px; border-bottom: 1px dashed rgba(58,42,30,.14); font-size: 15px;
  }
  .methods li:last-child { border-bottom: none; }
  .methods .n { color: var(--cinnabar-deep); font-weight: 700; letter-spacing: 1px; }
  .methods .note-tip { color: var(--ink-soft); font-size: 13px; letter-spacing: 1px; }

  /* ---- 动爻断法按钮 + 悬浮框 ---- */
  .header-btns {
    display: flex; justify-content: center; align-items: center;
    flex-wrap: wrap; gap: 14px; margin-top: 16px;
  }
  .header-btns .group-funcs { display: flex; gap: 10px; }
  /* 功能按钮：朱砂描边 + 图标，统一尺寸（动爻断法字多，居中收纳进胶囊） */
  .btn-duanfa {
    background: transparent; color: var(--ink-soft);
    border: 1px solid rgba(166,61,47,.4);
    font-size: 14px; letter-spacing: 3px; padding: 7px 18px;
    border-radius: 22px; cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
  }
  .btn-duanfa .ic { color: var(--cinnabar-deep); margin-right: 5px; }
  .btn-duanfa:hover { color: var(--cinnabar-deep); border-color: var(--cinnabar); background: rgba(166,61,47,.06); }
  /* 右上角竖排：退出（弱化灰）在上、AI 配置（朱砂区分）在下 */
  .header-corner {
    position: absolute; top: 14px; right: 16px;
    display: flex; flex-direction: column; align-items: stretch; gap: 12px;
    width: 100px;
  }
  .btn-logout, .btn-corner {
    background: transparent;
    font-family: inherit; font-size: 12px; letter-spacing: 3px;
    padding: 4px 0; border-radius: 16px; cursor: pointer;
    transition: all .15s ease; white-space: nowrap;
    width: 100%; text-align: center;
  }
  .btn-logout {
    color: #b9ab92;
    border: 1px dashed rgba(58,42,30,.3);
  }
  .btn-logout:hover { color: var(--cinnabar-deep); border-color: var(--cinnabar); }
  .btn-corner.cfg {
    color: var(--cinnabar-deep);
    border: 1px dashed rgba(166,61,47,.45);
  }
  .btn-corner.cfg:hover { background: rgba(166,61,47,.07); border-style: solid; }

  .modal-mask {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(40,28,18,.55);
    display: none; align-items: center; justify-content: center;
    padding: 20px;
  }
  .modal-mask.open { display: flex; }
  .modal {
    background: var(--card); border: 1px solid rgba(166,61,47,.2);
    border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
    width: 100%; max-width: 520px; max-height: 82vh; overflow-y: auto;
  }
  .modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid rgba(166,61,47,.18);
    font-size: 17px; font-weight: 700; letter-spacing: 4px; color: var(--cinnabar-deep);
  }
  .modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 22px; line-height: 1; color: var(--ink-soft); padding: 0 4px;
  }
  .modal-close:hover { color: var(--cinnabar-deep); }
  .modal-body { padding: 16px 18px; }

  /* ---- 六十四卦总览弹窗 ---- */
  .modal-wide { max-width: 860px; }
  .modal-scroll { max-height: 72vh; overflow-y: auto; }
  .hexbook { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }

  /* ---- 卜卦记录弹窗 ---- */
  .records-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
  .records-tip { font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }
  .records-list { list-style: none; max-height: 55vh; overflow-y: auto; }
  .record-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px dashed rgba(58,42,30,.14); }
  .record-item:last-child { border-bottom: none; }
  .record-main { flex: 1; min-width: 0; }
  .record-gua { font-size: 15px; font-weight: 700; color: var(--cinnabar-deep); letter-spacing: 1px; }
  .record-ai-flag { color: var(--gold-deep); font-size: 11px; margin-left: 8px; font-weight: 400; }
  .record-time { font-size: 12px; color: #b9ab92; margin-top: 2px; }
  .record-q { font-size: 13px; color: var(--ink-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .record-opts { display: flex; gap: 8px; flex-shrink: 0; }
  .record-opts .btn-save { padding: 3px 10px; font-size: 12px; }
  .records-empty { text-align: center; color: #b9ab92; font-size: 13px; letter-spacing: 2px; padding: 30px 0; }
  .hexbook-item {
    display: flex; gap: 14px; align-items: flex-start;
    background: #faf4e4; border: 1px solid rgba(166,61,47,.14);
    border-radius: 8px; padding: 12px 14px; font-size: 13.5px; line-height: 1.8;
  }
  .hb-icon { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; padding-top: 5px; }
  .hb-line { width: 36px; height: 4px; background: var(--line-ink); border-radius: 2px; }
  /* 阴爻：中间断开的两段（渐变实现，保持单 div） */
  .hb-line.yin {
    background: linear-gradient(90deg, var(--line-ink) 0 41%, transparent 41% 59%, var(--line-ink) 59% 100%);
  }
  .hexbook-item .hb-main { flex: 1; min-width: 0; }
  .hexbook-item .hb-name { font-size: 15px; font-weight: 700; color: var(--cinnabar-deep); letter-spacing: 2px; margin-bottom: 4px; }
  .hexbook-item .hb-gua { color: var(--ink); }
  .hexbook-item .hb-gua b { color: var(--cinnabar-deep); }
  .hexbook-item .hb-yao { color: var(--ink-soft); }
  .hexbook-item .hb-yao .y { color: var(--ink); }
  .hexbook-item .hb-yong { color: var(--gold-deep); font-weight: 700; }

  /* ---- 卜问区 ---- */
  .question-wrap { margin-top: 2px; }
  .question-wrap label { display: block; font-size: 14px; color: var(--ink-soft); letter-spacing: 2px; margin-bottom: 8px; }
  textarea#question {
    width: 100%; min-height: 72px; resize: vertical;
    padding: 10px 12px; border-radius: 8px;
    border: 1px solid rgba(58,42,30,.25);
    background: #fffdf6; color: var(--ink);
    font-family: inherit; font-size: 15px; line-height: 1.6;
    outline: none;
  }
  textarea#question:focus { border-color: var(--cinnabar); box-shadow: 0 0 0 2px rgba(166,61,47,.12); }
  textarea#question::placeholder { color: #b9ab92; letter-spacing: 1px; }

  /* ---- AI 解读区 ---- */
  .ai-bar { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
  .btn-ai {
    background: linear-gradient(180deg, #4a6d5f, #37503f);
    color: #f3efe2; border: 1px solid #2f4538;
    box-shadow: 0 3px 8px rgba(55,80,63,.3);
  }
  .btn-ai:hover { filter: brightness(1.12); }
  .btn-ai:disabled { opacity: .45; cursor: not-allowed; filter: none; }
  .ai-hint { font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; }
  .ai-status { flex-basis: 100%; font-size: 14px; color: var(--ink-soft); letter-spacing: 1px; }
  .ai-status.error { color: var(--cinnabar-deep); }
  .ai-status.ok { color: #3f6d5c; }
  .ai-output {
    margin-top: 14px; padding: 14px 16px;
    background: #fffdf6; border: 1px solid rgba(58,42,30,.16);
    border-left: 4px solid var(--cinnabar); border-radius: 8px;
    font-size: 15px; line-height: 1.8; color: var(--ink);
    white-space: pre-wrap; word-break: break-word;
  }
  .ai-output h3 {
    font-size: 16px; color: var(--cinnabar-deep); margin: 14px 0 6px;
    letter-spacing: 2px; border-bottom: 1px dashed rgba(166,61,47,.2); padding-bottom: 4px;
  }
  .ai-output h3:first-child { margin-top: 0; }
  .ai-output ul { margin: 6px 0 6px 20px; padding: 0; }
  .ai-output li { margin: 3px 0; }
  .ai-output .loading-dots::after { content: ''; animation: dots 1.2s steps(4,end) infinite; }
  @keyframes dots { 0% { content: ''; } 25% { content: '·'; } 50% { content: '··'; } 75% { content: '···'; } }

  .settings-details { margin-top: 10px; border: 1px dashed rgba(58,42,30,.25); border-radius: 8px; padding: 12px 14px; }
  .settings-details summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); letter-spacing: 2px; user-select: none; }
  .settings-row { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
  .settings-row label { font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }
  .settings-row input {
    padding: 7px 10px; border-radius: 6px;
    border: 1px solid rgba(58,42,30,.25); background: #fffdf6;
    font-family: inherit; font-size: 13px; color: var(--ink); outline: none;
  }
  .settings-row input:focus { border-color: var(--cinnabar); }
  .settings-actions { margin-top: 12px; display: flex; gap: 10px; }
  .btn-save {
    background: transparent; color: var(--cinnabar-deep);
    border: 1px solid var(--cinnabar); padding: 5px 18px;
    font-size: 14px; border-radius: 6px; cursor: pointer; letter-spacing: 2px;
  }
  .btn-save:hover { background: rgba(166,61,47,.08); }

  /* ---- AI 解读中：全屏 loading 遮罩 ---- */
  .ai-loading-mask {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(40,28,18,.45);
    display: none; align-items: center; justify-content: center;
  }
  .ai-loading-mask.open { display: flex; }
  .ai-loading-box {
    background: var(--card); border: 1px solid rgba(166,61,47,.2);
    border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
    padding: 30px 40px 26px; width: 320px; text-align: center;
  }
  .ai-loading-coin {
    width: 54px; height: 54px; margin: 0 auto;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #f2d493, var(--gold) 60%, var(--gold-deep));
    border: 2px solid var(--gold-deep);
    box-shadow: inset 0 -3px 6px rgba(120,80,20,.35), 0 3px 8px rgba(90,60,30,.25);
    animation: coinFlip 1.1s ease-in-out infinite;
  }
  @keyframes coinFlip {
    0%   { transform: rotateY(0deg); }
    50%  { transform: rotateY(180deg); }
    100% { transform: rotateY(360deg); }
  }
  .ai-loading-text { margin-top: 16px; font-size: 16px; letter-spacing: 3px; color: var(--ink); }
  .ai-loading-text::after { content: ''; animation: dots 1.2s steps(4,end) infinite; }
  .ai-loading-sub { margin-top: 6px; font-size: 12px; letter-spacing: 1px; color: var(--ink-soft); }
  .ai-progress {
    margin-top: 16px; height: 8px; border-radius: 4px;
    background: rgba(58,42,30,.12); overflow: hidden;
  }
  .ai-progress .bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--cinnabar), var(--gold));
    transition: width .3s ease;
  }

  @media (max-width: 560px) {
    .coins { gap: 18px; }
    .coin { width: 74px; height: 74px; }
    .coin::before { width: 17px; height: 17px; }
    .coin .mark { font-size: 18px; }
    .coin .sub { font-size: 9px; letter-spacing: 2px; }
    .hexagrams { gap: 16px; }
    .hex.lines-right, .hex.lines-left { border: none; padding: 0; }
  }

  /* ---- 登录门禁 ---- */
  .login-mask {
    position: fixed; inset: 0; z-index: 300;
    background: radial-gradient(circle at 50% 35%, #f7efdc, var(--bg));
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
  }
  .login-mask.hidden { display: none; }
  .login-box {
    width: 340px; max-width: 100%; text-align: center;
    background: var(--card); border: 1px solid rgba(166,61,47,.2);
    border-radius: 14px; box-shadow: 0 10px 40px rgba(90,60,30,.18);
    padding: 36px 32px 30px;
  }
  .login-box h1 {
    font-size: 28px; letter-spacing: 8px; color: var(--cinnabar-deep); font-weight: 700;
  }
  .login-box .sub { color: var(--ink-soft); font-size: 13px; letter-spacing: 3px; margin-top: 6px; }
  .login-coin {
    width: 64px; height: 64px; margin: 22px auto 0; border-radius: 50%;
    background: radial-gradient(circle at 33% 27%, #f8e6b0, #e9cd7e 20%, #cba04a 46%, #a87d2f 72%, #86621f);
    border: 1px solid #6b4d1c;
    box-shadow: inset 0 0 0 3px rgba(255,244,214,.3), inset 0 0 0 5px rgba(120,86,34,.35), inset 0 2px 3px rgba(255,240,200,.5), inset 0 -6px 12px rgba(60,38,8,.5), 0 4px 10px rgba(90,60,30,.3);
    position: relative;
    animation: loginCoinFloat 3s ease-in-out infinite;
  }
  .login-coin::before {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: 15px; height: 15px; transform: translate(-50%, -50%);
    background: linear-gradient(160deg, #1a1208, #3a2a14 45%, #0b0805);
    border-radius: 2px;
    box-shadow: inset 0 2px 3px rgba(0,0,0,.9), 0 0 0 2px rgba(240,215,160,.3), 0 0 0 3px rgba(90,62,20,.5);
  }
  .login-coin .lc { position: absolute; left: 50%; transform: translateX(-50%); color: var(--cinnabar-deep); font-weight: 700; font-family: "KaiTi","楷体","STKaiti",serif; }
  .login-coin .lc-top { top: 5px; font-size: 16px; }
  .login-coin .lc-bot { bottom: 4px; font-size: 8px; letter-spacing: 2px; color: #7a5c28; }
  @keyframes loginCoinFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
  }
  .login-box input {
    width: 100%; padding: 11px 14px; margin-top: 24px;
    border: 1px solid rgba(58,42,30,.3); border-radius: 8px;
    background: #fffdf6; color: var(--ink);
    font-family: inherit; font-size: 16px; letter-spacing: 6px; text-align: center;
    outline: none;
  }
  .login-box input:focus { border-color: var(--cinnabar); box-shadow: 0 0 0 2px rgba(166,61,47,.12); }
  .login-box .btn-login {
    width: 100%; margin-top: 16px;
    background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-deep));
    color: #fdf3e0; border: 1px solid var(--cinnabar-deep);
    font-family: inherit; font-size: 17px; letter-spacing: 6px;
    padding: 11px 0; border-radius: 8px; cursor: pointer;
    box-shadow: 0 3px 8px rgba(140,47,37,.3);
  }
  .login-box .btn-login:hover { filter: brightness(1.1); }
  .login-box .btn-login:disabled { opacity: .5; cursor: not-allowed; }
  .login-err { color: var(--cinnabar-deep); font-size: 13px; letter-spacing: 1px; margin-top: 12px; min-height: 18px; }
  .login-tip { color: #b9ab92; font-size: 12px; letter-spacing: 1px; margin-top: 14px; }
