/* ============================================================
   千禧梦 · 构成主义聊天 — 样式表 v3
   风格：El Lissitzky 式构成主义宣传画
   布局：浮动侧边栏 + 两栏（对话 | 桌宠）
   ============================================================ */

/* -------------------- 基础重置 -------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --red:        #D62828;
    --red-glow:   #E84040;
    --red-dark:   #B01E1E;
    --black:      #1A1A1A;
    --cream:      #F5F0E6;
    --cream-warm: #FFF8F0;
    --white:      #FFFFFF;
    --indigo:     #6366F1;
    --indigo-dim: #4B4FC7;
    --gray:       #6B6B6B;
    --gray-light: #AAAAAA;

    /* 布局尺寸 */
    --sidebar-width: 260px;
    --sidebar-collapsed: 48px;
    --pet-width: 220px;
}

html {
    height: 100%;
    /* 像素十字准星 — 红+黑描边 */
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Crect x='9' y='2' width='2' height='16' fill='%23D62828'/%3E%3Crect x='2' y='9' width='16' height='2' fill='%23D62828'/%3E%3Crect x='9' y='1' width='2' height='1' fill='%231A1A1A'/%3E%3Crect x='9' y='18' width='2' height='1' fill='%231A1A1A'/%3E%3Crect x='1' y='9' width='1' height='2' fill='%231A1A1A'/%3E%3Crect x='18' y='9' width='1' height='2' fill='%231A1A1A'/%3E%3C/svg%3E") 10 10, crosshair;
}

body {
    font-family: 'Arial Black', 'Impact', 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
    background: var(--cream);
    color: var(--black);
    height: 100vh;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* -------------------- 背景层 -------------------- */

.bg-stripes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 56px,
        rgba(214,40,40,0.035) 56px,
        rgba(214,40,40,0.035) 58px
    );
}



.radial-ring {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    width: 280px;
    height: 280px;
    border: 3px solid var(--black);
    border-radius: 50%;
    opacity: 0.07;
    bottom: -80px;
    right: -80px;
    transition: transform 0.6s ease;
}

/* ============================================================
   侧边栏 — 浮动可折叠
   ============================================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--black);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 6px solid var(--red);
    box-shadow: 4px 0 12px rgba(0,0,0,0.25);
}

/* 折叠态 */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
    clip-path: none;
}
.sidebar.collapsed .sidebar-header {
    padding: 16px 8px 12px;
    justify-content: center;
}
.sidebar.collapsed .sidebar-title {
    display: none;
}
.sidebar.collapsed .sidebar-close {
    display: none;
}
.sidebar.collapsed .session-list {
    display: none;
}
.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
    border-bottom: 3px solid var(--red);
}
.sidebar-title {
    font-size: 18px;
    font-weight: 900;
    color: var(--cream);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.sidebar-close {
    width: 32px;
    height: 32px;
    background: var(--red);
    border: none;
    color: var(--cream);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.25s ease;
}
.sidebar-close:hover {
    background: var(--indigo);
    transform: rotate(90deg);
}

.session-list {
    flex: 1;
    list-style: none;
    padding: 8px 0;
    overflow-y: auto;
}
.session-list::-webkit-scrollbar { width: 6px; }
.session-list::-webkit-scrollbar-track { background: transparent; }
.session-list::-webkit-scrollbar-thumb {
    background: rgba(245,240,230,0.12);
    border-radius: 3px;
}

.session-item {
    display: flex;
    align-items: center;
    padding: 10px 16px 10px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
    border-left: 3px solid transparent;
}
.session-item:hover {
    background: rgba(214,40,40,0.08);
    border-left-color: rgba(214,40,40,0.4);
}
.session-item.active {
    background: rgba(214,40,40,0.14);
    border-left-color: var(--red);
}
.session-item.active .session-title {
    color: var(--cream);
}

.session-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: rgba(245,240,230,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
    letter-spacing: 0.03em;
    font-family: 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
}
.session-item:hover .session-title {
    color: rgba(245,240,230,0.75);
}

.session-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    background: rgba(214,40,40,0.10);
    border: 1px solid rgba(214,40,40,0.20);
    color: rgba(245,240,230,0.45);
    font-size: 13px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.2s ease;
    border-radius: 0;
    opacity: 0.6;
}
.session-item:hover .session-delete {
    opacity: 1;
    background: rgba(214,40,40,0.18);
    border-color: rgba(214,40,40,0.35);
}
.session-delete:hover {
    color: var(--cream);
    background: var(--red);
    border-color: var(--red);
    opacity: 1;
}

