:root {
    --bg: #0c1018;
    --sidebar-bg: rgba(12, 16, 24, 0.96);
    --panel: rgba(15, 21, 32, 0.9);
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.04);
    --text: #f2f6fb;
    --muted: #8a96ae;
    --primary: #ff8e3c;
    --primary-soft: #ffc76c;
    --primary-dim: rgba(255, 142, 60, 0.15);
    --accent: #80d9ff;
    --accent-dim: rgba(128, 217, 255, 0.12);
    --success: #71d3a4;
    --danger: #ff7e7e;
    --SmartThemeQuoteColor: #e18a24;
    --SmartThemeEmColor: #c4c4c4;
    --SmartThemeUnderlineColor: #80d9ff;
    --user-bubble: rgba(255, 142, 60, 0.14);
    --user-border: rgba(255, 142, 60, 0.28);
    --bot-bubble: rgba(255, 255, 255, 0.05);
    --bot-border: rgba(255, 255, 255, 0.08);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --sidebar-width: 260px;
}

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

body {
    font-family: "Segoe UI", "PingFang SC", sans-serif;
    color: var(--text);
    background: var(--bg);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; }

/* ========== Topbar ========== */
.topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
    flex-wrap: nowrap;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.topbar-spacer {
    display: none;
}

.topbar-marquee-row {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
    height: 28px;
    border-radius: 14px;
    background: rgba(255, 142, 60, 0.08);
    border: 1px solid rgba(255, 142, 60, 0.15);
}

.marquee-text {
    display: block;
    white-space: nowrap;
    position: absolute;
    line-height: 28px;
    font-size: 12.5px;
    color: #ccc;
    animation: marquee-scroll var(--marquee-duration, 20s) linear infinite;
}

.topbar-marquee-row:hover .marquee-text {
    animation-play-state: paused;
}

@keyframes marquee-scroll {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* ========== Buttons ========== */
.btn-primary {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: #24160b;
    font-weight: 700;
    font-size: 14px;
    transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    transition: background 0.15s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.btn-link {
    background: none;
    color: var(--accent);
    font-size: 13px;
    padding: 4px 0;
}
.btn-link:hover { text-decoration: underline; }

.btn-close {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    font-size: 18px;
    color: var(--muted);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: all 0.15s;
}
.btn-close:hover {
    background: rgba(255,255,255,0.12);
    color: var(--text);
}

.btn-send {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    flex-shrink: 0;
}

.icon-coin {
    color: var(--primary-soft);
    margin-right: 4px;
}

.meta-chip {
    font-size: 12px;
    color: var(--muted);
    padding: 4px 10px;
    background: var(--accent-dim);
    border-radius: 99px;
    white-space: nowrap;
}

.hidden { display: none !important; }

/* ========== App body ========== */
.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.sidebar-tools .btn-ghost {
    padding: 6px 10px;
    font-size: 13px;
    flex: 1;
    text-align: center;
}

/* 用户芯片按钮 */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(255,142,60,0.12), rgba(255,142,60,0.04));
    border: 1px solid rgba(255,142,60,0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    box-sizing: border-box;
}
.user-chip:hover {
    background: linear-gradient(135deg, rgba(255,142,60,0.2), rgba(255,142,60,0.08));
    border-color: var(--primary);
    transform: scale(1.01);
}

.sidebar-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(59,130,246,0.04));
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    box-sizing: border-box;
    font-size: 13px;
    color: var(--text);
    margin-top: 8px;
}
.sidebar-action:hover {
    background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(59,130,246,0.08));
}
}
.user-chip-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #e06b20);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255,142,60,0.3);
}
.user-chip-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.user-chip-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-chip-sub {
    font-size: 11px;
    color: #8a96ae;
}
.user-chip-arrow {
    color: #666;
    font-size: 16px;
    flex-shrink: 0;
    margin-left: auto;
}

/* 设置页用户信息卡 */
.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--muted);
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.session-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.session-item.active { background: var(--primary-dim); color: var(--primary-soft); font-weight: 600; }

.session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-delete {
    background: none;
    color: var(--muted);
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}
.session-item:hover .session-delete { opacity: 1; }
.session-delete:hover { color: var(--danger); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.preset-select {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--muted);
}

