/* ══════════════════════════════════════════════════════
   乾坤 AI 科學面相館 — 算命館玄學風 CSS
   設計理念：紙質底紋 · 燈籠 · 雲紋 · 木板材質
   ══════════════════════════════════════════════════════ */

:root {
    /* 色調：老宣紙 · 朱砂 · 墨黑 · 古銅金 */
    --paper:        #f5eed8;
    --paper-dark:   #ede4c8;
    --paper-deep:   #d4c89a;
    --ink:          #1a1008;
    --ink-soft:     #2d2015;
    --cinnabar:     #c0392b;
    --cinnabar-l:   #e74c3c;
    --gold:         #c9a84c;
    --gold-l:       #e8c96a;
    --gold-d:       #8b6914;
    --jade:         #2e7d62;
    --border-wood:  #8b6914;
    --border-ink:   rgba(26, 16, 8, 0.18);
    --shadow-ink:   rgba(26, 16, 8, 0.25);

    /* 文字 */
    --t1:  #1a1008;
    --t2:  #2d2015;
    --t3:  #5a3e28;
    --t4:  #8b6b4a;
    --t5:  #b8a080;

    --serif: 'Noto Serif TC', 'Songti SC', serif;
    --sans:  'Noto Sans TC', 'PingFang TC', sans-serif;
    --mono:  'JetBrains Mono', monospace;

    --r: 8px;
    --r2: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    background: var(--paper);
    color: var(--t1);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

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

/* ══ 背景紙質層 ══ */
.bg-layer { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.bg-paper {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(201, 168, 76, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(192, 57, 43, 0.04) 0%, transparent 60%),
        #f2e8cc;
}

.bg-grain {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='0.06'/%3E%3C/svg%3E");
    opacity: 0.5;
}

/* 雲紋裝飾 */
.cloud-ornament {
    position: absolute;
    border-radius: 50%;
    opacity: 0.07;
    filter: blur(60px);
}
.c1 { width: 500px; height: 300px; background: var(--gold); top: -100px; left: -100px; }
.c2 { width: 400px; height: 400px; background: var(--cinnabar); bottom: 10%; right: -150px; }
.c3 { width: 350px; height: 200px; background: var(--gold); top: 40%; left: 30%; }

/* ══ 頂部匾額 ══ */
.site-header {
    position: relative;
    z-index: 10;
    background: linear-gradient(180deg, #1a0f05 0%, #2d1a08 50%, #3d2510 100%);
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 2px 0 var(--gold-d) inset;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

/* 燈籠 */
.lantern {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.lantern-body {
    width: 54px;
    height: 72px;
    background: linear-gradient(135deg, #c0392b 0%, #96281b 40%, #c0392b 70%, #e74c3c 100%);
    border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
    border: 2px solid #7b1a10;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 16px rgba(192,57,43,0.6), inset 0 2px 8px rgba(255,200,0,0.2);
    animation: lantern-sway 4s ease-in-out infinite alternate;
}

@keyframes lantern-sway {
    from { transform: rotate(-2deg); }
    to   { transform: rotate(2deg); }
}

.lantern-body span {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 200, 0, 0.8);
    letter-spacing: 0;
}

.lantern-tassel {
    width: 2px;
    height: 24px;
    background: linear-gradient(to bottom, #ffd700, #c9a84c, transparent);
    position: relative;
}
.lantern-tassel::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 8px; height: 8px;
    background: var(--gold);
    border-radius: 50%;
}

/* 標題塊 */
.hall-title-block { text-align: center; flex: 1; }

.hall-subtitle-top {
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 4px;
    color: var(--gold);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    opacity: 0.85;
}

.hall-title {
    font-family: var(--serif);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 900;
    color: #fef9e7;
    letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(201,168,76,0.5), 2px 2px 0 rgba(0,0,0,0.5);
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.hall-subtitle-bot {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: rgba(201,168,76,0.6);
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.hall-ornament-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--gold);
    font-size: 0.85rem;
}

.orn-diamond { font-size: 0.6rem; opacity: 0.6; }
.orn-line { flex: 1; max-width: 28px; height: 1px; background: linear-gradient(to right, transparent, var(--gold), transparent); }
.orn-char { font-family: var(--serif); font-size: 0.9rem; font-weight: 700; letter-spacing: 1px; }

/* ══ 主體 ══ */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

/* ══ 入口儀式區 ══ */
.entrance-section {
    text-align: center;
    padding: 3.5rem 1rem 2.5rem;
}

.entrance-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.entrance-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--jade);
    background: rgba(46, 125, 98, 0.1);
    border: 1px solid rgba(46, 125, 98, 0.3);
    border-radius: 9999px;
    padding: 0.35rem 1rem;
    letter-spacing: 1px;
    font-family: var(--mono);
}

.badge-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--jade);
    box-shadow: 0 0 6px var(--jade);
    animation: blink 2s infinite;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.entrance-desc {
    font-family: var(--serif);
    font-size: 1.05rem;
    color: var(--t3);
    line-height: 2;
}

.sys-status-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.sys-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--t3);
    background: rgba(26,16,8,0.06);
    border: 1px solid var(--border-ink);
    border-radius: 4px;
    padding: 0.3rem 0.75rem;
    font-family: var(--mono);
}