.sidebar-footer {
    padding: 12px 16px 20px;
    border-top: 1px solid rgba(245,240,230,0.08);
}
.sidebar-btn {
    width: 100%;
    padding: 12px;
    background: var(--red);
    border: none;
    color: var(--cream);
    font-family: inherit;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.25s ease;
    clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 100%);
}
.sidebar-btn:hover {
    background: var(--indigo-dim);
    transform: skewX(-3deg);
}



/* ============================================================
   主区域 — 两栏布局
   ============================================================ */

.main-layout {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100%;
    height: 100vh;
    margin-left: calc(var(--sidebar-width) + 12px);
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 侧边栏折叠时，主区域左移 */
body.sidebar-is-collapsed .main-layout {
    margin-left: calc(var(--sidebar-collapsed) + 12px);
}

/* -------------------- 对话面板 -------------------- */
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--cream);
    height: 100vh;
}

/* -------------------- 顶部栏 -------------------- */
.topbar {
    background: var(--black);
    position: relative;
    clip-path: polygon(0 0, 100% 0, 100% 88%, 0 100%);
    padding-bottom: 8px;
    flex-shrink: 0;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px 14px;
}
.topbar-stripe {
    height: 5px;
    background: var(--red);
    transform: skewX(-40deg) translateX(-6px);
    width: calc(100% + 12px);
    transition: background 0.35s ease;
}

/* 品牌区 */
.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.35s ease;
}
.brand:hover {
    transform: skewX(-6deg) translateX(8px);
}

.brand-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--red);
    display: grid;
    place-items: center;
    transition: all 0.35s ease;
}
.brand:hover .brand-icon {
    background: var(--indigo);
    transform: scale(1.08);
}
.brand-icon svg {
    width: 30px;
    height: 30px;
}

.brand-text h1 {
    font-size: 28px;
    font-weight: 900;
    color: var(--cream);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1;
}
.brand-text .subtitle {
    font-size: 9px;
    font-weight: 700;
    color: rgba(245,240,230,0.42);
    letter-spacing: 0.2em;
    margin-top: 4px;
    transition: color 0.35s ease;
}
.brand:hover .subtitle {
    color: var(--red);
}

.topbar-geo {
    width: 40px;
    height: 40px;
    position: relative;
    opacity: 0.3;
    transition: all 0.5s ease;
}
.topbar-geo::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid var(--red);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    transition: all 0.5s ease;
}
.brand:hover ~ .topbar-geo,
.topbar-geo:hover {
    opacity: 0.65;
    transform: rotate(25deg) scale(1.15);
}

/* 侧边栏切换按钮 */
.btn-toggle-sidebar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 2px solid rgba(245,240,230,0.25);
    cursor: pointer;
    display: grid;
    place-items: center;
    margin-right: 8px;
    transition: all 0.3s ease;
}
.btn-toggle-sidebar:hover {
    border-color: var(--red);
    background: rgba(214,40,40,0.12);
}
.hamburger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 16px;
}
.hamburger-line {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--cream);
    transition: all 0.3s ease;
}
.btn-toggle-sidebar:hover .hamburger-line:nth-child(1) {
    transform: translateY(-1px);
}
.btn-toggle-sidebar:hover .hamburger-line:nth-child(3) {
    transform: translateY(1px);
}

/* -------------------- 对话区 -------------------- */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    background: var(--cream-warm);
    position: relative;
}