.empty-hint {
    padding: 32px 12px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ========== Chat main ========== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background:
        radial-gradient(circle at 10% 20%, rgba(255, 142, 60, 0.06), transparent 30%),
        radial-gradient(circle at 90% 80%, rgba(128, 217, 255, 0.05), transparent 25%),
        var(--bg);
}

/* Welcome */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
}
.chat-welcome h2 { font-size: 22px; font-weight: 700; }
.chat-welcome p { color: var(--muted); font-size: 14px; }

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msg {
    max-width: 96%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
}

.msg-user {
    align-self: flex-end;
    background: var(--user-bubble);
    border: 1px solid var(--user-border);
    color: var(--primary-soft);
    padding: 6px 12px;
    line-height: 1.4;
    max-width: 70%;
}

.msg-assistant {
    align-self: flex-start;
    background: var(--bot-bubble);
    border: 1px solid var(--bot-border);
    padding: 8px 14px;
    line-height: 1.7;
}

.msg-user .msg-meta {
    margin-top: 2px;
}

.msg-greeting {
    border-color: rgba(225, 138, 36, 0.25);
    background: rgba(225, 138, 36, 0.06);
}

.msg-greeting-label {
    font-size: 11px;
    color: #e18a24;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.msg-gm {
    align-self: center;
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.12), rgba(59, 130, 246, 0.12));
    border: 1px solid rgba(147, 51, 234, 0.3);
    border-radius: 12px;
    padding: 10px 16px;
    margin: 4px 0;
    max-width: 90%;
    animation: gm-glow 2s ease-in-out infinite alternate;
}

.gm-label {
    font-size: 11px;
    color: #a78bfa;
    margin-bottom: 4px;
    letter-spacing: 1px;
    font-weight: 600;
}

.gm-content {
    color: #c4b5fd;
    font-size: 13.5px;
    line-height: 1.6;
}

@keyframes gm-glow {
    from { box-shadow: 0 0 6px rgba(147, 51, 234, 0.15); }
    to { box-shadow: 0 0 12px rgba(147, 51, 234, 0.3); }
}

.msg-meta {
    margin-top: -10px;
    font-size: 11px;
    color: var(--muted);
}

.msg-meta-info {
    display: block;
    margin-bottom: -10px;
    opacity: 0.6;
}

.msg-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.msg-action {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.msg-action .action-cost {
    font-size: 10px;
    opacity: 0.7;
}
.msg-action:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}
.msg-action:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.08);
    transition-duration: 0.05s;
}
.msg-action:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}
.msg-action.msg-regenerate:hover {
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}
.msg-action.msg-gen-image:hover {
    border-color: rgba(168, 85, 247, 0.4);
    color: #c084fc;
}
.msg-action.msg-copy:hover {
    border-color: rgba(74, 222, 128, 0.4);
    color: #4ade80;
}
.msg-action.msg-edit:hover {
    border-color: rgba(251, 191, 36, 0.4);
    color: #fbbf24;
}

.msg-edit-input {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
}

.msg-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--bot-bubble);
    border: 1px solid var(--bot-border);
    border-radius: var(--radius-md);
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: blink 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

/* 流式加载提示 */
.msg-streaming .msg-loading {
    color: var(--muted);
    font-size: 13px;
    padding: 4px 0;
    animation: loading-pulse 1.5s ease-in-out infinite;
}
@keyframes loading-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Input bar */
.chat-input-bar {
    padding: 12px 24px 16px;
    border-top: 1px solid var(--border);
    background: rgba(12, 16, 24, 0.6);
    flex-direction: column-reverse;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 10px;
}

#msg-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 160px;
    font-size: 14px;
    line-height: 1.5;
    padding: 2px 4px;
}