.sys-badge-green { color: var(--jade); background: rgba(46,125,98,0.08); border-color: rgba(46,125,98,0.2); }

.sys-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t5); flex-shrink: 0; }
.sys-dot-green { background: var(--jade); box-shadow: 0 0 5px var(--jade); animation: blink 2.5s infinite; }
.sys-dot.status-ready { background: var(--jade); box-shadow: 0 0 5px var(--jade); }
.sys-dot.status-amber { background: #e67e22; box-shadow: 0 0 5px #e67e22; }

/* ══ 供桌上傳區 ══ */
.offering-section {
    position: relative;
    background: rgba(255,253,240,0.85);
    border: 2px solid var(--gold-d);
    border-radius: 4px;
    padding: 0 0 1.5rem;
    box-shadow: 0 6px 32px var(--shadow-ink), inset 0 0 40px rgba(201,168,76,0.05);
    backdrop-filter: blur(4px);
    margin-bottom: 3rem;
}

/* 框角裝飾 */
.section-frame-top, .section-frame-bot { position: relative; height: 0; }

.frame-corner {
    position: absolute;
    width: 24px; height: 24px;
    border-color: var(--gold-d);
    border-style: solid;
}
.fc-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; }
.fc-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; }
.fc-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; }
.fc-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; }

.offering-inner {
    padding: 2rem 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* 上傳面板 */
.upload-panel {
    background: rgba(26,16,8,0.03);
    border: 1.5px solid var(--border-ink);
    border-radius: var(--r);
    overflow: hidden;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-ink);
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 700;
    color: var(--t1);
}

.panel-title svg { width: 16px; height: 16px; color: var(--gold-d); flex-shrink: 0; }

.tab-switcher {
    margin-left: auto;
    display: flex;
    background: rgba(26,16,8,0.08);
    border-radius: 6px;
    padding: 3px;
    gap: 3px;
}

.tab-btn {
    padding: 0.3rem 0.85rem;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--t4);
    font-family: var(--sans);
}

.tab-btn.active { background: var(--paper); color: var(--t1); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }

.tab-pane { display: none; padding: 1.25rem; }
.tab-pane.active { display: block; }

/* 拖放區 */
.dropzone {
    border: 2px dashed rgba(139,105,20,0.3);
    border-radius: var(--r);
    cursor: pointer;
    transition: all 0.25s;
    background: rgba(201,168,76,0.03);
}

.dropzone:hover, .dropzone.over {
    border-color: var(--gold-d);
    background: rgba(201,168,76,0.08);
}

.dz-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1.5rem;
    gap: 0.75rem;
    text-align: center;
}

.dz-bagua {
    font-size: 3.5rem;
    color: var(--gold-d);
    opacity: 0.4;
    line-height: 1;
    animation: bagua-spin 20s linear infinite;
}

@keyframes bagua-spin { to { transform: rotate(360deg); } }

.dz-main { font-family: var(--serif); font-size: 1rem; font-weight: 700; color: var(--t2); }
.dz-main u { color: var(--cinnabar); text-decoration: none; border-bottom: 2px solid var(--cinnabar); padding-bottom: 1px; }
.dz-hint { font-size: 0.8rem; color: var(--t4); font-weight: 500; }