.chat-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(26,26,26,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(26,26,26,0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

.chat-area::-webkit-scrollbar { width: 10px; }
.chat-area::-webkit-scrollbar-track { background: rgba(26,26,26,0.08); }
.chat-area::-webkit-scrollbar-thumb {
    background: var(--red);
    border: 2px solid rgba(26,26,26,0.08);
}
.chat-area::-webkit-scrollbar-thumb:hover { background: var(--red-glow); }

/* -------------------- 欢迎消息 -------------------- */
.welcome {
    text-align: center;
    padding: 40px 12px 28px;
    animation: fadeSkew 0.6s ease;
}
.welcome-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}
.welcome-icon svg {
    width: 56px;
    height: 56px;
    transition: transform 0.35s ease;
}
.welcome-icon svg:hover {
    transform: skewX(-10deg) scale(1.12);
}
.welcome-glitch {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--red);
    font-weight: 900;
    animation: glitchPulse 2s infinite;
    letter-spacing: 0.08em;
}
.welcome h2 {
    font-size: 24px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 14px;
    color: var(--black);
}
.welcome p {
    font-size: 15px;
    color: var(--gray);
    line-height: 1.9;
    max-width: 480px;
    margin: 0 auto 20px;
}
.welcome-line {
    width: 80px;
    height: 4px;
    background: var(--red);
    margin: 0 auto;
    transform: skewX(-35deg);
    transition: width 0.35s ease, background 0.35s ease;
}
.welcome-line:hover {
    width: 140px;
    background: var(--indigo);
}

/* -------------------- 消息气泡 -------------------- */
.message {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    animation: fadeSkew 0.35s ease;
    align-items: flex-start;
}
.message.robot { flex-direction: row; }
.message.user   { flex-direction: row-reverse; }

.msg-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    transition: transform 0.3s ease;
}
.message.robot .msg-avatar {
    background: var(--red);
}
.message.user .msg-avatar {
    background: var(--black);
}
.msg-avatar svg {
    width: 22px;
    height: 22px;
}
.msg-avatar:hover {
    transform: skewX(-8deg) scale(1.12);
}

.msg-body {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.msg-content {
    padding: 14px 18px;
    font-size: 15px;
    line-height: 1.75;
    word-break: break-word;
    position: relative;
}

.message.robot .msg-body {
    margin-left: 12px;
}
.message.robot .msg-content {
    background: var(--white);
    color: var(--black);
    border-left: 4px solid var(--red);
    transition: border-color 0.3s ease;
}
.message.robot .msg-content:hover {
    border-left-color: var(--indigo);
}

.message.user .msg-body {
    margin-right: 12px;
}
.message.user .msg-content {
    background: var(--white);
    color: var(--black);
    border-right: 4px solid var(--indigo);
    transition: border-color 0.3s ease;
}
.message.user .msg-content:hover {
    border-right-color: var(--red);
}

.message.robot .msg-content::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 14px;
    width: 0; height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 7px solid var(--white);
}
.message.user .msg-content::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 14px;
    width: 0; height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 7px solid var(--white);
}