.queue-status {
    font-size: 12px;
    color: var(--muted);
    padding: 4px 10px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    background: rgba(255, 142, 60, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
}
.queue-status .queue-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse-dot 1.4s ease-in-out infinite;
}
.queue-status.idle .queue-dot { background: #4caf50; animation: none; }
@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

/* ========== Suggest Dropdown ========== */
#btn-suggest {
    position: relative;
    flex-shrink: 0;
    padding: 4px 6px;
    font-size: 18px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
#btn-suggest:hover {
    color: var(--primary-soft);
    background: rgba(255, 142, 60, 0.1);
}
.suggest-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    background: rgba(18, 24, 36, 0.98);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 50;
    min-width: 280px;
    max-width: 360px;
    padding: 8px;
}
.suggest-dropdown-header {
    padding: 4px 8px 8px;
    font-size: 12px;
    color: var(--muted);
}
.suggest-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin-bottom: 4px;
    line-height: 1.5;
}
.suggest-item:last-child { margin-bottom: 0; }
.suggest-item:hover {
    background: rgba(255, 142, 60, 0.1);
    border-color: rgba(255, 142, 60, 0.3);
}
.suggest-loading {
    padding: 16px 12px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ========== Modals ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-auth-overlay {
    background: #0c1018;
    z-index: 200;
    backdrop-filter: none;
}

.modal {
    background: rgba(18, 24, 36, 0.98);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    width: 400px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.modal-sm { width: 360px; }
.modal-box { width: 500px; max-width: 92vw; max-height: 85vh; overflow-y: auto; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    padding: 0;
}
.modal-close-btn:hover {
    background: rgba(255,255,255,0.12);
    color: var(--text);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ========== Forms ========== */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-stack input,
.form-stack select {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.form-stack input::placeholder { color: var(--muted); }

.auth-switch {
    text-align: center;
}

.feedback {
    min-height: 18px;
    font-size: 13px;
    color: var(--muted);
}
.feedback.success { color: var(--success); }
.feedback.error { color: var(--danger); }

/* ========== Wallet modal ========== */
.wallet-balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--accent-dim);
    border-radius: var(--radius-sm);
}
.wallet-balance-row strong {
    font-size: 22px;
    color: var(--accent);
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.plan-btn {
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.plan-btn:hover { border-color: var(--primary); }
.plan-btn.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
}
.plan-btn strong { display: block; font-size: 16px; color: var(--primary-soft); }
.plan-btn span { font-size: 12px; color: var(--muted); }

.pay-buttons {
    display: flex;
    gap: 10px;
}

/* ========== New Chat RPG Style ========== */
.modal-lg { width: 560px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }

.newchat-section {
    margin-bottom: 16px;
}

.section-label {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary-soft);
}

.label-hint {
    font-weight: 400;
    font-size: 12px;
    color: var(--muted);
}

/* Greeting selection cards */
.greeting-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.greeting-card {
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    position: relative;
}

.greeting-card:hover {
    border-color: rgba(255, 142, 60, 0.4);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.greeting-card.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
}

.greeting-card-icon {
    font-size: 24px;
    margin-bottom: 6px;
    display: block;
}

.greeting-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.greeting-card-preview {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.greeting-card .card-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: #24160b;
    font-size: 13px;
    font-weight: 800;
    display: none;
    place-items: center;
}

.greeting-card.selected .card-check {
    display: grid;
}

/* Specify grid */
.specify-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.specify-select {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
}

.specify-select option {
    background: #1a2232;
    color: var(--text);
}

/* Character setting */
.character-setting-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.character-setting-row textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
    color: var(--text);
}

.character-setting-row textarea::placeholder {
    color: var(--muted);
}

.character-setting-actions {
    display: flex;
    justify-content: flex-end;
}

/* ========== Ninja Identity Form ========== */
.ninja-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.ninja-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ninja-field-wide {
    grid-column: 1 / -1;
}
.ninja-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}
.ninja-field input,
.ninja-field select,
.ninja-field textarea {
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.ninja-field input:focus,
.ninja-field select:focus,
.ninja-field textarea:focus {
    border-color: var(--primary);
}
.ninja-field select option {
    background: #1a2232;
    color: var(--text);
}

/* Opening mode options */
.opening-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.opening-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.opening-option:hover {
    border-color: rgba(255, 142, 60, 0.4);
    background: rgba(255, 255, 255, 0.05);
}
.opening-option.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
}
.opening-option input[type="radio"] {
    display: none;
}
.opening-icon {
    font-size: 22px;
    flex-shrink: 0;
}
.opening-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.opening-text strong {
    font-size: 14px;
    color: var(--text);
}
.opening-text small {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}
#custom-opening-input {
    margin-top: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    width: 100%;
    resize: vertical;
    outline: none;
}
#custom-opening-input:focus {
    border-color: var(--primary);
}

