/* ═══════════════════════════════════════════════════════════════
   OC Study /v3 — live demo core (functional skin, variant-tunable)
   HARD CONSTRAINTS (demo.js / canvas):
   - analysis card must stay DARK (canvas draws white/#4ade80/#facc15)
   - resting box-shadow of .spider-chart-container must be exactly
     `0 12px 32px rgba(0,0,0,0.08)` — JS hard-resets to that string
   - #spiderChart keeps width=600 height=430 attributes
   - chat card stays LIGHT (JS sets pale rgba header washes + dark text)
   ═══════════════════════════════════════════════════════════════ */

:root {
    --demo-band-bg: linear-gradient(180deg, #0a1f14 0%, #0c2417 55%, #0a1f14 100%);
    --demo-band-glow: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(26, 138, 94, 0.14), transparent 70%);
    --demo-label-color: #d4a017;
    --demo-h2-color: #ffffff;
    --demo-h2-accent: #4ade80;
    --demo-sub-color: rgba(255,255,255,0.55);
    --demo-card-bg: #0d271a;
    --demo-card-border: rgba(255,255,255,0.09);
    --demo-card-radius: 24px;
    --chat-bg: #ffffff;
    --chat-border: rgba(255,255,255,0.14);
    --chat-radius: 24px;
    --chat-shadow: 0 40px 90px rgba(0,0,0,0.35);
    --chat-ink: #1a2b1a;
    --chat-dim: #8a9888;
    --chat-line: #e6e2d8;
    --chat-bubble: #f3f1eb;
    --chat-accent: #15694a;
    --chat-accent-hover: #1a8a5e;
    --chat-accent-rgb: 21, 105, 74;
}

.live-demo {
    position: relative;
    background: var(--demo-band-bg);
    padding: 110px 32px 120px;
    color: rgba(255,255,255,0.85);
}
.live-demo::before {
    content: '';
    position: absolute; inset: 0;
    background: var(--demo-band-glow);
    pointer-events: none;
}
.live-demo-header {
    position: relative;
    max-width: 760px; margin: 0 auto;
    text-align: center; padding-bottom: 64px;
}
.live-demo-header .section-label {
    font-size: 0.72rem; font-weight: 700;
    letter-spacing: 0.22em; text-transform: uppercase;
    color: var(--demo-label-color);
    margin-bottom: 20px;
}
.live-demo-header h2 {
    font-family: var(--font-display);
    font-weight: var(--display-weight);
    font-size: clamp(2.1rem, 4.2vw, 3.3rem);
    letter-spacing: var(--display-tracking);
    text-transform: var(--display-transform);
    color: var(--demo-h2-color);
    line-height: 1.1;
}
.live-demo-header h2 .accent-text { font-style: var(--display-accent-style); color: var(--demo-h2-accent); }
.live-demo-header p {
    font-size: 1.02rem; color: var(--demo-sub-color);
    margin-top: 18px; line-height: 1.75;
}
.live-demo-inner {
    position: relative;
    max-width: 1400px; margin: 0 auto; width: 100%;
    display: grid; grid-template-columns: 1fr 1fr; gap: 28px;
    align-items: stretch;
}

/* ── Analysis card (dark) ───────────────────────────────────── */
.spider-chart-container {
    position: relative;
    z-index: 2;
    background: var(--demo-card-bg);
    border: 1px solid var(--demo-card-border);
    border-radius: var(--demo-card-radius);
    padding: 20px 22px 18px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.08);
    transition: box-shadow 0.5s ease;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    color: rgba(255,255,255,0.85);
}
.spider-chart-container.visible { opacity: 1; transform: scale(1); }

.analysis-loader {
    position: absolute; inset: 0; z-index: 10;
    background: var(--demo-card-bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px;
    border-radius: var(--demo-card-radius);
    opacity: 1;
    transition: opacity 0.4s ease;
}
.analysis-loader.fade-out { opacity: 0; pointer-events: none; }
.analysis-loader-spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: loaderSpin 0.8s linear infinite;
}
@keyframes loaderSpin { to { transform: rotate(360deg); } }
.analysis-loader-text { font-size: 0.85rem; color: rgba(255,255,255,0.5); font-weight: 500; }

.spider-chart-container .spider-title {
    font-size: 0.85rem; font-weight: 700;
    color: rgba(255,255,255,0.92);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 7px;
}
.spider-chart-container .spider-title .pulse-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #4ade80;
    animation: spiderPulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes spiderPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(74,222,128,0); }
}