/* -------------------- 加载动画 -------------------- */
.loading-msg {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    animation: fadeSkew 0.25s ease;
}
.loading-avatar {
    width: 40px;
    height: 40px;
    background: var(--red);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.loading-avatar svg {
    width: 22px;
    height: 22px;
}
.loading-bars {
    display: flex;
    gap: 5px;
    margin-left: 12px;
    padding: 14px 18px;
    background: var(--white);
    border-left: 4px solid var(--red);
}
.loading-bar {
    width: 7px;
    height: 22px;
    background: var(--red);
    animation: barPulse 1.1s infinite ease-in-out;
    transform-origin: bottom;
}
.loading-bar:nth-child(1) { animation-delay: 0s; }
.loading-bar:nth-child(2) { animation-delay: 0.12s; }
.loading-bar:nth-child(3) { animation-delay: 0.24s; }
.loading-bar:nth-child(4) { animation-delay: 0.36s; }

/* -------------------- 错误提示 -------------------- */
.error-toast {
    background: var(--red);
    color: var(--cream);
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 14px;
    animation: shakeX 0.5s ease;
    border: 2px solid var(--red-dark);
    letter-spacing: 0.04em;
}

/* -------------------- 输入区 -------------------- */
.input-zone {
    background: var(--black);
    padding: 0;
    position: relative;
    clip-path: polygon(0 10%, 100% 0, 100% 100%, 0 100%);
    flex-shrink: 0;
}
.input-zone-inner {
    padding: 18px 28px 20px;
}

.input-row {
    display: flex;
    gap: 0;
}

.input-field {
    flex: 1;
    padding: 14px 18px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    border: 3px solid var(--red);
    background: var(--cream);
    color: var(--black);
    outline: none;
    transition: all 0.3s ease;
}
.input-field:focus {
    border-color: var(--indigo);
    background: var(--white);
    box-shadow: 0 0 0 6px rgba(99,102,241,0.1);
}
.input-field::placeholder {
    color: var(--gray-light);
    font-weight: 400;
    font-style: italic;
}

.btn-send {
    padding: 14px 28px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 900;
    background: var(--red);
    color: var(--cream);
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all 0.25s ease;
    white-space: nowrap;
}
.btn-send:hover {
    background: var(--indigo-dim);
    transform: skewX(-6deg) translateX(6px);
}
.btn-send:active {
    transform: skewX(-6deg) translateX(8px) scale(0.96);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.btn-clear {
    padding: 0;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    color: rgba(245,240,230,0.35);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-clear::before {
    content: '— ';
}
.btn-clear:hover {
    color: var(--red);
    transform: skewX(-6deg);
}

.input-hint {
    font-size: 10px;
    color: rgba(245,240,230,0.2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* 停止按钮 */
.btn-stop {
    padding: 14px 24px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 900;
    background: var(--red-dark);
    color: var(--cream);
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all 0.25s ease;
    white-space: nowrap;
    display: none;
}

.btn-stop:hover {
    background: var(--red);
}

.btn-send:disabled {
    background: var(--red);
    color: var(--cream);
    cursor: not-allowed;
}

/* -------------------- 消息操作栏 -------------------- */
.msg-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px 8px;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.message:hover .msg-actions {
    opacity: 1;
}
.message.robot .msg-actions {
    border-top: 1px solid rgba(26,26,26,0.06);
}
.message.user .msg-actions {
    border-top: 1px solid rgba(99,102,241,0.1);
    justify-content: flex-end;
}
.msg-action-btn {
    background: none;
    border: none;
    font-family: 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-light);
    cursor: pointer;
    padding: 1px 4px;
    letter-spacing: 0.04em;
    transition: all 0.2s ease;
    text-transform: uppercase;
}
.msg-action-btn:hover {
    color: var(--red);
}
.msg-action-btn.copied {
    color: var(--indigo);
}
.msg-time {
    font-size: 10px;
    color: rgba(107,107,107,0.4);
    font-weight: 400;
    letter-spacing: 0.05em;
    margin-left: auto;
}

/* -------------------- Markdown 渲染 -------------------- */
.msg-content p {
    margin: 0 0 8px;
}
.msg-content p:last-child {
    margin-bottom: 0;
}
.msg-content ul, .msg-content ol {
    margin: 4px 0 8px 18px;
    padding: 0;
}
.msg-content li {
    margin-bottom: 2px;
}
.msg-content strong {
    font-weight: 900;
}
.msg-content em {
    font-style: italic;
}
.msg-content a {
    color: var(--indigo);
    text-decoration: underline;
}
.msg-content a:hover {
    color: var(--red);
}
.msg-content blockquote {
    border-left: 3px solid var(--red);
    margin: 8px 0;
    padding: 4px 12px;
    color: var(--gray);
    background: rgba(214,40,40,0.04);
}
.msg-content hr {
    border: none;
    border-top: 2px solid rgba(26,26,26,0.1);
    margin: 12px 0;
}
.msg-content table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
    width: 100%;
}
.msg-content th, .msg-content td {
    border: 1px solid rgba(26,26,26,0.15);
    padding: 6px 10px;
    text-align: left;
}
.msg-content th {
    background: rgba(26,26,26,0.06);
    font-weight: 900;
}

/* 代码块 */
.msg-content pre {
    position: relative;
    margin: 8px 0;
    border: 2px solid var(--black);
    background: #282c34;
    overflow-x: auto;
}
.msg-content pre code {
    display: block;
    padding: 14px 16px;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #abb2bf;
    background: none;
    border: none;
}
.msg-content code {
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 0.9em;
    background: rgba(26,26,26,0.06);
    padding: 1px 5px;
    border: 1px solid rgba(26,26,26,0.1);
}

/* 代码块复制按钮 */
.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(245,240,230,0.1);
    border: 1px solid rgba(245,240,230,0.2);
    color: rgba(245,240,230,0.5);
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all 0.2s ease;
    z-index: 2;
}
.code-copy-btn:hover {
    background: rgba(214,40,40,0.3);
    color: var(--cream);
    border-color: var(--red);
}
.code-copy-btn.copied {
    background: rgba(99,102,241,0.3);
    color: var(--cream);
    border-color: var(--indigo);
}

/* -------------------- 发布卡片 -------------------- */
.publish-card {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--cream-warm);
    border: 2px solid var(--black);
    border-left: 4px solid var(--red);
    transition: border-color 0.3s ease;
}
.publish-card:hover {
    border-left-color: var(--indigo);
}
.publish-card.loading {
    opacity: 0.6;
}
.publish-card.error {
    border-left-color: var(--red-dark);
    opacity: 0.7;
}
.publish-card-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
}
.publish-card-icon svg {
    width: 24px;
    height: 24px;
}
.publish-card-info {
    flex: 1;
    min-width: 0;
}
.publish-card-label {
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--black);
}
.publish-card-hint {
    font-size: 11px;
    color: var(--gray);
    margin-top: 2px;
}
.publish-card-url {
    font-size: 11px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    font-family: 'Courier New', monospace;
}
.publish-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.publish-card-btn {
    padding: 6px 12px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: 2px solid var(--black);
    background: var(--cream);
    color: var(--black);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}