/* Auth switch */
.auth-switch {
    text-align: center;
    padding-top: 8px;
}

.btn-link {
    background: none;
    color: var(--accent);
    font-size: 13px;
    padding: 4px 0;
    border: none;
    cursor: pointer;
}

.btn-link:hover { text-decoration: underline; }

.feedback {
    min-height: 18px;
    font-size: 13px;
    color: var(--muted);
}
.feedback.success { color: var(--success); }
.feedback.error { color: var(--danger); }

/* Wallet */
.wallet-balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--accent-dim);
    border-radius: var(--radius-sm);
}
.wallet-balance-row strong {
    font-size: 22px;
    color: var(--accent);
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.plan-btn {
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.plan-btn:hover { border-color: var(--primary); }
.plan-btn.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
}
.plan-btn strong { display: block; font-size: 16px; color: var(--primary-soft); }
.plan-btn span { font-size: 12px; color: var(--muted); }

.pay-buttons {
    display: flex;
    gap: 10px;
}

/* In-chat choice buttons */
.msg-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.choice-btn {
    padding: 10px 16px;
    background: rgba(255, 142, 60, 0.08);
    border: 1px solid rgba(255, 142, 60, 0.25);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-soft);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    text-align: left;
}

.choice-btn:hover {
    background: rgba(255, 142, 60, 0.18);
    border-color: var(--primary);
    transform: translateX(4px);
}

.choice-btn.chosen {
    border-color: var(--success);
    background: rgba(113, 211, 164, 0.1);
}

.choice-btn.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

/* ========== Markdown 文字美化 ========== */
.msg-content q {
    color: #e18a24;
    font-style: normal;
    quotes: none;
}
.msg-content q em, .msg-content q i { color: inherit; }

.msg-content em { color: var(--SmartThemeEmColor, #c4c4c4); font-style: italic; }

.msg-content strong { font-weight: 700; color: var(--text); }

.msg-content u { color: var(--SmartThemeUnderlineColor, #80d9ff); text-decoration: underline; }

.msg-content del, .msg-content s { opacity: 0.5; text-decoration: line-through; }

.msg-content code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--accent);
}

.msg-content p {
    margin: 0;
}

.msg-content {
    margin: -30px 0;
}

.msg-content pre {
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}
.msg-content pre code {
    background: none;
    padding: 0;
    color: var(--muted);
}

.msg-content blockquote {
    border-left: 3px solid #e18a24;
    padding-left: 10px;
    background: rgba(225,138,36,0.08);
    margin: 8px 0;
    color: var(--muted);
}

/* ========== 故事卡片 ========== */
.story-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    overflow: hidden;
}
.story-card-header {
    padding: 8px 12px;
    background: var(--accent-dim);
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.story-card-header:hover { background: rgba(128,217,255,0.2); }
.story-card-toggle {
    font-size: 10px;
    transition: transform 0.2s;
}
.story-card.collapsed .story-card-toggle { transform: rotate(-90deg); }
.story-card-body {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}
.story-card.collapsed .story-card-body { display: none; }

/* ========== 角色姓名输入 ========== */
.name-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.name-input-row input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
}
.name-input-row input::placeholder { color: var(--muted); }

.character-picker {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.picker-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    background: rgba(255,255,255,0.02);
}
.picker-tab {
    padding: 8px 14px;
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.picker-tab:hover { color: var(--text); }
.picker-tab.active {
    color: var(--primary-soft);
    border-bottom-color: var(--primary);
}
.picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px;
    max-height: 240px;
    overflow-y: auto;
}
.character-picker-item {
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}
.character-picker-item:hover { border-color: var(--primary); }
.character-picker-item.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
    color: var(--primary-soft);
    font-weight: 600;
}
.character-picker-item .picker-desc {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* ========== 输入控制区 ========== */
.input-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.dropdown-wrapper {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    background: rgba(18,24,36,0.98);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 50;
    min-width: 200px;
    overflow: hidden;
}
.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.dropdown-item:hover { background: rgba(255,255,255,0.06); }
.dropdown-item.active { color: var(--primary-soft); background: var(--primary-dim); }

.btn-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.btn-group-item {
    padding: 5px 10px;
    background: none;
    border: none;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-group-item + .btn-group-item { border-left: 1px solid var(--border); }
.btn-group-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.btn-group-item.active {
    background: var(--primary-dim);
    color: var(--primary-soft);
    font-weight: 600;
}

/* ========== 坨坨之神模态框 ========== */
.tuoshen-hint {
    padding: 12px 14px;
    background: rgba(128, 217, 255, 0.08);
    border: 1px solid rgba(128, 217, 255, 0.2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--accent);
    line-height: 1.6;
}

.tuoshen-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 14px;
}

.tuoshen-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tuoshen-column-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-soft);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.tuoshen-column-icon {
    font-size: 18px;
}

