/* ============================================================
 * 星球计划 - 首屏样式
 * 结构：顶部极简导航 → 上层对话 → 下层「家宅大赏」横向展示带
 * 三套视觉主题：mist（晨雾白，默认）/ sky（淡蓝天）/ sun（暖阳米）
 * ============================================================ */

:root {
    --bg: #f7f9fc;
    --bg-band-top: #ffffff;
    --bg-band-bottom: #edf3fb;
    --surface: #ffffff;
    --ink: #1a2230;
    --ink-2: #67738a;
    --ink-3: #9aa5b7;
    --line: rgba(24, 48, 92, 0.09);
    --accent: #2f6bff;
    --accent-ink: #ffffff;
    --accent-soft: #e9f0ff;
    --shadow-card: 0 22px 48px -22px rgba(20, 45, 90, 0.42);
    --shadow-soft: 0 8px 24px -14px rgba(20, 45, 90, 0.35);
    --radius: 18px;
}

/* 方案 A：晨雾白（默认） —— 干净、克制、留白最多 */
[data-theme="mist"] {
    --bg: #f7f9fc;
    --bg-band-top: #ffffff;
    --bg-band-bottom: #edf3fb;
    --accent: #2f6bff;
    --accent-soft: #e9f0ff;
}

/* 方案 B：淡蓝天 —— 天空感，与户外家宅题材最契合 */
[data-theme="sky"] {
    --bg: #eef7ff;
    --bg-band-top: #f6fbff;
    --bg-band-bottom: #dceefd;
    --accent: #0b8fdc;
    --accent-soft: #e0f3ff;
    --ink: #14263a;
}

/* 方案 C：暖阳米 —— 温度感强，偏「家的暖」 */
[data-theme="sun"] {
    --bg: #fdf8f1;
    --bg-band-top: #fffdf9;
    --bg-band-bottom: #f6ebdb;
    --accent: #d1743c;
    --accent-soft: #fdeee2;
    --ink: #2b2117;
    --ink-2: #7a6a58;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC',
        'Hiragino Sans GB', 'Microsoft YaHei', 'Segoe UI', sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    transition: background 0.4s ease;
}

body {
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

button, input { font-family: inherit; }

/* ============ 顶部导航 ============ */
.topbar {
    flex: 0 0 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: transparent;
    position: relative;
    z-index: 100;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: rgba(20, 45, 90, 0.06); }
.icon-btn:active { transform: scale(0.96); }

.brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--ink);
}

/* ============ 舞台 ============ */
.stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ============ 上层：对话 ============ */
.talk {
    flex: 0 1 auto;
    max-height: 50vh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 20px 12px;
    overflow: hidden;
}

.greet-block { flex: 0 0 auto; }

.greet {
    font-size: 30px;
    line-height: 1.22;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--ink);
}
.greet-sub {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink-2);
}

.chips {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    padding: 8px 13px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink-2);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.22s;
}
.chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

/* 对话线程 */
.thread {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
    scrollbar-width: none;
    scroll-behavior: smooth;
}
.thread::-webkit-scrollbar { display: none; }

.bubble {
    max-width: 86%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.62;
    white-space: pre-wrap;
    word-break: break-word;
    animation: rise 0.28s ease both;
}
@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.bubble-user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-ink);
    border-bottom-right-radius: 5px;
}
.bubble-ai {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
    border-bottom-left-radius: 5px;
    color: var(--ink);
}

.typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
}
.typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ink-3);
    animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* 输入胶囊 */
.composer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
}
.composer input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13.5px;
    color: var(--ink);
    padding: 8px 0;
}
.composer input::placeholder { color: var(--ink-3); }

.send {
    width: 36px; height: 36px;
    flex: 0 0 auto;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.18s, opacity 0.2s;
}
.send:hover { transform: scale(1.05); }
.send:active { transform: scale(0.94); }
.send:disabled { opacity: 0.45; cursor: default; }

/* ============ 状态卡（生成队列） ============ */
.status-slot { flex: 0 0 auto; }

.status-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 11px 14px;
    animation: rise 0.3s ease both;
}

.sc-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}
.sc-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex: 0 0 auto;
}
.status-card[data-state="queued"] .sc-dot { animation: pulse 1.4s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}
.sc-eta {
    margin-left: auto;
    font-size: 12px;
    font-weight: 400;
    color: var(--ink-2);
}
/* 服务重启后自动重跑的极简标记：只用一个 ↻ 图标，不增加文案负担 */
.sc-badge {
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 11px;
    color: var(--ink-3);
    background: rgba(47, 107, 255, 0.08);
    white-space: nowrap;
}
.sc-bar {
    height: 4px;
    border-radius: 4px;
    background: rgba(20, 45, 90, 0.08);
    margin: 10px 0 8px;
    overflow: hidden;
}
.sc-bar i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 1s linear;
}
.sc-sub {
    font-size: 11.5px;
    color: var(--ink-3);
    line-height: 1.5;
}
.sc-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.sc-actions button {
    flex: 1;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink-2);
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s;
}
.sc-actions button:hover { color: var(--ink); background: rgba(20, 45, 90, 0.05); }
.sc-actions button.primary {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
    font-weight: 500;
}
.sc-actions button.primary:hover { filter: brightness(1.06); }