.publish-card-btn:hover {
    background: var(--red);
    color: var(--cream);
    border-color: var(--red);
}

/* 发布下拉菜单 */
.msg-action-dropdown {
    position: relative;
    display: inline-block;
}
.msg-action-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--black);
    border: 2px solid var(--red);
    z-index: 50;
    min-width: 100px;
}
.msg-action-dropdown:hover .msg-action-menu {
    display: block;
}
.msg-action-menu button {
    display: block;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    color: var(--cream);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}
.msg-action-menu button:hover {
    background: var(--red);
}

/* ============================================================
   桌宠面板 — 右侧
   ============================================================ */

.pet-panel {
    width: var(--pet-width);
    flex-shrink: 0;
    background: var(--cream-warm);
    border-left: 3px solid var(--black);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* 网格纹理 */
.pet-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(26,26,26,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(26,26,26,0.03) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
}

/* 顶部装饰条 */
.pet-panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--red);
    transform: skewX(-20deg);
}

.pet-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
}

/* 桌宠机器人容器 */
.pet-robot {
    width: 180px;
    height: 150px;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
}
.pet-robot:hover {
    transform: scale(1.05);
}
.pet-robot:active {
    transform: scale(0.95);
}

.pet-robot svg {
    width: 100%;
    height: 100%;
}

/* 弹出的 emoji */
.pet-emoji {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pet-emoji.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-20px);
}
.pet-emoji.hide {
    opacity: 0;
    transform: translateX(-50%) translateY(-40px);
}

/* 状态文字 */
.pet-status {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-align: center;
    transition: color 0.3s ease;
}
.pet-status.active {
    color: var(--red);
}

/* 桌宠呼吸动画 */
@keyframes petBreathe {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
.pet-robot.idle {
    animation: petBreathe 3s ease-in-out infinite;
}

/* 桌宠思考动画 */
@keyframes petThink {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    75% { transform: rotate(3deg); }
}
.pet-robot.thinking {
    animation: petThink 0.8s ease-in-out infinite;
}

/* 桌宠回复动画 */
@keyframes petBounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}
.pet-robot.replying {
    animation: petBounce 0.5s ease;
}

/* ============================================================
   CRT 滤镜 / 开机动画
   ============================================================ */

.crt-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.6s ease;
}
.crt-overlay.active {
    opacity: 1;
}
.crt-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0,0,0,0.10) 0px,
        rgba(0,0,0,0.10) 1px,
        transparent 1px,
        transparent 3px
    );
}
.crt-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(255,0,0,0.015) 0%,
        transparent 25%,
        rgba(0,255,255,0.015) 75%,
        transparent 100%
    );
    mix-blend-mode: screen;
}

.crt-boot {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: var(--cream);
    animation: crtBoot 0.8s ease forwards;
}

@keyframes crtBoot {
    0% {
        opacity: 1;
        transform: scale(1.15);
        filter: brightness(8);
        background: #FFFFFF;
    }
    6% {
        opacity: 1;
        transform: scale(1.10);
        filter: brightness(6);
        background: #FFFFFF;
    }
    12% {
        opacity: 0.92;
        transform: scale(1.04);
        filter: brightness(2);
        background: var(--cream);
    }
    25% {
        opacity: 0.96;
        transform: scale(1.01);
        filter: brightness(1.2);
    }
    45% {
        opacity: 0.98;
        transform: scale(1.005);
        filter: brightness(1);
    }
    70% {
        opacity: 0.995;
    }
    100% {
        opacity: 0;
        transform: scale(1);
        filter: brightness(1);
        pointer-events: none;
    }
}

