:root {
    color-scheme: only light;
    --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "Kaiti SC", "SimSun", Georgia, serif;
    --page-bg: #f4efe4;
    --page-glow-top: rgba(185, 134, 46, 0.14);
    --page-glow-side: rgba(158, 42, 34, 0.06);
    --compass-color: rgba(138, 102, 42, 0.085);
    --card-bg: rgba(255, 252, 244, 0.9);
    --card-border: rgba(138, 108, 66, 0.22);
    --card-inner-ring: rgba(176, 134, 62, 0.14);
    --subtle-bg: rgba(134, 102, 54, 0.065);
    --stage-bg: rgba(118, 86, 40, 0.055);
    --input-bg: rgba(255, 255, 255, 0.92);
    --input-border: rgba(138, 108, 66, 0.28);
    --text-primary: #1c1814;
    --text-secondary: #594f42;
    --text-muted: #847868;
    --accent: #9e2a22;
    --accent-hover: #811f18;
    --accent-soft: rgba(158, 42, 34, 0.095);
    --accent-glow: rgba(158, 42, 34, 0.28);
    --gold: #9a6b1e;
    --gold-soft: rgba(154, 107, 30, 0.12);
    --gold-border: rgba(154, 107, 30, 0.34);
    --jade: #1c6b4b;
    --jade-soft: rgba(28, 107, 75, 0.11);
    --jade-border: rgba(28, 107, 75, 0.32);
    --bar-color: #27211a;
    --moving: #9e2a22;
    --moving-soft: rgba(158, 42, 34, 0.095);
    --moving-border: rgba(158, 42, 34, 0.3);
    --danger: #9e2a22;
    --danger-soft: rgba(158, 42, 34, 0.1);
    --danger-border: rgba(158, 42, 34, 0.36);
    --bar-moving: var(--moving);
    --bar-transformed: #1c6b4b;
    --yarrow-stalk: #8c6526;
    --yarrow-rem: #9e2a22;
    --shadow: 0 18px 44px rgba(46, 33, 14, 0.09), 0 2px 8px rgba(46, 33, 14, 0.04);
    --shadow-elevated: 0 22px 52px rgba(46, 33, 14, 0.14);
}

html.dark,
body.dark-mode {
    color-scheme: dark;
    --page-bg: #0b0e14;
    --page-glow-top: rgba(216, 164, 72, 0.12);
    --page-glow-side: rgba(227, 100, 85, 0.06);
    --compass-color: rgba(216, 164, 72, 0.075);
    --card-bg: rgba(18, 23, 33, 0.9);
    --card-border: rgba(216, 164, 72, 0.2);
    --card-inner-ring: rgba(216, 164, 72, 0.1);
    --subtle-bg: rgba(255, 245, 224, 0.04);
    --stage-bg: rgba(8, 11, 17, 0.56);
    --input-bg: rgba(11, 15, 23, 0.78);
    --input-border: rgba(216, 164, 72, 0.24);
    --text-primary: #f0eadf;
    --text-secondary: #b5ab99;
    --text-muted: #82796c;
    --accent: #d8a448;
    --accent-hover: #e7b963;
    --accent-soft: rgba(216, 164, 72, 0.14);
    --accent-glow: rgba(216, 164, 72, 0.3);
    --gold: #e6b85c;
    --gold-soft: rgba(230, 184, 92, 0.13);
    --gold-border: rgba(230, 184, 92, 0.34);
    --jade: #46c795;
    --jade-soft: rgba(70, 199, 149, 0.13);
    --jade-border: rgba(70, 199, 149, 0.32);
    --bar-color: #e6dfd2;
    --moving: #e36455;
    --moving-soft: rgba(227, 100, 85, 0.14);
    --moving-border: rgba(227, 100, 85, 0.36);
    --danger: #f07466;
    --danger-soft: rgba(240, 116, 102, 0.14);
    --danger-border: rgba(240, 116, 102, 0.38);
    --bar-moving: var(--moving);
    --bar-transformed: #46c795;
    --yarrow-stalk: #c99c4a;
    --yarrow-rem: #e36455;
    --shadow: 0 20px 52px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-elevated: 0 26px 60px rgba(0, 0, 0, 0.62);
}

* {
    box-sizing: border-box;
}