/* 相機 */
.webcam-box { border-radius: var(--r2); overflow: hidden; background: #000; border: 1.5px solid var(--border-ink); aspect-ratio: 4/3; }
#webcam-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }

.btn-capture {
    width: 100%;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: var(--r2);
    border: 1.5px solid var(--gold-d);
    background: rgba(201,168,76,0.1);
    color: var(--gold-d);
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-capture:hover { background: rgba(201,168,76,0.2); }
.btn-capture svg { width: 16px; height: 16px; }

/* 預覽區 */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.img-shrine {
    width: 100%;
    max-width: 520px;
    position: relative;
}

.shrine-border-top, .shrine-border-bot {
    height: 12px;
    background: repeating-linear-gradient(90deg, var(--gold-d) 0px, var(--gold-d) 8px, transparent 8px, transparent 16px);
    opacity: 0.4;
    border-radius: 2px;
}

.img-shrine img {
    width: 100%;
    display: block;
    border: 2px solid var(--gold-d);
    border-top: none;
    border-bottom: none;
    box-shadow: 0 4px 20px var(--shadow-ink);
}

.scan-overlay { position: absolute; inset: 12px; pointer-events: none; }
.scan-beam {
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--cinnabar), #fff, var(--cinnabar), transparent);
    box-shadow: 0 0 10px var(--cinnabar);
    animation: beam 2s ease-in-out infinite;
}
@keyframes beam { 0% { top: 0; } 100% { top: 100%; } }

.corner-mark { position: absolute; width: 18px; height: 18px; border-color: var(--gold); border-style: solid; }
.corner-mark.tl { top: 4px; left: 4px; border-width: 2.5px 0 0 2.5px; }
.corner-mark.tr { top: 4px; right: 4px; border-width: 2.5px 2.5px 0 0; }
.corner-mark.bl { bottom: 4px; left: 4px; border-width: 0 0 2.5px 2.5px; }
.corner-mark.br { bottom: 4px; right: 4px; border-width: 0 2.5px 2.5px 0; }

.preview-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--r2);
    border: 1.5px solid var(--border-ink);
    background: transparent;
    color: var(--t3);
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ghost:hover { background: rgba(26,16,8,0.07); color: var(--t1); }
.btn-ghost svg { width: 14px; height: 14px; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    border-radius: var(--r2);
    border: none;
    background: linear-gradient(135deg, var(--cinnabar) 0%, #96281b 100%);
    color: #fff;
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 16px rgba(192,57,43,0.4);
    letter-spacing: 2px;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(192,57,43,0.55); }
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: 0 4px 16px rgba(192,57,43,0.2); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* 設定神龕 */
.config-shrine {
    background: rgba(26,16,8,0.03);
    border: 1.5px solid var(--border-ink);
    border-radius: var(--r);
    overflow: hidden;
}

.config-shrine-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-ink);
    font-family: var(--serif);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--t1);
}
.config-shrine-title svg { width: 15px; height: 15px; color: var(--gold-d); }

.config-group {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid rgba(26,16,8,0.06);
    transition: all 0.3s ease;
}
.config-group:last-child { border-bottom: none; }

.config-group.disabled {
    background: rgba(26, 16, 8, 0.05);
    opacity: 0.55;
    pointer-events: none;
    cursor: not-allowed;
}
.config-group.disabled * {
    pointer-events: none;
}

.config-label {
    display: block;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--t4);
    margin-bottom: 0.65rem;
}

/* Provider 選擇 */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.provider-default-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0;
    flex-wrap: nowrap;
}

.provider-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.7rem 0.3rem;
    border-radius: var(--r2);
    border: 1.5px solid var(--border-ink);
    background: rgba(26,16,8,0.02);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--t3);
    position: relative;
}

.provider-card:hover { border-color: var(--gold-d); background: rgba(201,168,76,0.07); }
.provider-card.active {
    border-color: var(--gold-d);
    background: rgba(201,168,76,0.12);
    color: var(--gold-d);
    box-shadow: 0 0 10px rgba(201,168,76,0.2);
}