/* ============ 下层：家宅大赏 ============ */
.showcase {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 4px 0 10px;
    background: linear-gradient(180deg, var(--bg-band-top) 0%, var(--bg-band-bottom) 100%);
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
}

.showcase-head {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 20px 8px;
}
.showcase-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
}
.showcase-tip {
    margin-left: auto;
    font-size: 11px;
    color: var(--ink-3);
}

.showcase-viewport {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    perspective: 1300px;
    perspective-origin: 50% 45%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.showcase-viewport::-webkit-scrollbar { display: none; }

.showcase-track {
    height: 100%;
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 2px 20px 6px;
    will-change: transform;
}

.card {
    position: relative;
    flex: 0 0 auto;
    height: 100%;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius);
    overflow: hidden;
    background: #dfe8f4;
    box-shadow: var(--shadow-card);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.card-media {
    position: absolute;
    inset: -5%;
    will-change: transform;
    animation: cardDrift 24s ease-in-out infinite alternate;
}

@keyframes cardDrift {
    from { transform: scale(1.01) translate3d(-1.2%, 0.6%, 0); }
    to   { transform: scale(1.09) translate3d(1.2%, -0.8%, 0); }
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scale(1.04);
    will-change: transform;
    pointer-events: none;
}

/* 桌面端悬停微反馈（移动端无 hover，不影响触控） */
@media (hover: hover) {
    .card {
        transition: box-shadow 0.25s ease;
    }
    .card:hover {
        box-shadow: 0 26px 50px -20px rgba(30, 55, 95, 0.42);
    }
}

@media (prefers-reduced-motion: reduce) {
    .card-media { animation: none; transform: scale(1.02); }
}

.card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

.card-name {
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 6px rgba(20, 40, 70, 0.45);
    letter-spacing: 0.5px;
    pointer-events: none;
}

.like {
    position: absolute;
    left: 10px;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #3d4859;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.18s, background 0.2s, color 0.2s;
}
.like:hover { transform: scale(1.06); }
.like svg { width: 14px; height: 14px; }
.like.liked { color: #e2405b; background: rgba(255, 255, 255, 0.92); }
.like.pop svg { animation: heartPop 0.42s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes heartPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.showcase-fade {
    position: absolute;
    top: 38px;
    bottom: 10px;
    width: 26px;
    pointer-events: none;
    z-index: 2;
}
.showcase-fade.left { left: 0; background: linear-gradient(90deg, var(--bg-band-bottom), transparent); }
.showcase-fade.right { right: 0; background: linear-gradient(270deg, var(--bg-band-bottom), transparent); }

/* ============ 侧边栏 ============ */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 84vw;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
}
.sidebar.open { transform: translateX(0); }

.sidebar-header { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.sidebar-brand { font-size: 15px; font-weight: 600; letter-spacing: 1px; }

.btn-new-chat {
    margin: 14px 12px 4px;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.sidebar-section-title { font-size: 11.5px; color: var(--ink-3); padding: 14px 16px 6px; }

.history-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.history-empty { font-size: 12px; color: var(--ink-3); text-align: center; padding: 22px 0; }

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.15s;
}
.history-item:hover { background: rgba(20, 45, 90, 0.05); }
.history-item.active { background: var(--accent-soft); }
.history-item .h-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .h-del {
    border: none; background: none; color: var(--ink-3);
    cursor: pointer; padding: 2px 4px; visibility: hidden;
}
.history-item:hover .h-del { visibility: visible; }

.sidebar-footer {
    border-top: 1px solid var(--line);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
}
.user-info { min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; }
.user-desc { font-size: 11px; color: var(--ink-3); }

.sidebar-mask {
    position: fixed; inset: 0;
    background: rgba(15, 30, 60, 0.28);
    opacity: 0; pointer-events: none;
    transition: opacity 0.26s;
    z-index: 150;
}
.sidebar-mask.show { opacity: 1; pointer-events: auto; }

/* ============ 3D 预览弹层（可选能力） ============ */
.viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}
.viewer-modal[hidden] { display: none; }
.viewer-bar {
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 18px;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
}
.viewer-modal iframe { flex: 1 1 auto; width: 100%; border: none; }

/* ============ 桌面端 ============ */
@media (min-width: 900px) {
    .talk { max-height: 42vh; padding: 8px 36px 14px; }
    .greet { font-size: 34px; }
    .showcase-head { padding: 12px 36px 10px; }
    .showcase-track { padding: 2px 36px 8px; gap: 16px; }
    .showcase-fade { width: 34px; }
}

/* 小屏高度不足时进一步压缩上层 */
@media (max-height: 680px) {
    .greet { font-size: 25px; }
    .greet-sub { display: none; }
    .chips { margin-top: 10px; }
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
    .card img { transform: none !important; }
    .card { transform: none !important; }
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
