/* 游玩页视觉体系：移植旧站设计语言（暖橙用户气泡 / 半透明白 AI 卡 / 金橙对话高亮）
   并升级：hover 才出现的操作按钮、消息入场动画、流式光标、脉动状态点。 */

:root[data-theme="dark"] {
    --hy-user-bubble: rgba(255, 142, 60, .14);
    --hy-user-border: rgba(255, 142, 60, .28);
    --hy-user-text: #ffc76c;
    --hy-bot-bubble: rgba(255, 255, 255, .05);
    --hy-bot-border: rgba(255, 255, 255, .08);
    --hy-quote: #e18a24;          /* 对话金橙（旧站 SmartThemeQuoteColor） */
    --hy-quote-ref: #9fb4d8;      /* 『引用』灰蓝 */
    --hy-whisper: #9aa3b5;        /* *低语* 灰 */
    --hy-emphasis: #80d9ff;       /* _强调_ 天蓝（旧站 UnderlineColor） */
    --hy-greeting: #e18a24;
}

:root[data-theme="light"] {
    --hy-user-bubble: rgba(216, 109, 51, .11);
    --hy-user-border: rgba(216, 109, 51, .25);
    --hy-user-text: #b4571d;
    --hy-bot-bubble: rgba(255, 255, 255, .92);
    --hy-bot-border: rgba(67, 48, 76, .14);
    --hy-quote: #ad572c;
    --hy-quote-ref: #5a6e94;
    --hy-whisper: #6b7280;
    --hy-emphasis: #187da2;
    --hy-greeting: #ad572c;
}

/* ---------- 布局 ---------- */

.play-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--hy-space-4);
    min-height: calc(100dvh - var(--hy-topbar-h) - var(--hy-space-6) - var(--hy-space-5));
}

.play-sessions { display: none; }

.play-main {
    display: flex;
    flex-direction: column;
    background: var(--hy-bg-soft);
    border: 1px solid var(--hy-border);
    border-radius: var(--hy-radius-lg);
    overflow: hidden;
    height: calc(100dvh - var(--hy-topbar-h) - var(--hy-space-6) - var(--hy-space-5));
}

.play-head {
    display: flex;
    align-items: center;
    gap: var(--hy-space-3);
    padding: var(--hy-space-3) var(--hy-space-4);
    border-bottom: 1px solid var(--hy-border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--hy-surface) 60%, transparent), transparent);
}

.play-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.play-status { font-size: 12px; color: var(--hy-text-faint); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }

.play-status.busy { color: var(--hy-accent); }
.play-status.busy::before {
    content: "";
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--hy-accent);
    animation: hy-pulse 1.1s ease-in-out infinite;
}

@keyframes hy-pulse { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }

/* ---------- 剧情流 ---------- */

.play-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--hy-space-4) var(--hy-space-3);
    display: flex;
    flex-direction: column;
    gap: var(--hy-space-3);
    scrollbar-width: thin;
    scrollbar-color: var(--hy-border) transparent;
}

.play-messages::-webkit-scrollbar { width: 6px; }
.play-messages::-webkit-scrollbar-thumb { background: var(--hy-border); border-radius: 3px; }

.play-msg { animation: hy-msg-in .28s ease both; }

@keyframes hy-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* AI 剧情卡：近全宽 */
.play-msg.assistant {
    align-self: stretch;
    max-width: min(100%, 860px);
    background: var(--hy-bot-bubble);
    border: 1px solid var(--hy-bot-border);
    border-radius: var(--hy-radius-md);
    padding: 10px 14px 8px;
    font-size: 15px;
    line-height: 1.86;
}

/* 开场叙事 */
.play-msg.greeting { border-color: color-mix(in srgb, var(--hy-greeting) 30%, transparent); background: color-mix(in srgb, var(--hy-greeting) 7%, var(--hy-bot-bubble)); }

.msg-greeting-label {
    font-size: 11px;
    color: var(--hy-greeting);
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.msg-content { white-space: pre-wrap; word-break: break-word; }

/* 对话高亮 / 引用 / 低语 / 强调 */
.st-dialogue { color: var(--hy-quote); font-weight: 500; }
.st-dialogue.st-open { color: var(--hy-quote); }
.st-quote { color: var(--hy-quote-ref); }
.st-whisper { color: var(--hy-whisper); }
.st-underline { color: var(--hy-emphasis); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--hy-emphasis) 55%, transparent); }

/* 流式光标 */
.st-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -0.15em;
    background: var(--hy-accent);
    animation: hy-caret .9s steps(2) infinite;
}