body {
    position: relative;
    margin: 0;
    min-height: 100vh;
    overflow-x: clip;
    background-color: var(--page-bg);
    background-image:
        radial-gradient(ellipse 85% 48% at 50% -10%, var(--page-glow-top), transparent 72%),
        radial-gradient(ellipse 55% 40% at 88% 18%, var(--page-glow-side), transparent 70%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button,
a,
summary,
.hex-bar-row {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.label-short {
    display: none;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

.sacred-backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.sacred-compass {
    width: min(860px, 130vw);
    height: auto;
    margin-top: -210px;
    color: var(--compass-color);
    animation: compassDrift 120s linear infinite;
}

@keyframes compassDrift {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(980px, calc(100% - 28px));
    margin: 0 auto;
    padding: 26px 0 calc(60px + env(safe-area-inset-bottom, 0px));
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--card-bg);
    border: 1px solid var(--gold-border);
    color: var(--accent);
    box-shadow: var(--shadow), inset 0 0 0 3px var(--card-inner-ring);
    flex-shrink: 0;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.brand-title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: clamp(1.32rem, 3.2vw, 1.75rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    line-height: 1.2;
}

.brand-subtitle {
    margin: 4px 0 0;
    font-size: 0.84rem;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.86rem;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

.icon-btn:hover {
    border-color: var(--gold);
    color: var(--accent);
}

.icon-btn.icon-only {
    padding: 0;
    width: 38px;
}

.icon-btn.is-active {
    border-color: var(--gold);
    background: var(--gold-soft);
    color: var(--gold);
}

#theme-icon-sun {
    display: none;
}

#theme-icon-moon {
    display: block;
}

html.dark #theme-icon-sun,
body.dark-mode #theme-icon-sun {
    display: block;
}

html.dark #theme-icon-moon,
body.dark-mode #theme-icon-moon {
    display: none;
}

.panel-card {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.panel-ornate {
    box-shadow: var(--shadow), inset 0 0 0 1px var(--card-inner-ring);
}

.panel-ornate::before,
.panel-ornate::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    pointer-events: none;
    border-color: var(--gold-border);
    border-style: solid;
}

.panel-ornate::before {
    top: 8px;
    left: 8px;
    border-width: 1.5px 0 0 1.5px;
    border-top-left-radius: 5px;
}

.panel-ornate::after {
    bottom: 8px;
    right: 8px;
    border-width: 0 1.5px 1.5px 0;
    border-bottom-right-radius: 5px;
}

.load-error-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    border-radius: 10px;
    background: var(--danger-soft);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    font-size: 0.88rem;
    font-weight: 600;
}

.load-error-banner.is-hidden {
    display: none;
}

.question-row {
    margin-bottom: 16px;
}

.question-label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.question-input-wrap {
    position: relative;
}

.question-input {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 14px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.question-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.question-clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    display: grid;
    place-items: center;
    transition: color 0.16s ease, background-color 0.16s ease;
}

.question-clear-btn:hover {
    color: var(--text-primary);
    background: var(--subtle-bg);
}

.question-clear-btn.is-hidden {
    display: none;
}

.controls-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.mode-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: 11px;
    background: var(--subtle-bg);
    border: 1px solid var(--card-border);
}

.mode-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.mode-tab:hover {
    color: var(--text-primary);
}

.mode-tab.active {
    background: var(--card-bg);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.entropy-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--jade-soft);
    border: 1px solid var(--jade-border);
    color: var(--jade);
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.entropy-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: pulseDot 2.4s infinite ease-in-out;
}

@keyframes pulseDot {
    0%, 100% { opacity: 0.55; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1.16); }
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.16s ease, box-shadow 0.18s ease;
}

.compact-btn {
    min-height: 32px;
    padding: 0 12px;
    font-size: 0.8rem;
    border-radius: 8px;
}

.primary-btn {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fffaf2;
    box-shadow: 0 6px 16px var(--accent-soft);
}

html.dark .primary-btn,
body.dark-mode .primary-btn {
    color: #171108;
}

.primary-btn:hover:not(:disabled):not(.is-busy) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.primary-btn.is-busy,
.secondary-btn.is-busy,
.ghost-btn.is-busy,
.mode-tab.is-busy {
    opacity: 0.58;
    cursor: progress;
    transform: none;
}

.secondary-btn {
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-primary);
}

.secondary-btn:hover:not(:disabled):not(.is-busy) {
    border-color: var(--gold);
    color: var(--accent);
}

.ghost-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    padding: 0 12px;
    font-weight: 500;
}

.ghost-btn:hover:not(:disabled):not(.is-busy) {
    color: var(--accent);
    background: var(--subtle-bg);
}

.ghost-btn.is-danger-confirm {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
}

.toggle-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    color: var(--text-secondary);
    margin-left: auto;
    user-select: none;
    cursor: pointer;
}

.ritual-stage-wrap {
    display: grid;
    grid-template-rows: 1fr;
    margin-top: 18px;
    opacity: 1;
    transition: grid-template-rows 0.36s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease, margin-top 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.ritual-stage-wrap.is-collapsed {
    grid-template-rows: 0fr;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

.ritual-stage-inner {
    overflow: hidden;
    min-height: 0;
}

.ritual-stage {
    padding: 20px;
    border-radius: 13px;
    background: var(--stage-bg);
    border: 1px solid var(--gold-border);
    box-shadow: inset 0 0 28px rgba(154, 107, 30, 0.06);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 22px;
    align-items: center;
}

.ritual-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 152px;
    border-radius: 12px;
    padding: 8px;
    transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.ritual-visual.is-step-ready {
    cursor: pointer;
}

.ritual-visual.is-step-ready:hover {
    background: var(--gold-soft);
    box-shadow: inset 0 0 0 1px var(--gold-border);
}

.ritual-visual.is-step-ready:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.ritual-tap-hint {
    margin-top: 4px;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--gold);
    text-align: center;
}

.coins-tray {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(16px, 4vw, 34px);
    padding: 22px 18px 12px;
    border-radius: 14px;
    background: radial-gradient(ellipse 80% 60% at 50% 60%, var(--gold-soft), transparent 78%);
}

.coin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 82px;
}