.tuoshen-cards-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tuoshen-card {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.tuoshen-card:hover {
    border-color: rgba(255, 142, 60, 0.4);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.tuoshen-card.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
}

.tuoshen-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.tuoshen-card-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

/* @坨坨之神 区域 */
.tuoshen-at-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.tuoshen-at-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.6;
}

.tuoshen-examples {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.tuoshen-example-tag {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--muted);
    text-align: left;
    cursor: default;
}

#btn-tuoshen-quick {
    margin-top: 4px;
}

/* ========== 状态面板 ========== */
.status-panel {
    width: 360px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.status-panel-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.status-panel-header h4 { font-size: 15px; font-weight: 700; }
.status-panel-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Status card grid */
.scard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.scard {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-left: 3px solid var(--c, var(--accent));
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.scard-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    background: rgba(255,255,255,0.03);
    font-size: 12px;
    font-weight: 700;
    color: var(--c, var(--accent));
}
.scard-body {
    padding: 7px 10px 9px;
    font-size: 12px;
    color: var(--text);
    line-height: 1.55;
    white-space: pre-wrap;
    max-height: 220px;
    overflow-y: auto;
}

/* Legacy section cards (kept for compatibility) */
.status-section {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-left: 3px solid var(--section-color, var(--accent));
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.status-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    font-size: 13px;
    font-weight: 700;
    color: var(--section-color, var(--accent));
}
.status-section-icon { font-size: 15px; }
.status-section-label { letter-spacing: 0.5px; }
.status-section-body {
    padding: 8px 12px 10px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 250px;
    overflow-y: auto;
}

/* NPC cards inside status panel */
.npc-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.npc-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.npc-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-soft);
    margin-bottom: 6px;
}
.npc-card-field {
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 3px;
}
.npc-label {
    display: inline-block;
    min-width: 32px;
    color: var(--muted);
    margin-right: 4px;
    font-size: 11px;
}
.npc-affinity {
    color: #ff6b8a;
    font-weight: 600;
}

/* Status field (for status/location tags) */
.status-field {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 4px;
    display: flex;
    gap: 6px;
}
.status-field-label {
    color: var(--muted);
    font-size: 12px;
    min-width: 36px;
    flex-shrink: 0;
}

/* ========== 图库面板 ========== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.gallery-item {
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gallery-item-image {
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.gallery-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.gallery-item-image:hover img {
    transform: scale(1.05);
}

.gallery-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gallery-story {
    font-size: 12px;
    color: rgba(242,246,251,0.7);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-meta {
    font-size: 11px;
    color: rgba(242,246,251,0.4);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.gallery-chars {
    color: var(--color-accent, #80d9ff);
}

.gallery-actions {
    display: flex;
    gap: 6px;
}

.gallery-actions button {
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    color: rgba(242,246,251,0.6);
    font-size: 11px;
    cursor: pointer;
}

.gallery-actions button:hover {
    background: rgba(255,255,255,0.08);
}

.gallery-btn-delete {
    color: #ff6b6b !important;
    border-color: rgba(255,107,107,0.3) !important;
}
.gallery-btn-adjust {
    color: var(--accent) !important;
    border-color: rgba(128, 217, 255, 0.3) !important;
}

/* AI 生成水印 */
.ai-watermark {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    backdrop-filter: blur(4px);
    letter-spacing: 0.5px;
}

