/* 爻历安卓版 · 手机布局 v2
   纸色/宋体不变；卡片直接贴到屏幕左右边，页内只留上下卡片之间的纸色缝。 */

/* PC 端：这套竖排布局在所有宽度生效（原来包在 @media (max-width:900px) 里） */
  /* 用 clip 而不是 hidden：overflow-x:hidden 会让 position:sticky 的顶栏失效 */
  html, body { overflow-x: clip; }
  body {
    -webkit-text-size-adjust: 100%;
    background: var(--paper, #dfeada);
    padding: 0;
  }

  .app {
    max-width: none;
    padding: 0 0 calc(64px + env(safe-area-inset-bottom));
  }

  /* ---------- 顶栏 ---------- */
  .topbar {
    display: flex !important;
    flex-wrap: nowrap !important;
    position: sticky;
    top: 0;
    z-index: 60;
    margin: 0 0 8px;
    padding: 8px 12px;
    align-items: center;
    gap: 8px;
    background: var(--paper, #dfeada);
  background: color-mix(in srgb, var(--paper, #dfeada) 96%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line, #cbdbc0);
  }
  .brand { display: flex !important; align-items: center; gap: 8px; min-width: 0; }
  .brand .seal { width: 30px; height: 30px; line-height: 30px; font-size: 18px; }
  .brand-text {
    display: block !important;
    font-size: 20px !important;
    letter-spacing: .1em;
    white-space: nowrap;
  }
  .brand-text small { display: none !important; }
  .top-actions {
    display: flex !important;
    margin-left: auto !important;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .top-actions .btn {
    padding: 5px 8px !important;
    font-size: 12px !important;
    border-radius: 8px;
  }
  #btnZoom { display: none !important; }

  .settings-pop {
    position: fixed !important;
    top: 52px;
    right: 8px;
    left: auto !important;
    width: min(340px, 94vw);
    max-height: 76vh;
    overflow: auto;
    z-index: 90;
    -webkit-overflow-scrolling: touch;
  }

  /* ---------- 底部 dock ---------- */
  #m-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    height: calc(56px + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    display: flex;
    align-items: stretch;
    background: var(--card, #f5f9f0);
  background: color-mix(in srgb, var(--card, #f5f9f0) 97%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line, #cbdbc0);
    box-shadow: 0 -4px 18px rgba(60, 42, 20, .07);
    transition: transform .22s ease;
    will-change: transform;
  }
  #m-dock button {
    flex: 1;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--ink-3, #78896c);
    font: inherit;
    font-size: 11px;
    letter-spacing: .06em;
    padding: 4px 0;
  }
  #m-dock button svg { width: 21px; height: 21px; }
  #m-dock button.active { color: var(--dm, #a92e1c); font-weight: 700; }
  #m-dock button.active svg { stroke: currentColor; }
  body.kb-open #m-dock { display: none !important; }
  body.kb-open .app { padding-bottom: 12px !important; }
  body.dock-hidden #m-dock {
    transform: translateY(calc(100% + 10px));
    pointer-events: none;
  }

  /* ---------- 排盘页 ---------- */
  .view { padding-top: 0; }
  #view-cast.active { display: block !important; }
  #view-cast {
    --chart-fs: var(--m-chart-fs, 13.5px);
    --info-fs: var(--m-chart-fs, 13.5px);
  }
  #m-cast-wrap { display: flex; flex-direction: column; gap: 4px; }

  /* 卡片：左右贴边，不再有 10px 纸色框 */
  .m-card {
    background: var(--card, #f5f9f0);
    border: 0;
    border-top: 1px solid var(--line, #cbdbc0);
    border-bottom: 1px solid var(--line, #cbdbc0);
    border-radius: 0;
    padding: 11px 14px 6px;
    box-shadow: none;
    min-width: 0;
  }
  .m-card:empty { display: none; }
  .m-card.m-chart { padding: 0; }
  .m-card .chart {
    width: 100% !important;
    max-width: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    overflow: visible !important;
  }
  .m-card .gcal {
    display: block !important;
    position: static !important;
    width: auto !important;
    margin: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: transparent !important;
    touch-action: pan-y !important;
  }
  .m-card .field-row, .m-card .field { margin-bottom: 7px; }
  .m-card .field-row { display: flex; gap: 7px; align-items: flex-end; }
  .m-card .field-row.wrap { flex-wrap: wrap; }
  .m-card .field.grow { flex: 1 1 100%; min-width: 0; }

  /* 起卦时间：标签、时间框、此刻按钮同一行 */
  #modeTime .field-row { flex-wrap: nowrap; align-items: center; gap: 7px; }
  #modeTime .field.w-time {
    flex: 1 1 auto;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin-bottom: 0 !important;
  }
  #modeTime .field.w-time .field-label {
    flex: 0 0 auto;
    white-space: nowrap;
    letter-spacing: .08em;
  }
  #modeTime .field.w-time input[type="datetime-local"] {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    font-size: 13px;
    padding: 6px 8px;
  }
  #modeTime #btnNow { flex: 0 0 auto; padding: 6px 10px; }
  .m-card .cast-buttons {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 7px;
  }
  .m-card .cast-buttons #btnNew:not([hidden]) { grid-column: 1; grid-row: 1; justify-self: start; display: inline-flex; }
  .m-card .cast-buttons #btnShot { grid-column: 2; grid-row: 1; justify-self: center; }
  .m-card .cast-buttons #btnSave { grid-column: 3; grid-row: 1; justify-self: end; }
  .m-card .cast-buttons #saveHint { grid-column: 1 / -1; grid-row: 2; }
  .m-card .cast-buttons #saveHint:empty { display: none; }

  /* 六爻/起卦行并进时间卡，隐藏重复的“六爻”小标题 */
  .m-card .yao-head {
    margin: 4px 0 0;
    padding-top: 8px;
    border-top: 1px dashed var(--line, #cbdbc0);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .m-card .yao-head > .field-label { display: none; }
  .m-card .yao-tools { display: flex; flex: 1 1 100%; gap: 6px; flex-wrap: wrap; align-items: center; }
  #btnNewTop { color: var(--ink-2); white-space: nowrap; }
  .cast-hint { display: none; }
  .m-card .cast-hint {
    display: block;
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    text-align: center;
    font-size: 9px;
    line-height: 1.3;
    color: var(--ink-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* 起卦 / 再来一卦 / 卦名：字号在设置里调，三个一起变 */
  #view-cast .yao-head .yao-tools .btn {
    font-size: var(--m-castbtn-fs, 14px) !important;
    padding: 6px 8px;
  }
  /* 所问何事在起卦按钮下方 */
  .m-time .field-row.wrap { margin-top: 8px; }
  .m-time .field-row.wrap:last-child { margin-bottom: 0; }
  .m-time #question { font-size: var(--m-q-fs, 13.5px) !important; }
  #gzBaziHint:empty { display: none !important; margin: 0 !important; }
  /* 底部的更新此卦 / 再来一卦：字号也在设置里调 */
  .m-btns .cast-buttons .btn {
    font-size: var(--m-btmbtn-fs, 13.5px) !important;
    padding: 8px 14px;
  }

  /* ---------- 卦盘信息 ---------- */
  #view-cast .chart-info { padding: 12px 12px 4px; gap: 4px; }
  #view-cast .info-line { gap: 8px; align-items: flex-start; }
  #view-cast .info-line .k {
    flex: 0 0 40px;
    font-size: 12.5px;
    line-height: 1.7;
    padding-top: 1px;
  }
  #view-cast .info-line.recnav-combo .k { flex-basis: 58px; }
  #view-cast .info-line .v {
    font-size: 12.5px;
    line-height: 1.7;
  }
  #view-cast .info-line .v.q { font-size: 12.5px; }
  #view-cast .info-line .v.q { font-size: var(--m-q-fs, 13.5px) !important; }
  #view-cast .info-line .v .dt-cn { font-size: .88em; margin-left: 2px; }
  #view-cast .jie-inline { font-size: 10.5px; margin-left: 4px; }

  /* 干支四柱：一排四个 */
  .m-time .gz-grid { gap: 4px; }
  .m-time .gz-grid .field-label {
    font-size: 10px;
    line-height: 1.35;
    white-space: nowrap;
    gap: 1px;
  }
  .m-time .gz-grid .field-label em { font-size: 8px; }
  .m-time .gz-grid select { font-size: 11px; padding: 5px 2px; }

  #view-cast .pillars {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    margin-top: 0;
  }
  #view-cast .pillar { padding: 6px 2px 5px; border-radius: 5px; }
  #view-cast .pillar b { font-size: 15px; }
  #view-cast .pillar.key b { font-size: 17px; }
  #view-cast .pillar span { font-size: 9px; letter-spacing: .04em; }

  #view-cast .ss-block { margin-top: 0; padding-top: 4px; }
  #view-cast .ss-block .ss-list { max-height: none !important; overflow: visible !important; }
  #view-cast .ss-head { font-size: 12px; }
  #view-cast .ss-list { gap: 2px 12px; line-height: 1.7; }
  #view-cast .ss-item,
  #view-cast .ss-toggle { font-size: var(--m-ss-fs, 12.5px) !important; }
  #view-cast .ss-toggle { padding: 0; }

  /* 时间旁的干支历入口 */
  .gcal-link {
    display: inline-block;
    white-space: nowrap;
    margin-left: 5px;
    font-size: 10px;
    line-height: 1.5;
    color: var(--dm, #a92e1c);
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 8px;
    padding: 0 4px;
    vertical-align: 1px;
  }

  /* ---------- 排盘表 ---------- */
  #view-cast .chart-body { padding: 0 8px 8px; }
  #view-cast .ct-head,
  #view-cast .ct-row {
    grid-template-columns: max(30px, calc(var(--m-shen-fs, 11px) * 2.1)) minmax(0, 1.07fr) minmax(0, .93fr) !important;
    column-gap: 2px !important;
    align-items: center !important;
  }
  #view-cast .chart-body.no-bian .ct-head,
  #view-cast .chart-body.no-bian .ct-row {
    grid-template-columns: minmax(0, 1fr) max(30px, calc(var(--m-shen-fs, 11px) * 2.1)) 174px minmax(0, 1fr) !important;
    column-gap: 2px !important;
  }
  #view-cast .chart-body.no-bian .ct-head .h3 { display: none !important; }
  #view-cast .chart-body.no-bian .ct-head .h1 { grid-column: 2; }
  #view-cast .chart-body.no-bian .ct-head .h2 { grid-column: 3; justify-content: flex-start; }
  #view-cast .chart-body.no-bian .ct-row .ct-shen { grid-column: 2; }
  #view-cast .chart-body.no-bian .ct-row .ct-cell:not(.bian) {
    grid-column: 3;
    width: 174px;
    justify-content: flex-start;
  }
  #view-cast .chart-body.no-bian .ct-row .ct-extra {
    grid-column: 1 / -1;
    padding-left: 0;
    justify-content: center;
  }
  #view-cast .ct-head { padding: 7px 0 6px; }
  #view-cast .ct-head .h1 { font-size: var(--m-shen-fs, 11px); letter-spacing: 0; }
  #view-cast .ct-head .h2,
  #view-cast .ct-head .h3 {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    text-align: left;
    gap: 2px;
    font-size: calc(var(--m-chart-fs, 13.5px) + 1px);
    letter-spacing: .02em;
    min-width: 0;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #view-cast .ct-head .h3 { padding-left: 2px; }
  #view-cast .gh-name { font-size: inherit; }
  #view-cast .gh-gong { font-size: calc(var(--m-chart-fs, 13.5px) - 4px); letter-spacing: 0; }

  #view-cast .ct-row {
    min-height: 36px;
    padding: 4px 0;
  }
  #view-cast .ct-shen {
    font-size: var(--m-shen-fs, 11px) !important;
    letter-spacing: 0;
    line-height: 1.15;
  }
  #view-cast .ct-shen .qx {
    display: block;
    margin-top: 1px;
    font-size: 9.5px;
    line-height: 1.15;
  }

  /* 一行：六亲干支五行（左）→ 阴阳爻（右）→ 世应/动爻（紧贴爻旁） */
  #view-cast .ct-cell {
    display: flex;
    position: relative;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    flex-wrap: nowrap !important;
    padding: 0;
    min-width: 0;
    overflow: hidden;
  }
  #view-cast .ct-cell.bian { padding-left: 0; }
  #view-cast .ct-cell.bian .txt {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
  }
  #view-cast .chart-body.compact .ct-cell .txt {
    font-size: calc(var(--m-chart-fs, 13.5px) - 1.5px);
  }
  #view-cast .ct-cell .txt {
    display: block;
    flex: 0 0 auto;
    max-width: none;
    min-width: max-content;
    font-size: var(--m-chart-fs, 13.5px);
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #view-cast .ct-cell .yao-tail {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    flex: 0 0 auto;
    min-width: 0;
  }
  #view-cast .ct-cell .yao-tail .yao-graph {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  #view-cast .ct-cell .shi,
  #view-cast .ct-cell .ying,
  #view-cast .ct-cell .mark { margin-right: 2px; }
  #view-cast .ct-head,
  #view-cast .ct-row { column-gap: 0 !important; }
  #view-cast .ct-cell .txt > * { margin-right: 0; vertical-align: baseline; }
  #view-cast .ct-cell .txt .lq { margin-right: 1px; }
  #view-cast .ct-cell .txt .gz { margin-right: 1px; }
  .cb-actions { flex-wrap: wrap; }
  .cb-actions .btn { flex: 1 1 auto; }
  .cb-coin-progress { width: 100%; font-size: 10.5px; color: var(--ink-3); }
  .cast-body.coin-pane,
  .cast-body.auto-pane { min-height: 0; gap: 8px; }
  .cast-body.coin-pane .cb-tip { font-size: 11.5px; line-height: 1.6; }
  .cast-body.coin-pane .cb-actions { margin-top: 0; }
  .cast-body.coin-pane .coin-result { gap: 4px; min-height: 16px; }
  .cast-body.coin-pane .cb-coin-l { padding: 1px 5px; font-size: 11px; }
  #recNav,
  #recFolderNav,
  #recComboNav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
  }
  #recNav .btn:first-child,
  #recFolderNav .btn:first-child,
  #recComboNav .btn:first-child { justify-self: start; }
  #recNav .rec-nav-text,
  #recFolderNav .rec-nav-text,
  #recComboNav .rec-nav-text {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  #recNav .btn:last-child,
  #recFolderNav .btn:last-child,
  #recComboNav .btn:last-child { justify-self: end; }
  .rec-sn {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 9.5px;
    color: var(--ink-3, #78896c);
    border: 1px solid var(--line-2, #dbe7d1);
    border-radius: 4px;
    padding: 0 3px;
    margin-right: 4px;
  }
  #view-cast .ct-cell .txt .wx { margin-right: 2px; }
  #view-cast .ct-cell .txt .ny { font-size: 9px; color: var(--ink-3); margin-left: 1px; }
  /* 长生由梅花栏「长生」按钮开关 */
  #view-cast .ct-cell .txt .cs {
    display: inline-block;
    width: 2.8em;
    min-width: 2.8em;
    overflow: hidden;
    white-space: nowrap;
    text-align: center;
    font-size: 9px;
    color: var(--ink-3);
    margin-left: 0;
    cursor: pointer;
    border-bottom: 1px dotted var(--line-2, #aec29f);
  }
  #view-cast .ct-cell .yao-graph {
    order: 0 !important;
    flex: 0 0 auto;
    margin: 0 !important;
    gap: 2px;
    color: var(--ink);
  }
  #view-cast .yao-graph .bar { border-top-width: 6px; }
  #view-cast .yao-graph.yang .bar { width: 32px; }
  #view-cast .yao-graph.yin .bar { width: 15px; }
  #view-cast .ct-cell .shi,
  #view-cast .ct-cell .ying {
    flex: 0 0 auto;
    min-width: 1em;
    margin: 0 0 0 1px !important;
    text-align: center;
    font-size: calc(var(--m-chart-fs, 13.5px) - 3px);
    line-height: 1;
  }
  #view-cast .ct-cell .mark {
    flex: 0 0 auto;
    width: 1em;
    margin: 0 0 0 0 !important;
    text-align: center;
    font-size: calc(var(--m-chart-fs, 13.5px) - 2.5px);
    line-height: 1;
  }
  #view-cast .ct-cell .taiji { font-size: calc(var(--m-chart-fs, 13.5px) - 3px); }

  #view-cast .ct-extra {
    grid-column: 1 / -1;
    padding: 1px 0 0 32px;
    gap: 2px 6px;
    font-size: calc(var(--m-chart-fs, 13.5px) - 3px);
    line-height: 1.35;
  }
  #view-cast .ct-extra .fu > i,
  #view-cast .ct-extra .dfu > i {
    font-size: calc(var(--m-chart-fs, 13.5px) - 4.5px);
    padding: 0 2px;
    margin-right: 1px;
  }
  #view-cast .ct-extra .ny { display: none; }
  #view-cast .ct-extra .chip { font-size: calc(var(--m-chart-fs, 13.5px) - 4.5px); }
  #view-cast .ct-extra .fu .lq,
  #view-cast .ct-extra .dfu .lq,
  #view-cast .ct-extra .fu .gz,
  #view-cast .ct-extra .dfu .gz,
  #view-cast .ct-extra .fu .wx,
  #view-cast .ct-extra .dfu .wx { margin-right: 0; }
  #view-cast .ct-extra .gz i {
    font-style: normal;
    margin-right: 0;
    border: 0 !important;
    background: transparent !important;
    padding: 0;
  }

  body:not(.show-yao-states) #view-cast .yao-states,
  body:not(.show-yao-states) #view-cast .ct-extra .chips { display: none !important; }
  #view-cast .yao-states { gap: 2px 3px; margin-top: 1px; }
  #view-cast .yao-states .chip { font-size: 9px; line-height: 1.45; padding: 0 3px; }
  #view-cast .chart-note { padding: 10px 12px 12px; }

  /* ---------- 梅花栏 ---------- */
  #view-cast .meihua-bar {
    border-top: 1px solid var(--line, #cbdbc0);
    padding: 10px 10px 12px;
  }
  #view-cast .mh-head {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  #view-cast .mh-title {
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--ink-2, #3f3d38);
  }
  #view-cast .mh-actions {
    margin-left: 0;
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    row-gap: 4px;
    flex-wrap: nowrap;
  }
  #view-cast .mh-btn {
    font: inherit;
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    font-size: var(--m-mh-fs, 10px);
    letter-spacing: 0;
    line-height: 1.5;
    padding: 2px 2px;
    border: 1px solid var(--line-2, #aec29f);
    border-radius: 5px;
    background: transparent;
    color: var(--ink-2, #3f3d38);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  #view-cast .mh-btn.on {
    background: var(--ink, #16151a);
    color: var(--card, #f5f9f0);
    border-color: var(--ink, #16151a);
  }
  #view-cast .mh-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    margin-top: 9px;
    align-items: start;
  }
  #view-cast .mh-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
  }
  #view-cast .mh-hex {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    height: 34px;
    justify-content: center;
  }
  #view-cast .mh-line {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 1px;
    background: var(--ink, #16151a);
  }
  #view-cast .mh-line.yin {
    background: transparent;
    display: flex;
    justify-content: space-between;
  }
  #view-cast .mh-line.yin b {
    display: block;
    width: 17px;
    height: 4px;
    border-radius: 1px;
    background: var(--ink, #16151a);
  }
  #view-cast .mh-name {
    margin-top: 4px;
    max-width: 100%;
    font-family: var(--font-serif);
    font-size: 11px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #view-cast .pillar[data-cs-day],
  #view-cast .pillar[data-cs-month] { cursor: pointer; }
  #view-cast .pillar.cs-basis {
    outline: 2px solid var(--dm, #a92e1c);
    outline-offset: -2px;
  }
  #view-cast .ct-row.cs-base {
    background: var(--sel, #d5e4cb);
    box-shadow: inset 3px 0 var(--dm, #a92e1c);
  }

  /* ---------- 干支历 ---------- */
  /* ---------- 干支历弹窗 ---------- */
  #gcalModal .modal-card { width: 94vw; max-height: 88vh; }
  #gcalModal.gcal-size-s .modal-card { width: 82vw; max-height: 72vh; }
  #gcalModal.gcal-size-l .modal-card { width: 98vw; max-height: 94vh; }
  #gcalModal .modal-body {
    padding: 0 14px 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #gcalModal .gcal {
    position: static !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    touch-action: pan-y !important;
  }
  #gcalModal .gcal.expanded { padding: 0 !important; }
  #gcalModal .gcal-title,
  #gcalModal .gcal-head { gap: 6px; padding-bottom: 2px; }
  #gcalModal .gcal-sub { font-size: 11px; }
  .gcal-jie {
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--ink-3, #78896c);
    padding: 1px 0 4px;
  }
  .gcal-month-segs {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 0 5px;
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--ink-2, #3f3d38);
  }
  .gcal-month-segs .seg { white-space: nowrap; }
  .gcal-month-segs .seg b {
    font-weight: 600;
    color: var(--dm, #a92e1c);
    margin-left: 4px;
  }
  #gcalModal .gcal-nav { margin-top: 7px; }
  #gcalModal .gcal-nav input[type="date"] {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    font-size: 11.5px;
    padding: 3px 5px;
  }
  #gcalModal .gcal-nav .btn { font-size: 11px; padding: 3px 7px; }
  #gcalModal .gcal-week { margin-top: 7px; font-size: 10px; }
  #gcalModal .gcal-body { gap: 2px; }
  #gcalModal .gc-day { padding: 4px 1px 5px; }
  #gcalModal .gc-date { font-size: 9.5px; }
  #gcalModal .gc-gz { font-size: 10.5px; }
  #gcalModal .gcal-yingqi { margin-top: 8px; font-size: 11.5px; padding: 6px; }

  /* ---------- 卦历页 ---------- */
  #view-records.active { padding-top: 0; }
  .m-rec { display: flex !important; flex-direction: column; gap: 8px; }
  .m-rec .rec-side,
  .m-rec .rec-main,
  .m-rec .rec-toolbar {
    background: var(--card, #f5f9f0);
    border: 0;
    border-top: 1px solid var(--line, #cbdbc0);
    border-bottom: 1px solid var(--line, #cbdbc0);
    border-radius: 0;
    padding: 11px 14px;
    width: 100% !important;
    max-width: none !important;
    box-shadow: none;
  }
  .m-rec .rec-side {
    width: 100% !important;
    max-width: none !important;
    position: static;
    max-height: none;
    overflow: visible;
    text-align: left;
  }
  .m-rec .rec-toolbar { order: -1; display: flex !important; flex-wrap: wrap; gap: 7px; align-items: stretch; }
  .m-rec .rec-toolbar input[type="search"] { flex: 1 1 100%; min-width: 0; }
  .m-rec .rec-toolbar .btn { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
  .m-rec .rec-toolbar select { flex: 1.8 1 0; min-width: 0; font-size: 12px; }

  .rec-card {
    grid-template-columns: 3px 26px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 7px 10px 7px 0 !important;
    border-radius: 10px !important;
  }
  .rec-card .mini-hex { gap: 2px !important; }
  .rec-card .mini-hex i { height: 2.5px !important; }
  .rec-card .mini-hex i.yang { width: 24px !important; }
  .rec-card .mini-hex i.yin { width: 9px !important; }
  .rec-card .rec-side-meta { display: none !important; }
  .rec-card .rec-top { flex-wrap: nowrap !important; gap: 6px !important; }
  .rec-card .rec-gua { font-size: 14px !important; }
  .rec-card .rec-q,
  .rec-card .rec-note,
  .rec-card .rec-yq { font-size: 11.5px !important; margin-top: 2px !important; }
  .rec-card .vtag { font-size: 10px !important; }
  .rec-list { gap: 8px !important; }

  /* 卦历迷你卦象：阴爻两段，动爻红色 */
  .rec-card .mini-hex i { height: 2.5px !important; }
  .rec-card .mini-hex i.yang { width: 26px !important; background: var(--ink, #16151a); }
  .rec-card .mini-hex i.yin {
    width: 26px !important;
    display: flex !important;
    justify-content: space-between;
    background: transparent !important;
  }
  .rec-card .mini-hex i.yin b {
    display: block;
    width: 10px;
    height: 2.5px;
    border-radius: 1px;
    background: var(--ink, #16151a);
  }
  .rec-card .mini-hex i.yang.moving { background: var(--dm, #a92e1c) !important; }
  .rec-card .mini-hex i.moving b { background: var(--dm, #a92e1c) !important; }

  /* ---------- 工具页 ---------- */
  #view-tools.active { padding-top: 0; }
  .tools-grid {
    column-count: 1 !important;
    column-gap: 0;
    padding: 0;
  }
  .tool-card {
    border: 0;
    border-top: 1px solid var(--line, #cbdbc0);
    border-bottom: 1px solid var(--line, #cbdbc0);
    border-radius: 0;
    padding: 13px 14px 15px;
    margin-bottom: 8px;
    box-shadow: none;
  }
  .tool-card > header { gap: 7px; flex-wrap: wrap; }

  /* 纳音表 */
  #toolNayin .ny-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  #toolNayin .ny-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 6px 2px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 6px;
    background: transparent;
    color: var(--ink, #16151a);
    font: inherit;
    cursor: pointer;
  }
  #toolNayin .ny-item:active { background: var(--sel, #d5e4cb); }
  #toolNayin .ny-item b {
    font-family: var(--font-serif);
    font-size: 12.5px;
    letter-spacing: 0;
    line-height: 1.3;
    white-space: nowrap;
  }
  #toolNayin .ny-item span {
    font-size: 10px;
    color: var(--ink-3, #78896c);
    line-height: 1.3;
  }

  /* 十二长生工具 */
  .cs-mode-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 6px;
  }
  .cs-mode-btn {
    font: inherit;
    font-size: 11px;
    line-height: 1;
    padding: 4px 10px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 10px;
    background: transparent;
    color: var(--ink-2, #3f3d38);
  }
  .cs-mode-btn.on {
    background: var(--dm, #a92e1c);
    border-color: var(--dm, #a92e1c);
    color: #f7f1e5;
  }
  .cs-mode-basis {
    font-size: 10.5px;
    color: var(--ink-3, #78896c);
    margin-left: 2px;
  }
  .cs-wx {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
    margin: 2px 0 8px;
  }
  .cs-wx-btn {
    font: inherit;
    font-size: 12px;
    line-height: 1.4;
    padding: 3px 4px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 6px;
    background: transparent;
    color: var(--ink-2, #3f3d38);
    min-width: 0;
  }
  .cs-wx-btn.on {
    background: var(--ink, #16151a);
    border-color: var(--ink, #16151a);
    color: var(--card, #f5f9f0);
  }
  .cs-stage-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }
  .cs-stage {
    font: inherit;
    position: relative;
    text-align: center;
    padding: 6px 8px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 6px;
    background: transparent;
    color: var(--ink, #16151a);
    line-height: 1.4;
  }
  .cs-stage-edit {
    position: absolute;
    top: 4px;
    right: 6px;
    font-style: normal;
    font-size: 12px;
    line-height: 1;
    color: var(--ink-3, #78896c);
  }
  .cs-stage b { font-family: var(--font-serif); font-size: 13px; margin-right: 4px; }
  .cs-stage span { font-size: 10px; color: var(--ink-3, #78896c); }
  .cs-stage em {
    display: block;
    margin-top: 2px;
    font-size: 10.5px;
    font-style: normal;
    color: var(--ink-2, #3f3d38);
  }
  .cs-stage.on { border-color: var(--ink, #16151a); background: var(--sel, #d5e4cb); }
  .cs-tool-out {
    margin: 8px 0 0;
    font-size: 11px;
    line-height: 1.6;
    color: var(--ink-3, #78896c);
  }
  .ny-detail { text-align: center; padding: 6px 0 2px; }
  .ny-pair-top {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 16px;
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 600;
    letter-spacing: .08em;
  }
  .ny-pair-top .ny-gz { display: inline-block; }
  .ny-detail .ny-big {
    font-family: var(--font-serif);
    font-size: 34px;
    font-weight: 600;
    letter-spacing: .08em;
  }
  .ny-detail .ny-name {
    font-family: var(--font-serif);
    font-size: 20px;
    margin-top: 2px;
    letter-spacing: .06em;
  }
  .ny-detail .ny-meta {
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--ink-2, #3f3d38);
  }
  .ny-detail .ny-meaning {
    margin: 10px 4px 0;
    font-family: var(--font-serif);
    font-size: 13px;
    line-height: 1.8;
    text-align: left;
    color: var(--ink, #16151a);
  }
  .ny-detail .muted { margin-top: 10px; font-size: 11.5px; }

  /* 干支历被设置挪到工具页时，同样贴边 */
  .gcal-slot {
    margin: 0 0 8px;
    padding: 13px 14px 15px;
    border: 0;
    border-top: 1px solid var(--line, #cbdbc0);
    border-bottom: 1px solid var(--line, #cbdbc0);
    border-radius: 0;
    background: var(--card, #f5f9f0);
  }
  .gcal-slot .gcal { touch-action: pan-y; }

  /* ---------- 设置 / 弹窗 ---------- */
  body.tc-mode {
    font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  }

  .settings-pop .sp-group {
    border-top: 1px solid var(--line, #cbdbc0);
    padding: 1px 0;
  }
  .settings-pop .sp-group:first-child { border-top: 0; }
  .settings-pop .sp-group > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10.5px;
    letter-spacing: .16em;
    color: var(--ink-3, #78896c);
    padding: 7px 0 6px;
  }
  .settings-pop .sp-group > summary::-webkit-details-marker { display: none; }
  .settings-pop .sp-group > summary > span {
    font-size: 12.5px;
    letter-spacing: .04em;
    color: var(--ink, #16151a);
    flex: 0 0 auto;
  }
  .settings-pop .sp-group > summary > em {
    font-style: normal;
    font-size: 9.5px;
    letter-spacing: 0;
    color: var(--ink-3, #78896c);
    margin-left: auto;
    margin-right: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 58%;
  }
  .settings-pop .sp-group > summary::after { content: '▾'; font-size: 10px; opacity: .7; }
  .settings-pop .sp-group:not([open]) > summary::after { content: '▸'; }
  .settings-pop .sp-body {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 2px 0 7px;
  }
  .settings-pop .check-line {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 8px;
  }
  .settings-pop .check-line > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .settings-pop .check-line > input[type=checkbox] { flex: 0 0 auto; }
  .settings-pop .check-line select {
    margin-left: auto;
    max-width: 120px;
    font: inherit;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid var(--line, #cbdbc0);
    background: var(--card, #f5f9f0);
    color: var(--ink, #16151a);
  }
  .settings-pop .tool-prefs {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }
  .settings-pop .tool-pref {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .settings-pop .tool-pref .check-line { flex: 1; min-width: 0; }
  .settings-pop .tool-ord { display: flex; gap: 3px; flex: 0 0 auto; }
  .settings-pop .tool-ord-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 5px;
    background: transparent;
    color: var(--ink-2, #3f3d38);
    font: inherit;
    font-size: 13px;
    line-height: 1;
  }

  .modal-card { width: 94vw; max-height: 88vh; }
  .modal { z-index: 100 !important; }
  .modal-body { padding: 12px 14px; }
  .shot-choices { display: flex; gap: 8px; margin-bottom: 8px; }
  .shot-choices .btn { flex: 1 1 0; }
  .shot-choices .shot-range.on {
    background: var(--ink, #16151a);
    border-color: var(--ink, #16151a);
    color: var(--card, #f5f9f0);
  }
  .shot-actions { display: flex; gap: 7px; flex-wrap: wrap; }
  .shot-actions .btn { flex: 1 1 0; }
  .io-opts { display: flex; flex-direction: column; gap: 8px; }
  .io-opt {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 7px;
    background: transparent;
    color: var(--ink, #16151a);
    font: inherit;
  }
  .io-opt b { font-size: 13.5px; font-weight: 600; }
  .io-opt span { font-size: 11.5px; color: var(--ink-3, #78896c); }
  .io-opt:active { background: var(--hover, #eaf3e2); }

  .icon-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
    gap: 7px;
  }
  .icon-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px 5px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 8px;
    background: transparent;
    color: var(--ink, #16151a);
    font: inherit;
    font-size: 10.5px;
  }
  .icon-choice img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: block;
  }
  .icon-choice.on {
    border-color: var(--dm, #a92e1c);
    box-shadow: inset 0 0 0 1px var(--dm, #a92e1c);
    background: var(--hover, #eaf3e2);
  }
  .icon-tip { margin: 5px 0 0; font-size: 10px; }

  .manual-card {
    width: 94vw;
    max-height: 88vh;
  }
  .manual-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(88vh - 62px);
    padding: 10px 14px 18px;
  }
  .manual-sec { padding: 8px 0 10px; border-bottom: 1px solid var(--line-2, #dbe7d1); }
  .manual-sec:last-child { border-bottom: 0; }
  .manual-sec h3 {
    margin: 0 0 5px;
    font-size: 14px;
    color: var(--dm, #a92e1c);
    letter-spacing: .02em;
  }
  .manual-sec ul, .manual-sec ol { margin: 0; padding-left: 19px; }
  .manual-sec ol { list-style: decimal; }
  .manual-sec li {
    font-size: 12px;
    line-height: 1.7;
    margin: 2px 0;
    color: var(--ink, #16151a);
  }
  .manual-sec li b { font-weight: 600; }
  .manual-note {
    text-align: center;
    background: var(--hover, #eaf3e2);
    border-radius: 8px;
    margin-top: 12px;
    padding: 14px 10px;
  }
  .manual-note p {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 13.5px;
    line-height: 1.8;
    color: var(--ink, #16151a);
  }
  .manual-note .manual-sign {
    margin-top: 8px;
    font-size: 12px;
    color: var(--ink-3, #78896c);
  }
  .manual-mantra {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line, #cbdbc0);
  }
  .manual-mantra p { margin: 4px 0; }
  .manual-mantra .mantra-cn {
    font-size: 15px;
    letter-spacing: .08em;
    color: var(--dm, #a92e1c);
  }
  .manual-mantra .mantra-sa {
    font-family: "Noto Serif Devanagari", "Nirmala UI", serif;
    font-size: 22px;
    line-height: 1.8;
  }
  .manual-mantra .mantra-iast {
    font-size: 12px;
    color: var(--ink-3, #78896c);
    letter-spacing: .04em;
  }
  #csEditText {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    font: inherit;
    font-size: 13.5px;
    line-height: 1.7;
    padding: 8px 10px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 7px;
    background: var(--card, #f5f9f0);
    color: var(--ink, #16151a);
  }
  .cs-view-text {
    min-height: 120px;
    padding: 6px 2px;
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.9;
    text-align: center;
    color: var(--ink, #16151a);
    white-space: pre-wrap;
  }
  #csEditModal.cs-edit-zoom .modal-card {
    width: 98vw;
    max-height: 94vh;
  }
  #csEditModal.cs-edit-zoom .cs-view-text,
  #csEditModal.cs-edit-zoom #csEditText {
    font-size: 17px;
  }

  /* 灵感 */
  .insp-card .modal-body { display: flex; flex-direction: column; gap: 8px; }  #inspText {
    width: 100%;
    min-height: 104px;
    resize: vertical;
    font: inherit;
    font-size: 13.5px;
    line-height: 1.7;
    padding: 8px 10px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 7px;
    background: var(--card, #f5f9f0);
    color: var(--ink, #16151a);
  }
  .insp-actions { display: flex; gap: 7px; flex-wrap: wrap; }
  .insp-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: 34vh;
    overflow: auto;
    padding-top: 2px;
  }
  .insp-item {
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 7px;
    padding: 7px 9px;
    background: var(--card, #f5f9f0);
  }
  .insp-item p {
    margin: 0;
    white-space: pre-wrap;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--ink, #16151a);
  }
  .insp-item .insp-time {
    margin-top: 3px;
    font-size: 10px;
    color: var(--ink-3, #78896c);
  }
  .insp-item .insp-ops {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
  }
  .insp-item .insp-ops button {
    font: inherit;
    font-size: 11px;
    padding: 1px 6px;
    border: 1px solid var(--line, #cbdbc0);
    border-radius: 5px;
    background: transparent;
    color: var(--ink-2, #3f3d38);
  }
  .cast-tabs { gap: 6px; }
  .cast-tab { padding: 4px 10px; font-size: 12.5px; }
  .cb-line { grid-template-columns: 40px repeat(4, minmax(0, 1fr)) !important; gap: 4px; }
  .cb-opt { font-size: 11px; padding: 6px 2px; }
  .cb-tip { font-size: 11.5px; }

  .foot { display: none !important; }


/* 超窄屏（320 一类）再收一档，保证变卦文字不被截断 */
@media (max-width: 345px) {
  #view-cast .ct-cell .txt {
    font-size: min(var(--m-chart-fs, 13.5px), 17px);
    max-width: calc(100% - 48px);
  }
  #view-cast .ct-cell .txt .lq,
  #view-cast .ct-cell .txt .gz { font-size: inherit !important; }
  #view-cast .ct-cell .txt .ny { font-size: 8.5px; }
  #view-cast .yao-graph.yang .bar { width: 30px; }
  #view-cast .yao-graph.yin .bar { width: 13.5px; }
  #view-cast .ct-cell .shi,
  #view-cast .ct-cell .ying { min-width: 10px; font-size: 10px; }
  #view-cast .ct-cell .mark { width: 10px; font-size: 10px; }
}

/* 切换页面的轻微滑动反馈 */
@keyframes m-view-in-left {
  from { opacity: .35; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes m-view-in-right {
  from { opacity: .35; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}
.view.m-in-left { animation: m-view-in-left .18s ease-out both; }
.view.m-in-right { animation: m-view-in-right .18s ease-out both; }
.m-card .field-row.meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  align-items: start;
}
.m-card .field-row.meta-row > .field { min-width: 0; }


/* 系列（链条）分组：手机端也要能点开收起、能改名 */
.rec-group { margin: 6px 0 12px; border: 1px dashed #cbd9bf; border-radius: 10px; padding: 8px 8px 10px; }
.rec-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rg-toggle { display: flex; align-items: baseline; gap: 6px; flex: 1 1 auto; min-width: 0;
  background: none; border: 0; padding: 2px 0; text-align: left; font: inherit; font-size: 12.5px; color: #6b7a60; }
.rg-chev { font-size: 11px; }
.rg-count { font-family: var(--font-serif); color: #3f3d38; }
.rg-title { font-style: normal; color: #3f3d38; font-family: var(--font-serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rg-tag { font-style: normal; font-size: 11px; color: #a92e1c; border: 1px solid currentColor; border-radius: 5px; padding: 0 4px; }
.rg-rename { flex: none; background: none; border: 1px solid #aec29f; border-radius: 6px; padding: 0 7px; font-size: 11.5px; color: #6b7a60; }
.rec-group.collapsed { padding-bottom: 8px; }

.sameq-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 2px 6px; border-top: 1px dashed #cbd9bf; }
.sq-toggle { display: flex; align-items: baseline; gap: 6px; flex: 1 1 auto; min-width: 0;
  background: none; border: 0; padding: 0; text-align: left; font-family: var(--font-serif); font-size: 13px; color: #3f3d38; }
.sq-count { letter-spacing: .04em; }
.sq-title { font-style: normal; font-size: 12px; color: #6b7a60; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* 安卓版专属：触摸目标放大、隐藏打印后的排布 */
html.on-android .rg-toggle,
html.on-android .sq-toggle {
  min-height: 44px;
  padding: 6px 2px;
  font-size: 14px;
}
html.on-android .rg-rename {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}
html.on-android .rec-group-head { gap: 10px; }
html.on-android .rg-chev, html.on-android .sq-chev { font-size: 14px; }
html.on-android .rg-title, html.on-android .sq-title { font-size: 14px; }
html.on-android .rg-count, html.on-android .sq-count { font-size: 14px; }
html.on-android .sameq-title .btn {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13.5px;
}
html.on-android .rec-group { padding: 10px 10px 12px; }
html.on-android .sameq-title { padding: 10px 2px 8px; }
/* 安卓没有打印，顶栏留白收一下 */
html.on-android .topbar { gap: 6px; }


/* 2.7.4 安卓专属：弹层放大（桌面/轻量版不受影响，靠 html.on-android 限定） */
/* ---------- 安卓：弹层按「分类」菜单的观感 ---------- */
html.on-android .pick-pop {
  border-radius: 14px;
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, .55);
}
html.on-android .pick-list { padding: 8px; }
html.on-android .pick-opt {
  font-size: 17px;
  line-height: 1.4;
  padding: 14px 16px;
  min-height: 54px;
  border-radius: 10px;
}
html.on-android .pick-opt + .pick-opt { margin-top: 2px; }
html.on-android .pick-opt.on { font-weight: 600; }
html.on-android .pick-foot { padding: 8px 10px; }
html.on-android .pick-foot .btn { min-height: 40px; font-size: 15px; }

/* 安卓上四柱按钮也放大一点，跟弹层呼应 */
html.on-android .gz-pick {
  font-size: 16px;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 10px;
}