.coin-stage {
    position: relative;
    width: 74px;
    height: 74px;
    display: grid;
    place-items: center;
    perspective: 780px;
}

.coin-ground-shadow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    width: 58px;
    height: 12px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(22, 14, 4, 0.42) 0%, rgba(22, 14, 4, 0) 72%);
    opacity: 0.72;
    pointer-events: none;
}

.coin-body {
    position: relative;
    width: 68px;
    height: 68px;
    transform-style: preserve-3d;
    transform: rotateY(var(--coin-rest-rot, 0deg));
    will-change: transform;
}

.coin-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.coin-face-back {
    transform: rotateY(180deg);
}

.coin-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.coin-item.is-flipping .coin-body {
    animation: coinToss3d var(--coin-duration, 620ms) cubic-bezier(0.22, 0.85, 0.34, 1) var(--coin-delay, 0ms) forwards;
}

.coin-item.is-flipping .coin-ground-shadow {
    animation: coinShadowToss var(--coin-duration, 620ms) cubic-bezier(0.22, 0.85, 0.34, 1) var(--coin-delay, 0ms) forwards;
}

@keyframes coinToss3d {
    0% {
        transform: translateY(0) scale(1) rotateX(0deg) rotateY(var(--coin-start-rot, 0deg));
    }
    34% {
        transform: translateY(var(--coin-peak-y, -48px)) scale(1.14) rotateX(var(--coin-tilt-x, 22deg)) rotateY(calc(var(--coin-end-rot) * 0.48));
    }
    72% {
        transform: translateY(2px) scale(0.95) rotateX(6deg) rotateY(calc(var(--coin-end-rot) * 0.94));
    }
    86% {
        transform: translateY(-7px) scale(1.03) rotateX(-3deg) rotateY(var(--coin-end-rot));
    }
    100% {
        transform: translateY(0) scale(1) rotateX(0deg) rotateY(var(--coin-end-rot));
    }
}

@keyframes coinShadowToss {
    0% {
        transform: translateX(-50%) scale(0.92);
        opacity: 0.72;
    }
    34% {
        transform: translateX(-50%) scale(0.5);
        opacity: 0.22;
    }
    72% {
        transform: translateX(-50%) scale(1.06);
        opacity: 0.82;
    }
    86% {
        transform: translateX(-50%) scale(0.84);
        opacity: 0.56;
    }
    100% {
        transform: translateX(-50%) scale(0.96);
        opacity: 0.76;
    }
}

.coin-label {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--subtle-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.coin-label.is-pending {
    opacity: 0.55;
}

.coin-label.is-back {
    color: var(--gold);
    border-color: var(--gold-border);
    background: var(--gold-soft);
}

.ritual-status {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    min-height: 1.5em;
    transition: opacity 0.2s ease;
}

.ritual-status strong {
    font-family: var(--font-serif);
    color: var(--text-primary);
    font-size: 0.98rem;
}

.yarrow-stage {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.yarrow-bian-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.yarrow-bian-pill {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    background: var(--input-bg);
    transition: all 0.2s ease;
}

.yarrow-bian-pill.is-active {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-soft);
    box-shadow: 0 0 0 2px var(--gold-soft);
}

.yarrow-bian-pill.is-done {
    border-color: var(--jade-border);
    color: var(--jade);
    background: var(--jade-soft);
}

.yarrow-svg {
    width: 100%;
    height: 84px;
    display: block;
    border-radius: 10px;
    background: radial-gradient(ellipse at center, var(--gold-soft), transparent 76%);
}

.yarrow-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.yarrow-step-line {
    padding: 3px 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.yarrow-step-line.is-active {
    background: var(--gold-soft);
    color: var(--text-primary);
    font-weight: 600;
}

.yarrow-step-line.is-pending {
    opacity: 0.45;
}

.stack-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-left: 18px;
    border-left: 1px dashed var(--card-border);
}

.stack-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 248px;
    min-width: 0;
}