.gallery-btn-download {
    color: #4caf50 !important;
    border-color: rgba(76, 175, 80, 0.3) !important;
}

/* ===== 四选一分组 ===== */
.gallery-group {
    background: rgba(128, 217, 255, 0.06);
    border: 1px solid rgba(128, 217, 255, 0.15);
    border-radius: 10px;
    padding: 10px;
    grid-column: 1 / -1;
}

.gallery-group-label {
    text-align: center;
    font-size: 13px;
    color: var(--color-accent, #80d9ff);
    margin-bottom: 8px;
    font-weight: 500;
}

.gallery-group-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.gallery-group-images .group-item {
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.gallery-group-images .group-item:hover {
    border-color: rgba(128, 217, 255, 0.4);
}

.gallery-group-images .group-item.selected {
    border-color: #80d9ff;
    box-shadow: 0 0 0 2px rgba(128, 217, 255, 0.3);
}

.gallery-group-images .group-item .gallery-item-image {
    aspect-ratio: 1;
}

.gallery-group-info {
    text-align: center;
    font-size: 11px;
    color: rgba(242, 246, 251, 0.4);
    margin-top: 6px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

/* ===== 失败图 ===== */
.gallery-item-failed {
    border-color: rgba(255, 107, 107, 0.3);
    background: rgba(255, 107, 107, 0.05);
}

.gallery-failed-placeholder {
    width: 100%;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 6px;
    color: #ff6b6b;
    font-size: 14px;
}

@media (max-width: 768px) {
    .tuoshen-columns { grid-template-columns: 1fr; }
    .greeting-cards { grid-template-columns: 1fr; }
    .specify-grid { grid-template-columns: 1fr; }
    .character-picker { grid-template-columns: repeat(2, 1fr); }
    .scard-row { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.25s;
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }

    /* topbar：grid 两列，汉堡跨两行 */
    .topbar {
        display: grid;
        grid-template-columns: 44px 1fr;
        grid-template-rows: auto auto;
        gap: 4px;
        padding: 6px 10px;
    }
    .topbar-left {
        grid-column: 2;
        grid-row: 1;
        gap: 4px;
        flex-basis: auto;
        flex-wrap: nowrap;
    }
    .topbar-spacer {
        display: none;
    }
    .topbar-left > .btn-ghost {
        flex: 0 0 auto;
        justify-content: center;
    }
    .topbar-left .btn-ghost { padding: 4px 8px; font-size: 11px; }
    .topbar-right .btn-ghost { padding: 4px 8px; font-size: 11px; }
    .topbar-right { gap: 4px; }
    .topbar-marquee-row {
        grid-column: 2;
        grid-row: 2;
        flex-basis: auto;
        height: 24px;
    }

    /* 汉堡按钮：正方形，跨两行 */
    .btn-hamburger {
        display: inline-flex !important;
        grid-row: 1 / 3;
        grid-column: 1;
        font-size: 18px;
        padding: 0;
        width: 44px;
        height: 100%;
        min-height: auto;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        background: rgba(255,255,255,0.08);
        border: 1px solid var(--border);
    }
    .btn-hamburger:hover {
        background: rgba(255,255,255,0.15);
    }

    /* 滚动公告：文字从右滑入，停在最左边不消失 */
    @keyframes marquee-scroll-mobile {
        0% { transform: translateX(100%); }
        100% { transform: translateX(0); }
    }
    .topbar-marquee-row .marquee-text {
        line-height: 24px;
        font-size: 11px;
        animation-name: marquee-scroll-mobile;
    }

    /* 消息区允许收缩，给输入栏让位 */
    .chat-messages {
        padding: 14px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* 输入栏不被压缩，确保按钮可见 */
    .chat-input-bar {
        padding: 10px 14px;
        flex-shrink: 0;
    }

    /* 工具栏按钮均匀分布 */
    .input-actions > .btn-ghost {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }

    .msg { max-width: 98%; }
    .msg-user { padding: 5px 10px; line-height: 1.4; max-width: 75%; }
    .msg-assistant { padding: 0 12px; line-height: 1.7; }
    .input-controls { flex-wrap: wrap; }

    /* 状态面板：手机端全屏覆盖 */
    .status-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100% !important;
        z-index: 30;
        border-left: none;
    }

    /* 输入操作区：按钮按内容自适应宽度 */
    .input-actions {
        flex-wrap: nowrap;
        gap: 6px;
    }
    .input-actions .btn-ghost {
        padding: 6px 10px;
        font-size: 12px;
        white-space: nowrap;
        flex: none;
        text-align: center;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 6px;
    }
    /* 隐藏底部续写按钮（已与发送合并） */
    #btn-continue { display: none !important; }

    /* 模态框：居中+紧凑+可滚动 */
    .modal-overlay { align-items: center; }
    .modal, .modal-box {
        width: auto !important;
        max-width: calc(100vw - 24px) !important;
        max-height: 85dvh;
        border-radius: var(--radius-lg);
        overflow-y: auto;
        padding: 14px;
        font-size: 13px;
    }
    .modal-lg {
        width: auto !important;
        max-width: calc(100vw - 24px) !important;
    }
    .modal-header { margin-bottom: 10px; }
    .modal-header h3 { font-size: 15px; }

    /* 欢迎页隐藏 */
    .chat-welcome { display: none !important; }

    /* 新冒险 & 主角设定：header 固定，body 独立滚动 */
    #modal-new-chat > .modal,
    #modal-character > .modal {
        max-height: 85dvh !important;
        padding: 12px 14px;
        display: flex !important;
        flex-direction: column;
        overflow: hidden !important;
    }
    #modal-new-chat > .modal > .modal-header,
    #modal-character > .modal > .modal-header {
        flex-shrink: 0;
    }
    #modal-new-chat > .modal > .modal-body,
    #modal-character > .modal > .modal-body {
        flex: 1 1 0%;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .btn-close {
        width: 36px;
        height: 36px;
        font-size: 22px;
        border-radius: 10px;
    }
    /* 忍者表单：手机端缩小间距 */
    .ninja-form-grid {
        gap: 8px;
    }
    .ninja-field input,
    .ninja-field select,
    .ninja-field textarea {
        padding: 8px 10px;
        font-size: 13px;
    }
    .opening-option {
        padding: 10px 12px;
        gap: 8px;
    }
    .opening-icon { font-size: 20px; }
    .opening-text strong { font-size: 13px; }
    .opening-text small { font-size: 11px; }
    .newchat-section { margin-bottom: 10px; }
    .section-label { margin-bottom: 6px; font-size: 13px; }

    /* 钱包显示：精简但可见 */
    #btn-wallet { padding: 4px 8px; font-size: 11px; }
    #wallet-display { font-size: 11px; }
}

/* ========== 饭团记录 ========== */
.wallet-log-list {
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.wallet-log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255,255,255,0.02);
    border-radius: 6px;
    font-size: 13px;
}
.wallet-log-item .log-desc {
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wallet-log-item .log-amount {
    font-weight: 700;
    margin: 0 10px;
    flex-shrink: 0;
}
.wallet-log-item .log-amount.positive { color: #4ade80; }
.wallet-log-item .log-amount.negative { color: #f87171; }
.wallet-log-item .log-time {
    color: #666;
    font-size: 11px;
    flex-shrink: 0;
}

/* ========== 用户设置弹窗 ========== */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-soft);
}

.settings-section input {
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
}

.settings-section input::placeholder {
    color: var(--muted);
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1px 0;
}

.modal-settings {
    padding: 16px;
}

.modal-settings .modal-header {
    margin-bottom: 12px;
}

/* ========== 图片生成指示器 ========== */
.image-gen-indicator {
    position: fixed;
    top: 16px;
    right: 16px;
    background: rgba(12, 16, 24, 0.9);
    border: 1px solid var(--primary, #ff8e3c);
    border-radius: 8px;
    padding: 8px 16px;
    color: var(--primary, #ff8e3c);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.image-gen-indicator.hidden {
    display: none;
}

.gen-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,142,60,0.3);
    border-top-color: #ff8e3c;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

/* ========== Toast 通知 ========== */
.toast-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(12, 16, 24, 0.95);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px 20px;
    color: #f2f6fb;
    font-size: 14px;
    z-index: 10000;
    transition: opacity 0.3s;
}

.toast-notification.hidden {
    display: none;
}

.toast-notification.toast-ok {
    border-color: #4caf50;
    color: #4caf50;
}

.toast-notification.toast-error {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.toast-notification.toast-warn {
    border-color: #ff9800;
    color: #ff9800;
}

/* ========== 主角设定模态框 ========== */
.char-design-save-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

#char-design-name {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
}

#char-design-setting {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    color: var(--text);
}