.spider-bts-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 3px 10px; border-radius: 100px;
    font-size: 0.63rem; font-weight: 600;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase; letter-spacing: 0.09em;
    margin-left: auto;
    transition: background 0.4s ease, border-color 0.4s ease, color 0.4s ease, box-shadow 0.4s ease;
}
.spider-bts-badge .bts-default { display: inline; }
.spider-bts-badge .bts-analyzing { display: none; align-items: center; gap: 5px; }
.spider-bts-badge::before { content: '⚙'; font-size: 0.7rem; transition: opacity 0.3s ease; }
.spider-bts-badge.analyzing {
    background: rgba(74,222,128,0.12);
    border-color: rgba(74,222,128,0.3);
    color: #4ade80;
    text-shadow: 0 0 8px rgba(74,222,128,0.4);
    animation: btsBadgePulse 2s ease-in-out infinite;
}
.spider-bts-badge.analyzing::before { content: none; }
.spider-bts-badge.analyzing .bts-default { display: none; }
.spider-bts-badge.analyzing .bts-analyzing { display: inline-flex; }
.bts-dots { display: flex; gap: 2px; }
.bts-dots span {
    width: 5px; height: 5px; border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74,222,128,0.6);
    animation: aiDotPulse 1.2s ease-in-out infinite;
}
.bts-dots span:nth-child(2) { animation-delay: 0.15s; }
.bts-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes btsBadgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
    50% { box-shadow: 0 0 12px 2px rgba(74,222,128,0.25); }
}

.spider-analysis-bar { display: flex; gap: 10px; width: 100%; margin-bottom: 12px; }
.spider-analysis-panel,
.spider-strategy-panel {
    flex: 1;
    font-size: 0.76rem; line-height: 1.55;
    padding: 11px 13px;
    border-radius: 10px;
    min-height: 52px;
    transition: opacity 0.4s ease, background 0.4s ease;
    font-weight: 500;
}
.spider-analysis-panel {
    background: rgba(74,222,128,0.07);
    border-left: 3px solid #4ade80;
    color: rgba(255,255,255,0.82);
}
.spider-analysis-panel em { font-style: italic; color: rgba(74,222,128,0.65); }
.spider-strategy-panel {
    background: rgba(250,204,21,0.07);
    border-left: 3px solid #facc15;
    color: rgba(255,255,255,0.82);
}
.spider-strategy-panel .strategy-text { color: rgba(255,255,255,0.75); }
.spider-analysis-panel .panel-label,
.spider-strategy-panel .panel-label {
    font-size: 0.62rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.09em;
    margin-bottom: 4px; opacity: 0.65;
}

.ai-processing-badge {
    display: inline-flex; align-items: center; gap: 4px;
    margin-left: 6px;
    opacity: 0; transform: translateX(-4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    vertical-align: middle;
}
.ai-processing-badge.active { opacity: 1; transform: translateX(0); }
.ai-processing-badge .ai-badge-dots { display: flex; gap: 2px; }
.ai-processing-badge .ai-badge-dots span {
    width: 5px; height: 5px; border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74,222,128,0.6);
    animation: aiDotPulse 1.2s ease-in-out infinite;
}
.ai-processing-badge .ai-badge-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-processing-badge .ai-badge-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiDotPulse {
    0%, 80%, 100% { opacity: 0.4; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.3); }
}
.ai-processing-badge .ai-badge-label {
    font-size: 0.52rem; font-weight: 700;
    color: #4ade80;
    text-transform: uppercase; letter-spacing: 0.12em;
    text-shadow: 0 0 8px rgba(74,222,128,0.4);
}

.spider-chart-top { width: 100%; display: flex; gap: 14px; }
.spider-canvas-wrap { flex: 1; min-width: 0; }
.spider-canvas-wrap canvas { width: 100%; height: auto; }

.chapter-panel {
    width: 156px; flex-shrink: 0;
    border-left: 1px solid rgba(255,255,255,0.09);
    padding: 8px 0 8px 14px;
    display: flex; flex-direction: column; gap: 4px;
}
.chapter-panel-title {
    font-size: 0.68rem; font-weight: 700;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase; letter-spacing: 0.07em;
    margin-bottom: 6px;
}
.chapter-entry {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.75);
    line-height: 1.4;
    padding: 5px 7px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.chapter-entry.show { opacity: 1; transform: translateY(0); }