@keyframes hy-caret { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* 阶段提示 */
.phase-hint { color: var(--hy-text-muted); font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }

.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--hy-accent); animation: hy-dot 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes hy-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* meta 与操作 */
.msg-meta-info { margin-top: 6px; font-size: 11px; color: var(--hy-text-faint); }

.msg-actions {
    display: flex;
    gap: var(--hy-space-2);
    margin-top: 4px;
    opacity: 0;
    transition: opacity var(--hy-transition);
}

.play-msg:hover .msg-actions, .play-msg:focus-within .msg-actions { opacity: 1; }

.msg-action {
    border: none;
    background: none;
    color: var(--hy-text-faint);
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 6px;
    transition: color var(--hy-transition), background var(--hy-transition);
}

.msg-action:hover { color: var(--hy-accent); background: color-mix(in srgb, var(--hy-accent) 10%, transparent); }

/* 用户气泡 */
.play-msg.user {
    align-self: flex-end;
    max-width: 76%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.play-msg.user .play-bubble {
    background: var(--hy-user-bubble);
    border: 1px solid var(--hy-user-border);
    color: var(--hy-user-text);
    border-radius: var(--hy-radius-md);
    border-bottom-right-radius: 4px;
    padding: 8px 13px 7px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.play-msg-time { font-size: 10px; color: var(--hy-text-faint); }

.play-error-text { color: var(--hy-danger); font-size: 13px; }

/* 空态欢迎 */
.play-welcome {
    margin: auto;
    text-align: center;
    padding: var(--hy-space-7) var(--hy-space-4);
}

.play-welcome-icon { font-size: 44px; margin-bottom: var(--hy-space-3); }

/* ---------- 输入区 ---------- */

.play-input { padding: var(--hy-space-3); border-top: 1px solid var(--hy-border); background: var(--hy-surface); }

.play-input-inner {
    display: flex;
    align-items: flex-end;
    gap: var(--hy-space-2);
    background: var(--hy-bg);
    border: 1px solid var(--hy-border);
    border-radius: 22px;
    padding: 6px 6px 6px 16px;
    transition: border-color var(--hy-transition), box-shadow var(--hy-transition);
}

.play-input-inner:focus-within {
    border-color: var(--hy-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hy-accent) 15%, transparent);
}

.play-input textarea {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    outline: none;
    padding: 8px 0;
    max-height: 140px;
    font-size: 15px;
    line-height: 1.5;
}

.play-send-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--hy-accent), color-mix(in srgb, var(--hy-accent) 60%, #7c6cf0));
    transition: transform var(--hy-transition), opacity var(--hy-transition), box-shadow var(--hy-transition);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--hy-accent) 35%, transparent);
}

.play-send-btn svg { width: 17px; height: 17px; }
.play-send-btn:hover { transform: translateY(-1px); }
.play-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.play-send-btn.busy { animation: hy-pulse 1.1s infinite; }

.btn-stop {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 18px;
    border-color: var(--hy-danger);
    color: var(--hy-danger);
    background: color-mix(in srgb, var(--hy-danger) 8%, transparent);
    padding: 8px 14px;
}

.stop-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--hy-danger); }

/* ---------- 会话列表（桌面左栏） ---------- */

.play-sessions {
    background: var(--hy-bg-soft);
    border: 1px solid var(--hy-border);
    border-radius: var(--hy-radius-lg);
    overflow: hidden;
    height: calc(100dvh - var(--hy-topbar-h) - var(--hy-space-6) - var(--hy-space-5));
}

.play-sessions-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--hy-space-3) var(--hy-space-4);
    border-bottom: 1px solid var(--hy-border);
    font-weight: 600;
}

.play-session-list { overflow-y: auto; height: calc(100% - 53px); padding: var(--hy-space-2); }

.play-session-item {
    display: flex;
    align-items: center;
    gap: var(--hy-space-3);
    padding: var(--hy-space-2) var(--hy-space-3);
    border-radius: var(--hy-radius-md);
    cursor: pointer;
    transition: background var(--hy-transition);
}

.play-session-item:hover { background: var(--hy-surface-2); }

.play-session-item.active {
    background: var(--hy-surface-2);
    box-shadow: inset 3px 0 0 var(--hy-accent);
}

.psi-emoji {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 18px;
    background: var(--hy-surface);
    border: 1px solid var(--hy-border);
    border-radius: 10px;
}

.psi-main { flex: 1; min-width: 0; }

.psi-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psi-sub { font-size: 11px; color: var(--hy-text-faint); }

@media (min-width: 900px) {
    .play-layout { grid-template-columns: 280px 1fr; }
    .play-sessions { display: flex; flex-direction: column; }
    #play-list-btn { display: none; }
}