#char-design-setting::placeholder {
    color: var(--muted);
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* ========== 编辑状态高亮 ========== */
.setting-editing {
    border-color: var(--primary) !important;
    box-shadow: 0 0 8px rgba(255, 142, 60, 0.3) !important;
    background: rgba(255, 142, 60, 0.06) !important;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

/* ========== 默认设定图标记 ========== */
.gallery-item.default-portrait {
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(255, 142, 60, 0.25);
}
.gallery-item.default-portrait .default-badge {
    display: inline-block;
}
.default-badge {
    display: none;
    background: var(--primary);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    margin-right: 6px;
}
.btn-set-default {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-set-default:hover {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-set-default.active {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-dim);
}

/* ========== 图片灯箱 ========== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: pointer;
}

.lightbox-overlay.hidden {
    display: none !important;
}

.lightbox-close {
    position: fixed;
    top: 12px;
    right: 12px;
    background: rgba(255, 60, 60, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.6);
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 10000;
    transition: background 0.15s, transform 0.15s;
}

.lightbox-close:hover {
    background: rgba(255, 60, 60, 1);
    transform: scale(1.1);
}

.lightbox-download {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 201;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.lightbox-download:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-watermark {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    pointer-events: none;
    backdrop-filter: blur(4px);
    z-index: 10000;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    cursor: default;
    position: relative;
    z-index: 1;
}

/* ========== 自定义对话框（替代 alert/confirm/prompt） ========== */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15000;
    animation: dialog-fade-in 0.15s ease;
}

@keyframes dialog-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dialog-box {
    background: rgba(18, 24, 36, 0.98);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    width: 360px;
    max-width: 88vw;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    color: var(--text);
}

.dialog-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #f2f6fb;
}