.btn-crt-toggle {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 9997;
    width: 38px;
    height: 38px;
    background: var(--black);
    border: 2px solid rgba(245,240,230,0.12);
    color: rgba(245,240,230,0.3);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 13px;
    transition: all 0.3s ease;
    clip-path: polygon(20% 0, 100% 0, 80% 100%, 0 100%);
    font-family: 'Courier New', monospace;
    font-weight: 700;
    letter-spacing: 0.05em;
    opacity: 0.4;
}
.btn-crt-toggle:hover {
    opacity: 1;
    border-color: var(--red);
    color: var(--red);
}
.btn-crt-toggle.active {
    color: var(--red);
    border-color: var(--red);
    opacity: 0.8;
}

/* ============================================================
   自定义鼠标 — 可交互元素 hover 变为小机器人头
   ============================================================ */

a, button, .btn, .btn-send, .btn-clear, .btn-toggle-sidebar,
.session-item, .sidebar-btn, .sidebar-close, .pet-robot,
.btn-crt-toggle, .session-delete {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Crect x='6' y='4' width='8' height='8' fill='%23D62828' stroke='%231A1A1A' stroke-width='1'/%3E%3Crect x='8' y='6' width='2' height='2' fill='%23F5F0E6'/%3E%3Crect x='12' y='6' width='2' height='2' fill='%23F5F0E6'/%3E%3Crect x='9' y='10' width='4' height='1' fill='%23F5F0E6'/%3E%3Cline x1='10' y1='2' x2='10' y2='4' stroke='%231A1A1A' stroke-width='1'/%3E%3Ccircle cx='10' cy='2' r='1.5' fill='%23D62828'/%3E%3C/svg%3E") 10 10, pointer;
}

/* ============================================================
   通用动画
   ============================================================ */

@keyframes fadeSkew {
    from {
        opacity: 0;
        transform: translateY(14px) skewX(-3deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) skewX(0);
    }
}

@keyframes barPulse {
    0%, 55%, 100% {
        transform: scaleY(0.35);
        opacity: 0.45;
    }
    25% {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    20%  { transform: translateX(-12px) skewX(-2deg); }
    40%  { transform: translateX(12px) skewX(2deg); }
    60%  { transform: translateX(-7px) skewX(-1deg); }
    80%  { transform: translateX(7px) skewX(1deg); }
}

@keyframes glitchPulse {
    0%, 100% { opacity: 0.3; letter-spacing: 0.08em; }
    50% { opacity: 1; letter-spacing: 0.16em; }
}

/* 流式输出光标 */
.msg-content.streaming::after {
    content: '▍';
    display: inline-block;
    animation: cursorBlink 0.7s step-end infinite;
    color: var(--red);
    font-weight: 900;
    margin-left: 2px;
}

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

/* ============================================================
   响应式
   ============================================================ */

@media (max-width: 900px) {
    :root {
        --pet-width: 160px;
    }
    .pet-robot {
        width: 110px;
        height: 110px;
    }
}

@media (max-width: 700px) {
    .pet-panel {
        display: none;
    }
    .sidebar {
        width: 220px;
    }
    :root {
        --sidebar-width: 220px;
    }
}

@media (max-width: 520px) {
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
    }
.sidebar.mobile-open {
    transform: translateX(0);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.visible {
    display: block;
}

    .main-layout {
        margin-left: 0 !important;
    }
    body.sidebar-is-collapsed .main-layout {
        margin-left: 0 !important;
    }

    .panel {
        border-left: none;
    }

    .topbar-inner {
        padding: 14px 16px 12px;
    }
    .brand-text h1 { font-size: 22px; }
    .brand-icon { width: 40px; height: 40px; }
    .brand-icon svg { width: 24px; height: 24px; }
    .topbar-geo { display: none; }

    .chat-area {
        padding: 16px;
    }
    .input-zone-inner {
        padding: 14px 16px 16px;
    }
    .input-zone {
        clip-path: polygon(0 6%, 100% 0, 100% 100%, 0 100%);
    }

    .msg-content {
        max-width: 82%;
        font-size: 14px;
        padding: 12px 14px;
    }
    .btn-send {
        padding: 14px 18px;
        font-size: 14px;
    }
    .input-field {
        font-size: 14px;
        padding: 12px 14px;
    }
}