.provider-icon { font-size: 1.3rem; color: var(--gold-d); line-height: 1; }
.openai-c { color: var(--jade); }
.gemini-c { color: #3b82f6; }

.dev-mark {
    position: absolute;
    bottom: 3px; right: 4px;
    font-size: 0.45rem;
    font-weight: 900;
    color: var(--jade);
    line-height: 1;
}

/* 風格 */
.style-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
}

.style-chip {
    cursor: pointer;
}

.style-chip span {
    display: block;
    text-align: center;
    padding: 0.5rem 0.2rem;
    border-radius: var(--r2);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--border-ink);
    color: var(--t3);
    background: rgba(26,16,8,0.02);
    transition: all 0.2s;
}

.style-chip:hover span { border-color: var(--gold-d); }
.style-chip input:checked + span {
    border-color: var(--cinnabar);
    color: var(--cinnabar);
    background: rgba(192,57,43,0.07);
}

/* 進階 Key */
.adv-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--t4);
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-align: left;
    transition: color 0.2s;
}
.adv-toggle:hover { color: var(--t1); }
.adv-toggle svg { width: 14px; height: 14px; flex-shrink: 0; }
#adv-chevron { margin-left: auto; transition: transform 0.2s; }
#adv-chevron.open { transform: rotate(180deg); }

.adv-body {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.key-row {
    display: flex;
    background: rgba(26,16,8,0.05);
    border: 1.5px solid var(--border-ink);
    border-radius: var(--r2);
    overflow: hidden;
}
.key-row:focus-within { border-color: var(--gold-d); }
.key-row input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    padding: 0.6rem 0.85rem;
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--t1);
}
.key-row input::placeholder { color: var(--t5); font-family: var(--sans); }
.key-vis-btn {
    padding: 0 0.75rem;
    background: none;
    border: none;
    color: var(--t4);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}
.key-vis-btn:hover { color: var(--t2); }
.key-vis-btn svg { width: 14px; height: 14px; }
.key-note {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--t4);
    font-weight: 500;
}
.key-note svg { width: 12px; height: 12px; color: var(--jade); flex-shrink: 0; }

.key-provider-hint {
    font-size: 0.78rem;
    color: var(--t3);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.key-apply-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.65rem;
}

.key-link {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--mono);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    text-decoration: none;
    border: 1.5px solid;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}
.key-link:hover { opacity: 0.8; transform: translateY(-1px); }

.key-link-gemini { color: #3b82f6; border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.06); }
.key-link-claude { color: var(--gold-d); border-color: rgba(139,105,20,0.4); background: rgba(201,168,76,0.06); }
.key-link-openai { color: var(--jade); border-color: rgba(46,125,98,0.4); background: rgba(46,125,98,0.06); }

/* 預設引擎說明文字 */
.dev-key-notice {
    font-size: 0.75rem;
    color: #bca480;
    line-height: 1.4;
    font-weight: 500;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

#provider-default-btn {
    min-width: 180px;
    flex-shrink: 0;
}

/* 操作按鈕區塊（設定板底部） */
.config-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-ink);
    margin-top: 0.5rem;
}

/* ══ 批命進行中 ══ */
.divining-section {
    display: flex;
    justify-content: center;
    padding: 5rem 1rem;
    margin-bottom: 3rem;
}

.divining-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
    text-align: center;
    max-width: 480px;
}

.divining-circle {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dc-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
}
.dc-r1 { inset: 0; border-top-color: var(--gold-d); border-right-color: var(--gold-d); animation: spin 1.6s linear infinite; }
.dc-r2 { inset: 12px; border-top-color: var(--cinnabar); animation: spin 1.1s linear infinite reverse; opacity: 0.8; }
.dc-r3 { inset: 24px; border-top-color: var(--gold); animation: spin 0.8s linear infinite; opacity: 0.5; }
@keyframes spin { to { transform: rotate(360deg); } }

.dc-bagua { font-size: 1.8rem; color: var(--gold-d); position: relative; z-index: 1; }

.divining-title {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--t1);
    letter-spacing: 2px;
}

.divining-tip {
    font-size: 0.9rem;
    color: var(--t3);
    line-height: 1.8;
    transition: opacity 0.4s;
}