.chapter-entry .chapter-plus { color: #4ade80; font-weight: 700; }

.spider-demo-note {
    width: 100%;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.55);
    text-align: center;
    margin-top: 12px;
    padding: 11px 14px;
    line-height: 1.6;
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: 10px;
}
.spider-demo-note strong { color: #4ade80; font-weight: 700; }

/* ── Chat card (light) ──────────────────────────────────────── */
.chat-preview {
    position: relative; z-index: 1;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    overflow: hidden;
    box-shadow: var(--chat-shadow);
    display: flex; flex-direction: column;
    color: var(--chat-ink);
}
.chat-preview-header {
    padding: 15px 18px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--chat-line);
    background: var(--chat-bg);
    transition: background 0.6s ease;
}
.chat-preview-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #15694a, #1a8a5e);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 800; color: #fff;
    flex-shrink: 0;
    transition: background 0.5s ease;
}
.chat-preview-info { min-width: 0; }
.chat-preview-info h4 { font-size: 0.9rem; font-weight: 700; margin: 0; line-height: 1.2; transition: opacity 0.3s; color: var(--chat-ink); }
.chat-preview-info span {
    font-size: 0.7rem; color: var(--chat-accent);
    display: flex; align-items: center; gap: 4px;
    transition: opacity 0.3s;
}
.chat-preview-info span::before {
    content: ''; width: 5px; height: 5px;
    background: var(--chat-accent); border-radius: 50%;
}
.chat-preview-body {
    padding: 20px;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex; flex-direction: column; gap: 6px;
}
.chat-preview-body::-webkit-scrollbar { width: 4px; }
.chat-preview-body::-webkit-scrollbar-track { background: transparent; }
.chat-preview-body::-webkit-scrollbar-thumb { background: #d5cfc2; border-radius: 4px; }

.chat-scroll-btn {
    position: absolute;
    bottom: 74px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--chat-accent);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 10;
    white-space: nowrap;
}
.chat-scroll-btn.visible { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.chat-scroll-btn:hover { filter: brightness(1.1); }

.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 0.85rem;
    line-height: 1.55;
    opacity: 0;
    transform: translateY(12px);
    animation: chatMsgIn 0.4s ease forwards;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
@keyframes chatMsgIn { to { opacity: 1; transform: translateY(0); } }
.chat-msg.bot {
    align-self: flex-start;
    background: var(--chat-bubble);
    border: 1px solid var(--chat-line);
    border-radius: 4px 16px 16px 16px;
    color: var(--chat-ink);
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--chat-accent);
    border-radius: 16px 4px 16px 16px;
    color: #fff;
}
.chat-msg .msg-label {
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 4px; opacity: 0.6;
}
.chat-msg.user .msg-label { color: rgba(255,255,255,0.7); }
.chat-msg.bot .msg-label { color: var(--chat-dim); }

.chat-typing {
    padding: 14px 20px;
    display: flex; gap: 5px; align-items: center;
    opacity: 0;
    animation: chatMsgIn 0.3s ease forwards;
}
.chat-typing.bot {
    align-self: flex-start;
    background: var(--chat-bubble);
    border: 1px solid var(--chat-line);
    border-radius: 4px 16px 16px 16px;
}
.chat-typing.student {
    align-self: flex-end;
    background: var(--chat-accent);
    border-radius: 16px 4px 16px 16px;
}
.chat-typing .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--chat-dim);
    animation: typingDot 1.4s ease-in-out infinite;
}
.chat-typing.student .dot { background: rgba(255,255,255,0.6); }
.chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.chat-divider {
    text-align: center;
    font-size: 0.68rem;
    color: var(--chat-dim);
    padding: 8px 0;
    opacity: 0;
    animation: chatMsgIn 0.4s ease forwards;
}
.chat-divider span {
    background: var(--chat-bg);
    padding: 2px 12px;
    border-radius: 100px;
    border: 1px solid var(--chat-line);
}
.chat-join-notice {
    text-align: center;
    font-size: 0.7rem;
    color: var(--chat-dim);
    padding: 10px 0 4px;
    opacity: 0;
    animation: chatMsgIn 0.5s ease forwards;
}
.chat-join-notice .join-inner {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--chat-bubble);
    padding: 5px 14px;
    border-radius: 100px;
    border: 1px solid var(--chat-line);
}
.chat-join-notice .join-dot {
    width: 6px; height: 6px; border-radius: 50%;
    display: inline-block;
}

.chat-inline-chart {
    max-width: 85%;
    align-self: flex-start;
    padding: 8px;
    opacity: 0;
    animation: chatMsgIn 0.5s ease forwards;
}
.chat-inline-chart canvas {
    border-radius: 12px;
    border: 1px solid var(--chat-line);
    background: var(--chat-bg);
}
.chat-inline-chart .chart-container {
    background: var(--chat-bg);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--chat-line);
    position: relative;
    width: 320px;
    max-width: 100%;
}
.chat-inline-chart .chart-title {
    font-size: 0.78rem; font-weight: 700;
    color: var(--chat-ink);
    margin-bottom: 10px; text-align: center;
}
.chat-inline-chart .chart-container canvas {
    max-height: 220px; height: 200px; width: 100%;
    display: block; border: none;
}