.dialog-message {
    font-size: 13px;
    line-height: 1.6;
    color: var(--muted);
    margin-bottom: 18px;
    white-space: pre-wrap;
    word-break: break-word;
}

.dialog-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    outline: none;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.dialog-input:focus {
    border-color: var(--accent);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.dialog-btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.15s;
    color: var(--muted);
    background: transparent;
}

.dialog-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.dialog-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.dialog-btn-primary:hover {
    opacity: 0.85;
}

.dialog-btn-danger {
    background: rgba(255, 80, 80, 0.15);
    border-color: rgba(255, 80, 80, 0.3);
    color: #ff6b6b;
}

.dialog-btn-danger:hover {
    background: rgba(255, 80, 80, 0.25);
}

/* ========== 捐赠支持 ========== */
.donation-section {
    margin-top: 16px;
}

.donation-section-title {
    font-size: 14px;
    color: rgba(242,246,251,0.6);
    margin-bottom: 10px;
    text-align: center;
}

.donation-qrcode-wrap {
    text-align: center;
    margin-bottom: 8px;
}

.donation-qrcode-wrap img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.donation-hint {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    margin: 4px 0 0;
}

.donation-afdian-btn {
    display: block;
    text-align: center;
    text-decoration: none;
}

/* ========== 饭团飘字动画 ========== */
@keyframes float-up-fade {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-40px); }
}
.wallet-float-text {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    color: #4ade80;
    font-size: 16px;
    font-weight: 800;
    pointer-events: none;
    white-space: nowrap;
    animation: float-up-fade 1.8s ease-out forwards;
    z-index: 100;
    text-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}
.wallet-float-text.co-builder {
    color: #ffc76c;
    font-size: 18px;
    text-shadow: 0 0 8px rgba(255, 199, 108, 0.6);
}
@media (max-width: 768px) {
    .wallet-float-text { font-size: 14px; }
    .wallet-float-text.co-builder { font-size: 15px; }
}