.divining-steps {
    display: flex;
    align-items: center;
    gap: 0;
}

.step-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.sn-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--paper-deep);
    border: 2px solid var(--paper-deep);
    transition: all 0.4s;
}

.step-node span:last-child {
    font-size: 0.7rem;
    color: var(--t5);
    font-family: var(--mono);
    white-space: nowrap;
    font-weight: 600;
}

.step-node.active .sn-dot { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 10px rgba(201,168,76,0.6); }
.step-node.active span:last-child { color: var(--t1); font-weight: 700; }
.step-node.done .sn-dot { background: var(--jade); border-color: var(--jade); }
.step-node.done span:last-child { color: var(--jade); }

.step-connector {
    width: 40px; height: 2px;
    background: var(--border-ink);
    margin-bottom: 1.25rem;
}

/* ══ 鑑定結果 ══ */
.result-section {
    animation: fadeUp 0.4s ease;
    margin-bottom: 3rem;
}

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

.result-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: linear-gradient(180deg, #2d1a08, #1a0f05);
    border: 1.5px solid var(--gold-d);
    border-radius: var(--r) var(--r) 0 0;
    color: var(--gold-l);
    margin-bottom: 0;
}

.result-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--serif);
    font-size: 0.95rem;
    font-weight: 700;
}

.live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--jade);
    box-shadow: 0 0 6px var(--jade);
    animation: blink 2s infinite;
}

.result-time { font-size: 0.75rem; font-family: var(--mono); opacity: 0.7; font-weight: 400; }

.result-topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.model-tag {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--mono);
    padding: 0.2rem 0.55rem;
    background: rgba(201,168,76,0.15);
    border: 1.5px solid rgba(201,168,76,0.4);
    border-radius: 4px;
    color: var(--gold-l);
}

.icon-btn {
    width: 30px; height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(201,168,76,0.3);
    border-radius: var(--r2);
    background: rgba(201,168,76,0.08);
    color: var(--gold-l);
    cursor: pointer;
    transition: all 0.2s;
}
.icon-btn:hover { background: rgba(201,168,76,0.2); border-color: var(--gold); }
.icon-btn svg { width: 14px; height: 14px; }

/* 鑑定書主體 */
.certificate-body {
    background: rgba(255,253,240,0.95);
    border: 1.5px solid var(--gold-d);
    border-top: none;
    border-radius: 0 0 var(--r) var(--r);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    box-shadow: 0 6px 32px var(--shadow-ink);
}

/* 相片框 */
.cert-photo-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.cert-photo-frame {
    position: relative;
    max-width: 420px;
    width: 100%;
}

.cert-photo-frame img {
    width: 100%;
    display: block;
    border-radius: 2px;
    box-shadow: 0 4px 20px var(--shadow-ink);
}

.photo-frame-corner {
    position: absolute;
    width: 22px; height: 22px;
    border-color: var(--gold-d);
    border-style: solid;
}
.pfc-tl { top: -4px; left: -4px; border-width: 3px 0 0 3px; }
.pfc-tr { top: -4px; right: -4px; border-width: 3px 3px 0 0; }
.pfc-bl { bottom: -4px; left: -4px; border-width: 0 0 3px 3px; }
.pfc-br { bottom: -4px; right: -4px; border-width: 0 3px 3px 0; }

.cert-photo-caption {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--t4);
    text-align: center;
    letter-spacing: 0.5px;
}

/* 雙路線 */
.dual-analysis { border-top: 1px solid var(--border-ink); padding-top: 2rem; }

.dual-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--serif);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--t2);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1.25rem;
    font-family: var(--mono);
}
.dual-header svg { width: 15px; height: 15px; color: var(--gold-d); }

.dual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 640px) { .dual-grid { grid-template-columns: 1fr; } }