.chat-fake-input {
    padding: 10px 14px;
    border-top: 1px solid var(--chat-line);
    background: var(--chat-bg);
    display: flex; align-items: flex-end; gap: 10px;
}
.chat-fake-input-field {
    flex: 1;
    background: var(--chat-bubble);
    border: 1px solid var(--chat-line);
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 0.82rem;
    color: var(--chat-ink);
    font-family: inherit;
    min-height: 18px;
    max-height: calc(18px * 2 + 9px * 2);
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    line-height: 18px;
}
.chat-fake-input-field::after {
    content: '';
    display: inline-block;
    width: 1.5px; height: 14px;
    background: var(--chat-accent);
    vertical-align: middle;
    margin-left: 1px;
    animation: fakeCursor 1s step-end infinite;
    opacity: 0;
}
.chat-fake-input-field.typing::after { opacity: 1; }
@keyframes fakeCursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.chat-fake-send {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--chat-accent);
    border: none; cursor: default;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.4;
    transition: opacity 0.2s;
    pointer-events: none;
}
.chat-fake-send.ready { opacity: 1; pointer-events: auto; cursor: pointer; animation: sendPulse 1s ease-in-out infinite; }
@keyframes sendPulse {
    0%, 100% { transform: scale(1); box-shadow: none; }
    50% { transform: scale(1.12); box-shadow: 0 0 8px rgba(var(--chat-accent-rgb), 0.5); }
}
.chat-fake-send svg { width: 14px; height: 14px; fill: #fff; }

.chat-header-controls { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.lang-selector-wrap { position: relative; display: inline-block; }
.lang-selector {
    appearance: none; -webkit-appearance: none;
    background: var(--chat-bubble); border: 1px solid var(--chat-line);
    color: var(--chat-ink); font-size: 0.72rem; padding: 5px 22px 5px 8px;
    border-radius: 8px; cursor: pointer; font-weight: 500;
    height: 28px; line-height: 1;
}
.lang-selector:hover { background: var(--chat-line); }
.lang-selector option { color: #333; background: #fff; }
.lang-selector-wrap::after {
    content: '▾'; position: absolute; right: 7px; top: 50%;
    transform: translateY(-50%); color: var(--chat-dim);
    font-size: 0.6rem; pointer-events: none;
}
.chat-pause-btn {
    background: var(--chat-accent); border: 1px solid var(--chat-accent);
    color: #fff; font-size: 0.72rem; padding: 5px 10px;
    border-radius: 8px; cursor: pointer; font-weight: 600;
    display: flex; align-items: center; gap: 4px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap; height: 28px; line-height: 1;
}
.chat-pause-btn:hover { background: var(--chat-accent-hover); border-color: var(--chat-accent-hover); }
.chat-pause-btn.paused { background: var(--chat-accent); color: #fff; border-color: var(--chat-accent); }
.chat-pause-btn.paused:hover { background: var(--chat-accent-hover); }

/* ── CJK font-size boost ────────────────────────────────────── */
.lang-zh .chat-msg { font-size: 0.95rem; line-height: 1.65; }
.lang-zh .chat-msg .msg-label { font-size: 0.7rem; }
.lang-zh .spider-analysis-panel,
.lang-zh .spider-strategy-panel { font-size: 0.82rem; line-height: 1.75; }
.lang-zh .spider-analysis-panel .panel-label,
.lang-zh .spider-strategy-panel .panel-label { font-size: 0.67rem; }
.lang-zh .spider-demo-note { font-size: 0.83rem; line-height: 1.75; }
.lang-zh .chapter-panel-title { font-size: 0.76rem; }
.lang-zh .chapter-entry { font-size: 0.73rem; }
.lang-zh .spider-chart-container .spider-title { font-size: 0.9rem; }
.lang-zh .chat-preview-info h4 { font-size: 0.95rem; }

/* ── Demo responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .live-demo-inner { grid-template-columns: 1fr; }
    .spider-chart-top { display: none; }
    .spider-chart-container { padding: 16px 18px; }
    .chat-preview { height: 460px; min-height: 0; }
}
@media (max-width: 768px) {
    .live-demo { padding: 90px 20px 96px; }
    .spider-analysis-bar { flex-direction: column; gap: 8px; }
    .chat-preview { height: 420px; min-height: 0; }
}
@media (max-width: 480px) {
    .chat-preview { height: 380px; }
}
