/* 对话内教学盘：用宿主主题变量，带兜底；所有选择器以 .ttc 为前缀，避免污染 */
.ttc { --ttc-line: var(--color-border, rgba(128,128,128,.35)); --ttc-text: var(--color-text, #222); --ttc-muted: var(--color-text-muted, #888); --ttc-accent: var(--color-accent, #b8860b);
  --ttc-lu: #3a9d6a; --ttc-quan: #3b82c4; --ttc-ke: #8b5cf6; --ttc-ji: #d9534f; --ttc-geo: #8a8a8a;
  box-sizing: border-box; width: 100%; max-width: 460px; margin: 10px 0; color: var(--ttc-text); font-size: 12px; line-height: 1.4; }
.ttc *, .ttc *::before, .ttc *::after { box-sizing: border-box; }
.ttc-gridwrap { position: relative; padding: 11px; }
.ttc-grid { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, minmax(104px, auto)); border: 1px solid var(--ttc-line); border-radius: 4px; }
.ttc-cell { position: relative; z-index: 2; min-width: 0; padding: 0; border: 1px solid var(--ttc-line); margin: -.5px; display: flex; flex-direction: column; justify-content: space-between; gap: 0; }
.ttc-cell.is-off { background: transparent; }
.ttc-cell.is-on { background: color-mix(in srgb, var(--ttc-accent) 5%, transparent); }
.ttc-cell.role-source { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ttc-quan) 55%, transparent); }
.ttc-cell.role-target { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ttc-ji) 45%, transparent); }
.ttc-cell.role-focus { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ttc-accent) 55%, transparent); }
/* 宫内布局与工作台紫微盘一致（.sihua-palace）：上面星曜竖排，下面一行 [天干/地支 | 大限宫名/年龄 | 本命宫名竖排] */
.ttc-top { align-self: stretch; display: flex; flex-direction: column; gap: 2px; min-height: 0; padding: 5px 2px 1px; }
.ttc-starrow { display: flex; flex-wrap: wrap; align-content: flex-start; align-items: flex-start; gap: 1px 1px; min-width: 0; }
.ttc-star { display: inline-flex; width: 14px; min-width: 14px; flex: 0 0 14px; align-items: center; justify-content: flex-start; gap: 0; font-size: 12.5px; font-weight: 600; line-height: 1; text-align: center; text-orientation: upright; writing-mode: vertical-rl; color: var(--sihua-adjective, #716d64); }
.ttc-star.ttc-k-major { color: var(--sihua-major, #b24b43); }
.ttc-star.ttc-k-soft { color: var(--sihua-soft, #356f96); }
.ttc-star.ttc-k-tough { color: var(--sihua-tough, #4d4b45); }
.ttc-star-name { font-weight: 650; line-height: 1; text-align: center; }
.ttc-bright { display: inline-block; margin-block-start: 1px; color: var(--ttc-muted); font-size: 8.5px; font-style: normal; font-weight: 600; line-height: 1; }
.ttc-star .ttc-box { writing-mode: horizontal-tb; width: 12px; height: 12px; margin-block-start: 2px; font-size: 9px; border-radius: 2px; }
.ttc-star .ttc-sex { writing-mode: horizontal-tb; margin: 2px 0 0; font-size: 10px; }
.ttc-flow { color: var(--ttc-muted); font-size: 9.5px; line-height: 1.2; white-space: nowrap; }
.ttc-foot { align-self: stretch; width: 100%; display: grid; grid-template-columns: 16px minmax(0, 1fr) 17px; height: 36px; flex: none; margin-top: auto; border-top: 1.2px solid var(--ttc-line); color: var(--ttc-text); }
.ttc-branch { display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1.2px solid var(--ttc-line); font-size: 13px; line-height: 1.15; }
.ttc-decade { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); min-width: 0; border-right: 1.2px solid var(--ttc-line); }
.ttc-dname, .ttc-decade i { display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; font-style: normal; line-height: 1; white-space: nowrap; }
.ttc-dname { color: var(--sihua-stem, #47755a); border-bottom: 1.2px solid var(--ttc-line); font-size: 12px; font-weight: 600; }
.ttc-decade i { font-size: 11px; }
.ttc-pname { display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; line-height: 1; writing-mode: vertical-rl; }
.ttc-cell.is-off .ttc-foot { opacity: .42; }
.ttc-mut { display: inline-block; padding: 0 3px; border-radius: 3px; font-size: 10px; color: #fff; }
.ttc-box { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 3px; font-size: 10.5px; font-weight: 700; color: #fff; line-height: 1; }
.ttc-mut-lu { background: var(--ttc-lu); } .ttc-mut-quan { background: var(--ttc-quan); } .ttc-mut-ke { background: var(--ttc-ke); } .ttc-mut-ji { background: var(--ttc-ji); }
.ttc-self { margin-top: 3px; font-size: 10.5px; color: #fff; padding: 0 4px; border-radius: 3px; width: fit-content; }
.ttc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.ttc-head strong { font-size: 13.5px; } .ttc-head span { color: var(--ttc-muted); font-size: 11px; }
.ttc-lines { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; overflow: visible; }
.ttc-line { stroke-width: 2; fill: none; stroke-linecap: round; stroke-dasharray: 6 4; }
.ttc-line-lu { stroke: var(--ttc-lu); } .ttc-line-quan { stroke: var(--ttc-quan); } .ttc-line-ke { stroke: var(--ttc-ke); } .ttc-line-ji { stroke: var(--ttc-ji); }
.ttc-line-geo { stroke: var(--ttc-geo); stroke-dasharray: 3 3; }
.ttc-arrow-head.ttc-line-lu { fill: var(--ttc-lu); stroke: none; } .ttc-arrow-head.ttc-line-quan { fill: var(--ttc-quan); stroke: none; }
.ttc-arrow-head.ttc-line-ke { fill: var(--ttc-ke); stroke: none; } .ttc-arrow-head.ttc-line-ji { fill: var(--ttc-ji); stroke: none; }
.ttc-arrow-head.ttc-line-geo { fill: var(--ttc-geo); stroke: none; }
.ttc-badge, .ttc-num { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; color: #fff; font-size: 10.5px; font-weight: 600; flex: none; }
.ttc-badge { position: absolute; z-index: 4; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--color-bg, #fff); }
.ttc-badge-lu { background: var(--ttc-lu); } .ttc-badge-quan { background: var(--ttc-quan); } .ttc-badge-ke { background: var(--ttc-ke); } .ttc-badge-ji { background: var(--ttc-ji); } .ttc-badge-geo { background: var(--ttc-geo); }
.ttc ol.ttc-routes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.ttc ol.ttc-routes li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.ttc ol.ttc-routes li::marker { content: ''; }
.ttc p { margin: 0; }
.ttc-routes li.is-bad .ttc-route-text { text-decoration: line-through; color: var(--ttc-muted); }
.ttc-reason { color: var(--ttc-ji); font-style: normal; font-size: 11px; }
.ttc-note, .ttc-notice { margin: 6px 0 0; color: var(--ttc-muted); font-size: 11.5px; }
.ttc-full { margin-top: 8px; padding: 3px 10px; border: 1px solid var(--ttc-line); border-radius: 12px; background: transparent; color: var(--ttc-accent); cursor: pointer; font-size: 12px; }
.ttc-full:hover { background: color-mix(in srgb, var(--ttc-accent) 10%, transparent); }
@media (max-width: 420px) { .ttc-grid { grid-template-rows: repeat(4, minmax(68px, auto)); } .ttc { font-size: 11px; } }

/* ───── 八字教学盘 ───── */
.ttc-bazi { --ttb-pos: #3a9d6a; --ttb-clash: #d9534f; --ttb-punish: #e08a2e; --ttb-harm: #9a6bd0; --ttb-break: #8a8a8a; --ttb-gen: #2f8fc4; --ttb-ctl: #c0563a; max-width: 420px; }
.ttb-cols { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--ttc-line); border-radius: 8px; overflow: hidden; }
.ttb-col { min-height: 168px; padding: 6px 4px; text-align: center; border-left: 1px solid var(--ttc-line); }
/* 版式同工作台四柱表：最左一列是行名（主星/天干/地支/藏干），流年、大运在最左，其后是年月日时；每柱占 5 行并继承父网格的行，同一行跨柱同高。无 subgrid 的旧浏览器退回堆叠 */
.ttc-bazi { --ttb-label-w: 0px; }
.ttc-bazi.ttb-rl { --ttb-label-w: 30px; }
.ttb-rl .ttb-arcs { margin-left: var(--ttb-label-w); width: calc(100% - var(--ttb-label-w)); }
.ttb-rowlabels { padding: 6px 0; color: var(--ttc-muted); font-size: 11px; background: color-mix(in srgb, var(--ttc-muted) 6%, transparent); border-left: 0 !important; }
.ttb-rl-cell { display: flex; align-items: center; justify-content: center; min-height: 0; line-height: 1.2; }
.ttb-rl-cell:last-child { align-items: flex-start; padding-top: 11px; }
.ttb-title { color: var(--ttc-muted); font-size: 11px; line-height: 1.3; }
@supports (grid-template-rows: subgrid) {
  .ttb-cols { grid-template-rows: auto; min-height: 168px; }
  .ttb-col, .ttb-spare { min-height: 0; display: grid; grid-row: span 6; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
  .ttb-col > * { min-height: 0; align-self: center; }
  .ttb-col > .ttb-hidden { align-self: start; }
  .ttb-col > .ttb-note { align-self: start; padding-bottom: 4px; }
  .ttb-col > .ttb-note:empty { padding: 0; }
  .ttb-layer:empty, .ttb-meaning:empty { margin: 0; }
}
.ttb-col:first-child { border-left: 0; }
.ttb-col.is-on { background: color-mix(in srgb, var(--ttc-accent) 5%, transparent); }
.ttb-col.role-source { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ttb-pos) 55%, transparent); }
.ttb-col.role-target { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ttc-quan) 55%, transparent); }
.ttb-col.role-unverified { outline: 1px dashed color-mix(in srgb, var(--ttb-clash) 55%, transparent); outline-offset: -2px; }
.ttb-col.role-focus { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ttc-accent) 55%, transparent); }
.ttb-label { color: var(--ttc-muted); font-size: 11px; }
.ttb-god { margin: 2px 0 4px; font-size: 11px; color: var(--ttc-muted); }
.ttb-gz { font-size: 24px; font-weight: 600; line-height: 1.25; }
.ttb-wx-wood { color: #4caf68; } .ttb-wx-fire { color: #e2574c; } .ttb-wx-earth { color: #b8893b; } .ttb-wx-metal { color: #b9b9b9; } .ttb-wx-water { color: #4a90d9; }
.ttb-hidden { margin-top: 6px; padding-top: 5px; border-top: 1px dashed var(--ttc-line); display: grid; gap: 1px; }
.ttb-hid-row { display: flex; justify-content: center; gap: 4px; font-size: 12px; }
.ttb-hid-god { color: var(--ttc-muted); font-size: 10.5px; }
.ttb-arcs { position: relative; width: 100%; }
.ttb-svg { display: block; overflow: visible; }
.ttb-line { stroke-width: 1.5; fill: none; }
.ttb-pos { stroke: var(--ttb-pos); } .ttb-clash { stroke: var(--ttb-clash); } .ttb-punish { stroke: var(--ttb-punish); } .ttb-harm { stroke: var(--ttb-harm); } .ttb-break { stroke: var(--ttb-break); } .ttb-gen { stroke: var(--ttb-gen); } .ttb-ctl { stroke: var(--ttb-ctl); }
.ttb-badge { position: absolute; transform: translate(-50%, -50%); padding: 0 6px; height: 17px; display: inline-flex; align-items: center; border-radius: 9px; color: #fff; font-size: 10.5px; white-space: nowrap; }
.ttb-b-pos { background: var(--ttb-pos); } .ttb-b-clash { background: var(--ttb-clash); } .ttb-b-punish { background: var(--ttb-punish); } .ttb-b-harm { background: var(--ttb-harm); } .ttb-b-break { background: var(--ttb-break); } .ttb-b-gen { background: var(--ttb-gen); } .ttb-b-ctl { background: var(--ttb-ctl); }

/* ───── 绘制动画：线条依次画出、徽标淡入；尊重"减少动态效果" ───── */
@keyframes ttc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ttc-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ttc-pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.ttc .ttb-badge { opacity: 0; animation: ttc-pop .3s ease forwards; animation-delay: calc(var(--ttc-i, 0) * .25s + .45s); }
.ttc-bazi .ttb-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ttc-draw .55s ease forwards; animation-delay: calc(var(--ttc-i, 0) * .25s + .1s); }
@media (prefers-reduced-motion: reduce) { .ttc .ttc-route, .ttc .ttc-badge, .ttc .ttb-badge, .ttc-bazi .ttb-line { animation: none; opacity: 1; stroke-dashoffset: 0; } }

/* ───── 工具联动：运行中指示 ───── */
@keyframes ttc-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.ttc-notice.ttc-live { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0; padding: 2px 10px; border: 1px solid var(--color-border, rgba(128,128,128,.35)); border-radius: 12px; color: var(--color-accent, #b8860b); animation: ttc-pulse 1.2s ease-in-out infinite; }
.ttc-notice.ttc-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: reduce) { .ttc-notice.ttc-live { animation: none; } }
.ttc-figs { margin: 6px 0; }

/* 一步一图：标签、生年/自化层次、虚实、男女星、应期、说明 */
.ttc-tags { display: flex; gap: 3px; margin-bottom: 2px; }
.ttc-tag { font-size: 10px; padding: 0 4px; border-radius: 3px; color: #fff; background: #c0603f; }
.ttc-tag-laiyin { background: #5a7a99; }
.ttc-sex { font-size: 11px; font-weight: 700; margin-left: 2px; }
.ttc-sex-m { color: #3a74b8; }
.ttc-sex-f { color: #c24c7a; }
.ttc-zi { margin-top: 3px; font-size: 10px; color: #fff; padding: 0 4px; border-radius: 3px; width: fit-content; }
.ttc-zi-in { opacity: .75; }
.ttc-route.is-void .ttc-line { opacity: .35; stroke-dasharray: 3 3; }
.ttc-route.is-chong .ttc-line { stroke-dasharray: 2 3; }
.ttc-solid { font-size: 10.5px; padding: 0 5px; border-radius: 3px; }
.ttc-solid.is-solid { color: #2f7d4f; background: rgba(47,125,79,.12); }
.ttc-solid.is-void { color: var(--ttc-muted); background: rgba(128,128,128,.12); }
.ttc-axis { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.ttc-axis-label { font-size: 11px; color: var(--ttc-muted); }
.ttc-year { border: 1px solid #d8d2c8; background: transparent; color: inherit; border-radius: 12px; padding: 1px 9px; font-size: 11.5px; cursor: default; }
.ttc-year.is-main { border-color: #c0603f; color: #c0603f; }
.ttc-year.is-sub { border-color: #b08a3a; color: #8a6a22; }
.ttc-year.is-none { opacity: .6; }
.ttc-year.is-active { background: rgba(192,96,63,.14); }
.ttc-cell.is-yr { outline: 2px solid #c0603f; }
.ttc-yr { margin-top: 3px; font-size: 10.5px; font-weight: 700; color: #c0603f; }
.ttc-caption { margin: 8px 0 0; font-size: 12.5px; border-left: 3px solid #c0603f; padding-left: 8px; }

.ttb-layer { font-size: 10px; color: var(--ttc-muted); margin-bottom: 2px; }
.ttb-col.role-layer { background: rgba(192,96,63,.06); }
.ttc-axis-detail { margin-top: 4px; font-size: 11.5px; }
.ttc-axis-title { font-weight: 700; margin-bottom: 2px; }
.ttc-axis-hit.is-hot { color: #c0603f; }

/* 盲派做功图：体/用标记、做功弧（粗色，和刑冲弧区分） */
.ttz-tag { font-size: 10px; margin-left: 2px; padding: 0 3px; border-radius: 3px; color: #fff; vertical-align: super; }
.ttz-body { background: #4a7c59; }
.ttz-use { background: #a8603a; }
.ttb-line.ttb-zg { stroke: #7a4fb0; stroke-width: 3; }
.ttb-b-zg { background: #7a4fb0; color: #fff; }
.ttz-neutral { color: var(--ttc-muted); background: rgba(128,128,128,.12); }

.ttb-meaning { font-size: 10px; color: var(--ttc-muted); line-height: 1.25; margin-bottom: 2px; }
.ttb-strength { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: 12px; }
.ttb-st-label { font-weight: 700; }
.ttb-st-item { margin-right: 6px; }
.ttb-spare { min-height: 60px; }

/* 窄栏（右侧面板打开、手机）下收紧：字号与内边距缩小，名称允许换行 */
@media (max-width: 520px) {
  .ttc-name { font-size: 11px; word-break: break-all; }
  .ttc-zi, .ttc-tag { font-size: 10px; }
  .ttb-col { padding: 4px 2px; }
  .ttb-meaning, .ttb-layer { font-size: 9px; }
  .ttc-year { padding: 1px 6px; font-size: 11px; }
}

/* ── 无关宫位淡显宫名（看得出方位，不放星曜）── */
/* 飞宫标签：药丸形、不换行（'破军权' 这类三字标签原先挤成竖排） */
.ttc-grid > .ttc-badge { width: auto; min-width: 17px; height: 18px; padding: 0 6px; border-radius: 9px; white-space: nowrap; box-shadow: 0 0 0 2px var(--color-bg, #fff); }

/* ── 参照 App 三合盘的版式 ── */
.ttc-grid > .ttc-mid { grid-row: 2 / 4; grid-column: 2 / 4; z-index: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; padding: 6px; text-align: center; font-size: 11px; color: var(--ttc-muted); }
.ttc-mid-name { font-size: 14px; color: var(--ttc-text); }
.ttc-mid-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.ttc-mid-row b { font-weight: 500; color: var(--ttc-text); }
.ttc-zarrow { position: absolute; z-index: 6; width: 22px; height: 12px; display: block; pointer-events: auto; }
.ttc-zarrow svg { display: block; overflow: visible; }
.ttc-zshaft { fill: none; stroke-width: 3; stroke-linecap: round; }
.ttc-zhead { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ttc-zarrow-lu .ttc-zshaft, .ttc-zarrow-lu .ttc-zhead { stroke: var(--ttc-lu); }
.ttc-zarrow-quan .ttc-zshaft, .ttc-zarrow-quan .ttc-zhead { stroke: var(--ttc-quan); }
.ttc-zarrow-ke .ttc-zshaft, .ttc-zarrow-ke .ttc-zhead { stroke: var(--ttc-ke); }
.ttc-zarrow-ji .ttc-zshaft, .ttc-zarrow-ji .ttc-zhead { stroke: var(--ttc-ji); }

/* 窄屏：宫格只留干支与职名，层次小字与中宫信息收小，免得挤成竖排 */
@media (max-width: 420px) {
  .ttc-star { font-size: 12px; }
  .ttc-grid > .ttc-mid { font-size: 10px; gap: 2px; padding: 4px; }
  .ttc-mid-name { font-size: 12.5px; }
  .ttc-gridwrap { padding: 10px; }
}

/* 流年踩中：直接标在盘上（实心＝踩落点宫，空心＝踩发射宫或落点宫的对宫） */
.ttc-cell.is-hit { box-shadow: inset 0 0 0 2px #c0603f; }
.ttc-hits { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.ttc-hit { font-size: 10px; line-height: 1.5; padding: 0 5px; border-radius: 9px; white-space: nowrap; font-weight: 600; }
.ttc-hit.is-main { background: #c0603f; color: #fff; }
.ttc-hit.is-sub { border: 1px solid #c0603f; color: #c0603f; background: transparent; }

/* ── 循环小动画（loop-ziwei.js 在图进入屏幕时加 .ttc-loop；不播时就是静态图）── */
.ttc-loop .ttc-line { --p: 10; animation: ttc-flow 1.2s linear infinite; animation-delay: calc(var(--ttc-i, 0) * -.35s); }
.ttc-loop .ttc-line-geo, .ttc-loop .ttc-route.is-void .ttc-line, .ttc-loop .ttc-route.is-chong .ttc-line { --p: 6; }
@keyframes ttc-flow { to { stroke-dashoffset: calc(var(--p) * -1px); } }
.ttc-loop .ttc-cell.role-target[style*="--ttc-pi"] { animation: ttc-land 2.4s ease-in-out infinite; animation-delay: calc(var(--ttc-pi, 0) * .45s); }
@keyframes ttc-land { 0%, 100% { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ttc-ji) 40%, transparent); } 35% { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ttc-ji) 80%, transparent); } }
.ttc-hit, .ttc-year, .ttc-cell.is-hit { transition: opacity .35s, box-shadow .35s, background-color .35s; }
.ttc-cycling .ttc-hit:not(.is-cur), .ttc-cycling .ttc-year:not(.is-cur) { opacity: .22; }
.ttc-cycling .ttc-cell.is-hit:not(.is-curcell) { box-shadow: none; }
.ttc-cycling .ttc-year.is-cur { background: rgba(192,96,63,.16); }
@media (prefers-reduced-motion: reduce) { .ttc-loop .ttc-line, .ttc-loop .ttc-cell.role-target { animation: none; } }