.dual-card {
    background: rgba(26,16,8,0.03);
    border: 1.5px solid var(--border-ink);
    border-radius: var(--r);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.card-a { border-top: 3px solid rgba(60, 100, 180, 0.7); }
.card-b { border-top: 3px solid rgba(192, 57, 43, 0.7); }

.dual-card-title { display: flex; align-items: flex-start; gap: 0.6rem; }

.route-badge {
    font-size: 0.7rem;
    font-weight: 800;
    font-family: var(--mono);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

.badge-a { background: rgba(60,100,180,0.12); border: 1px solid rgba(60,100,180,0.35); color: #3c64b4; }
.badge-b { background: rgba(192,57,43,0.12); border: 1px solid rgba(192,57,43,0.35); color: var(--cinnabar); }

.route-name { font-family: var(--serif); font-size: 1rem; font-weight: 800; color: var(--t1); }
.route-sub  { font-size: 0.72rem; color: var(--t4); font-family: var(--mono); font-weight: 600; margin-top: 2px; }

.metric-list { list-style: none; display: flex; flex-direction: column; gap: 0.65rem; }
.metric-item { display: flex; flex-direction: column; gap: 0.2rem; }
.metric-row { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; }
.metric-name { color: var(--t2); }
.metric-val { color: #3c64b4; font-family: var(--mono); font-size: 0.78rem; font-weight: 700; }

.bar-track { height: 5px; background: rgba(26,16,8,0.08); border-radius: 9999px; overflow: hidden; }
.bar-fill-a { height: 100%; background: linear-gradient(to right, #3c64b4, #6b8de8); border-radius: 9999px; transition: width 1.2s cubic-bezier(.16,1,.3,1); }

.cnn-result-list { display: flex; flex-direction: column; gap: 0.65rem; }
.cnn-item { display: flex; flex-direction: column; gap: 0.2rem; }
.cnn-row { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; }
.cnn-name { color: var(--t2); }
.cnn-val { color: var(--cinnabar); font-family: var(--mono); font-size: 0.78rem; font-weight: 700; }
.bar-fill-b { height: 100%; background: linear-gradient(to right, var(--cinnabar), #e74c3c); border-radius: 9999px; transition: width 1.2s cubic-bezier(.16,1,.3,1); }

.cnn-source-tag {
    font-size: 0.63rem;
    font-family: var(--mono);
    color: var(--t5);
    background: rgba(26,16,8,0.04);
    border: 1px solid var(--border-ink);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    margin-top: 0.1rem;
    display: inline-block;
    align-self: flex-start;
}

.route-summary {
    font-size: 0.85rem;
    color: var(--t2);
    background: rgba(26,16,8,0.04);
    border-radius: var(--r2);
    padding: 0.65rem 0.85rem;
    line-height: 1.8;
    border-left: 3px solid;
    margin-top: 0.75rem;
    font-weight: 500;
}
.card-a .route-summary { border-left-color: #3c64b4; }
.card-b .route-summary { border-left-color: var(--cinnabar); }

.route-summary strong, .cnn-item strong, .dual-card strong {
    color: var(--cinnabar);
    font-weight: 700;
    font-family: var(--serif);
}

.route-summary .title-label {
    color: var(--t1);
    font-family: var(--sans);
}

/* ══ 命運捲軸 ══ */
.fate-scroll {
    border-top: 1px solid var(--border-ink);
    padding-top: 2rem;
}

.fate-scroll-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.fate-scroll-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--serif);
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--t1);
    letter-spacing: 3px;
}

.scroll-orn { color: var(--gold-d); font-size: 0.9rem; opacity: 0.7; }

.fate-model-tag {
    font-size: 0.7rem;
    font-family: var(--mono);
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    background: rgba(192,57,43,0.08);
    border: 1px solid rgba(192,57,43,0.3);
    border-radius: 3px;
    color: var(--cinnabar);
}

.fate-scroll-seal {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.seal-top-line, .seal-bot-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold-d), transparent);
}

.seal-mark {
    font-family: var(--serif);
    font-size: 0.9rem;
    font-weight: 900;
    color: var(--gold-d);
    background: rgba(201,168,76,0.1);
    border: 1.5px solid rgba(201,168,76,0.4);
    padding: 0.2rem 0.8rem;
    border-radius: 3px;
    letter-spacing: 3px;
}

.fate-scroll-footer {
    margin-top: 2rem;
    text-align: center;
}

.footer-char {
    font-family: var(--serif);
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--gold-d);
    opacity: 0.4;
    letter-spacing: 4px;
}

/* Markdown */
.markdown-body { font-size: 0.97rem; line-height: 1.9; color: var(--t2); font-family: var(--sans); }
.markdown-body h2 { font-family: var(--serif); font-size: 1.05rem; font-weight: 900; color: var(--t1); margin: 1.75rem 0 0.8rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border-ink); letter-spacing: 1px; }
.markdown-body h2:first-child { margin-top: 0; }
.markdown-body p { margin-bottom: 0.85rem; font-weight: 400; }
.markdown-body ul { margin: 0.6rem 0 0.8rem 1.4rem; }
.markdown-body li { margin-bottom: 0.3rem; }
.markdown-body strong { color: var(--cinnabar); font-weight: 700; font-family: var(--serif); }
.markdown-body blockquote {
    margin: 1rem 0;
    padding: 0.65rem 1.1rem;
    background: rgba(201,168,76,0.06);
    border-left: 4px solid var(--gold-d);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--t3);
    font-size: 0.95rem;
    font-family: var(--serif);
}

/* ══ 頁腳 ══ */
.site-footer {
    position: relative;
    background: linear-gradient(180deg, #1a0f05, #0d0804);
    border-top: 2px solid var(--gold-d);
    padding: 3rem 2rem;
    text-align: center;
    overflow: hidden;
}

.footer-cloud {
    position: absolute;
    width: 200px; height: 60px;
    background: radial-gradient(ellipse, rgba(201,168,76,0.08), transparent);
    border-radius: 50%;
    top: 10px;
}
.footer-cloud-l { left: -50px; }
.footer-cloud-r { right: -50px; }

.footer-inner { position: relative; z-index: 1; }
.footer-title { font-family: var(--serif); font-size: 1.1rem; font-weight: 900; color: var(--gold-l); letter-spacing: 3px; margin-bottom: 0.5rem; }
.footer-tech { font-family: var(--mono); font-size: 0.7rem; color: rgba(201,168,76,0.45); letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.footer-disclaimer { font-size: 0.72rem; color: rgba(255,255,255,0.25); }

/* ══ 列印 ══ */


@media print {
    .site-header, .entrance-section, .offering-section, .result-topbar .result-topbar-right, .site-footer { display: none !important; }
    .certificate-body { border: none; box-shadow: none; }
    .markdown-body { color: #000; }
    .cert-photo-block { display: block !important; } /* 列印證書時重新顯現照片，保持證書完整性 */
}

/* ══ 響應式 ══ */
@media (max-width: 640px) {
    .header-inner { padding: 1rem; gap: 0.75rem; }
    .hall-title { font-size: 1.5rem; letter-spacing: 2px; }
    .lantern-body { width: 42px; height: 56px; }
    .lantern-body span { font-size: 1.2rem; }
    .certificate-body { padding: 1.25rem; }
    .main-content { padding: 0 1rem 3rem; }
    .offering-inner { padding: 1.25rem 1rem 0; }
    .palace-grid { grid-template-columns: 1fr 1fr; }
}

/* ══ 五宮專業命理評分樣式 ══ */
.palace-scores-container {
    margin: 1.5rem 0;
    padding: 1.25rem;
    border: 1px solid var(--border-wood);
    background: var(--paper-dark);
    border-radius: var(--r);
    box-shadow: inset 0 0 10px rgba(139, 105, 20, 0.1);
}
.palace-scores-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--serif);
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--cinnabar);
    margin-bottom: 1rem;
    border-bottom: 1px dashed var(--gold);
    padding-bottom: 0.5rem;
}
.palace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.75rem;
}
.palace-card {
    background: var(--paper);
    border: 1px solid var(--border-ink);
    padding: 0.75rem;
    border-radius: var(--r2);
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.25s ease;
}
.palace-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(139, 105, 20, 0.15);
}
.palace-name {
    font-family: var(--serif);
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--t2);
    margin-bottom: 0.25rem;
}
.palace-score-num {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--cinnabar);
    margin-bottom: 0.25rem;
}
.palace-progress {
    width: 100%;
    height: 6px;
    background: rgba(26, 16, 8, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.palace-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--cinnabar));
    border-radius: 3px;
    transition: width 1s ease-out;
}