.stack-caption {
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.stack-slot {
    display: grid;
    grid-template-columns: 34px minmax(64px, 1fr) 54px;
    align-items: center;
    gap: 10px;
    padding: 3px 6px;
    border-radius: 7px;
    font-size: 0.79rem;
    color: var(--text-muted);
    transition: background-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.stack-slot.is-filled {
    color: var(--text-secondary);
}

.stack-slot.is-casting-now {
    background: var(--gold-soft);
    color: var(--gold);
    box-shadow: inset 0 0 0 1px var(--gold-border);
}

.stack-slot-label {
    text-align: right;
    font-weight: 600;
}

.stack-slot-bar {
    width: 100%;
    height: 10px;
    display: flex;
    align-items: center;
}

.stack-slot-bar .yao-graphic {
    height: 7px;
}

.stack-slot-bar.is-moving .yao-solid,
.stack-slot-bar.is-moving .yao-broken-part {
    background: var(--bar-moving);
}

.stack-slot.is-just-revealed .yao-solid {
    transform-origin: center;
    animation: barRevealSolid 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.stack-slot.is-just-revealed .yao-broken-part {
    animation: barRevealBroken 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.stack-slot.is-just-revealed .stack-slot-bar.is-moving .yao-graphic {
    animation: movingPulse 0.7s ease-out;
}

@keyframes barRevealSolid {
    from { transform: scaleX(0.12); opacity: 0.25; }
    to { transform: scaleX(1); opacity: 1; }
}

@keyframes barRevealBroken {
    from { transform: scaleX(0.25); opacity: 0.25; }
    to { transform: scaleX(1); opacity: 1; }
}

@keyframes movingPulse {
    0% { filter: drop-shadow(0 0 0 transparent); }
    45% { filter: drop-shadow(0 0 8px var(--accent-glow)); }
    100% { filter: drop-shadow(0 0 0 transparent); }
}

.stack-slot-placeholder {
    width: 100%;
    height: 2px;
    background: var(--card-border);
    border-radius: 2px;
}

.stack-slot.is-casting-now .stack-slot-placeholder {
    background: var(--gold);
    animation: pulseDot 1.2s infinite ease-in-out;
}

.stack-slot-state {
    font-variant-numeric: tabular-nums;
}

.stack-slot.is-moving .stack-slot-state {
    color: var(--bar-moving);
    font-weight: 700;
}

.manual-area.is-hidden {
    display: none;
}

.manual-hint {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.84rem;
    color: var(--text-secondary);
    margin: 0 0 14px;
    padding: 10px 13px;
    border-radius: 10px;
    background: var(--subtle-bg);
    border-left: 3px solid var(--gold-border);
}

.manual-rule-details summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--gold);
    font-weight: 600;
    user-select: none;
}

.manual-rule-details p {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.manual-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 232px;
    gap: 18px;
    align-items: start;
}

.manual-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.manual-row {
    display: grid;
    grid-template-columns: 98px repeat(4, minmax(0, 1fr));
    gap: 7px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 9px;
    border: 1px solid transparent;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.manual-row.is-next-target {
    background: var(--gold-soft);
    border-color: var(--gold-border);
}

.manual-row-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.manual-row.is-next-target .manual-row-label {
    color: var(--gold);
}

.manual-next-tag {
    display: none;
    font-size: 0.66rem;
    padding: 1px 5px;
    border-radius: 999px;
    background: var(--gold);
    color: #fffaf2;
    font-weight: 600;
    line-height: 1.3;
}

html.dark .manual-next-tag,
body.dark-mode .manual-next-tag {
    color: #171108;
}

.manual-row.is-next-target .manual-next-tag {
    display: inline-flex;
}

.manual-opt {
    min-height: 38px;
    padding: 4px 6px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 0.79rem;
    transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.manual-opt:hover {
    border-color: var(--gold);
    color: var(--text-primary);
}

.manual-opt.selected {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.manual-preview-panel {
    padding: 14px;
    border-radius: 12px;
    background: var(--stage-bg);
    border: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.manual-preview-head {
    font-family: var(--font-serif);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-primary);
}

.manual-preview-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
    padding-top: 6px;
    border-top: 1px dashed var(--card-border);
    width: 100%;
}

.manual-preview-meta strong {
    font-family: var(--font-serif);
    color: var(--accent);
}

.result-section {
    scroll-margin-top: 12px;
}

.result-section.is-hidden {
    display: none;
}

.result-section.is-entering {
    animation: resultRise 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.result-meta-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px dashed var(--card-border);
}

.result-question-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.result-question-display {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    flex: 1 1 220px;
}

.result-question-tag {
    flex-shrink: 0;
    font-family: var(--font-serif);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--gold-soft);
    border: 1px solid var(--gold-border);
    color: var(--gold);
}

.result-question-text {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.result-question-text.is-empty {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.84rem;
    font-weight: 400;
}

.result-question-edit-btn {
    border: 1px solid var(--card-border);
    background: var(--subtle-bg);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.result-question-edit-btn:hover {
    border-color: var(--gold);
    color: var(--accent);
}

.result-question-editor {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.result-question-input {
    flex: 1 1 220px;
    height: 36px;
    padding: 0 11px;
    border-radius: 8px;
    border: 1px solid var(--gold-border);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.result-question-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold-soft);
}

.result-meta-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.result-meta-pill {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--subtle-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
}

.result-history-pill {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--gold-soft);
    border: 1px solid var(--gold-border);
    color: var(--gold);
}

.copy-bar {
    position: sticky;
    top: 10px;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 13px;
    background: var(--card-bg);
    border: 1px solid var(--gold-border);
    box-shadow: var(--shadow-elevated);
    margin-bottom: 18px;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.copy-feedback {
    font-size: 0.84rem;
    color: var(--danger);
    font-weight: 600;
    margin-left: auto;
}

.hex-overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
    margin-bottom: 18px;
}

.hex-bridge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 4px;
    color: var(--gold);
}

.hex-bridge-badge {
    font-family: var(--font-serif);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--gold-soft);
    border: 1px solid var(--gold-border);
    white-space: nowrap;
}

.hex-bridge-arrow {
    color: var(--gold);
    opacity: 0.85;
}

.hex-card {
    padding: 16px 18px;
    border-radius: 13px;
    background: var(--subtle-bg);
    border: 1px solid var(--card-border);
}

.hex-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.hex-card-top .hex-card-tag {
    margin-bottom: 0;
}

.hex-card-tag {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 10px;
}

.hex-card-tag.is-changed {
    background: var(--jade-soft);
    color: var(--jade);
}

.hex-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.hex-card-head.is-clickable {
    cursor: pointer;
    padding: 6px 8px;
    margin: -6px -8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.hex-card-head.is-clickable:hover,
.hex-card-head.is-clickable:focus-visible {
    background: var(--gold-soft);
    border-color: var(--gold-border);
    outline: none;
}

.hex-card-head.is-guaci-focus {
    background: var(--gold-soft);
    border-color: var(--gold-border);
}

.hex-card-head.is-guaci-sub-focus {
    border-color: var(--gold-border);
    border-style: dashed;
}

.hex-title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.38rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.hex-sub {
    margin: 3px 0 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.hex-glyph {
    width: 44px;
    height: 44px;
    padding: 7px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--gold-border);
    color: var(--accent);
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.hex-glyph.is-changed {
    color: var(--jade);
}

.hex-bars {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hex-bar-row {
    display: grid;
    grid-template-columns: 42px minmax(64px, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 4px 6px;
    border-radius: 7px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.hex-bar-row:hover,
.hex-bar-row.is-linked-hover,
.hex-bar-row:active {
    background: var(--gold-soft);
    box-shadow: inset 0 0 0 1px var(--gold-border);
}

.hex-bar-row.is-focus {
    background: var(--gold-soft);
    box-shadow: inset 3px 0 0 var(--gold);
}

.hex-bar-row.is-sub-focus {
    box-shadow: inset 2.5px 0 0 var(--gold-border);
}

.hex-bar-row.is-focus:hover,
.hex-bar-row.is-focus.is-linked-hover {
    box-shadow: inset 3px 0 0 var(--gold), inset 0 0 0 1px var(--gold-border);
}

.hex-bar-name {
    font-family: var(--font-serif);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
}

.hex-bar-meta {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    white-space: nowrap;
}

.hex-role-pill {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    line-height: 1.3;
    white-space: nowrap;
}

.hex-role-pill.is-main {
    background: var(--gold-soft);
    color: var(--gold);
    border: 1px solid var(--gold-border);
}

.hex-role-pill.is-sub {
    color: var(--gold);
    border: 1px dashed var(--gold-border);
}

.hex-bar-chevron {
    color: var(--text-muted);
    opacity: 0.32;
    transition: opacity 0.16s ease, transform 0.16s ease, color 0.16s ease;
    flex-shrink: 0;
}

.hex-bar-row:hover .hex-bar-chevron,
.hex-bar-row.is-linked-hover .hex-bar-chevron,
.hex-bar-row.is-focus .hex-bar-chevron {
    opacity: 0.9;
    color: var(--gold);
}

.yao-graphic {
    width: 100%;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.yao-solid {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    background: var(--bar-color);
}

.yao-broken-part {
    width: 44%;
    height: 100%;
    border-radius: 3px;
    background: var(--bar-color);
}

.hex-bar-row.is-moving .yao-solid,
.hex-bar-row.is-moving .yao-broken-part {
    background: var(--bar-moving);
}

.hex-bar-row.is-transformed .yao-solid,
.hex-bar-row.is-transformed .yao-broken-part {
    background: var(--bar-transformed);
}

.hex-bar-mark {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bar-moving);
    text-align: right;
}

.hex-bar-mark.is-transformed {
    color: var(--bar-transformed);
}

.hex-bar-mark.is-static {
    color: var(--text-muted);
    font-weight: 400;
}

.hex-static-empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.guidance-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 13px 16px;
    border-radius: 11px;
    background: var(--gold-soft);
    border: 1px solid var(--gold-border);
    font-size: 0.93rem;
    line-height: 1.7;
}

.guidance-text {
    flex: 1 1 260px;
}

.guidance-banner strong {
    font-family: var(--font-serif);
    color: var(--gold);
    font-size: 1rem;
}

.guidance-jump-btn {
    border: 1px solid var(--gold-border);
    background: var(--card-bg);
    color: var(--gold);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.guidance-jump-btn:hover {
    border-color: var(--gold);
    background: var(--input-bg);
    transform: translateY(-1px);
}

.section-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.section-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.section-title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.14rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.section-note {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.scripture-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.scripture-filter {
    display: inline-flex;
    padding: 3px;
    border-radius: 9px;
    background: var(--subtle-bg);
    border: 1px solid var(--card-border);
}

.filter-chip {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.filter-chip.active {
    background: var(--card-bg);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.scripture-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

@media (min-width: 840px) {
    .scripture-layout.is-dual:not(.is-single-visible) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }
}

.scripture-hex-block {
    border-radius: 13px;
    border: 1px solid var(--card-border);
    background: var(--subtle-bg);
    overflow: hidden;
}

.scripture-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 16px;
    background: var(--stage-bg);
    border-bottom: 1px solid var(--card-border);
}

.scripture-block-head .hex-card-tag {
    margin-bottom: 0;
}

.scripture-block-title {
    font-family: var(--font-serif);
    font-size: 1.04rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.scripture-hex-block.is-filtered-out,
.guaci-box.is-filtered-out,
.line-item.is-filtered-out {
    display: none;
}

.guaci-box,
.line-item {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px 16px;
}

.guaci-box {
    border-bottom: 1px solid var(--card-border);
    background: transparent;
    scroll-margin-top: 88px;
}

.guaci-box.is-focus {
    background: var(--gold-soft);
    box-shadow: inset 3.5px 0 0 var(--gold);
}

.guaci-box.is-sub-focus {
    box-shadow: inset 2.5px 0 0 var(--gold-border);
}

.guaci-box.is-flash {
    animation: clauseFlash 1.25s ease;
}

.clause-rail {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding-top: 2px;
}

.clause-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.clause-main {
    min-width: 0;
}

.clause-label {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.badge {
    font-size: 0.69rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    line-height: 1.35;
}

.badge-moving {
    background: var(--moving-soft);
    color: var(--moving);
}

.badge-transformed {
    background: var(--jade-soft);
    color: var(--jade);
}

.badge-focus {
    background: var(--gold-soft);
    color: var(--gold);
    border: 1px solid var(--gold-border);
}

.badge-sub-focus {
    background: transparent;
    color: var(--gold);
    border: 1px dashed var(--gold-border);
}

.badge-extra {
    background: var(--subtle-bg);
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
}

.clause-text {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.02rem;
    line-height: 1.72;
    color: var(--text-primary);
}

.xiang-note {
    margin: 5px 0 0;
    padding-left: 9px;
    border-left: 2px solid var(--gold-border);
    font-family: var(--font-serif);
    font-size: 0.85rem;
    line-height: 1.66;
    color: var(--text-secondary);
}

.xiang-tag {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--gold);
    margin-right: 6px;
}

.scripture-layout.is-xiang-hidden .xiang-note {
    display: none;
}

.lines-list {
    display: flex;
    flex-direction: column;
}

.line-item {
    border-top: 1px dashed var(--card-border);
    background: transparent;
    scroll-margin-top: 88px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.line-item:first-child,
.line-item.is-first-visible {
    border-top: none;
}

.line-item.is-moving {
    background: var(--moving-soft);
}

.line-item.is-transformed {
    background: var(--jade-soft);
}

.line-item.is-focus {
    box-shadow: inset 3.5px 0 0 var(--gold);
}

.line-item.is-sub-focus {
    box-shadow: inset 2.5px 0 0 var(--gold-border);
}

.line-item.is-extra {
    border-top-style: solid;
    background: var(--stage-bg);
}

.line-item.is-flash {
    animation: clauseFlash 1.25s ease;
}

@keyframes clauseFlash {
    0% { box-shadow: inset 3.5px 0 0 var(--gold), 0 0 0 0 var(--gold-soft); }
    30% { box-shadow: inset 3.5px 0 0 var(--gold), 0 0 0 5px var(--gold-soft); }
    100% { box-shadow: inset 3.5px 0 0 var(--gold), 0 0 0 0 transparent; }
}

@media (min-width: 781px) {
    .scripture-layout.is-single:not(.is-focus-active) .lines-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scripture-layout.is-single:not(.is-focus-active) .line-item[data-line-index="0"] {
        grid-column: 1;
        grid-row: 1;
        border-top: none;
    }

    .scripture-layout.is-single:not(.is-focus-active) .line-item[data-line-index="1"] {
        grid-column: 1;
        grid-row: 2;
    }

    .scripture-layout.is-single:not(.is-focus-active) .line-item[data-line-index="2"] {
        grid-column: 1;
        grid-row: 3;
    }

    .scripture-layout.is-single:not(.is-focus-active) .line-item[data-line-index="3"] {
        grid-column: 2;
        grid-row: 1;
        border-top: none;
        border-left: 1px dashed var(--card-border);
    }

    .scripture-layout.is-single:not(.is-focus-active) .line-item[data-line-index="4"] {
        grid-column: 2;
        grid-row: 2;
        border-left: 1px dashed var(--card-border);
    }

    .scripture-layout.is-single:not(.is-focus-active) .line-item[data-line-index="5"] {
        grid-column: 2;
        grid-row: 3;
        border-left: 1px dashed var(--card-border);
    }

    .scripture-layout.is-single:not(.is-focus-active) .line-item.is-extra {
        grid-column: 1 / -1;
        grid-row: 4;
    }
}

.tech-details summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text-secondary);
    user-select: none;
}

.tech-details summary::-webkit-details-marker {
    display: none;
}

.tech-summary-chevron {
    flex-shrink: 0;
    transition: transform 0.22s ease, color 0.22s ease;
    color: var(--text-muted);
}

.tech-details[open] .tech-summary-chevron {
    transform: rotate(180deg);
    color: var(--gold);
}

.tech-details summary:hover {
    color: var(--accent);
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin: 14px 0;
    font-size: 0.86rem;
}

.tech-meta-item {
    padding: 10px 12px;
    border-radius: 9px;
    background: var(--subtle-bg);
    border: 1px solid var(--card-border);
}

.tech-meta-item span {
    display: block;
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.table-scroll {
    overflow-x: auto;
    border-radius: 10px;
    background-image:
        linear-gradient(to right, var(--card-bg), var(--card-bg)),
        linear-gradient(to right, var(--card-bg), var(--card-bg)),
        linear-gradient(to right, rgba(0, 0, 0, 0.14), transparent),
        linear-gradient(to left, rgba(0, 0, 0, 0.14), transparent);
    background-position: left center, right center, left center, right center;
    background-repeat: no-repeat;
    background-size: 18px 100%, 18px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

.najia-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    min-width: 560px;
}

.najia-table th,
.najia-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
}

.najia-table th {
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--subtle-bg);
}

.najia-table tr.is-moving td {
    color: var(--moving);
    font-weight: 600;
}

.najia-role-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    line-height: 1.35;
}

.najia-role-badge.is-shi {
    background: var(--gold-soft);
    color: var(--gold);
    border: 1px solid var(--gold-border);
}

.najia-role-badge.is-ying {
    background: var(--subtle-bg);
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
}

.najia-void-tag {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 0 4px;
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px dashed var(--card-border);
    background: var(--subtle-bg);
    vertical-align: middle;
}

.najia-legend {
    margin: 8px 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-empty {
    margin: 0;
    font-size: 0.86rem;
    color: var(--text-muted);
}

.history-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.history-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.history-item:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
}

.history-item.is-active {
    border-color: var(--gold);
    background: var(--gold-soft);
}

.history-left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 220px;
    min-width: 0;
}

.history-glyph {
    width: 22px;
    height: 22px;
    color: var(--accent);
    flex-shrink: 0;
}

.history-text-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.history-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

.history-title {
    font-family: var(--font-serif);
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-method-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--subtle-bg);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    flex-shrink: 0;
}

.history-question {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-meta {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.history-delete-btn {
    flex-shrink: 0;
    width: 38px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-muted);
    display: grid;
    place-items: center;
    transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.history-delete-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-soft);
}

.blessing-toast {
    position: fixed;
    top: auto;
    left: auto;
    right: clamp(16px, 3vw, 28px);
    bottom: calc(clamp(16px, 3.5vh, 28px) + env(safe-area-inset-bottom, 0px));
    transform: none;
    z-index: 60;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.blessing-toast.is-hidden {
    display: none;
}

.blessing-card {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    padding: 15px 18px 16px;
    background: var(--card-bg);
    border: 1px solid var(--gold-border);
    box-shadow: var(--shadow-elevated), inset 0 0 0 1px var(--card-inner-ring);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.blessing-card::before,
.blessing-card::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    pointer-events: none;
    border-color: var(--gold-border);
    border-style: solid;
}

.blessing-card::before {
    top: 7px;
    left: 7px;
    border-width: 1.5px 0 0 1.5px;
    border-top-left-radius: 4px;
}

.blessing-card::after {
    bottom: 8px;
    right: 7px;
    border-width: 0 1.5px 1.5px 0;
    border-bottom-right-radius: 4px;
}

.blessing-toast.is-visible .blessing-card {
    animation: blessingEnter 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.blessing-toast.is-leaving .blessing-card {
    animation: blessingLeave 0.3s ease forwards;
}

@keyframes blessingEnter {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes blessingLeave {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
}

.blessing-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px dashed var(--card-border);
}

.blessing-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--jade);
}

.blessing-close-btn {
    width: 36px;
    height: 36px;
    margin: -4px -6px -4px 0;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: color 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.blessing-close-btn:hover {
    color: var(--accent);
    border-color: var(--card-border);
    background: var(--subtle-bg);
}

.blessing-body {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 15px;
    align-items: center;
}

.blessing-emblem-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.blessing-emblem-ring {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
    background: radial-gradient(circle, var(--gold-soft) 0%, transparent 72%);
    border: 1px solid var(--gold-border);
    box-shadow: inset 0 0 0 3px var(--card-inner-ring);
}

.blessing-emblem {
    width: 68px;
    height: 68px;
    color: var(--gold);
}

.blessing-emblem svg {
    width: 100%;
    height: 100%;
    display: block;
}

.talisman-stroke {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}

.blessing-toast.is-visible .talisman-stroke {
    animation: talismanDraw 0.78s cubic-bezier(0.25, 0.9, 0.35, 1) var(--stroke-delay, 0.08s) forwards;
}

@keyframes talismanDraw {
    from { stroke-dashoffset: 100; }
    to { stroke-dashoffset: 0; }
}

.blessing-emblem-name {
    font-family: var(--font-serif);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--gold);
    margin-top: 6px;
}

.blessing-content {
    min-width: 0;
}

.blessing-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.blessing-hex-label {
    font-family: var(--font-serif);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blessing-seal {
    flex-shrink: 0;
    padding: 2px 6px;
    border: 1.5px solid currentColor;
    border-radius: 4px;
    color: var(--bar-moving);
    background: var(--accent-soft);
    font-family: var(--font-serif);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    line-height: 1.15;
    box-shadow: inset 0 0 0 1px currentColor;
    transform: rotate(-5deg);
}

.blessing-toast.is-visible .blessing-seal {
    animation: sealStamp 0.44s cubic-bezier(0.2, 0.9, 0.32, 1.12) 0.24s both;
}

@keyframes sealStamp {
    0% {
        opacity: 0;
        transform: scale(2.05) rotate(-15deg);
    }
    70% {
        opacity: 0.96;
        transform: scale(0.94) rotate(-4deg);
    }
    100% {
        opacity: 0.94;
        transform: scale(1) rotate(-5deg);
    }
}

.blessing-wish {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.72;
    color: var(--text-primary);
}

.blessing-quote {
    margin: 6px 0 0;
    font-family: var(--font-serif);
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.blessing-progress-track {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.5px;
    background: var(--subtle-bg);
}

.blessing-progress-bar {
    height: 100%;
    width: 100%;
    transform-origin: left center;
    background: linear-gradient(90deg, var(--gold), var(--accent));
}

.blessing-toast.is-visible .blessing-progress-bar {
    animation: blessingCountdown var(--blessing-duration, 4400ms) linear forwards;
}

.blessing-toast.is-paused .blessing-progress-bar {
    animation-play-state: paused;
}

@keyframes blessingCountdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 780px) {
    .manual-workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .manual-preview-panel {
        order: -1;
        padding: 11px 12px;
        gap: 7px;
    }

    .manual-preview-panel .stack-preview {
        gap: 4px;
        max-width: 100%;
    }

    .manual-preview-panel .stack-slot {
        padding: 2px 6px;
        font-size: 0.75rem;
    }

    .hex-overview-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .hex-bridge {
        flex-direction: row;
        padding: 2px 0;
    }

    .hex-bridge-arrow {
        transform: rotate(90deg);
    }
}

@media (max-width: 640px) {
    .label-full {
        display: none;
    }

    .label-short {
        display: inline;
    }

    .page-shell {
        width: calc(100% - 20px);
        padding: 16px 0 calc(44px + env(safe-area-inset-bottom, 0px));
    }

    .top-bar {
        align-items: flex-start;
        gap: 8px;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
    }

    .brand-subtitle {
        font-size: 0.77rem;
        line-height: 1.4;
    }

    .panel-card {
        padding: 15px;
    }

    .mode-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .mode-tab {
        padding: 8px 4px;
        font-size: 0.82rem;
        text-align: center;
        white-space: nowrap;
    }

    #auto-manual-area .action-row > #instant-cast-btn,
    #auto-manual-area .action-row > #step-cast-btn {
        flex: 1 1 calc(50% - 5px);
        padding: 0 10px;
    }

    .ritual-stage {
        grid-template-columns: minmax(0, 1fr);
        padding: 15px;
    }

    .stack-column {
        padding-left: 0;
        padding-top: 14px;
        border-left: none;
        border-top: 1px dashed var(--card-border);
    }

    .coin-item {
        width: 68px;
    }

    .coin-stage {
        width: 62px;
        height: 62px;
    }

    .coin-body {
        width: 56px;
        height: 56px;
    }

    .manual-row {
        grid-template-columns: 74px repeat(2, minmax(0, 1fr));
    }

    .manual-row-label {
        grid-row: span 2;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
    }

    .copy-bar {
        top: 6px;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 8px 10px;
    }

    .copy-bar .primary-btn {
        flex: 1 1 auto;
        min-height: 38px;
        padding: 0 10px;
        font-size: 0.84rem;
        white-space: nowrap;
    }

    .copy-bar .secondary-btn,
    .copy-bar .ghost-btn {
        min-height: 38px;
        padding: 0 10px;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .copy-feedback {
        position: absolute;
        left: 50%;
        top: calc(100% + 6px);
        transform: translateX(-50%);
        margin-left: 0;
        padding: 4px 12px;
        border-radius: 999px;
        background: var(--card-bg);
        border: 1px solid var(--danger-border);
        box-shadow: var(--shadow);
        white-space: nowrap;
    }

    .copy-feedback:empty {
        display: none;
    }

    .guaci-box,
    .line-item {
        grid-template-columns: 54px minmax(0, 1fr);
        gap: 10px;
        padding: 10px 13px;
    }

    .scripture-block-head {
        padding: 10px 13px;
    }

    .toggle-check {
        margin-left: 0;
    }

    .blessing-toast {
        top: auto;
        right: auto;
        left: 50%;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        transform: translateX(-50%);
        width: calc(100vw - 20px);
    }

    .blessing-card {
        padding: 13px 14px 14px;
    }

    .blessing-close-btn {
        width: 40px;
        height: 40px;
        margin: -6px -8px -6px 0;
    }

    .blessing-body {
        grid-template-columns: 76px minmax(0, 1fr);
        gap: 12px;
    }

    .blessing-emblem-ring {
        width: 72px;
        height: 72px;
    }

    .blessing-emblem {
        width: 58px;
        height: 58px;
    }

    .blessing-wish {
        font-size: 0.95rem;
    }
}

@media (max-width: 520px) {
    .home-link-text {
        display: none;
    }

    .home-link {
        width: 38px;
        padding: 0;
    }
}

@media (max-width: 360px) {
    .coins-tray {
        gap: 10px;
        padding: 16px 6px 10px;
    }

    .coin-item {
        width: 62px;
    }

    .coin-stage {
        width: 56px;
        height: 56px;
    }

    .coin-body {
        width: 50px;
        height: 50px;
    }

    .copy-bar .primary-btn {
        padding: 0 8px;
        font-size: 0.8rem;
    }

    .copy-bar .secondary-btn,
    .copy-bar .ghost-btn {
        padding: 0 8px;
        font-size: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .sacred-compass {
        animation: none !important;
    }

    .talisman-stroke {
        stroke-dashoffset: 0 !important;
    }

    .blessing-seal {
        opacity: 0.94 !important;
        transform: rotate(-5deg) !important;
    }
}
