: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;
    --item-card-body-font: "Long Cang", "龙藏", "KaiTi", "STKaiti", cursive;
    --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;
    --app-vh: 100dvh;
}

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

html {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: pan-y;
}

body {
    font-family: "Segoe UI", "PingFang SC", sans-serif;
    color: var(--text);
    background: var(--bg);
    height: 100%;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

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

.app-boot-loader {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: grid;
    place-items: center;
    padding:
        max(18px, env(safe-area-inset-top))
        max(16px, env(safe-area-inset-right))
        max(18px, env(safe-area-inset-bottom))
        max(16px, env(safe-area-inset-left));
    background:
        radial-gradient(circle at 50% 42%, rgba(128, 217, 255, 0.12), transparent 30%),
        linear-gradient(145deg, #070b12, #101827 58%, #080b12);
    color: var(--text);
    overflow: hidden;
    transition: opacity .32s ease, visibility .32s ease;
}
.app-boot-loader.is-done {
    opacity: 0;
    visibility: hidden;
}
.app-boot-loader-card {
    width: min(280px, 100%);
    max-height: calc(100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 28px 24px;
    border: 1px solid rgba(255, 199, 108, 0.22);
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.025)),
        rgba(12, 16, 24, 0.86);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.08);
}
.app-boot-loader-rune {
    width: 58px;
    height: 58px;
    border: 2px solid rgba(255, 199, 108, 0.7);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 18px rgba(128, 217, 255, 0.2), inset 0 0 20px rgba(255, 199, 108, 0.08);
    animation: boot-rune-spin 1.2s linear infinite;
}
.app-boot-loader-rune::before,
.app-boot-loader-rune::after {
    content: '';
    position: absolute;
    inset: 9px;
    border: 1px solid rgba(128, 217, 255, 0.55);
    transform: rotate(45deg);
}
.app-boot-loader-rune::after {
    inset: 20px;
    border-radius: 50%;
    transform: none;
    background: rgba(128, 217, 255, 0.16);
}
.app-boot-loader-title {
    font-weight: 800;
    color: #ffe2a3;
    line-height: 1.2;
}
.app-boot-loader-text {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
    text-align: center;
}
.app-boot-loader-skip {
    margin-top: 4px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255,199,108,0.30);
    background: rgba(255,199,108,0.10);
    color: #ffe2a3;
    font-size: 13px;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.app-boot-loader-skip:hover {
    background: rgba(255,199,108,0.16);
}
.app-boot-loader-skip[hidden] {
    display: none;
}
.app-boot-loader.is-slow .app-boot-loader-rune {
    animation-duration: 1.8s;
    border-color: rgba(128, 217, 255, 0.65);
}
@keyframes boot-rune-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
    .app-boot-loader-card {
        width: min(260px, 100%);
        padding: 24px 18px;
        gap: 9px;
    }
    .app-boot-loader-rune {
        width: 50px;
        height: 50px;
    }
    .app-boot-loader-title { font-size: 15px; }
    .app-boot-loader-text,
    .app-boot-loader-skip { font-size: 12px; }
}

@media (max-height: 460px) and (orientation: landscape) {
    .app-boot-loader-card {
        width: min(360px, 100%);
        grid-template-columns: auto minmax(0, 1fr);
        justify-items: start;
        text-align: left;
        padding: 18px 20px;
    }
    .app-boot-loader-rune {
        grid-row: 1 / span 3;
        width: 44px;
        height: 44px;
    }
    .app-boot-loader-text { text-align: left; }
    .app-boot-loader-skip { margin-top: 0; }
}

/* ========== 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;
    flex-wrap: wrap;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
    position: relative;
}
.topbar-right #badge-builder { order: 98; }
.topbar-right #btn-donate { order: 99; }
.builder-card {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: rgba(18, 24, 36, 0.98);
    border: 1px solid rgba(255, 142, 60, 0.2);
    border-radius: 10px;
    padding: 10px 14px;
    width: 240px;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.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: inline-flex;
    white-space: nowrap;
    position: absolute;
    line-height: 28px;
    font-size: 12.5px;
    color: #ccc;
    animation-name: marquee-scroll;
    animation-duration: var(--marquee-duration, 20s);
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

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

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

/* ========== 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;
    border: 1px solid rgba(255, 224, 160, 0.18);
    box-shadow: 0 8px 18px rgba(255, 142, 60, 0.12), inset 0 1px 0 rgba(255,255,255,0.18);
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-primary:hover { opacity: 0.94; transform: translateY(-1px); filter: saturate(1.08); }
.btn-primary:active { transform: translateY(1px) scale(0.985); box-shadow: inset 0 2px 6px rgba(0,0,0,0.18); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; filter: grayscale(0.12); }

.btn-ghost {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.035)),
        rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover {
    transform: translateY(-1px);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.11), rgba(255,255,255,0.05)),
        rgba(255, 255, 255, 0.04);
    border-color: rgba(255,199,108,0.20);
}
.btn-ghost:active { transform: translateY(1px) scale(0.985); }
.btn-ghost:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.12);
}
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.msg-action:focus-visible,
.sidebar-action:focus-visible {
    outline: 2px solid rgba(128, 217, 255, 0.72);
    outline-offset: 2px;
}

.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(239, 68, 68, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: all 0.15s;
    cursor: pointer;
}
.btn-close:hover {
    background: rgba(239, 68, 68, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}
.btn-close svg {
    width: 18px;
    height: 18px;
}

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

.btn-stop {
    background: var(--error) !important;
    color: #fff !important;
    border-color: var(--error) !important;
}
.btn-stop:hover {
    opacity: 0.88;
}
.btn-stopping {
    background: #888 !important;
    color: #ccc !important;
    border-color: #888 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}
.btn-stopping:hover {
    background: #888 !important;
    opacity: 0.6;
}

.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;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* Desktop: center chat content to avoid left-heavy layout on wide screens */
@media (min-width: 1024px) {
    body:not(.sandbox-app) .chat-welcome,
    body:not(.sandbox-app) .chat-messages,
    body:not(.sandbox-app) .chat-input-bar {
        width: min(1200px, 100%);
        margin-left: auto;
        margin-right: auto;
    }
}

/* ========== 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));
}
.world-hub-action {
    background: linear-gradient(135deg, rgba(255,142,60,0.16), rgba(255,142,60,0.06));
    border-color: rgba(255,142,60,0.32);
}
.world-hub-action:hover {
    background: linear-gradient(135deg, rgba(255,142,60,0.24), rgba(255,142,60,0.1));
}
.community-link {
    background: linear-gradient(135deg, rgba(76,175,80,0.15), rgba(76,175,80,0.05));
    border-color: rgba(76,175,80,0.35);
    text-decoration: none;
    color: var(--text);
}
.community-link:hover {
    background: linear-gradient(135deg, rgba(76,175,80,0.25), rgba(76,175,80,0.1));
}
.user-chip-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #e06b20);
    color: inherit;
    font-size: 20px;
    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-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.user-chip-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-chip-tags {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}
.user-chip-uid {
    font-size: 10px;
    color: #888;
    background: rgba(255,255,255,0.06);
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    margin-left: 6px;
}
.user-chip-uid:hover {
    background: rgba(255,255,255,0.14);
    color: #aaa;
}

/* ========== Badges (topbar) ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: all 0.2s ease;
    line-height: 1.5;
}
.badge:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

/* 共建者 — 淡金渐变徽章，与赞赏按钮同尺寸 */
.badge-builder {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: #f5e6c0;
    border: 1px solid rgba(218,175,90,0.35);
    background: linear-gradient(135deg, rgba(218,175,90,0.25) 0%, rgba(180,140,60,0.18) 100%);
    box-shadow: 0 1px 4px rgba(200,160,60,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* 忍者等级 — 紧凑标签 */
.badge-rank {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.badge-rank-实习忍者 {
    color: #9ca3af;
    border: 1px solid rgba(156,163,175,0.4);
    background: rgba(156,163,175,0.15);
}
.badge-rank-下忍 {
    color: #a78bfa;
    border: 1px solid rgba(167,139,250,0.4);
    background: rgba(167,139,250,0.15);
}
.badge-rank-中忍 {
    color: #34d399;
    border: 1px solid rgba(52,211,153,0.4);
    background: rgba(52,211,153,0.15);
}
.badge-rank-上忍 {
    color: #f472b6;
    border: 1px solid rgba(244,114,182,0.4);
    background: rgba(244,114,182,0.15);
}
.badge-rank-精英上忍 {
    color: #c084fc;
    border: 1px solid rgba(192,132,252,0.5);
    background: linear-gradient(135deg, rgba(192,132,252,0.2) 0%, rgba(168,85,247,0.15) 100%);
    box-shadow: 0 0 8px rgba(168,85,247,0.15);
}
.badge-rank-传说忍者 {
    color: #fbbf24;
    border: 1px solid rgba(251,191,36,0.5);
    background: linear-gradient(135deg, rgba(251,191,36,0.2) 0%, rgba(245,158,11,0.15) 100%);
    box-shadow: 0 0 10px rgba(251,191,36,0.2), 0 0 20px rgba(251,191,36,0.08);
    text-shadow: 0 0 8px rgba(251,191,36,0.3);
}
.badge-rank-商人 {
    color: #38bdf8;
    border: 1px solid rgba(56,189,248,0.4);
    background: rgba(56,189,248,0.15);
}

.rank-progress-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    max-width: 100%;
}

.rank-progress-meta {
    display: inline-flex;
    flex-direction: column;
    gap: 0;
    min-width: 86px;
    width: 100%;
}

.rank-progress-track {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.rank-progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(255,255,255,0.25), currentColor);
}

.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-item.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.session-item.disabled:hover {
    background: transparent;
    color: var(--muted);
}

.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); }

.session-edit {
    background: none;
    color: var(--muted);
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.session-item.active .session-edit { opacity: 0.5; }
.session-item:hover .session-edit { opacity: 1; }
.session-edit:hover { color: var(--primary-soft); }

.session-branch {
    background: none;
    color: var(--muted);
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.session-item:hover .session-branch { opacity: 1; }
.session-branch:hover { color: var(--primary-soft); }

.session-group-header { display:flex; align-items:center; padding:6px 12px; cursor:pointer; font-size:12px; font-weight:600; color:var(--muted); gap:6px; user-select:none; }
.session-group-header:hover { background:var(--hover, rgba(255,255,255,0.04)); }
.session-group-toggle { font-size:10px; transition:transform .2s; display:inline-block; width:12px; text-align:center; }
.session-group-header.expanded .session-group-toggle { transform:rotate(0deg); }
.session-group-items.collapsed { display:none; }
.session-group-count { font-size:11px; opacity:.6; margin-left:auto; }

.session-rename-input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--primary-dim, rgba(255, 142, 60, 0.4));
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    padding: 2px 6px;
    outline: none;
}
.session-rename-input:focus {
    border-color: var(--primary-soft, #ff8e3c);
}

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

.sidebar-divider {
    border-top: 1px solid rgba(255,255,255,0.08);
    margin: 8px 4px;
}

.mobile-root-entry {
    display: none !important;
}

.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;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    position: relative;
    overflow: hidden;
    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; }

/* Sandbox workshop */
.sandbox-workshop {
    flex: 1;
    overflow: auto;
    padding: 34px clamp(18px, 4vw, 54px);
    color: var(--text);
}

.sandbox-hero {
    max-width: 860px;
    margin-bottom: 22px;
}

.sandbox-kicker {
    color: #ffb15f;
    font-size: 13px;
    letter-spacing: 0.18em;
    margin: 0 0 8px;
    display: inline;
}

#sandbox-import-share {
    font-size: 11px;
    padding: 1px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

#sandbox-world-share {
    font-size: 13px;
}

.sandbox-hero h1 {
    font-size: clamp(26px, 5vw, 48px);
    line-height: 1.08;
    margin: 0 0 12px;
}

.sandbox-hero p {
    color: var(--muted);
    line-height: 1.8;
    max-width: 720px;
}

.sandbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 980px;
}

.sandbox-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
}

.sandbox-field span[data-count-for] {
    float: right;
    color: var(--muted);
    font-size: 11px;
}

.sandbox-wide { grid-column: 1 / -1; }

.sandbox-field textarea,
.sandbox-field input {
    width: 100%;
    color: var(--text);
    background: rgba(5, 8, 14, 0.48);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 11px 12px;
    line-height: 1.65;
}

.sandbox-row-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* sandbox char tabs */
.sandbox-char-section {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
}
.sandbox-char-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sandbox-char-tab {
    padding: 5px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.sandbox-char-tab:hover { background: rgba(255, 255, 255, 0.08); }
.sandbox-char-tab.active {
    background: var(--sandbox-accent);
    color: #111827;
    border-color: var(--sandbox-accent);
    font-weight: 600;
}
.sandbox-char-tab-add {
    padding: 5px 12px;
    border-radius: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}
.sandbox-char-tab-add:hover { border-color: var(--sandbox-accent); color: var(--sandbox-accent); }
.sandbox-char-panel {
    min-height: 80px;
}
.sandbox-char-panel .sandbox-char-fields {
    display: grid;
    gap: 10px;
}
.sandbox-char-panel .sandbox-char-fields input,
.sandbox-char-panel .sandbox-char-fields textarea {
    width: 100%;
    color: var(--text);
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.sandbox-char-panel .sandbox-char-fields input:focus,
.sandbox-char-panel .sandbox-char-fields textarea:focus,
.sandbox-field textarea:focus,
.sandbox-field input:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--sandbox-accent) 55%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sandbox-accent) 22%, transparent);
    background: rgba(8, 12, 20, 0.52);
}
.sandbox-char-panel .sandbox-char-fields textarea {
    min-height: 60px;
    resize: vertical;
}
.sandbox-portrait-area {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.14);
}
.sandbox-portrait-preview {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.15);
}
.sandbox-portrait-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    border: 2px dashed rgba(255, 255, 255, 0.12);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
    line-height: 1.3;
}
.sandbox-portrait-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sandbox-char-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

.sandbox-npc-fav {
    min-width: 78px;
    font-size: 13px;
    padding: 6px 10px;
    line-height: 1.2;
    white-space: nowrap;
}

.sandbox-npc-fav:disabled {
    opacity: 0.48;
}

/* 自定义阵营/关键角色 */
.sandbox-faction-section,
.sandbox-key-roles-section {
    margin: 8px 0;
}

.sandbox-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--muted);
}

.sandbox-faction-row,
.sandbox-key-role-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.sandbox-faction-row input,
.sandbox-key-role-row input {
    flex: 1;
    min-width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: 6px;
    background: var(--sandbox-active-field-bg);
    color: var(--text);
    font-size: 13px;
}

.sandbox-faction-row input:focus,
.sandbox-key-role-row input:focus {
    outline: none;
    border-color: var(--primary-soft);
}

@media (max-width: 480px) {
    .sandbox-faction-row,
    .sandbox-key-role-row {
        flex-direction: column;
    }
    .sandbox-faction-row input,
    .sandbox-key-role-row input {
        min-width: 100%;
    }
}

/* NPC type tabs */
.npc-type-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}
.npc-type-tab {
    padding: 5px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.npc-type-tab.active {
    background: var(--primary-soft);
    color: #111;
    border-color: var(--primary-soft);
    font-weight: 600;
}

/* NPC status badge */
.npc-status-badge {
    display: inline-block;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 6px;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 4px;
}
.npc-status-离队 { background: #b8860b; color: #fff; }
.npc-status-失踪 { background: #d2691e; color: #fff; }
.npc-status-死亡 { background: #8b0000; color: #fff; }
.npc-status-归档 { background: #555; color: #ccc; }

/* NPC status row */
.sandbox-npc-status-row {
    margin-top: 4px;
}
.sandbox-npc-status-row label {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.sandbox-npc-status-row select {
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-size: 12px;
}
.npc-behavior-rules {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}
.npc-behavior-rules-head,
.npc-behavior-rule-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.npc-behavior-rules-head {
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
}
.npc-behavior-rule-row {
    flex-wrap: wrap;
}
.npc-behavior-rule-row input[data-behavior-rule-text],
.npc-behavior-rule-row input[data-behavior-rule-trigger] {
    flex: 1 1 180px;
    min-width: 0;
    color: var(--text);
    background: rgba(5, 8, 14, 0.48);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 7px 9px;
    font-size: 12px;
    line-height: 1.45;
}
.npc-behavior-rule-row input[data-behavior-rule-text]::placeholder,
.npc-behavior-rule-row input[data-behavior-rule-trigger]::placeholder {
    color: var(--muted);
}
.npc-behavior-rule-row input[data-behavior-rule-text]:focus,
.npc-behavior-rule-row input[data-behavior-rule-trigger]:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--sandbox-accent, var(--accent)) 55%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sandbox-accent, var(--accent)) 18%, transparent);
    background: rgba(8, 12, 20, 0.58);
}
.npc-behavior-rule-enabled {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
}
.fav-rule-chip {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 6px 6px 0;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(184, 160, 255, 0.12);
    color: var(--text);
    font-size: 12px;
}
.fav-rule-chip span {
    color: var(--muted);
}
.sandbox-npc-story-data {
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(128, 217, 255, 0.06);
    border: 1px solid rgba(128, 217, 255, 0.12);
    font-size: 11px;
    line-height: 1.5;
}
.story-data-title {
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 3px;
}
.story-data-age {
    color: var(--muted);
    font-weight: 400;
    font-size: 10px;
}
.story-data-line {
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Story NPC list */
.story-npc-item {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 10px;
}
.story-npc-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}
.story-npc-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.story-npc-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.story-npc-actions .btn-sm {
    min-height: 32px;
    min-width: 76px;
}
.story-npc-grid {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 10px;
}
.story-npc-col { display: flex; flex-direction: column; align-items: center; }
.story-npc-preview {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--muted);
}
.story-npc-preview[data-action="lightbox"] { cursor: pointer; }
.story-npc-portrait-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    margin-top: 6px;
    width: 100%;
}
.story-npc-portrait-btns 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;
    transition: background 0.15s, color 0.15s;
    width: 100%;
}
.story-npc-portrait-btns button:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}
.story-npc-portrait-btns .btn-npc-gen {
    color: var(--accent) !important;
    border-color: rgba(128, 217, 255, 0.3) !important;
}
.story-npc-portrait-btns .btn-npc-gen:hover {
    background: rgba(128, 217, 255, 0.1) !important;
}
.btn-xs {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.btn-xs:hover { background: var(--hover); }
.btn-primary.btn-xs {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary.btn-xs:hover { opacity: 0.85; }
.story-npc-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.story-npc-locked {
    margin-bottom: 6px;
}
.locked-field {
    font-size: 12px;
    color: var(--muted);
    opacity: 0.7;
    line-height: 1.5;
}
.story-npc-field-label {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-bottom: 4px;
}
.story-npc-field-label textarea,
.story-npc-field-label input {
    width: 100%;
    margin-top: 2px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-size: 12px;
    resize: vertical;
}
.story-npc-field-label textarea { min-height: 40px; }

.sandbox-world-characters {
    margin-top: 14px;
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.sandbox-world-characters.empty {
    display: block;
}

.sandbox-world-characters-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.sandbox-world-character-card {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(10, 14, 24, 0.45);
    border: 1px solid rgba(128, 217, 255, 0.12);
}

.sandbox-world-character-card strong {
    font-size: 13px;
    color: #eef6ff;
}

.sandbox-world-character-card span,
.sandbox-world-character-card em {
    font-size: 12px;
    color: var(--muted);
    font-style: normal;
}

.sandbox-world-character-card p {
    font-size: 12px;
    line-height: 1.55;
    color: #d5deeb;
}

.sandbox-npc-list {
    display: grid;
    gap: 10px;
}

.sandbox-npc-item {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
}
.sandbox-npc-item input {
    width: 100%;
    color: var(--text);
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.5;
}

.sandbox-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 980px;
    padding: 18px 0 40px;
}

/* Root custom sandbox app: independent shell, scoped away from /rzbox */
body.sandbox-app {
    --sandbox-accent: #ff9f43;
    --sandbox-bg-dim: 0.16;
    --sandbox-card-opacity: 0.62;
    --sandbox-surface-bg: rgba(12, 20, 34, var(--sandbox-card-opacity));
    --sandbox-surface-bg-preview: rgba(12, 20, 34, 0.24);
    --sandbox-field-bg: rgba(9, 14, 24, 0.52);
    --sandbox-field-bg-preview: rgba(9, 14, 24, 0.20);
    --sandbox-field-border: rgba(255, 255, 255, 0.11);
    --sandbox-field-border-preview: rgba(255, 255, 255, 0.07);
    --sandbox-active-surface-bg: var(--sandbox-surface-bg);
    --sandbox-active-field-bg: var(--sandbox-field-bg);
    --sandbox-active-field-border: var(--sandbox-field-border);
    min-height: 100dvh;
    background:
        linear-gradient(rgba(8, 12, 20, var(--sandbox-bg-dim)), rgba(8, 12, 20, var(--sandbox-bg-dim))),
        var(--sandbox-bg-image, none),
        #0c1018;
    background-size: cover, cover, auto;
    overflow: hidden;
}

body.sandbox-app.sandbox-bg-preview {
    --sandbox-active-surface-bg: var(--sandbox-surface-bg-preview);
    --sandbox-active-field-bg: var(--sandbox-field-bg-preview);
    --sandbox-active-field-border: var(--sandbox-field-border-preview);
}

body.sandbox-app > .topbar,
body.sandbox-app > .app-body {
    display: none !important;
}

body:not(.sandbox-app) .sandbox-shell {
    display: none !important;
}

body.sandbox-app .sandbox-shell {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 100dvh;
    color: var(--text);
    touch-action: pan-y;
}

.sandbox-topbar {
    grid-column: 1 / -1;
}

.sandbox-dock {
    grid-column: 1;
}

.sandbox-stage {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

.sandbox-topbar .btn-hamburger {
    display: none;
}

/* sandbox-topbar 继承 RZBOX topbar 行为 */
.sandbox-topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.sandbox-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}
.sandbox-topbar-marquee {
    flex: 1;
    min-width: 0;
}

.sandbox-menu-toggle {
    cursor: pointer;
}

.sandbox-dock {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 18px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    -webkit-tap-highlight-color: transparent;
}

body.sandbox-app,
body.sandbox-app button,
body.sandbox-app a,
body.sandbox-app .sandbox-drawer-overlay,
body.sandbox-app .sandbox-dock * {
    -webkit-tap-highlight-color: transparent;
}

body.sandbox-app button:focus {
    outline: none;
}

.sandbox-user-chip {
    width: 100%;
    margin-bottom: 2px;
}

.sandbox-user-chip .user-chip-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 6px;
    align-items: center;
}

.sandbox-user-chip .user-chip-name-row {
    grid-column: 1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.sandbox-user-chip .sandbox-user-rank,
.sandbox-user-chip .user-chip-tags {
    width: auto;
    justify-content: flex-start;
}

.sandbox-user-chip .sandbox-user-uid,
.sandbox-user-chip .user-chip-uid {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: end;
    margin-left: 0;
    font-size: 12px;
    line-height: 1.1;
    padding: 3px 8px;
}

.sandbox-user-chip .user-chip-name {
    font-size: 15px;
}

.sandbox-user-chip .badge-rank {
    font-size: 12px;
    padding: 3px 8px;
}

.sandbox-user-chip .rank-progress-chip {
    gap: 5px;
}

.sandbox-user-chip .rank-progress-meta {
    min-width: 110px;
}

.sandbox-user-chip .rank-progress-track {
    height: 5px;
}

.sandbox-dock-mobile-head {
    display: none;
}

.sandbox-dock-close {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    width: 32px;
    height: 32px;
}

.sandbox-drawer-overlay {
    display: none;
}

.sandbox-primary-action {
    border-radius: 12px;
    padding: 11px 14px;
    color: #24160b;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    box-shadow: 0 14px 34px rgba(255, 142, 60, 0.26);
}

.sandbox-session-list {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-top: 8px;
}

.sandbox-session-list .session-item {
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-light);
}

.sandbox-session-list .session-delete {
    opacity: 1;
    flex-shrink: 0;
    color: rgba(242, 246, 251, 0.62);
    background: rgba(255, 255, 255, 0.06);
}

.sandbox-session-list .session-delete:hover {
    color: #fff;
    background: rgba(255, 126, 126, 0.20);
}

.sandbox-session-list .session-branch {
    opacity: 1;
    flex-shrink: 0;
    color: rgba(242, 246, 251, 0.62);
    background: rgba(255, 255, 255, 0.06);
}
.sandbox-session-list .session-branch:hover {
    color: #fff;
    background: rgba(124, 138, 255, 0.20);
}

.sandbox-dock-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
}

.sandbox-settings-tabs {
    display: grid;
    grid-template-columns: repeat(6, minmax(72px, 1fr));
    grid-auto-rows: 40px;
    gap: 8px;
    margin-bottom: 12px;
    align-items: stretch;
    min-height: 40px;
    box-sizing: border-box;
    contain: layout paint;
}

.sandbox-settings-panel {
    display: grid;
    gap: 14px;
}

body.sandbox-app .sandbox-field textarea,
body.sandbox-app .sandbox-field input,
body.sandbox-app .sandbox-char-panel .sandbox-char-fields input,
body.sandbox-app .sandbox-char-panel .sandbox-char-fields textarea,
body.sandbox-app .sandbox-npc-item input {
    background: var(--sandbox-active-field-bg);
    border-color: var(--sandbox-active-field-border);
}

body.sandbox-app .sandbox-field textarea:focus,
body.sandbox-app .sandbox-field input:focus,
body.sandbox-app .sandbox-char-panel .sandbox-char-fields input:focus,
body.sandbox-app .sandbox-char-panel .sandbox-char-fields textarea:focus,
body.sandbox-app .sandbox-npc-item input:focus {
    border-color: color-mix(in srgb, var(--sandbox-accent) 55%, var(--sandbox-active-field-border));
    background: color-mix(in srgb, var(--sandbox-accent) 8%, var(--sandbox-active-field-bg));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sandbox-accent) 18%, transparent);
}

body.sandbox-app .sandbox-char-section,
body.sandbox-app .sandbox-portrait-area,
body.sandbox-app .sandbox-npc-manager,
body.sandbox-app .sandbox-npc-list {
    background: color-mix(in srgb, var(--sandbox-active-field-bg) 76%, transparent);
    border-color: var(--sandbox-active-field-border);
}

.sandbox-settings-tab {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 42px;
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: 8px;
    background: var(--sandbox-active-field-bg);
    color: var(--text);
    padding: 0 10px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    transform: none;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    font-synthesis: none;
    contain: layout paint style;
    backface-visibility: hidden;
    touch-action: manipulation;
}

.sandbox-empty-panel {
    display: grid;
    gap: 8px;
    padding: 18px;
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--sandbox-active-field-bg) 84%, transparent);
    color: var(--muted);
    line-height: 1.6;
}

.sandbox-empty-panel strong {
    color: var(--text);
    font-size: 14px;
}

.sandbox-economy-card {
    display: grid;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--sandbox-active-field-bg) 78%, transparent);
}

.sandbox-economy-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.sandbox-economy-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.sandbox-economy-grid select {
    width: 100%;
    padding: 9px 12px;
    background: var(--sandbox-active-field-bg);
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.character-settings-tabs {
    position: sticky;
    top: 0;
    z-index: 220;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 0 0 10px;
    margin-bottom: 12px;
    background: var(--panel);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.18);
}

.character-settings-tab {
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.character-settings-tab.active {
    border-color: var(--primary-soft);
    background: rgba(255, 142, 60, 0.16);
    color: var(--text);
}

.character-settings-panel {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 12px;
}

#modal-character .settings-divider {
    display: none;
}

.sandbox-settings-tab.active {
    border-color: color-mix(in srgb, var(--sandbox-accent) 48%, var(--sandbox-active-field-border));
    background: color-mix(in srgb, var(--sandbox-accent) 20%, var(--sandbox-active-field-bg));
}

.sandbox-settings-tab:hover,
.sandbox-settings-tab:focus,
.sandbox-settings-tab:active,
.sandbox-settings-tab.active:hover,
.sandbox-settings-tab.active:focus,
.sandbox-settings-tab.active:active {
    transform: none;
    outline: none;
}

.sandbox-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 clamp(12px, 2.4vw, 30px) clamp(12px, 2.4vw, 24px);
}


.sandbox-wizard,
.sandbox-chat-layout {
    position: relative;
    z-index: 1;
    width: min(1400px, 100%);
    margin: 0 auto;
}

.sandbox-wizard {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 0;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 34px clamp(18px, 4vw, 54px);
    background: var(--sandbox-active-surface-bg);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.sandbox-wizard-head {
    position: relative;
    padding-right: 48px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sandbox-settings-close {
    position: absolute;
    top: 0;
    right: 0;
}

.sandbox-wizard-head h1 {
    margin: 0 0 10px;
    font-size: clamp(28px, 5vw, 54px);
    line-height: 1.04;
    letter-spacing: -0.04em;
}

.sandbox-wizard-head p:not(.sandbox-kicker) {
    margin: 0;
    max-width: 680px;
    color: rgba(248, 244, 234, 0.70);
    line-height: 1.8;
}

.sandbox-stepper {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}
.sandbox-step-dot {
    width: auto;
}

.sandbox-step-dot {
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 9px 6px;
    color: rgba(248, 244, 234, 0.64);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    line-height: 1.2;
    min-height: 40px;
    transform: none;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.sandbox-step-dot span {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    font-size: 12px;
}

.sandbox-step-dot.active {
    color: #111827;
    background: var(--sandbox-accent);
    font-weight: 800;
}

.sandbox-step-dot:hover,
.sandbox-step-dot:focus,
.sandbox-step-dot:active,
.sandbox-step-dot.active:hover,
.sandbox-step-dot.active:focus,
.sandbox-step-dot.active:active {
    transform: none;
    outline: none;
}

.sandbox-step-dot.done {
    color: #f8f4ea;
    border-color: color-mix(in srgb, var(--sandbox-accent) 45%, transparent);
}

.sandbox-step {
    display: grid;
    gap: 14px;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 10px;
    animation: sandboxRise 0.28s ease both;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.sandbox-field-hero {
    padding: 18px;
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: var(--radius-md);
    background: var(--sandbox-active-field-bg);
}
.sandbox-field-hero textarea {
    font-size: 15px;
    min-height: 140px;
}

.sandbox-advanced-toggle {
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--sandbox-active-field-bg) 72%, transparent);
    overflow: clip;
    contain: layout paint;
}
.sandbox-advanced-toggle summary {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 44px;
    height: 44px;
    padding: 12px 14px 12px 36px;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    font-weight: 600;
    user-select: none;
    list-style: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    transform: none;
    transition: color 0.18s ease, background-color 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    font-synthesis: none;
    contain: layout paint style;
    backface-visibility: hidden;
    touch-action: manipulation;
}
.sandbox-advanced-toggle summary::-webkit-details-marker { display: none; }
.sandbox-advanced-toggle summary::before {
    content: '▸';
    position: absolute;
    left: 14px;
    top: 50%;
    width: 14px;
    text-align: center;
    line-height: 1;
    transform: translateY(-50%) rotate(0deg);
    transition: transform 0.18s ease;
}
.sandbox-advanced-toggle[open] summary::before { transform: translateY(-50%) rotate(90deg); }
.sandbox-advanced-toggle summary:hover,
.sandbox-advanced-toggle summary:focus,
.sandbox-advanced-toggle summary:active {
    transform: none;
    outline: none;
}

@media (hover: hover) and (pointer: fine) {
    .sandbox-settings-tab:hover {
        border-color: color-mix(in srgb, var(--sandbox-accent) 30%, var(--sandbox-active-field-border));
        background: color-mix(in srgb, var(--sandbox-accent) 12%, var(--sandbox-active-field-bg));
    }

    .sandbox-step-dot:hover {
        border-color: color-mix(in srgb, var(--sandbox-accent) 28%, rgba(255, 255, 255, 0.12));
        background: rgba(255, 255, 255, 0.08);
    }

    .sandbox-advanced-toggle summary:hover {
        color: rgba(248, 244, 234, 0.84);
        background: rgba(255, 255, 255, 0.03);
    }
}
.sandbox-advanced-body {
    display: grid;
    gap: 14px;
    padding: 0 14px 14px;
}

.sandbox-isekai-only.hidden {
    display: none;
}

.sandbox-choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sandbox-choice-pill {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    color: #e9edf6;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.sandbox-choice-pill.active {
    background: color-mix(in srgb, var(--sandbox-accent) 22%, rgba(255,255,255,0.06));
    border-color: color-mix(in srgb, var(--sandbox-accent) 58%, rgba(255,255,255,0.14));
    color: #fff;
}

.sandbox-field-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sandbox-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.sandbox-switch input {
    display: none;
}

.sandbox-switch-slider {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: rgba(255,255,255,0.16);
    transition: background-color 0.18s ease;
}

.sandbox-switch-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.18s ease;
}

.sandbox-switch input:checked + .sandbox-switch-slider {
    background: color-mix(in srgb, var(--sandbox-accent) 65%, rgba(255,255,255,0.16));
}

.sandbox-switch input:checked + .sandbox-switch-slider::after {
    transform: translateX(16px);
}

.sandbox-switch-label {
    font-size: 13px;
    color: var(--muted);
}

.sandbox-outline-card {
    display: grid;
    gap: 8px;
}

#sandbox-outline-tasks,
#official-isekai-outline-tasks,
#char-isekai-outline-tasks {
    width: 100%;
    min-height: 104px;
    box-sizing: border-box;
    resize: vertical;
    padding: 10px 12px;
    border: 1px solid var(--sandbox-active-field-border);
    border-radius: 8px;
    background: var(--sandbox-active-field-bg);
    color: var(--text);
    caret-color: var(--text);
    font: inherit;
    line-height: 1.5;
    outline: none;
}

#sandbox-outline-tasks::placeholder,
#official-isekai-outline-tasks::placeholder,
#char-isekai-outline-tasks::placeholder {
    color: var(--muted);
    opacity: 0.82;
}

#sandbox-outline-tasks:focus,
#official-isekai-outline-tasks:focus,
#char-isekai-outline-tasks:focus {
    border-color: color-mix(in srgb, var(--sandbox-accent) 55%, var(--sandbox-active-field-border));
    background: color-mix(in srgb, var(--sandbox-accent) 8%, var(--sandbox-active-field-bg));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--sandbox-accent) 16%, transparent);
}

#sandbox-outline-tasks:disabled,
#official-isekai-outline-tasks:disabled,
#char-isekai-outline-tasks:disabled {
    color: color-mix(in srgb, var(--text) 62%, transparent);
    background: color-mix(in srgb, var(--sandbox-active-field-bg) 70%, transparent);
    cursor: not-allowed;
}

.sandbox-outline-banner {
    position: absolute;
    top: 6px;
    left: 12px;
    right: 12px;
    z-index: 6;
    pointer-events: none;
    padding: 6px 8px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(8, 14, 28, 0.62);
    backdrop-filter: blur(8px);
}

.sandbox-outline-banner-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    pointer-events: auto;
}

.sandbox-outline-banner-text {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 180px;
}

.sandbox-outline-banner-label {
    flex: 0 0 auto;
    color: rgba(248, 244, 234, 0.62);
    font-size: 11px;
}

.sandbox-outline-banner-title {
    min-width: 0;
    color: #f4f6fb;
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sandbox-outline-banner-sub {
    color: var(--muted);
    font-size: 11px;
    flex: 0 0 auto;
}

.sandbox-outline-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.sandbox-outline-action {
    appearance: none;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    color: #f2f4fa;
    padding: 3px 7px;
    font-size: 11px;
    line-height: 1.3;
    cursor: pointer;
}

.sandbox-outline-progress {
    display: none;
}

.sandbox-bg-gen-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.sandbox-bg-gen-row input {
    flex: 1;
}
.sandbox-bg-gen-row button {
    white-space: nowrap;
}
.sandbox-field-hint {
    color: var(--muted);
    font-size: 12px;
}

.sandbox-time-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(140px, 0.45fr);
    gap: 12px;
}

@keyframes sandboxRise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.sandbox-split {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.sandbox-upload input[type="file"] {
    padding: 14px;
    border-style: dashed;
}

.sandbox-bottom-bar {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    z-index: 8;
}

.sandbox-bottom-bar .btn-lg {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    text-align: center;
}

.sandbox-bottom-bar .feedback {
    grid-column: 1 / -1;
}

.sandbox-review {
    display: grid;
    gap: 10px;
}

.sandbox-review-row {
    padding: 14px;
    border-radius: 18px;
    background: var(--sandbox-active-field-bg);
}

.sandbox-review-row span {
    color: var(--sandbox-accent);
    font-size: 12px;
    font-weight: 800;
}

.sandbox-review-row p {
    margin: 6px 0 0;
    color: rgba(248, 244, 234, 0.82);
    line-height: 1.75;
    white-space: pre-wrap;
}

.sandbox-chat-layout {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
}

.sandbox-chat-header {
    display: none;
}

/* ---- sandbox 内容区：消息 + 面板双列 ---- */
.sandbox-chat-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
.sandbox-chat-content:has(.sandbox-panel-mount.active) {
    grid-template-columns: minmax(0, 1fr) 360px;
}

/* ---- 面板挂载区 ---- */
#sandbox-panel-mount {
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--sandbox-active-surface-bg);
}
#sandbox-panel-mount.active {
    display: flex;
}
#sandbox-panel-mount .status-panel {
    width: 100%;
    max-height: none;
    border: none;
    border-top: none;
    background: transparent;
    flex: 1;
    min-height: 0;
}

.sandbox-chat-mount {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.sandbox-chat-mount .chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 12px 12px 16px;
}

.sandbox-input-mount .chat-input-bar {
    position: relative;
    border-top: 1px solid color-mix(in srgb, var(--sandbox-accent) 24%, rgba(255, 255, 255, 0.08));
    background: var(--sandbox-active-surface-bg);
    margin-top: 6px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

/* sandbox 消息卡：仅通过 CSS 变量控制背景透明度，其余继承 rzbox */
body.sandbox-app .msg-assistant,
body.sandbox-app .msg-user {
    background: var(--sandbox-active-surface-bg);
}

body.sandbox-app .input-actions-trailing #btn-bg-preview.active {
    background: rgba(255, 159, 67, 0.2);
    color: #ffd9b0;
}

body.sandbox-app .input-actions-trailing #btn-bg-preview {
    min-width: 34px;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
}

body.sandbox-app .input-actions-trailing #btn-bg-preview svg {
    display: inline-block;
    vertical-align: middle;
}

body.sandbox-app.sandbox-bg-preview .sandbox-stage > * {
    opacity: 1;
}

/* ---- 聊天态：固定输入栏在底部（全局，不仅限桌面） ---- */
body.sandbox-app.sandbox-chat-active .sandbox-shell {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}
body.sandbox-app.sandbox-chat-active .sandbox-stage {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
body.sandbox-app.sandbox-chat-active .sandbox-chat-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
body.sandbox-app.sandbox-chat-active .sandbox-chat-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
body.sandbox-app.sandbox-chat-active .sandbox-chat-mount {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
body.sandbox-app.sandbox-chat-active .sandbox-chat-mount .chat-messages {
    height: auto;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

body.sandbox-app.sandbox-chat-active .sandbox-chat-content:has(.sandbox-outline-banner:not(.hidden)) .sandbox-chat-mount .chat-messages {
    padding-top: 42px;
}
body.sandbox-app.sandbox-chat-active .sandbox-input-mount {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    body.sandbox-app {
        overflow: hidden;
    }

    body.sandbox-app .sandbox-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(0, 1fr);
    }

    .sandbox-dock { grid-column: 1; }
    .sandbox-stage { grid-column: 1; overflow: auto; }

    body.sandbox-app .sandbox-topbar {
        display: grid;
        grid-template-columns: 44px 1fr auto;
        grid-template-rows: auto auto;
        gap: 4px;
        padding: 6px 10px;
    }
    .sandbox-topbar .sandbox-topbar-left {
        grid-column: 2;
        grid-row: 1;
        gap: 4px;
        flex-basis: auto;
        flex-wrap: nowrap;
    }
    .sandbox-topbar .sandbox-topbar-right {
        gap: 4px;
        grid-column: 3;
        grid-row: 1;
        flex-shrink: 0;
    }
    .sandbox-topbar .sandbox-topbar-marquee {
        grid-column: 2 / 4;
        grid-row: 2;
        flex-basis: auto;
        height: 24px;
    }
    .sandbox-topbar .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);
    }

    .sandbox-dock {
        position: fixed;
        z-index: 31;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(82vw, 260px);
        grid-row: auto;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 12px;
        gap: 8px;
        border-right: 1px solid var(--border);
        border-bottom: 0;
        transform: translateX(-105%);
        transition: transform 220ms ease;
    }

    body.sandbox-drawer-open .sandbox-dock {
        transform: translateX(0);
    }

    .sandbox-dock-mobile-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 4px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border);
    }

    .sandbox-primary-action,
    .sandbox-dock .sidebar-action {
        white-space: nowrap;
        padding: 9px 10px;
        border-radius: 12px;
        font-size: 13px;
        flex: 0 0 auto;
        text-align: left;
    }

    .sandbox-user-chip {
        margin-bottom: 4px;
    }

    .sandbox-dock-footer {
        margin-top: 4px;
        padding-top: 8px;
    }

    .sandbox-session-list {
        order: initial;
        flex: 1 1 auto;
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 2px 0 0;
        gap: 8px;
    }

    .sandbox-session-list .session-item {
        min-width: 0;
    }

    .sandbox-stage {
        padding: 0 4px 8px;
        overflow: auto;
    }

    .sandbox-drawer-overlay {
        display: block;
        position: fixed;
        z-index: 30;
        inset: 0;
        border: 0;
        background: rgba(4, 8, 14, 0.46);
        opacity: 0;
        pointer-events: none;
        transition: opacity 220ms ease;
    }

    body.sandbox-drawer-open .sandbox-drawer-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .sandbox-wizard,
    .sandbox-chat-layout {
        width: 100%;
        height: 100%;
        min-height: 0;
    }

    .sandbox-wizard {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        gap: 10px;
        overflow-y: auto;
        padding: 16px 12px;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    .sandbox-wizard-head h1 {
        font-size: 24px;
    }

    .sandbox-kicker,
    .sandbox-wizard-head p:not(.sandbox-kicker) {
        display: none;
    }

    .sandbox-stepper {
        display: none;
    }

    .sandbox-step {
        padding-right: 0;
        padding-bottom: 0;
    }

    .sandbox-split {
        grid-template-columns: 1fr;
    }

    .sandbox-field textarea {
        max-height: 34dvh;
    }

    .sandbox-npc-item {
        grid-template-columns: 1fr;
    }

    .sandbox-bottom-bar {
        bottom: 0;
        z-index: 8;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 0;
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    }

    .sandbox-bottom-bar .feedback {
        display: none;
    }

    .sandbox-bottom-bar .btn-lg {
        width: 100%;
        min-width: 0;
        min-height: 46px;
        padding: 0 10px;
        font-size: 14px;
    }

    .sandbox-settings-tabs {
        position: sticky;
        top: 0;
        z-index: 3;
        display: flex;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        padding: 6px 0 8px;
        margin-bottom: 10px;
        background: var(--sandbox-active-surface-bg);
        backdrop-filter: blur(10px);
    }

    .sandbox-settings-tabs::-webkit-scrollbar {
        display: none;
    }

    .sandbox-settings-tab {
        flex: 0 0 auto;
        width: auto;
        min-width: 72px;
        height: 38px;
        padding: 0 12px;
        font-size: 12px;
    }

    .sandbox-economy-card {
        padding: 12px;
    }

    .sandbox-economy-actions {
        width: 100%;
        justify-content: stretch;
    }

    .sandbox-economy-actions .btn-sm {
        flex: 1 1 120px;
    }

    .sandbox-economy-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .sandbox-chat-layout {
        height: 100%;
    }

    /* ---- 手机端面板挂载区：全屏弹层 ---- */
    .sandbox-chat-content {
        grid-template-columns: minmax(0, 1fr) 0 !important;
        position: relative;
    }

    #sandbox-panel-mount {
        position: fixed;
        inset: 0;
        z-index: 50;
        border-left: none;
        padding-top: 48px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #sandbox-panel-mount .status-panel {
        max-height: none;
    }

    .sandbox-chat-mount .chat-messages {
        padding: 16px 4px 12px 10px;
    }
    body.sandbox-app .msg { font-size: var(--msg-font-size, 15px); max-width: 100%; }

    /* ---- 聊天态优化：扩大阅读面积 ---- */

    body.sandbox-app.sandbox-chat-active .sandbox-shell {
        height: var(--app-vh, 100dvh);
        max-height: var(--app-vh, 100dvh);
        min-height: 0;
        overflow: hidden;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-stage {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-chat-layout {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-chat-mount {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount {
        flex-shrink: 0;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .chat-input-bar {
        position: relative;
        padding: 8px 12px;
        padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .input-actions {
        gap: 4px;
        margin-bottom: 4px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .input-actions::-webkit-scrollbar {
        display: none;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .input-actions .btn-ghost {
        padding: 4px 8px;
        font-size: 11px;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .input-wrapper {
        position: relative;
        grid-template-columns: 42px minmax(0, 1fr) 40px;
        padding: 6px 8px;
        gap: 6px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: visible;
        box-sizing: border-box;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount #btn-suggest {
        z-index: 5;
        width: 42px;
        min-width: 42px;
        height: 40px;
        min-height: 40px;
        padding: 0;
        align-self: center !important;
        justify-content: center;
        flex: 0 0 42px;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount #msg-input {
        position: relative;
        z-index: 1;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .btn-send {
        position: relative;
        z-index: 2;
        width: 40px;
        min-width: 40px;
        padding-left: 0;
        padding-right: 0;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .suggest-dropdown {
        left: 0;
        min-width: min(280px, calc(100vw - 24px));
        max-width: calc(100vw - 24px);
        z-index: 60;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount .input-compliance-hint {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 2px;
        text-align: center;
        font-size: 9px;
        line-height: 1;
        opacity: 0.35;
        pointer-events: auto;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-chat-mount .chat-messages {
        padding-bottom: 8px;
    }
}

/* ============================================================
   物品卡片 · 真实物件拟态
   结构: .item-card > .item-card-head + .item-card-stage
         .item-card-stage > .item-card-surface + .item-card-mark + .item-card-body
   ============================================================ */

/* === 基础壳 === */
.item-card {
    display: block;
    margin: 14px 0;
    border: 1px solid rgba(160, 140, 110, 0.35);
    border-radius: 6px;
    background: #f5e6c8;
    box-shadow: 2px 4px 14px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    position: relative;
}

.item-card-head {
    cursor: pointer;
    list-style: none;
    padding: 10px 14px 0;
    margin-block-end: 0;
    font-weight: 700;
    color: #3a2e1e;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 9px;
    border-radius: 6px 6px 0 0;
}
.item-card-head::-webkit-details-marker { display: none; }

.item-card-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.item-card-title b { font-size: 14px; line-height: 1.25; }
.item-card-title small {
    color: rgba(58, 46, 30, 0.55);
    font-size: 12px;
    line-height: 1.35;
    font-weight: 500;
}

/* === 标题艺术字（龙藏 + 系统楷体 fallback） === */
.item-card-heading-main,
.item-card-heading-sub {
    font-family: "Long Cang", "龙藏", "STKaiti", "Kaiti SC", "KaiTi", "FZKai-Z03", "Songti SC", cursive;
    letter-spacing: 0.06em;
}
.item-card-heading-main {
    text-shadow: 0 1px 2px rgba(80, 60, 20, 0.1);
}
.item-card-heading-sub {
    font-family: "Long Cang", "龙藏", "STKaiti", "Kaiti SC", "KaiTi", "FZKai-Z03", "Songti SC", cursive;
    letter-spacing: 0.08em;
    text-shadow: 0 0 1px rgba(80, 60, 20, 0.06);
}
.item-card--world-otherworld .item-card-heading-main,
.item-card--world-otherworld .item-card-heading-sub {
    font-family: "Long Cang", "龙藏", "STKaiti", "Kaiti SC", "Palatino Linotype", "Times New Roman", cursive;
    letter-spacing: 0.05em;
}
.item-card-type {
    font-family: "Long Cang", "龙藏", "STKaiti", "Kaiti SC", "KaiTi", "Songti SC", cursive;
    letter-spacing: 0.04em;
}

.item-card-toggle {
    opacity: 0.6;
    transition: transform .2s ease;
}
.item-card[open] .item-card-toggle { transform: rotate(180deg); }

/* === 舞台层 === */
.item-card-stage {
    position: relative;
    border-top: 0;
    margin-top: 0;
    padding: 0 16px 16px;
    overflow: hidden;
    border-radius: 0 0 6px 6px;
}

/* === 材质纹理层 === */
.item-card-surface {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
}

/* === 正文 === */
.item-card-body {
    text-align: left !important;
    text-indent: 2em;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 2.05;
    color: #2e2418;
    font-size: 16px;
    font-family: var(--item-card-body-font);
    position: relative;
    z-index: 2;
}
.item-card-body p,
.item-card-body blockquote,
.item-card-body pre {
    text-indent: 0;
    margin: 0;
}

/* === 印记层 === */
.item-card-mark {
    position: absolute;
    right: 12px;
    bottom: 10px;
    font-size: 11px;
    letter-spacing: 1px;
    opacity: 0.5;
    color: #6b5a40;
    border: 1px solid rgba(120, 100, 70, 0.3);
    border-radius: 3px;
    padding: 2px 6px;
    pointer-events: none;
    z-index: 3;
}

/* === 类型标签 === */
.item-card-type {
    display: inline-block;
    color: #5a4a30;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .2px;
    padding: 3px 9px;
    border-radius: 4px;
    background: rgba(160, 140, 100, 0.15);
    border: 1px solid rgba(160, 140, 100, 0.25);
}

/* ============================================================
   基础类型：纸条 — 泛黄纸条，撕边，折痕
   ============================================================ */
.item-card--note {
    background: #f5e6c8;
    border: 1px solid rgba(180, 150, 100, 0.45);
    transform: rotate(-0.8deg);
    box-shadow:
        2px 4px 12px rgba(0, 0, 0, 0.18),
        -1px 0 0 rgba(200, 170, 120, 0.3),
        1px 0 0 rgba(200, 170, 120, 0.3);
}
.item-card--note .item-card-head {
    border-bottom: 1px dashed rgba(160, 130, 80, 0.25);
    background: linear-gradient(180deg, rgba(210, 190, 150, 0.15), transparent);
}
.item-card--note .item-card-stage {
    border-top: none;
}
.item-card--note .item-card-surface::before {
    /* 纸纹横线 */
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0, transparent 27px,
        rgba(180, 160, 120, 0.1) 27px, rgba(180, 160, 120, 0.1) 28px
    );
}
.item-card--note .item-card-surface::after {
    /* 折痕 + 水渍 */
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 38%, rgba(160, 140, 100, 0.08) 39%, rgba(160, 140, 100, 0.08) 40%, transparent 41%),
        radial-gradient(ellipse at 65% 25%, rgba(150, 130, 80, 0.07) 0%, transparent 40%);
}
.item-card--note .item-card-mark {
    border-style: dashed;
    opacity: 0.35;
}

/* ============================================================
   基础类型：信件 — 展开信纸，折线，落款
   ============================================================ */
.item-card--letter {
    background: #f0e8dc;
    border: 1px solid rgba(170, 140, 90, 0.4);
    box-shadow:
        3px 5px 16px rgba(0, 0, 0, 0.2),
        inset 0 0 40px rgba(160, 130, 80, 0.05);
}
.item-card--letter .item-card-head {
    background: linear-gradient(180deg, rgba(190, 170, 130, 0.12), transparent);
    border-bottom: 1px solid rgba(160, 130, 80, 0.2);
}
.item-card--letter .item-card-stage {
    border-top: none;
}
.item-card--letter .item-card-surface::before {
    /* 信纸横线 */
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0, transparent 28px,
        rgba(160, 140, 100, 0.08) 28px, rgba(160, 140, 100, 0.08) 29px
    );
}
.item-card--letter .item-card-surface::after {
    /* 横向折痕 */
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: 42%;
    height: 2px;
    background: linear-gradient(90deg, transparent 5%, rgba(140, 120, 80, 0.12) 30%, rgba(140, 120, 80, 0.15) 50%, rgba(140, 120, 80, 0.12) 70%, transparent 95%);
}
.item-card--letter .item-card-body {
    font-family: var(--item-card-body-font);
    line-height: 1.95;
    letter-spacing: 0.02em;
    text-indent: 2em;
}

/* ============================================================
   基础类型：档案 — 牛皮档案袋，机密章，编号条
   ============================================================ */
.item-card--file {
    background: linear-gradient(178deg, #c9a06c, #b8895a 40%, #a87848);
    border: 1px solid rgba(140, 100, 50, 0.5);
    border-radius: 3px;
    box-shadow:
        3px 5px 18px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 230, 180, 0.15);
}
.item-card--file .item-card-head {
    background: linear-gradient(180deg, rgba(200, 160, 100, 0.2), rgba(180, 140, 80, 0.08));
    border-bottom: 2px solid rgba(140, 100, 50, 0.3);
    color: #3a2a14;
    position: relative;
}
/* 文件夹 tab */
.item-card--file .item-card-head::before {
    content: '';
    position: absolute;
    top: -8px; left: 16px;
    width: 50px; height: 10px;
    background: linear-gradient(180deg, #c9a06c, #b8895a);
    border: 1px solid rgba(140, 100, 50, 0.4);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}
.item-card--file .item-card-stage {
    border-top: none;
    background: #f0e8d8;
    margin: 0 6px 6px;
    border-radius: 2px;
    border: 1px solid rgba(180, 160, 120, 0.25);
}
/* 大号半透明机密章 */
.item-card--file .item-card-surface::after {
    content: '机密';
    position: absolute;
    right: 20px;
    top: 50%;
    font-size: 72px;
    font-weight: 900;
    color: rgba(200, 50, 30, 0.07);
    transform: translateY(-50%) rotate(-18deg);
    letter-spacing: 8px;
    pointer-events: none;
}
/* 编号条 */
.item-card--file .item-card-surface::before {
    content: '';
    position: absolute;
    top: 6px; left: 8px;
    width: 55px; height: 14px;
    background: rgba(220, 200, 160, 0.4);
    border: 1px solid rgba(180, 160, 120, 0.3);
    border-radius: 1px;
}
.item-card--file .item-card-body {
    color: #2a1e0e;
}
.item-card--file .item-card-type {
    color: #5a3a18;
    background: rgba(200, 160, 100, 0.2);
    border-color: rgba(160, 120, 60, 0.3);
}

/* ============================================================
   基础类型：短信 — 手机屏幕，状态栏，气泡
   ============================================================ */
.item-card--sms {
    background: #10141c;
    border: 1px solid rgba(60, 80, 120, 0.5);
    border-radius: 14px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        inset 0 0 0 2px rgba(30, 40, 60, 0.5);
}
.item-card--sms .item-card-head {
    background: linear-gradient(180deg, #1a2030, #161c28);
    color: #c8d8f0;
    padding: 6px 14px;
    border-bottom: 1px solid rgba(60, 80, 120, 0.2);
    border-radius: 14px 14px 0 0;
}
/* 状态栏 */
.item-card--sms .item-card-head::before {
    content: '12:00     ●●●';
    display: block;
    font-size: 9px;
    font-weight: 400;
    color: rgba(160, 180, 210, 0.45);
    letter-spacing: 1px;
    margin-bottom: 3px;
    font-family: -apple-system, 'Helvetica Neue', sans-serif;
}
.item-card--sms .item-card-stage {
    border-top: none;
    background: #10141c;
    padding: 10px 14px 16px;
}
.item-card--sms .item-card-body {
    background: #1e2638;
    border-radius: 12px 12px 12px 4px;
    padding: 10px 14px;
    color: #d0daf0;
    border: 1px solid rgba(60, 80, 120, 0.12);
    font-size: 14px;
    line-height: 1.7;
}
.item-card--sms .item-card-type {
    color: #8ab4f0;
    background: rgba(80, 120, 200, 0.12);
    border-color: rgba(80, 120, 200, 0.2);
}

/* ============================================================
   基础类型：任务单 — 告示纸，钉孔，悬赏章
   ============================================================ */
.item-card--quest {
    background: #f0e4c8;
    border: 1px solid rgba(160, 130, 80, 0.4);
    box-shadow:
        2px 4px 14px rgba(0, 0, 0, 0.2),
        -2px -1px 8px rgba(0, 0, 0, 0.04);
}
.item-card--quest .item-card-head {
    border-bottom: 2px solid rgba(140, 110, 60, 0.25);
    background: linear-gradient(180deg, rgba(200, 180, 140, 0.1), transparent);
}
/* 钉孔 */
.item-card--quest .item-card-head::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    background: radial-gradient(circle, rgba(80, 60, 40, 0.5) 30%, transparent 70%);
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 0 1px rgba(100, 80, 50, 0.2);
}
.item-card--quest .item-card-stage {
    border-top: none;
}
/* 纸角翘起 */
.item-card--quest::after {
    content: '';
    position: absolute;
    bottom: 0; right: 0;
    width: 20px; height: 20px;
    background: linear-gradient(135deg, transparent 50%, rgba(200, 180, 140, 0.4) 50%);
    border-radius: 0 0 6px 0;
}
.item-card--quest .item-card-body {
    color: #3a2e18;
}
.item-card--quest .item-card-body::before {
    content: '■ ';
    color: #8a7040;
    font-size: 11px;
}
/* 悬赏章 */
.item-card--quest .item-card-mark {
    border: 2px solid rgba(180, 60, 40, 0.45);
    border-radius: 50%;
    color: rgba(180, 60, 40, 0.6);
    font-weight: 800;
    padding: 3px 8px;
    transform: rotate(-8deg);
    opacity: 0.7;
}

/* ============================================================
   基础类型：系统通知 — 终端窗口，扫描线，状态灯
   ============================================================ */
.item-card--system {
    background: #0a0e16;
    border: 1px solid rgba(40, 140, 90, 0.35);
    border-radius: 6px;
    font-family: 'Consolas', 'Courier New', monospace;
    box-shadow:
        0 0 24px rgba(30, 140, 80, 0.06),
        inset 0 0 50px rgba(0, 0, 0, 0.4);
}
/* 标题栏 */
.item-card--system .item-card-head {
    background: linear-gradient(180deg, #101820, #0c1418);
    color: #60d890;
    padding: 6px 14px;
    border-bottom: 1px solid rgba(40, 140, 90, 0.15);
    font-family: inherit;
    border-radius: 6px 6px 0 0;
    position: relative;
}
/* 状态灯 */
.item-card--system .item-card-head::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    background: #30c060;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 6px rgba(48, 192, 96, 0.5);
}
.item-card--system .item-card-head::after {
    content: 'SYSTEM';
    font-size: 9px;
    color: rgba(60, 180, 120, 0.5);
    letter-spacing: 3px;
    margin-left: 6px;
}
.item-card--system .item-card-stage {
    border-top: none;
    background: #080c14;
}
/* 扫描线 + 网格 */
.item-card--system .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(to bottom, transparent 0, transparent 2px, rgba(40, 140, 90, 0.025) 2px, rgba(40, 140, 90, 0.025) 4px),
        repeating-linear-gradient(90deg, transparent 0, transparent 2px, rgba(40, 140, 90, 0.015) 2px, rgba(40, 140, 90, 0.015) 4px);
}
/* CRT 曲面光晕 */
.item-card--system .item-card-surface::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.25) 100%);
}
.item-card--system .item-card-body {
    color: #90d8a8;
    font-family: inherit;
    font-size: 13px;
}
.item-card--system .item-card-type {
    color: #60d890;
    background: rgba(40, 140, 90, 0.1);
    border-color: rgba(40, 140, 90, 0.2);
}
.item-card--system .item-card-mark {
    color: rgba(40, 140, 90, 0.35);
    border-color: rgba(40, 140, 90, 0.15);
}

/* ============================================================
   扩展类型：装备 / 补给 / 遗物 / 货币
   日志中这些真实物品经常被模型写成类型字段，沿用现有物品卡壳体补皮肤。
   ============================================================ */
.item-card--gear {
    background: linear-gradient(160deg, #202633, #10151f 58%, #2d2318);
    border-color: rgba(196, 164, 92, 0.42);
    box-shadow:
        0 10px 26px rgba(0, 0, 0, 0.34),
        inset 0 1px 0 rgba(255, 226, 160, 0.08);
}
.item-card--gear .item-card-head {
    color: #ead8a0;
    background:
        linear-gradient(90deg, rgba(196,164,92,0.18), rgba(255,255,255,0.02)),
        rgba(15, 20, 30, 0.68);
    border-bottom: 1px solid rgba(196,164,92,0.22);
}
.item-card--gear .item-card-stage {
    background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(0,0,0,0.10));
}
.item-card--gear .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, transparent 0 48%, rgba(196,164,92,0.12) 49% 51%, transparent 52%),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 13px);
}
.item-card--gear .item-card-body,
.item-card--gear .item-card-title small {
    color: #dacbaf;
}
.item-card--gear .item-card-type {
    color: #ffe5a2;
    background: rgba(196,164,92,0.16);
    border-color: rgba(196,164,92,0.26);
}
.item-card--gear .item-card-mark {
    color: rgba(255,226,160,0.62);
    border-color: rgba(255,226,160,0.26);
}

.item-card--supply {
    background: linear-gradient(168deg, #23331f, #111b16 60%, #2b2416);
    border-color: rgba(118, 190, 128, 0.38);
}
.item-card--supply .item-card-head {
    color: #dff0c8;
    background: linear-gradient(90deg, rgba(118,190,128,0.16), rgba(255,255,255,0.02));
    border-bottom: 1px solid rgba(118,190,128,0.18);
}
.item-card--supply .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 16% 24%, rgba(118,190,128,0.12), transparent 30%),
        radial-gradient(circle at 84% 72%, rgba(255,199,108,0.08), transparent 32%),
        repeating-linear-gradient(0deg, transparent 0 25px, rgba(118,190,128,0.035) 25px 26px);
}
.item-card--supply .item-card-body,
.item-card--supply .item-card-title small {
    color: #cfe7c4;
}
.item-card--supply .item-card-type {
    color: #dff0c8;
    background: rgba(118,190,128,0.14);
    border-color: rgba(118,190,128,0.24);
}
.item-card--supply .item-card-mark {
    color: rgba(158,220,166,0.62);
    border-color: rgba(158,220,166,0.24);
}

.item-card--relic {
    background: linear-gradient(145deg, #1a1430, #101827 58%, #0b1018);
    border-color: rgba(142, 126, 255, 0.38);
    box-shadow:
        0 0 22px rgba(128, 96, 255, 0.10),
        0 10px 28px rgba(0, 0, 0, 0.32);
}
.item-card--relic .item-card-head {
    color: #e5dcff;
    background:
        radial-gradient(circle at 12% 0, rgba(128,217,255,0.18), transparent 36%),
        linear-gradient(90deg, rgba(142,126,255,0.15), rgba(255,255,255,0.018));
    border-bottom: 1px solid rgba(142,126,255,0.18);
}
.item-card--relic .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 28% 30%, rgba(142,126,255,0.18), transparent 32%),
        radial-gradient(circle at 76% 78%, rgba(128,217,255,0.12), transparent 38%),
        linear-gradient(120deg, transparent 0 42%, rgba(255,255,255,0.05) 43% 44%, transparent 45%);
}
.item-card--relic .item-card-body,
.item-card--relic .item-card-title small {
    color: #cfc6ea;
}
.item-card--relic .item-card-type {
    color: #eee6ff;
    background: rgba(142,126,255,0.16);
    border-color: rgba(142,126,255,0.28);
}
.item-card--relic .item-card-mark {
    color: rgba(190,178,255,0.68);
    border-color: rgba(190,178,255,0.30);
    text-shadow: 0 0 10px rgba(142,126,255,0.34);
}

.item-card--coin {
    background: linear-gradient(165deg, #4b3518, #21170d 62%, #101014);
    border-color: rgba(255, 199, 108, 0.42);
}
.item-card--coin .item-card-head {
    color: #ffe2a3;
    background: linear-gradient(90deg, rgba(255,199,108,0.18), rgba(255,255,255,0.02));
    border-bottom: 1px solid rgba(255,199,108,0.22);
}
.item-card--coin .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 76% 24%, rgba(255,199,108,0.22), transparent 22%),
        repeating-radial-gradient(circle at 78% 26%, rgba(255,199,108,0.16) 0 1px, transparent 1px 7px);
}
.item-card--coin .item-card-body,
.item-card--coin .item-card-title small {
    color: #ead2a8;
}
.item-card--coin .item-card-type {
    color: #ffe8b8;
    background: rgba(255,199,108,0.16);
    border-color: rgba(255,199,108,0.28);
}
.item-card--coin .item-card-mark {
    color: rgba(255,226,160,0.70);
    border-color: rgba(255,226,160,0.28);
}

/* === 默认回退 === */
.item-card--default {
    background: #f5e6c8;
    border-color: rgba(180, 150, 100, 0.4);
}

/* ============================================================
   风格变体（附加在 .item-card-surface 上）
   ============================================================ */

/* 雨夜密信 — 冷蓝水渍，湿痕 */
.item-card--style-rain.item-card {
    background: linear-gradient(170deg, #cdd2dc, #b8c0d0);
    border-color: rgba(80, 100, 140, 0.4);
    box-shadow: 2px 4px 18px rgba(40, 60, 100, 0.22);
}
.item-card--style-rain .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 28%, rgba(80, 120, 170, 0.14) 0%, transparent 22%),
        radial-gradient(circle at 72% 58%, rgba(80, 120, 170, 0.1) 0%, transparent 18%),
        radial-gradient(circle at 45% 82%, rgba(80, 120, 170, 0.12) 0%, transparent 25%),
        radial-gradient(circle at 88% 15%, rgba(80, 120, 170, 0.08) 0%, transparent 15%);
}
.item-card--style-rain .item-card-surface::after {
    /* 底部潮痕 */
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 35%;
    background: linear-gradient(0deg, rgba(60, 90, 130, 0.08), transparent);
}
.item-card--style-rain .item-card-body { color: #2a3040; }
.item-card--style-rain .item-card-head { color: #2a3040; }

/* 官府文书 — 朱印，规整边框 */
.item-card--style-official.item-card {
    background: #f8f0e0;
    border: 2px solid rgba(180, 140, 80, 0.5);
}
.item-card--style-official .item-card-head {
    background: linear-gradient(180deg, rgba(200, 160, 100, 0.12), transparent);
    border-bottom: 2px solid rgba(180, 140, 80, 0.25);
}
/* 大号半透明"官"水印 */
.item-card--style-official .item-card-surface::before {
    content: '官';
    position: absolute;
    right: 25px;
    top: 50%;
    font-size: 80px;
    font-weight: 900;
    color: rgba(200, 60, 40, 0.05);
    transform: translateY(-50%) rotate(-12deg);
}
/* 竖排红印 */
.item-card--style-official .item-card-surface::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 20%;
    width: 28px;
    height: 60%;
    border: 2px solid rgba(200, 50, 30, 0.12);
    border-radius: 2px;
}
.item-card--style-official .item-card-mark {
    border: 3px solid rgba(200, 50, 30, 0.55);
    color: rgba(200, 50, 30, 0.75);
    font-weight: 900;
    border-radius: 2px;
}

/* 江湖暗号 — 破损，刀痕 */
.item-card--style-jianghu.item-card {
    background: linear-gradient(170deg, #d0c0a0, #b8a880);
    border-color: rgba(120, 100, 60, 0.45);
    box-shadow: 2px 4px 16px rgba(0, 0, 0, 0.22);
}
.item-card--style-jianghu .item-card-surface::before {
    /* 刀痕斜线 */
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(38deg, transparent 38%, rgba(100, 80, 40, 0.07) 40%, transparent 42%),
        linear-gradient(-32deg, transparent 52%, rgba(100, 80, 40, 0.06) 54%, transparent 56%);
}
.item-card--style-jianghu .item-card-surface::after {
    /* 暗红水印 */
    content: '暗';
    position: absolute;
    right: 12px; bottom: 20px;
    font-size: 50px;
    font-weight: 900;
    color: rgba(140, 40, 30, 0.06);
}
.item-card--style-jianghu .item-card-body { color: #3a3018; }

/* 宗门秘笺 — 符纹，水墨 */
.item-card--style-sect.item-card {
    background: linear-gradient(170deg, #e8e0f0, #d8d0e8);
    border-color: rgba(120, 100, 160, 0.3);
}
.item-card--style-sect .item-card-surface::before {
    /* 符纹网格 */
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(60deg, transparent 0, transparent 18px, rgba(120, 100, 160, 0.04) 18px, rgba(120, 100, 160, 0.04) 19px),
        repeating-linear-gradient(-60deg, transparent 0, transparent 18px, rgba(120, 100, 160, 0.04) 18px, rgba(120, 100, 160, 0.04) 19px);
}
.item-card--style-sect .item-card-surface::after {
    content: '秘';
    position: absolute;
    right: 18px; top: 50%;
    font-size: 56px;
    font-weight: 900;
    color: rgba(100, 80, 140, 0.05);
    transform: translateY(-50%);
}
.item-card--style-sect .item-card-body { color: #2e2040; }

/* 魔法卷轴 — 羊皮纸，烧边 */
.item-card--style-scroll.item-card {
    background: linear-gradient(175deg, #e8d8b0, #d4c090);
    border-color: rgba(160, 130, 70, 0.45);
    box-shadow:
        3px 5px 18px rgba(0, 0, 0, 0.2),
        inset 0 0 30px rgba(140, 110, 50, 0.06);
}
/* 烧边暗角 */
.item-card--style-scroll .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(80, 50, 20, 0.1) 0%, transparent 30%),
        radial-gradient(ellipse at 100% 100%, rgba(80, 50, 20, 0.1) 0%, transparent 25%),
        radial-gradient(ellipse at 100% 0%, rgba(80, 50, 20, 0.08) 0%, transparent 20%),
        radial-gradient(ellipse at 0% 100%, rgba(80, 50, 20, 0.06) 0%, transparent 20%);
}
.item-card--style-scroll .item-card-surface::after {
    content: '☆  ☽  ☆';
    position: absolute;
    right: 12px; bottom: 6px;
    font-size: 10px;
    color: rgba(120, 90, 40, 0.2);
    letter-spacing: 3px;
}
.item-card--style-scroll .item-card-body { color: #3a2e14; }
.item-card--style-scroll .item-card-head { color: #3a2e14; }

/* 未来终端 — 电子屏，霓虹边 */
.item-card--style-cyber.item-card {
    background: #080c14;
    border: 1px solid rgba(0, 200, 255, 0.25);
    border-radius: 8px;
    box-shadow:
        0 0 24px rgba(0, 180, 220, 0.08),
        inset 0 0 40px rgba(0, 0, 0, 0.4);
}
.item-card--style-cyber .item-card-head {
    background: linear-gradient(180deg, #0e1828, #0a1020);
    color: #00d8f0;
    border-bottom: 1px solid rgba(0, 200, 255, 0.12);
}
.item-card--style-cyber .item-card-stage {
    border-top: none;
}
.item-card--style-cyber .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(to bottom, transparent 0, transparent 2px, rgba(0, 200, 255, 0.025) 2px, rgba(0, 200, 255, 0.025) 4px),
        repeating-linear-gradient(90deg, transparent 0, transparent 2px, rgba(0, 200, 255, 0.015) 2px, rgba(0, 200, 255, 0.015) 4px);
}
.item-card--style-cyber .item-card-body {
    color: #a0e8f0;
    font-family: 'Consolas', 'Courier New', monospace;
}
.item-card--style-cyber .item-card-type {
    color: #00d8f0;
    background: rgba(0, 200, 255, 0.1);
    border-color: rgba(0, 200, 255, 0.2);
}
.item-card--style-cyber .item-card-mark {
    color: rgba(0, 200, 255, 0.35);
    border-color: rgba(0, 200, 255, 0.15);
}

/* 异世界公会委托 — 暗蓝公会档案、金色钉扣 */
.item-card--style-guild.item-card {
    background: linear-gradient(165deg, #1a2433, #111827 62%, #18130e);
    border-color: rgba(255, 199, 108, 0.36);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 226, 160, 0.08);
}
.item-card--style-guild .item-card-head {
    color: #ffe2a3;
    background: linear-gradient(90deg, rgba(255,199,108,0.16), rgba(128,217,255,0.04)), rgba(10, 16, 26, 0.62);
    border-bottom: 1px solid rgba(255,199,108,0.20);
}
.item-card--style-guild .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 16px 16px, rgba(255,199,108,0.18) 0 2px, transparent 3px),
        radial-gradient(circle at calc(100% - 16px) 16px, rgba(255,199,108,0.18) 0 2px, transparent 3px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 18px);
}
.item-card--style-guild .item-card-surface::after {
    content: 'GUILD';
    position: absolute;
    right: 16px;
    bottom: 8px;
    color: rgba(255,199,108,0.10);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 4px;
}

/* 王国/边境文书 — 暗金边框、军令纹 */
.item-card--style-kingdom.item-card {
    background: linear-gradient(170deg, #252130, #121923 60%, #211709);
    border-color: rgba(214, 172, 92, 0.42);
}
.item-card--style-kingdom .item-card-head {
    color: #f1d58d;
    background: linear-gradient(90deg, rgba(214,172,92,0.18), rgba(80,120,200,0.04));
    border-bottom: 1px solid rgba(214,172,92,0.22);
}
.item-card--style-kingdom .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, transparent 0 47%, rgba(214,172,92,0.10) 48% 50%, transparent 51%),
        linear-gradient(-135deg, transparent 0 47%, rgba(128,217,255,0.05) 48% 50%, transparent 51%);
}
.item-card--style-kingdom .item-card-surface::after {
    content: '王';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%) rotate(-10deg);
    color: rgba(214,172,92,0.08);
    font-size: 76px;
    font-weight: 900;
}

/* 学院文书 — 秘蓝网格、课本压纹 */
.item-card--style-academy.item-card {
    background: linear-gradient(165deg, #121f32, #0e1728 60%, #14111f);
    border-color: rgba(128, 217, 255, 0.30);
}
.item-card--style-academy .item-card-head {
    color: #d7f1ff;
    background: linear-gradient(90deg, rgba(128,217,255,0.15), rgba(142,126,255,0.07));
    border-bottom: 1px solid rgba(128,217,255,0.18);
}
.item-card--style-academy .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, transparent 0 17px, rgba(128,217,255,0.035) 17px 18px),
        repeating-linear-gradient(90deg, transparent 0 17px, rgba(128,217,255,0.025) 17px 18px);
}
.item-card--style-academy .item-card-surface::after {
    content: '学院';
    position: absolute;
    right: 16px;
    bottom: 10px;
    color: rgba(128,217,255,0.09);
    font-size: 30px;
    font-weight: 800;
}

/* 炼金/药剂 — 瓶中辉光、配方线 */
.item-card--style-alchemy.item-card {
    background: linear-gradient(165deg, #172b24, #0d1718 62%, #1c1710);
    border-color: rgba(113, 211, 164, 0.34);
}
.item-card--style-alchemy .item-card-head {
    color: #d8f5dc;
    background: linear-gradient(90deg, rgba(113,211,164,0.16), rgba(255,199,108,0.05));
    border-bottom: 1px solid rgba(113,211,164,0.18);
}
.item-card--style-alchemy .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 28% 44%, rgba(113,211,164,0.16), transparent 26%),
        radial-gradient(circle at 78% 28%, rgba(255,199,108,0.10), transparent 22%),
        repeating-linear-gradient(90deg, transparent 0 26px, rgba(113,211,164,0.035) 26px 27px);
}
.item-card--style-alchemy .item-card-surface::after {
    content: '⚗';
    position: absolute;
    right: 18px;
    bottom: 8px;
    color: rgba(113,211,164,0.16);
    font-size: 38px;
}

/* 遗迹/古代残片 — 石板裂纹、冷光 */
.item-card--style-ruin.item-card {
    background: linear-gradient(150deg, #191b24, #0f1722 58%, #121012);
    border-color: rgba(142, 126, 255, 0.34);
}
.item-card--style-ruin .item-card-head {
    color: #dcd6ff;
    background: linear-gradient(90deg, rgba(142,126,255,0.14), rgba(128,217,255,0.06));
    border-bottom: 1px solid rgba(142,126,255,0.18);
}
.item-card--style-ruin .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(35deg, transparent 0 42%, rgba(142,126,255,0.08) 43% 44%, transparent 45%),
        linear-gradient(-25deg, transparent 0 54%, rgba(128,217,255,0.06) 55% 56%, transparent 57%),
        radial-gradient(circle at 70% 34%, rgba(142,126,255,0.13), transparent 24%);
}
.item-card--style-ruin .item-card-surface::after {
    content: '◇';
    position: absolute;
    right: 18px;
    bottom: 8px;
    color: rgba(142,126,255,0.18);
    font-size: 42px;
}

/* 黑市/密令 — 暗纹封套、低饱和红光 */
.item-card--style-shadow.item-card {
    background: linear-gradient(165deg, #1d1720, #0e1119 62%, #140e10);
    border-color: rgba(255, 126, 126, 0.30);
}
.item-card--style-shadow .item-card-head {
    color: #f0c3c3;
    background: linear-gradient(90deg, rgba(255,126,126,0.12), rgba(255,255,255,0.025));
    border-bottom: 1px solid rgba(255,126,126,0.14);
}
.item-card--style-shadow .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% 20%, rgba(255,126,126,0.12), transparent 24%),
        repeating-linear-gradient(135deg, transparent 0 12px, rgba(255,126,126,0.035) 12px 13px);
}
.item-card--style-shadow .item-card-surface::after {
    content: '密';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%) rotate(8deg);
    color: rgba(255,126,126,0.09);
    font-size: 58px;
    font-weight: 900;
}

/* ============================================================
   材质变体（附加在 .item-card-surface 上）
   ============================================================ */

/* 潮湿黄纸 — 水渍圆斑 */
.item-card--mat-damp .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 25% 35%, rgba(100, 80, 40, 0.1) 0%, transparent 22%),
        radial-gradient(circle at 68% 62%, rgba(100, 80, 40, 0.08) 0%, transparent 18%),
        radial-gradient(circle at 45% 85%, rgba(100, 80, 40, 0.06) 0%, transparent 20%);
}
.item-card--mat-damp .item-card-surface::after {
    /* 墨迹晕染 */
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 55% 45%, rgba(60, 40, 20, 0.05) 0%, transparent 35%);
}

/* 粗麻纸 — 纤维纹 */
.item-card--mat-rough .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, transparent 0, transparent 3px, rgba(140, 110, 70, 0.05) 3px, rgba(140, 110, 70, 0.05) 4px),
        repeating-linear-gradient(90deg, transparent 0, transparent 4px, rgba(140, 110, 70, 0.035) 4px, rgba(140, 110, 70, 0.035) 5px);
}

/* 竹简 — 竖向竹纹 */
.item-card--mat-bamboo {
    background: linear-gradient(175deg, #c8b888, #b0a070);
    border-color: rgba(140, 120, 60, 0.45);
}
.item-card--mat-bamboo .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent 0, transparent 26px,
        rgba(100, 80, 40, 0.12) 26px, rgba(100, 80, 40, 0.12) 28px
    );
}
.item-card--mat-bamboo .item-card-body { color: #3a2e14; }

/* 羊皮纸 — 暖色，卷边 */
.item-card--mat-parchment .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(120, 80, 30, 0.08) 0%, transparent 30%),
        radial-gradient(ellipse at 100% 100%, rgba(120, 80, 30, 0.07) 0%, transparent 25%),
        radial-gradient(ellipse at 100% 0%, rgba(100, 70, 25, 0.05) 0%, transparent 20%);
}

/* 电子屏 — 扫描线 */
.item-card--mat-screen .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(to bottom, transparent 0, transparent 2px, rgba(0, 200, 255, 0.025) 2px, rgba(0, 200, 255, 0.025) 4px),
        repeating-linear-gradient(90deg, transparent 0, transparent 2px, rgba(0, 200, 255, 0.015) 2px, rgba(0, 200, 255, 0.015) 4px);
}

/* 血污纸 — 血迹 */
.item-card--mat-blood .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 35% 28%, rgba(140, 30, 20, 0.07) 0%, transparent 18%),
        radial-gradient(circle at 62% 68%, rgba(140, 30, 20, 0.05) 0%, transparent 22%),
        radial-gradient(circle at 18% 78%, rgba(120, 20, 15, 0.04) 0%, transparent 15%);
}

/* 魔晶/水晶 — 折射光 */
.item-card--mat-crystal .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(125deg, transparent 0 38%, rgba(128,217,255,0.14) 39% 41%, transparent 42%),
        linear-gradient(35deg, transparent 0 58%, rgba(142,126,255,0.12) 59% 61%, transparent 62%),
        radial-gradient(circle at 70% 30%, rgba(128,217,255,0.18), transparent 24%);
}

/* 金属/武器 — 拉丝暗纹 */
.item-card--mat-metal .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(110deg, rgba(255,255,255,0.09), transparent 22% 78%, rgba(0,0,0,0.10)),
        repeating-linear-gradient(0deg, transparent 0 4px, rgba(255,255,255,0.035) 4px 5px);
}

/* 布料/衣物 — 织纹 */
.item-card--mat-cloth .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, rgba(255,255,255,0.028) 0 1px, transparent 1px 7px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.022) 0 1px, transparent 1px 9px);
}

/* 皮革/兽皮 — 低光斑驳 */
.item-card--mat-leather .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 25% 30%, rgba(255,199,108,0.08), transparent 24%),
        radial-gradient(circle at 70% 64%, rgba(0,0,0,0.16), transparent 26%),
        linear-gradient(160deg, rgba(255,255,255,0.04), transparent);
}

/* 石板/遗迹 — 粗粝石纹 */
.item-card--mat-stone .item-card-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(30deg, transparent 0 46%, rgba(255,255,255,0.05) 47% 48%, transparent 49%),
        repeating-linear-gradient(90deg, transparent 0 20px, rgba(255,255,255,0.025) 20px 21px);
}

/* 船帮暗记 — 波纹水印 */
.item-card--seal-gang .item-card-mark {
    background: rgba(40, 80, 120, 0.15);
    border: 1px solid rgba(40, 80, 120, 0.25);
    border-radius: 50%;
    color: rgba(40, 80, 120, 0.6);
    padding: 4px 10px;
    opacity: 0.7;
}
.item-card--seal-gang .item-card-mark::before {
    content: '～';
    margin-right: 2px;
    font-size: 13px;
}

/* ============================================================
   印记模板
   ============================================================ */

.item-card--seal-fire .item-card-mark {
    background: radial-gradient(circle at 40% 35%, rgba(220, 80, 40, 0.88), rgba(180, 40, 20, 0.82));
    border: none;
    border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
    padding: 5px 10px;
    color: #ffe8d8;
    box-shadow: 0 2px 8px rgba(180, 40, 20, 0.3), inset 0 -1px 2px rgba(0, 0, 0, 0.15);
    opacity: 0.9;
}
.item-card--seal-wood .item-card-mark {
    background: rgba(140, 100, 50, 0.45);
    border: 2px solid rgba(160, 120, 60, 0.55);
    border-radius: 3px;
    color: #e0d0b0;
    opacity: 0.8;
}
.item-card--seal-stamp .item-card-mark {
    background: transparent;
    border: 3px solid rgba(200, 40, 40, 0.7);
    border-radius: 2px;
    color: rgba(200, 40, 40, 0.8);
    font-weight: 900;
    padding: 3px 8px;
    opacity: 0.8;
}
.item-card--seal-wax .item-card-mark {
    background: radial-gradient(circle at 45% 40%, rgba(180, 50, 30, 0.82), rgba(140, 30, 20, 0.78));
    border: none;
    border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
    padding: 5px 10px;
    color: #ffd8c0;
    box-shadow: 0 2px 8px rgba(140, 30, 20, 0.3), inset 0 1px 2px rgba(255, 200, 160, 0.15);
    opacity: 0.9;
}
.item-card--seal-steel .item-card-mark {
    background: rgba(160, 170, 185, 0.2);
    border: 1px solid rgba(180, 190, 200, 0.35);
    border-radius: 2px;
    color: #808890;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.15), 0 -1px 0 rgba(0, 0, 0, 0.2);
    opacity: 0.75;
}
.item-card--seal-guild .item-card-mark,
.item-card--seal-kingdom .item-card-mark,
.item-card--seal-academy .item-card-mark,
.item-card--seal-rune .item-card-mark,
.item-card--seal-alchemy .item-card-mark {
    border-radius: 999px;
    opacity: 0.82;
}
.item-card--seal-guild .item-card-mark {
    color: #ffe2a3;
    border-color: rgba(255,199,108,0.34);
    background: rgba(255,199,108,0.10);
}
.item-card--seal-kingdom .item-card-mark {
    color: #f1d58d;
    border-color: rgba(214,172,92,0.38);
    background: rgba(214,172,92,0.11);
}
.item-card--seal-academy .item-card-mark {
    color: #bfeaff;
    border-color: rgba(128,217,255,0.34);
    background: rgba(128,217,255,0.10);
}
.item-card--seal-rune .item-card-mark {
    color: #ded6ff;
    border-color: rgba(142,126,255,0.36);
    background: rgba(142,126,255,0.12);
    text-shadow: 0 0 8px rgba(142,126,255,0.34);
}
.item-card--seal-alchemy .item-card-mark {
    color: #d8f5dc;
    border-color: rgba(113,211,164,0.34);
    background: rgba(113,211,164,0.11);
}
.item-card--seal-none .item-card-mark {
    display: none;
}

/* ============================================================
   世界作用域样式
   ============================================================ */

/* 历史世界：浅底暖色系 */
.item-card--world-history.item-card {
    background: #f8f3e8;
    border-color: #c8b88a;
    box-shadow: 2px 3px 8px rgba(120, 100, 60, .12);
}
.item-card--world-history .item-card-head {
    color: #3a2e14;
}
.item-card--world-history .item-card-head::before,
.item-card--world-history .item-card-head::after { display: none; }
.item-card--world-history .item-card-stage {
    background: linear-gradient(170deg, #f5edd8 0%, #ece2c8 100%);
    border-color: #d4c49a;
}
.item-card--world-history .item-card-surface::before {
    background:
        repeating-linear-gradient(0deg, transparent 0 27px, rgba(160, 130, 70, .08) 27px 28px),
        linear-gradient(90deg, #f0e6cc 0%, #ebe0c2 100%);
    opacity: 1;
}
.item-card--world-history .item-card-surface::after {
    background:
        radial-gradient(ellipse 60% 40% at 20% 30%, rgba(180, 150, 80, .1) 0%, transparent 70%),
        radial-gradient(ellipse 50% 50% at 75% 70%, rgba(160, 130, 70, .08) 0%, transparent 70%);
    mix-blend-mode: multiply;
}
.item-card--world-history .item-card-body { color: #3a2e14; }
.item-card--world-history .item-card-type {
    background: #d4c090;
    color: #3a2e14;
}
.item-card--world-history .item-card-mark {
    color: #7a6030;
    text-shadow: none;
}

/* 历史世界系统通知：浅底深字，确保可读 */
.item-card--system.item-card--world-history .item-card-head {
    background: linear-gradient(90deg, #d4c090, #c8b480);
    color: #2a1e08;
}
.item-card--system.item-card--world-history .item-card-type {
    background: #b8a060;
    color: #2a1e08;
}

/* 异世界：深底奇幻系 */
.item-card--world-otherworld.item-card {
    background: linear-gradient(135deg, #1a1030, #101828);
    border-color: #4a3878;
    box-shadow: 0 0 14px rgba(100, 60, 180, .12), 2px 3px 8px rgba(0, 0, 0, .25);
}
.item-card--world-otherworld.item-card--gear {
    background: linear-gradient(145deg, #25202c, #111824 58%, #241b13);
    border-color: rgba(214, 172, 92, 0.42);
}
.item-card--world-otherworld.item-card--supply {
    background: linear-gradient(145deg, #1d2f26, #0f1918 60%, #1d1a12);
    border-color: rgba(118, 211, 164, 0.36);
}
.item-card--world-otherworld.item-card--relic {
    background: linear-gradient(145deg, #1a1333, #0d1727 60%, #0a0f18);
    border-color: rgba(128, 217, 255, 0.34);
}
.item-card--world-otherworld.item-card--coin {
    background: linear-gradient(145deg, #473014, #161418 60%, #0d1018);
    border-color: rgba(255, 199, 108, 0.40);
}
.item-card--world-otherworld .item-card-head {
    color: #d8cce8;
}
.item-card--world-otherworld .item-card-stage {
    background: linear-gradient(170deg, #18102a 0%, #0e1420 100%);
    border-color: #3a2860;
}
.item-card--world-otherworld .item-card-surface::before {
    background:
        radial-gradient(ellipse 40% 40% at 30% 30%, rgba(120, 80, 200, .08) 0%, transparent 60%),
        radial-gradient(ellipse 30% 50% at 70% 60%, rgba(80, 120, 200, .06) 0%, transparent 60%);
    opacity: 1;
}
.item-card--world-otherworld .item-card-surface::after { display: none; }
.item-card--world-otherworld .item-card-body { color: #c8bce0; }
.item-card--world-otherworld .item-card-type {
    background: rgba(100, 60, 180, .3);
    color: #d8cce8;
}
.item-card--world-otherworld .item-card-mark {
    color: #9a80c0;
    text-shadow: 0 0 6px rgba(120, 80, 200, .3);
}

/* 异世界深底可读性兜底 */
.item-card--world-otherworld .item-card-title b { color: #e8e0f8; }
.item-card--world-otherworld .item-card-title small { color: #b0a0d0; }

/* 异世界文书化正文覆盖：更紧凑的行距与段距 */
.item-card--world-otherworld .item-card-body.doc-body-structured {
    line-height: 1.7;
    text-indent: 0;
    font-family: KaiTi, 楷体, 'STKaiti', serif;
    font-size: 1.05em;
}
/* 文书标题 */
.item-card--world-otherworld .doc-heading {
    text-align: center;
    font-size: 1.08em;
    font-weight: 600;
    color: #e8e0f8;
    margin: 0 0 .55em;
    letter-spacing: .06em;
}
/* 条款段 */
.item-card--world-otherworld .doc-clause {
    margin: .45em 0;
    color: #d0c4e8;
}
/* 文书字段行 */
.item-card--world-otherworld .doc-field {
    color: #b8a8d8;
    margin: .2em 0;
    text-indent: 0;
}
/* 普通段落 */
.item-card--world-otherworld .doc-para {
    margin: .5em 0;
    text-indent: 2em;
    color: #c8bce0;
}

/* ============================================================
   移动端
   ============================================================ */
@media (max-width: 900px) {
    .item-card {
        margin: 12px 0;
        max-width: 100%;
    }
    .item-card--note,
    .item-card--default {
        transform: rotate(-0.3deg);
    }
    .item-card-head {
        padding: 9px 12px 0;
        column-gap: 7px;
    }
    .item-card-type {
        font-size: 11px;
        padding: 2px 7px;
    }
    .item-card-title { font-size: 14px; }
    .item-card-stage {
        padding: 0 12px 15px;
        margin-top: 0;
    }
    .item-card-body {
        font-size: 15px;
        line-height: 1.78;
        margin: 0;
        text-indent: 2em;
    }
    .item-card-heading-main,
    .item-card-heading-sub {
        letter-spacing: 0.03em;
        text-shadow: none;
    }
    .item-card--style-rain .item-card-surface::before {
        opacity: 0.06;
    }
    .item-card--mat-damp .item-card-surface::before,
    .item-card--mat-rough .item-card-surface::before,
    .item-card--mat-bamboo .item-card-surface::before {
        opacity: 0.04;
    }
    .item-card--file .item-card-head::before {
        width: 36px;
    }
    .item-card--file .item-card-surface::after {
        font-size: 48px;
    }
    .item-card--file .item-card-stage {
        margin: 0 4px 4px;
    }
    .item-card--style-official .item-card-surface::before {
        font-size: 50px;
    }
    .item-card--style-jianghu .item-card-surface::after {
        font-size: 32px;
    }
    .item-card--style-sect .item-card-surface::after {
        font-size: 36px;
    }
    .item-card--quest::after {
        width: 14px;
        height: 14px;
    }
}

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

.history-load-control {
    display: flex;
    justify-content: center;
    flex: 0 0 auto;
    padding: 2px 0 6px;
}
.history-load-control button {
    min-height: 30px;
    max-width: min(100%, 360px);
    padding: 6px 14px;
    border: 1px solid rgba(128, 217, 255, 0.20);
    border-radius: 999px;
    background: rgba(128, 217, 255, 0.09);
    color: #cfefff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.history-load-control button:hover {
    background: rgba(128, 217, 255, 0.14);
}
.history-load-control.is-error button {
    border-color: rgba(255, 126, 126, 0.30);
    background: rgba(255, 126, 126, 0.10);
    color: #ffd1d1;
}
.history-load-control.is-loading button {
    opacity: 0.78;
    cursor: wait;
}

/* 滚动白名单：允许纵向触摸滚动 */
#chat-messages,
#chat-messages *,
.session-list,
.session-list *,
#sandbox-panel-mount,
#sandbox-panel-mount *,
.status-panel-body,
.status-panel-body *,
.wallet-log-list,
.wallet-log-list *,
.modal-body,
.modal-body *,
#announcements-list,
#announcements-list *,
#gallery-modal-body,
#gallery-modal-body * {
    touch-action: pan-y;
}

#chat-messages,
.session-list,
.status-panel-body,
.modal-body,
.modal,
.modal-box,
.wallet-log-list,
#gallery-modal-body {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

/* 可交互元素恢复触摸操作 */
textarea, input, select, [contenteditable="true"] {
    touch-action: manipulation;
}
button, a, label, [role="button"] {
    touch-action: manipulation;
}

#chat-messages::-webkit-scrollbar,
.session-list::-webkit-scrollbar,
.status-panel-body::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
#gallery-modal-body::-webkit-scrollbar,
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* ========== Scroll Slider（右侧半露手柄） ========== */
.scroll-slider {
    position: absolute;
    right: 0;
    width: 20px;
    z-index: 16;
    pointer-events: auto;
    transition: width 0.22s ease, background 0.22s ease;
    background: transparent;
    border-radius: 14px;
}

body.modal-open .scroll-slider {
    opacity: 0;
    pointer-events: none;
    transform: translateX(24px);
}

.scroll-slider.collapsed {
    width: 20px;
}

.scroll-slider.expanded {
    width: 28px;
    background: rgba(0, 0, 0, 0.12);
}

.scroll-slider::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 6px;
    bottom: 6px;
    width: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.scroll-slider.expanded::before {
    opacity: 1;
}

.scroll-slider-pull {
    position: absolute;
    left: 3px;
    right: 3px;
    width: auto;
    height: 44px;
    border-radius: 11px;
    background: rgba(225, 138, 36, 0.3);
    border: 1.5px solid rgba(225, 138, 36, 0.6);
    cursor: grab;
    z-index: 2;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

.scroll-slider.expanded .scroll-slider-pull {
    border-color: rgba(225, 138, 36, 0.75);
    background: rgba(225, 138, 36, 0.34);
}

.scroll-slider-pull.active {
    border-color: rgba(225, 138, 36, 0.85);
    background: rgba(225, 138, 36, 0.45);
    cursor: grabbing;
}

.scroll-slider-pull svg {
    width: 10px;
    height: 16px;
    stroke: rgba(225, 138, 36, 0.7);
    stroke-width: 1.2;
    stroke-linecap: round;
    fill: none;
}

.scroll-slider-tooltip {
    position: absolute;
    right: 32px;
    background: rgba(225, 138, 36, 0.9);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}

.scroll-slider-tooltip.visible {
    opacity: 1;
}

.scroll-slider-tooltip::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: rgba(225, 138, 36, 0.9);
}

.msg {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: var(--msg-font-size, 14px);
    line-height: var(--msg-line-height, 1.74);
    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: 8px 12px 7px;
    line-height: var(--msg-line-height-user, 1.58);
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.msg-user .msg-content {
    margin: 0;
}

.msg-assistant {
    align-self: flex-start;
    background: var(--bot-bubble);
    border: 1px solid var(--bot-border);
    padding: 8px 13px 6px;
    margin-bottom: 0;
    line-height: var(--msg-line-height-assistant, 1.86);
    outline: none;
}

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

.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-tag-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
    color: var(--muted);
    line-height: 1.4;
    align-items: center;
    position: relative;
}
.tag-bar-rollback {
    position: absolute;
    top: -36px;
    right: 0;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.tag-bar-rollback:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.4);
}
.msg-tag-bar .tag-bar-item {
    opacity: 1;
    transform: none;
    animation: none;
}
.tag-bar-time {
    background: rgba(255, 180, 0, 0.12);
    color: #ffb400;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 12px;
}
.tag-bar-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--muted);
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    white-space: nowrap;
}
.tag-bar-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
    transform: translateY(-1px);
}
.tag-bar-syncing {
    background: rgba(128, 217, 255, 0.12);
    color: #80d9ff;
    border: 1px solid rgba(128, 217, 255, 0.2);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    position: relative;
    overflow: hidden;
}
.tag-bar-syncing::after {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: rgba(128, 217, 255, 0.15);
    width: var(--tag-progress, 0%);
    transition: width 0.3s ease;
    pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
    .tag-bar-syncing::after { transition: none; }
}
@keyframes tag-item-reveal {
    from { opacity: 0; transform: translateY(2px); }
    to { opacity: 1; transform: translateY(0); }
}
/* NPC内心面板样式 */
.inner-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    text-align: center;
}
.inner-hint {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    margin-bottom: 8px;
    opacity: 0.7;
}
.inner-cost {
    font-size: 11px;
    opacity: 0.7;
}
.inner-char-unlocked .inner-cost { display: none; }
.inner-char-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 12px;
}
.inner-char-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(200, 168, 255, 0.08);
    border: 1px solid rgba(200, 168, 255, 0.2);
    color: #c8a8ff;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
}
.inner-char-label {
    display: inline-block;
}
.inner-char-btn:hover {
    background: rgba(200, 168, 255, 0.18);
    border-color: rgba(200, 168, 255, 0.4);
}
.inner-char-btn.active {
    background: rgba(200, 168, 255, 0.25);
    border-color: #c8a8ff;
    color: #fff;
    font-weight: 600;
}
.inner-char-loading {
    pointer-events: none;
}
.inner-char-btn[data-loading="1"] .inner-char-label,
.inner-char-btn[data-loading="1"] .inner-cost {
    visibility: hidden;
}
.inner-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid rgba(200, 168, 255, 0.32);
    border-top-color: #f2e8ff;
    border-radius: 50%;
    animation: inner-spin 0.6s linear infinite;
    pointer-events: none;
}
@keyframes inner-spin {
    to { transform: rotate(360deg); }
}
.inner-detail {
    background: rgba(200, 168, 255, 0.06);
    border: 1px solid rgba(200, 168, 255, 0.12);
    border-radius: 8px;
    padding: 12px;
}
.inner-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #d4b8ff;
    margin-bottom: 6px;
}
.inner-thought-content {
    font-style: italic;
    color: #c8a8ff;
    line-height: 1.6;
    padding: 4px 0;
    white-space: pre-wrap;
    font-size: 13px;
}

.msg-meta {
    margin-top: 8px;
    margin-bottom: 0;
    font-size: 11px;
    color: var(--muted);
    outline: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.msg-meta-info {
    font-size: 10px;
    color: var(--muted);
    opacity: 0.5;
    text-align: right;
    margin-top: 2px;
    line-height: 1.2;
}

.msg-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.msg-user .msg-actions {
    justify-content: flex-end;
    margin-top: 0;
}

.msg-user .msg-meta-info {
    margin-top: 0;
    align-self: flex-end;
}

.msg-action {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.msg-action .action-cost {
    font-size: 10px;
    opacity: 0.7;
}
.msg-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.06);
}
.msg-action:active {
    transform: scale(0.95);
    transition-duration: 0.05s;
}
.msg-action:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}
/* 复制 - 灰色 */
.msg-action.msg-copy {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #888;
}
.msg-action.msg-copy:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ccc;
}
/* 重新生成 - 蓝色 */
.msg-action.msg-regenerate {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}
.msg-action.msg-regenerate:hover {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.4);
}
/* 生成图片 - 紫色 */
.msg-action.msg-gen-image {
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: #c084fc;
}
.msg-action.msg-gen-image:hover {
    background: rgba(168, 85, 247, 0.16);
    border-color: rgba(168, 85, 247, 0.4);
}
.msg-action.msg-gen-image.msg-gen-image-busy {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.35);
    color: #d8b4fe;
}
.msg-action.msg-gen-image.msg-gen-image-retry {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fda4af;
}
.msg-action.msg-gen-image.msg-gen-image-retry:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.35);
}
.msg-action.msg-view-image {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #86efac;
}
.msg-action.msg-view-image:hover {
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(34, 197, 94, 0.4);
}
.msg-action.msg-image-regen {
    background: rgba(249, 115, 22, 0.08);
    border: 1px solid rgba(249, 115, 22, 0.2);
    color: #fdba74;
}
.msg-action.msg-image-regen:hover {
    background: rgba(249, 115, 22, 0.16);
    border-color: rgba(249, 115, 22, 0.35);
}
/* 编辑 - 琥珀色 */
.msg-action.msg-edit {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}
.msg-action.msg-edit:hover {
    background: rgba(251, 191, 36, 0.16);
    border-color: rgba(251, 191, 36, 0.4);
}
/* 回溯 - 红色 */
.msg-action.msg-rollback {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #9ca3af;
}
.msg-action.msg-rollback:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #d1d5db;
}
.msg-action.msg-delete {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.22);
    color: #ffb4b4;
}
.msg-action.msg-delete:hover {
    background: rgba(248, 113, 113, 0.16);
    border-color: rgba(248, 113, 113, 0.38);
    color: #ffd1d1;
}

.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: #d6c6ef;
    font-size: 13px;
    padding: 7px 10px;
    border: 1px solid rgba(128,217,255,0.12);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(128,217,255,0.08), rgba(255,199,108,0.035)),
        rgba(255,255,255,0.025);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    animation: loading-pulse 1.5s ease-in-out infinite;
}
.msg-loading-dots {
    display: inline-flex;
    align-items: center;
    margin-left: 2px;
    letter-spacing: 0;
}
.msg-loading-dots span {
    display: inline-block;
    width: 0.35em;
    text-align: center;
    opacity: 0.2;
    animation: loading-dot 1.2s infinite;
}
.msg-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.msg-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes loading-pulse {
    0%, 100% { opacity: 0.72; box-shadow: 0 0 0 rgba(128,217,255,0); }
    50% { opacity: 1; box-shadow: 0 0 16px rgba(128,217,255,0.10); }
}
@keyframes loading-dot {
    0%, 80%, 100% { opacity: 0.2; }
    40% { 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: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: 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 {
    width: 100%;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 160px;
    font-size: 14px;
    line-height: 1.5;
    padding: 2px 4px;
}

.input-actions-trailing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.time-advance-area {
    position: relative;
    display: inline-flex;
}

.time-advance-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    cursor: pointer;
}

.time-advance-btn.is-open,
.time-advance-btn:hover {
    color: #fff0c9;
    background: rgba(255, 199, 108, 0.18);
}

.time-advance-popover {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    width: 256px;
    padding: 9px;
    border: 1px solid rgba(255, 199, 108, 0.22);
    border-radius: 8px;
    background: rgba(12, 16, 24, 0.97);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
    z-index: 40;
}

.time-advance-title {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 5px;
}

.time-advance-current {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    margin: 0 0 7px;
    padding: 6px 7px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
}

.time-advance-current b {
    min-width: 0;
    overflow: hidden;
    color: #fff0c9;
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-current-actions {
    display: flex;
    justify-content: flex-end;
    margin: -2px 0 8px;
}

.btn-world-time-edit.active {
    border-color: rgba(255, 199, 108, 0.42);
    color: #fff0c9;
    background: rgba(255, 199, 108, 0.12);
}

.time-advance-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.time-advance-opt {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    padding: 6px 8px;
    font-size: 12px;
    cursor: pointer;
}

.time-advance-opt:hover,
.time-advance-opt.active {
    border-color: rgba(255, 199, 108, 0.48);
    background: rgba(255, 199, 108, 0.14);
    color: #fff0c9;
}

.time-advance-custom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 76px auto;
    gap: 5px;
    margin-top: 7px;
}

.time-advance-custom input,
.time-advance-custom select {
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 6px 8px;
    font-size: 12px;
    color-scheme: dark;
}

.time-advance-custom select option {
    background: #121826;
    color: #eef4fb;
}

/* ========== Font size toggle ========== */
.font-size-area {
    position: relative;
}
#btn-font-size {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    color: #9ac7ff;
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: rgba(59, 130, 246, 0.12);
}
#btn-font-size:hover,
#btn-font-size.is-open {
    color: #d7ebff;
    background: rgba(59, 130, 246, 0.2);
}
#btn-fullscreen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    transition: all 0.15s;
}
#btn-fullscreen.state-expand {
    color: #ffd978;
    border: 1px solid rgba(250, 204, 21, 0.35);
    background: rgba(250, 204, 21, 0.12);
}
#btn-fullscreen.state-expand:hover {
    color: #fff2be;
    background: rgba(250, 204, 21, 0.2);
}
#btn-fullscreen.state-shrink {
    color: #ff9797;
    border: 1px solid rgba(248, 113, 113, 0.35);
    background: rgba(248, 113, 113, 0.12);
}
#btn-fullscreen.state-shrink:hover {
    color: #ffdede;
    background: rgba(248, 113, 113, 0.2);
}
.font-size-popover {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    display: flex;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 20;
}
.font-size-opt {
    background: none;
    border: 1px solid transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-weight: 700;
    transition: all 0.15s;
    line-height: 1;
}
.font-size-opt:hover {
    color: var(--text);
    background: rgba(255,255,255,0.06);
}
.font-size-opt.active {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(255,142,60,0.1);
}
.font-size-opt[data-size="16"] { font-size: 14px; }
.font-size-opt[data-size="18"] { font-size: 17px; }
.font-size-opt[data-size="20"] { font-size: 21px; }

.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; }
.queue-status.tag-sync .queue-dot { background: #80d9ff; }
@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* 剧情总结中状态徽标 */
.summary-status-badge {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 20;
    font-size: 12px;
    color: var(--muted);
    background: rgba(128, 217, 255, 0.1);
    border: 1px solid rgba(128, 217, 255, 0.2);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    animation: summary-badge-in 0.3s ease;
    pointer-events: none;
}
.summary-status-badge.hidden { display: none; }
.summary-status-badge.fade-out { animation: summary-badge-out 0.5s ease forwards; }
.summary-spinner {
    width: 12px; height: 12px;
    border: 2px solid rgba(128, 217, 255, 0.3);
    border-top-color: #80d9ff;
    border-radius: 50%;
    animation: summary-spin 0.8s linear infinite;
}
@keyframes summary-spin {
    to { transform: rotate(360deg); }
}
@keyframes summary-badge-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes summary-badge-out {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-6px); }
}

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

/* ========== Suggest Dropdown ========== */
#btn-suggest {
    position: relative;
    font-size: 22px;
    padding: 0 6px;
    align-self: stretch !important;
    display: flex;
    align-items: center;
    min-width: 36px;
}

.input-shortcut-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(242, 246, 251, 0.82);
    transition: all 0.15s ease;
}

.input-shortcut-btn:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.24);
    color: #fff;
}

.suggest-shortcut {
    font-size: 16px;
    line-height: 1;
    grid-row: span 2;
    height: auto;
}
#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);
}

#status-panel,
#inner-panel {
    align-items: flex-start;
    padding-top: 8vh;
}

.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: hidden;
    display: flex;
    flex-direction: column;
    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: hidden;
    display: flex;
    flex-direction: column;
}

.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(239, 68, 68, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 14px;
    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(239, 68, 68, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}
.modal-close-btn svg {
    width: 21px;
    height: 21px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#modal-new-chat > .modal {
    max-height: min(92vh, 820px);
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modal-new-chat > .modal > .modal-header {
    flex-shrink: 0;
}

#modal-new-chat > .modal > .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 10px;
}

#modal-new-chat #btn-create-chat {
    flex: 0 0 auto;
    min-height: 44px;
    margin-top: 4px;
    margin-bottom: 2px;
}

#announcements-list,
#gallery-modal-body {
    max-height: 70vh;
}

/* ========== 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-code-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
    justify-items: start;
}
.auth-code-row #register-code {
    flex: 1;
    width: 100%;
}
.auth-code-row .auth-code-send {
    width: 128px !important;
    min-width: 128px;
    max-width: 72vw;
    min-height: 32px;
    justify-content: flex-start !important;
    text-align: left !important;
    align-self: flex-start !important;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.1;
    color: #d8f1ff;
    background: rgba(128, 217, 255, 0.14);
    border: 1px solid rgba(128, 217, 255, 0.42);
}
.auth-code-row .auth-code-send:hover {
    background: rgba(128, 217, 255, 0.22);
    border-color: rgba(128, 217, 255, 0.62);
}

.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);
}

/* Tag select (统一下拉标签样式) */
.tag-select {
    position: relative;
    width: 100%;
}
.tag-select-trigger {
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.tag-select-trigger:hover {
    border-color: rgba(255, 142, 60, 0.45);
    background: rgba(255, 142, 60, 0.08);
}
.tag-select.open .tag-select-trigger {
    border-color: var(--primary);
    background: rgba(255, 142, 60, 0.12);
}
.tag-select-value {
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tag-select-caret {
    font-size: 14px;
    color: var(--muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.tag-select.open .tag-select-caret {
    transform: rotate(180deg);
    color: var(--primary-soft);
}
.tag-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 210px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(14, 20, 31, 0.98);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    z-index: 130;
    padding: 4px;
}
.tag-select-option {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 13px;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.tag-select-option-main {
    display: block;
}
.tag-select-option-hint {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
}
.tag-select-option:hover {
    background: rgba(255, 255, 255, 0.07);
}
.tag-select-option.active {
    background: rgba(255, 142, 60, 0.14);
    color: var(--primary-soft);
    font-weight: 600;
}

.tag-select-option.active .tag-select-option-hint {
    color: rgba(255, 199, 108, 0.74);
}

body.sandbox-app #sandbox-official-route-pack-field .tag-select-trigger,
body.sandbox-app #sandbox-official-opening-event-field .tag-select-trigger,
body.sandbox-app #isekai-route-pack-field .tag-select-trigger,
body.sandbox-app #isekai-opening-event-field .tag-select-trigger {
    background:
        linear-gradient(135deg, rgba(255, 199, 108, 0.08), rgba(128, 217, 255, 0.045)),
        var(--sandbox-active-field-bg, rgba(255, 255, 255, 0.05));
    border-color: color-mix(in srgb, var(--sandbox-accent, #ff8e3c) 30%, var(--sandbox-active-field-border, rgba(255,255,255,.1)));
}

body.sandbox-app #sandbox-official-route-pack-field .tag-select-trigger:hover,
body.sandbox-app #sandbox-official-opening-event-field .tag-select-trigger:hover,
body.sandbox-app #sandbox-official-route-pack-field .tag-select.open .tag-select-trigger,
body.sandbox-app #sandbox-official-opening-event-field .tag-select.open .tag-select-trigger,
body.sandbox-app #isekai-route-pack-field .tag-select-trigger:hover,
body.sandbox-app #isekai-opening-event-field .tag-select-trigger:hover,
body.sandbox-app #isekai-route-pack-field .tag-select.open .tag-select-trigger,
body.sandbox-app #isekai-opening-event-field .tag-select.open .tag-select-trigger {
    border-color: color-mix(in srgb, var(--sandbox-accent, #ff8e3c) 58%, rgba(255,255,255,.12));
    background:
        linear-gradient(135deg, rgba(255, 199, 108, 0.13), rgba(128, 217, 255, 0.07)),
        var(--sandbox-active-field-bg, rgba(255, 255, 255, 0.06));
}

/* 兼容旧选择器（保留） */
.ninja-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.ninja-pill {
    padding: 6px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.2;
}
.ninja-pill:hover {
    background: rgba(255, 142, 60, 0.1);
    border-color: rgba(255, 142, 60, 0.4);
    color: var(--text);
}
.ninja-pill.active {
    background: rgba(255, 142, 60, 0.15);
    border-color: var(--primary);
    color: var(--primary-soft);
    font-weight: 600;
}

/* Opening mode selector */
.opening-mode-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.opening-mode-field .tag-select-trigger {
    min-height: 42px;
}
.opening-mode-field .tag-select-value {
    font-size: 14px;
}
.opening-mode-hint {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    padding: 0 2px;
}
#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: #f2a445;
    font-style: normal;
    quotes: none;
}

.msg-content .inline-quote,
.msg-content q.inline-quote {
    display: inline;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

.msg-content .sfx-word {
    color: #f3b35d;
    font-weight: 600;
}

.msg-content .sfx-quote {
    color: #f3b35d;
    font-weight: 600;
    display: inline;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

.msg-content .dialogue-quote {
    display: block;
    color: #f2a445;
    background: linear-gradient(90deg, rgba(225, 138, 36, 0.16), rgba(225, 138, 36, 0.06));
    border: 1px solid rgba(225, 138, 36, 0.28);
    border-left: 3px solid rgba(225, 138, 36, 0.55);
    border-radius: 8px;
    padding: 7px 11px 7px 12px;
    margin: 9px 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.msg-content .dialogue-quote em, .msg-content .dialogue-quote i,
.msg-content .dialogue-quote .sfx-word,
.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;
}

/* 小说感排版：仅 AI 正文旁白段落首行缩进 */
.msg-assistant .msg-content p {
    text-indent: 2em;
    margin: 0 0 0.9em;
    line-height: var(--msg-line-height-assistant, 1.86);
}
.msg-assistant .msg-content {
    letter-spacing: var(--msg-letter-spacing-assistant, 0.02em);
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    line-break: strict;
    text-wrap: pretty;
}
.msg-assistant .msg-content p:last-child {
    margin-bottom: 0;
}

/* 对话黄框与引用块保持顶格，不参与旁白缩进 */
.msg-assistant .msg-content p .dialogue-quote,
.msg-assistant .msg-content p q.dialogue-quote,
.msg-assistant .msg-content p blockquote,
.msg-assistant .msg-content p pre {
    text-indent: 0;
}

.msg-content {
    margin: 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);
    word-break: normal;
    overflow-wrap: break-word;
    line-break: strict;
}

/* ========== 故事卡片 ========== */
.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;
}

/* ========== 编辑模式 ========== */
.editor-hint {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

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

.model-mode {
    margin-bottom: 12px;
}

.model-mode-title {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.model-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.model-card {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.model-card:hover {
    border-color: rgba(255, 142, 60, 0.35);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.model-card.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
    box-shadow: 0 0 12px rgba(255, 142, 60, 0.1);
}

.model-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.model-card-desc {
    margin-top: 4px;
    font-size: 11px;
    color: var(--muted);
    line-height: 1.45;
}

.editor-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.editor-card:hover {
    border-color: rgba(255, 142, 60, 0.35);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.editor-card.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
    box-shadow: 0 0 12px rgba(255, 142, 60, 0.1);
}

.editor-card-icon {
    font-size: 22px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.editor-card-body {
    flex: 1;
    min-width: 0;
}

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

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

.editor-card-tag {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    letter-spacing: 0.5px;
}

.editor-card-tag.tag-accent {
    background: rgba(128, 217, 255, 0.1);
    color: var(--accent);
}

.editor-card-tag.tag-rare {
    background: rgba(255, 142, 60, 0.12);
    color: var(--primary-soft);
}

/* 思考模式 */
.editor-think {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.editor-switch-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.editor-switch-group .editor-think {
    margin-top: 0;
}

.editor-think-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.editor-think-label input[type="checkbox"] {
    display: none;
}

.editor-think-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.editor-think-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.2s, background 0.2s;
}

.editor-think-label input:checked + .editor-think-switch {
    background: var(--primary-dim);
}

.editor-think-label input:checked + .editor-think-switch::after {
    transform: translateX(16px);
    background: var(--primary);
}

.editor-think-desc {
    margin: 8px 0 0 46px;
    font-size: 11px;
    color: var(--muted);
    line-height: 1.5;
    opacity: 0.8;
}

/* ========== 状态面板 ========== */
.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;
    overflow-y: auto;
}

.status-world-time {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(255, 180, 0, 0.22);
    border-radius: 7px;
    background: rgba(255, 180, 0, 0.08);
    color: #ffcb73;
    padding: 8px 10px;
    font-size: 12px;
}

.status-world-time-label {
    color: var(--muted);
    white-space: nowrap;
}

.status-world-time-value {
    min-width: 0;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status tabs + list */
.status-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}
.status-tab {
    min-height: 40px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
}
.status-tab:hover {
    border-color: rgba(128, 217, 255, 0.45);
    background: rgba(128, 217, 255, 0.08);
}
.status-tab.active {
    border-color: rgba(128, 217, 255, 0.75);
    background: rgba(128, 217, 255, 0.2);
    box-shadow: 0 0 0 1px rgba(128, 217, 255, 0.35) inset;
}
.status-tab-icon {
    font-size: 13px;
    line-height: 1;
}
.status-tab-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.status-tab-panel {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 10px 6px;
}
.status-tab-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-soft);
    margin-bottom: 8px;
}
.status-list {
    margin: 0;
    padding: 0 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.status-list-item {
    font-size: 12px;
    line-height: 1.55;
    color: var(--text);
    white-space: pre-wrap;
    opacity: 1;
    transform: none;
    animation: none;
}
.status-profile-grid,
.status-profile-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.status-profile-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.045);
}
.status-profile-card.wide {
    min-height: 64px;
}
.status-profile-card span {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}
.status-profile-card strong {
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
    font-weight: 600;
    word-break: break-word;
}
.status-profile-block {
    margin-top: 10px;
}
.status-profile-heading {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.status-profile-text {
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.status-hero-card {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 12px;
    border: 1px solid rgba(128, 217, 255, 0.18);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(128, 217, 255, 0.08), rgba(255, 180, 108, 0.045)),
        rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.status-hero-title {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--primary-soft);
    font-size: 13px;
    line-height: 1.4;
}
.status-field-row {
    display: grid;
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 9px;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 7px;
    background: rgba(0,0,0,0.12);
}
.status-field-label-rich {
    color: #ffcf8a;
    font-size: 12px;
    line-height: 1.65;
    white-space: nowrap;
}
.status-field-copy {
    min-width: 0;
    color: var(--text);
    font-size: 12px;
    line-height: 1.7;
    word-break: normal;
    overflow-wrap: break-word;
}
.status-rumor-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.status-rumor-line {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 6px;
    align-items: start;
}
.status-rumor-avatar {
    line-height: 1.5;
    opacity: 0.95;
}
.status-rumor-text {
    min-width: 0;
    color: var(--muted);
    line-height: 1.65;
}
.status-rumor-text b {
    color: var(--text);
    font-weight: 700;
}
.affinity-card-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 8px;
    max-height: min(42vh, 420px);
    overflow-y: auto;
    padding-right: 4px;
}
.affinity-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.affinity-card:hover,
.affinity-card:focus-visible {
    border-color: color-mix(in srgb, var(--sandbox-accent, var(--primary)) 48%, var(--border));
    background: rgba(255,255,255,0.07);
    transform: translateY(-1px);
    outline: none;
}
.affinity-card-main {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) minmax(34px, auto);
    gap: 6px;
    align-items: center;
}
.affinity-avatar {
    font-size: 20px;
    line-height: 1;
    text-align: center;
}
.affinity-name {
    min-width: 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.affinity-score {
    min-width: 30px;
    padding: 1px 6px;
    border: 1px solid rgba(255, 207, 138, 0.28);
    border-radius: 7px;
    background: rgba(255,255,255,0.08);
    color: #ffcf8a;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
}
.affinity-tier {
    color: #ffd28f;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.45;
}
.affinity-desc {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
    word-break: normal;
    overflow-wrap: break-word;
}
.affinity-card-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 2px;
}
.status-profile-scroll {
    max-height: min(42vh, 460px);
    overflow-y: auto;
    padding-right: 4px;
}
@keyframes status-item-reveal {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── isekai status panel ── */
.isekai-status-panel { display:flex; flex-direction:column; gap:14px; }
.isekai-section { background:rgba(255,255,255,.02); border:1px solid var(--border); border-radius:var(--radius-sm); padding:10px; }
.isekai-section-title { font-size:12px; font-weight:700; color:var(--primary-soft); margin-bottom:8px; display:flex; align-items:center; gap:6px; }
.isekai-subsection { margin-top:10px; padding-top:10px; border-top:1px solid rgba(255,255,255,.07); }
.isekai-subtitle { font-size:12px; font-weight:700; color:var(--muted); margin-bottom:7px; }
.isekai-identity-meter { display:flex; gap:4px; }
.isekai-meter-step { flex:1; display:flex; flex-direction:column; align-items:center; gap:3px; padding:6px 4px; border-radius:6px; background:rgba(255,255,255,.02); border:1px solid var(--border); opacity:.4; transition:all .2s; }
.isekai-meter-step.active { opacity:1; border-color:var(--step-color, var(--border)); }
.isekai-meter-step.current { background:rgba(255,255,255,.06); box-shadow:0 0 8px rgba(var(--step-color, 128,217,255),.2); }
.isekai-meter-step .step-icon { font-size:14px; }
.isekai-meter-step .step-label { font-size:10px; color:var(--muted); white-space:nowrap; }
.isekai-meter-step.active .step-label { color:var(--step-color, var(--text)); font-weight:600; }
.isekai-corruption-bar { height:8px; background:rgba(255,255,255,.06); border-radius:4px; overflow:hidden; }
.isekai-corruption-fill { height:100%; border-radius:4px; transition:width .3s ease; }
.isekai-corruption-badge { font-size:11px; font-weight:600; padding:1px 8px; border-radius:10px; color:#fff; }
.isekai-faction-list { display:flex; flex-direction:column; gap:6px; }
.isekai-faction-row { display:flex; align-items:center; gap:8px; }
.isekai-faction-row .faction-name { font-size:11px; color:var(--muted); width:80px; flex-shrink:0; text-align:right; }
.isekai-faction-row .faction-bar-wrap { flex:1; height:6px; background:rgba(255,255,255,.06); border-radius:3px; position:relative; overflow:hidden; }
.isekai-faction-row .faction-bar-center { position:absolute; left:50%; top:0; width:1px; height:100%; background:rgba(255,255,255,.15); }
.isekai-faction-row .faction-bar-fill { position:absolute; top:0; height:100%; border-radius:3px; transition:width .3s; }
.isekai-faction-row .faction-bar-right { left:50%; }
.isekai-faction-row .faction-bar-left { right:50%; }
.isekai-faction-row .faction-val { font-size:11px; font-weight:600; width:36px; text-align:center; }
.faction-remove-btn { font-size:14px; color:#e74c3c; cursor:pointer; opacity:.5; transition:opacity .2s; margin-left:4px; }
.faction-remove-btn:hover { opacity:1; }
.isekai-faction-add-row { margin-top:6px; }
.isekai-faction-add-btn { font-size:11px; color:var(--primary-soft); background:rgba(255,255,255,.06); border:1px dashed rgba(255,255,255,.15); border-radius:4px; padding:3px 10px; cursor:pointer; transition:background .2s; }
.isekai-faction-add-btn:hover { background:rgba(255,255,255,.12); }
.isekai-region-bar { display:flex; gap:6px; flex-wrap:wrap; }
.isekai-region-bar .region-tag, .isekai-region-bar .stage-tag, .isekai-region-bar .route-tag { font-size:11px; padding:2px 8px; border-radius:4px; background:rgba(255,255,255,.08); color:var(--primary-soft); }
.isekai-region-bar .stage-tag { background:rgba(52,152,219,.15); color:#3498db; }
.isekai-region-bar .route-tag { background:rgba(46,204,113,.15); color:#2ecc71; }
.isekai-contract-meter { height:8px; background:rgba(255,255,255,.06); border-radius:4px; overflow:hidden; }
.isekai-contract-fill { height:100%; border-radius:4px; transition:width .3s ease; }
.isekai-contract-badge, .isekai-supply-badge { font-size:11px; font-weight:600; padding:1px 8px; border-radius:10px; color:#fff; }
.isekai-key-figures, .isekai-potential-events { font-size:12px; color:var(--muted); line-height:1.6; }

/* ── isekai template picker ── */
.isekai-template-overlay { position:fixed; inset:0; z-index:10000; background:rgba(0,0,0,.6); display:flex; align-items:center; justify-content:center; backdrop-filter:blur(2px); }
.isekai-template-dialog { background:var(--surface, #1a1d23); border:1px solid var(--border); border-radius:12px; width:min(680px, 92vw); max-height:80vh; display:flex; flex-direction:column; box-shadow:0 16px 48px rgba(0,0,0,.4); }
.isekai-template-header { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--border); font-size:14px; font-weight:700; color:var(--primary-soft); }
.isekai-template-close { background:none; border:none; color:var(--muted); font-size:16px; cursor:pointer; padding:4px 8px; border-radius:4px; }
.isekai-template-close:hover { background:rgba(255,255,255,.08); }
.isekai-template-footer { display:flex; justify-content:flex-end; gap:8px; padding:12px 16px; border-top:1px solid var(--border); }

.maintenance-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 20, .72);
    backdrop-filter: blur(4px);
}
.maintenance-overlay.hidden { display: none; }
.maintenance-card {
    width: min(320px, calc(100vw - 40px));
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface, #171b24);
    color: var(--text);
    padding: 22px 20px;
    text-align: center;
    box-shadow: 0 18px 48px rgba(0,0,0,.38);
}
.maintenance-spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 12px;
    border: 3px solid rgba(255,255,255,.16);
    border-top-color: var(--primary-soft, #80d9ff);
    border-radius: 50%;
    animation: spin .9s linear infinite;
}
.maintenance-title { font-weight: 700; margin-bottom: 6px; }
.maintenance-text { color: var(--muted); font-size: 13px; line-height: 1.6; }

.time-current-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    margin: 4px 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,.03);
}
.time-editor-title { color: var(--muted); font-size: 12px; }
.time-editor-row {
    display: flex;
    align-items: center;
    gap: 5px;
}
.time-editor-row input {
    min-width: 0;
    height: 28px;
    padding: 4px 7px;
    border: 1px solid var(--sandbox-active-field-border, var(--border));
    border-radius: 6px;
    background: var(--sandbox-active-field-bg, rgba(255,255,255,.05));
    color: var(--text);
}
.time-editor-row input[data-world-time-calendar] { flex: 1.2; }
.time-editor-row input[data-world-time-year] { flex: .8; }
.time-editor-row.compact input { width: 52px; }
.time-editor-row.compact input[data-world-time-minute] { width: 48px; }
.btn-world-time-save { align-self: flex-end; }

/* ── inventory panel ── */
.inv-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.inv-chip {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.inv-chip:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.inv-chip.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary-soft);
}
.inv-body { max-height: 360px; overflow-y: auto; }
.inv-overview-total {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
}
.inv-overview-total strong { color: var(--primary-soft); font-size: 16px; }
.inv-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.inv-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 6px;
    background:
        radial-gradient(circle at 50% 0, rgba(255,255,255,0.08), transparent 52%),
        rgba(255,255,255,0.03);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.inv-stat-card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--primary) 26%, var(--border-light));
}
.inv-stat-icon { font-size: 18px; }
.inv-stat-count { font-size: 16px; font-weight: 700; color: var(--text); }
.inv-stat-label { font-size: 10px; color: var(--muted); }
.inv-stat-empty { opacity: 0.4; }
.inv-bucket-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 24px 0; }
.inv-recent-title { font-size: 12px; font-weight: 700; color: var(--primary-soft); margin-bottom: 6px; }
.inv-change-list { list-style: none; padding: 0; margin: 0; }
.inv-change-item {
    font-size: 12px;
    color: var(--muted);
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
    line-height: 1.5;
}
.inv-change-item.empty { color: rgba(255,255,255,0.2); font-style: italic; }
.inv-item-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 7px;
}
.inv-item {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--text);
    padding: 8px 9px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background:
        radial-gradient(circle at 0 50%, rgba(255,199,108,0.055), transparent 42%),
        linear-gradient(90deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015)),
        rgba(255,255,255,0.018);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    position: relative;
    overflow: hidden;
    transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.inv-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 0 2px 2px 0;
    background: rgba(255,255,255,0.12);
}
.inv-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 0 42%, rgba(255,255,255,0.055) 50%, transparent 58%);
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform .42s ease, opacity .18s ease;
}
.inv-item:hover {
    transform: translateX(2px);
    border-color: color-mix(in srgb, var(--primary) 24%, var(--border-light));
    background:
        linear-gradient(90deg, var(--primary-dim), rgba(255,255,255,0.018)),
        rgba(255,255,255,0.025);
    box-shadow: 0 8px 18px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.04);
}
.inv-item:hover::after {
    transform: translateX(110%);
    opacity: 1;
}
.inv-item-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
    border-radius: 8px;
    background:
        radial-gradient(circle at 35% 20%, rgba(255,255,255,0.14), transparent 42%),
        rgba(255,255,255,0.035);
    font-size: 15px;
    position: relative;
    z-index: 1;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.inv-item-main {
    min-width: 0;
    flex: 1;
    display: grid;
    gap: 3px;
    position: relative;
    z-index: 1;
}
.inv-item-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.inv-item-qty { color: var(--primary-soft); font-weight: 700; font-size: 12px; }
.inv-item-meta {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.inv-item-type { font-size: 10px; color: var(--muted); background: rgba(255,255,255,0.04); padding: 1px 6px; border-radius: 4px; }
.inv-item--currency::before { background: #ffd978; }
.inv-item--equipment::before { background: #ffc76c; }
.inv-item--quest_item::before { background: #80d9ff; }
.inv-item--consumable::before { background: #71d3a4; }
.inv-item--realestate::before { background: #c8a8ff; }
.inv-item--slave::before { background: #f0a8ff; }
.inv-item--other::before { background: #aeb8cc; }
.inv-item--currency .inv-item-icon { color: #ffd978; border-color: rgba(255,217,120,.30); background: radial-gradient(circle at 35% 22%, rgba(255,217,120,.18), rgba(255,217,120,.06)); }
.inv-item--equipment .inv-item-icon { color: #ffc76c; border-color: rgba(255,199,108,.30); background: radial-gradient(circle at 35% 22%, rgba(255,199,108,.18), rgba(255,199,108,.06)); }
.inv-item--quest_item .inv-item-icon { color: #80d9ff; border-color: rgba(128,217,255,.30); background: radial-gradient(circle at 35% 22%, rgba(128,217,255,.18), rgba(128,217,255,.06)); }
.inv-item--consumable .inv-item-icon { color: #71d3a4; border-color: rgba(113,211,164,.30); background: radial-gradient(circle at 35% 22%, rgba(113,211,164,.18), rgba(113,211,164,.06)); }
.inv-item--realestate .inv-item-icon { color: #c8a8ff; border-color: rgba(200,168,255,.30); background: radial-gradient(circle at 35% 22%, rgba(200,168,255,.18), rgba(200,168,255,.06)); }
.inv-item--slave .inv-item-icon { color: #f0a8ff; border-color: rgba(240,168,255,.28); background: radial-gradient(circle at 35% 22%, rgba(240,168,255,.16), rgba(240,168,255,.055)); }
.inv-item--other .inv-item-icon { color: #cbd5e1; border-color: rgba(203,213,225,.22); background: radial-gradient(circle at 35% 22%, rgba(203,213,225,.12), rgba(203,213,225,.04)); }

/* ── inventory editor ── */
.inv-chips-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inv-chips-wrap .inv-chips { flex: 1; }
.inv-edit-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.inv-edit-btn:hover { background: var(--primary-dim); border-color: var(--primary); color: var(--primary-soft); }
.inv-editor-title {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 15px; font-weight: 600; color: #f2f6fb; margin-bottom: 12px;
}
.inv-editor-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }
.inv-editor-close:hover { color: var(--text); }
.inv-editor-body { max-height: 60vh; overflow-y: auto; margin-bottom: 16px; }
.inv-editor-bucket-label { font-size: 13px; font-weight: 600; color: var(--primary-soft); margin: 12px 0 6px; }
.inv-editor-bucket-label:first-child { margin-top: 0; }
.inv-editor-row {
    display: flex; gap: 6px; margin-bottom: 6px; align-items: center;
    flex-wrap: wrap;
}
.inv-editor-row input {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 6px 8px; font-size: 12px;
    color: var(--text); outline: none; box-sizing: border-box;
}
.inv-editor-row input:focus { border-color: var(--accent); }
.inv-editor-row input:nth-child(1) { flex: 3; min-width: 100px; }
.inv-editor-row input:nth-child(2) { flex: 1; min-width: 60px; }
.inv-editor-row input:nth-child(3) { flex: 1; min-width: 50px; }
.inv-editor-row input:nth-child(4) { flex: 2; min-width: 80px; }
.inv-editor-delete {
    background: none; border: none; color: #e74c3c; font-size: 16px;
    cursor: pointer; padding: 2px 6px; flex-shrink: 0; line-height: 1;
}
.inv-editor-delete:hover { color: #ff6b6b; }
.inv-editor-add-row {
    background: rgba(255,255,255,0.04); border: 1px dashed var(--border);
    color: var(--muted); font-size: 12px; padding: 6px 12px;
    border-radius: var(--radius-sm); cursor: pointer; width: 100%;
    text-align: center; margin-top: 4px;
}
.inv-editor-add-row:hover { border-color: var(--primary); color: var(--primary-soft); }

/* ── wlog panel ── */
/* === 世界报告面板（结构化分段） === */
.wlog-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 420px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.wlog-seg {
    display: grid;
    grid-template-columns: 20px auto;
    grid-template-rows: auto auto;
    gap: 0 6px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.02);
    font-size: 13px;
    line-height: 1.55;
}
.wlog-seg-icon {
    grid-row: 1 / 3;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}
.wlog-seg-label {
    font-weight: 600;
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: .04em;
}
.wlog-seg-body {
    color: var(--text);
    word-break: break-word;
    overflow-wrap: anywhere;
}
/* 分段类型色条 */
.wlog-seg--mainline { border-left: 3px solid rgba(52,152,219,.45); }
.wlog-seg--events   { border-left: 3px solid rgba(241,196,15,.45); }
.wlog-seg--figures  { border-left: 3px solid rgba(155,89,182,.45); }
.wlog-seg--dead     { border-left: 3px solid rgba(231,76,60,.45); }
.wlog-seg--corruption { border-left: 3px solid rgba(46,204,113,.35); }
.wlog-seg--exposure { border-left: 3px solid rgba(230,126,34,.45); }
.wlog-seg--deviation { border-left: 3px solid rgba(149,165,166,.45); }
.wlog-seg--mem {
    border-left: 3px solid rgba(128,217,255,.3);
    grid-template-columns: 20px 1fr;
}
.wlog-seg--mem .wlog-seg-icon { grid-row: 1; }
.wlog-seg--mem .wlog-seg-body { grid-column: 2; }

/* 移动端紧凑 */
@media (max-width: 600px) {
    .wlog-panel { gap: 5px; max-height: 50vh; }
    .wlog-seg { padding: 7px 8px; font-size: 12.5px; gap: 0 5px; }
    .wlog-seg-icon { font-size: 13px; }
    .wlog-seg-label { font-size: 10.5px; }
}
.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-modal-body {
    position: relative;
    overflow-y: auto;
}

.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-story-label {
    color: var(--accent);
    margin-right: 4px;
}

.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;
}
.gallery-btn-set-bg {
    color: #9bd8ff !important;
    border-color: rgba(80, 180, 255, 0.35) !important;
    background: rgba(80, 180, 255, 0.12) !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;
}


.input-compliance-hint {
    text-align: center;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.25);
    padding: 2px 0 0;
    line-height: 1.5;
}
.input-compliance-hint a {
    color: rgba(255, 255, 255, 0.35);
    text-decoration: none;
}
.input-compliance-hint a:hover {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: underline;
}

/* 输入快捷区：左侧固定宽度，避免压缩输入框 */
.track-btn {
    font-size: 11px;
    letter-spacing: 0;
    opacity: 0.6;
}
.track-btn:hover {
    opacity: 1;
}

/* 图库版本徽章 */
.gallery-version-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(255, 142, 60, 0.85);
    color: #fff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 8px;
    pointer-events: none;
    font-weight: 600;
    letter-spacing: 0.3px;
}

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

.gallery-notice {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 214, 102, 0.28);
    background: rgba(255, 214, 102, 0.08);
    color: rgba(242, 246, 251, 0.82);
    font-size: 12px;
    line-height: 1.5;
}

/* ===== 失败图 ===== */
.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) {
    .mobile-root-entry {
        display: flex !important;
    }
    :root {
        --msg-line-height: 1.86;
        --msg-line-height-user: 1.72;
        --msg-line-height-assistant: 1.96;
        --msg-letter-spacing-assistant: 0.028em;
    }

    /* 全局防溢出：禁止 body 以外的任何横向滚动 */
    .app-body { max-width: 100vw; overflow: hidden; }
    .topbar { max-width: 100vw; overflow: hidden; }
    .chat-main { max-width: 100vw; overflow: hidden; }
    .msg-content { max-width: 100%; overflow-wrap: break-word; word-break: break-word; }
    .msg-assistant .msg-content {
        word-break: normal;
        overflow-wrap: break-word;
        line-break: strict;
    }
    .msg-content img { max-width: 100%; height: auto; }

    .greeting-cards { grid-template-columns: 1fr; }
    .specify-grid { grid-template-columns: 1fr; }
    .character-picker { grid-template-columns: repeat(2, 1fr); }
    .status-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .status-field-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .affinity-card-list {
        grid-template-columns: 1fr;
    }
    .status-hero-card {
        padding: 10px;
    }

    .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 auto;
        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 .badge-builder { padding: 4px 8px; font-size: 11px; }
    .topbar-right { gap: 4px; grid-column: 3; grid-row: 1; flex-shrink: 0; }
    .topbar-marquee-row {
        grid-column: 2 / 4;
        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);
    }

    /* 滚动公告：移动端沿用 RZBOX 连续滚动 */
    .topbar-marquee-row .marquee-text {
        line-height: 24px;
        font-size: 11px;
        animation-name: marquee-scroll;
    }

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

    /* 输入栏不被压缩，确保按钮可见 */
    .chat-input-bar {
        padding: 10px 14px;
        flex-shrink: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }

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

    .msg { max-width: 98%; }
    .msg {
        font-size: var(--msg-font-size, 15px);
    }
    .msg-user {
        padding: 7px 11px 6px;
        line-height: var(--msg-line-height-user, 1.56);
        max-width: 75%;
        gap: 4px;
    }
    .msg-assistant { padding: 8px 13px 4px; line-height: var(--msg-line-height-assistant, 1.96); }
    .msg-assistant .msg-content p {
        text-indent: 1.5em;
        margin: 0 0 0.98em;
        line-height: var(--msg-line-height-assistant, 1.96);
    }
    .msg-assistant .msg-content p:last-child { margin-bottom: 0; }
    .msg-assistant .msg-content p .dialogue-quote {
        text-indent: 0;
    }
    .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;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .input-actions::-webkit-scrollbar {
        display: none;
    }
    .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;
    }
    .input-actions-trailing .btn-ghost {
        padding: 6px 8px;
        min-width: 32px;
    }
    .input-actions-trailing {
        margin-left: 0;
        flex: 0 0 auto;
    }
    .input-shortcut-btn {
        width: 26px;
        height: 26px;
        min-width: 26px;
        border-radius: 6px;
    }
    .suggest-shortcut {
        font-size: 14px;
    }
    #btn-font-size {
        font-size: 12px;
    }
    /* 隐藏底部续写按钮（已与发送合并） */
    #btn-continue { display: none !important; }

    /* 模态框：居中+紧凑+可滚动 */
    .modal-overlay { align-items: center; padding: 0 12px; box-sizing: border-box; }
    .modal, .modal-box {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 85dvh;
        border-radius: var(--radius-lg);
        overflow: hidden;
        padding: 14px;
        font-size: 13px;
        box-sizing: border-box;
    }
    .modal-lg {
        width: 100% !important;
        max-width: 100% !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: 92dvh !important;
        padding: 12px 14px;
        display: flex !important;
        flex-direction: column;
        overflow: hidden !important;
        box-sizing: border-box;
    }
    #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;
        padding-bottom: 12px;
    }

    .character-settings-tabs {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 6px;
        padding-bottom: 8px;
    }

    .character-settings-tabs::-webkit-scrollbar {
        display: none;
    }

    .character-settings-tab {
        flex: 0 0 auto;
        min-width: 68px;
        height: 36px;
        padding: 0 10px;
        font-size: 12px;
    }
    /* 忍者表单：手机端紧凑两列 */
    .ninja-form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .ninja-field {
        min-width: 0;
        overflow: visible;
    }
    .ninja-field input,
    .ninja-field select,
    .ninja-field textarea {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding: 7px 10px;
        font-size: 13px;
    }
    .ninja-field .tag-select {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .ninja-field .tag-select-trigger {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding: 7px 10px;
        font-size: 13px;
    }
    .ninja-field .tag-select-menu {
        left: 0;
        right: 0;
        width: auto;
        box-sizing: border-box;
    }
    .ninja-label { font-size: 11px; }
    .label-hint { display: none; }
    /* 角色设定 textarea 限制 */
    .ninja-field-wide textarea {
        max-width: 100%;
    }
    .btn-close {
        width: 36px;
        height: 36px;
        font-size: 22px;
        border-radius: 10px;
    }
    /* 按钮行可换行 */
    .newchat-action-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .opening-mode-field {
        gap: 6px;
    }
    .opening-mode-field .tag-select-trigger {
        min-height: 38px;
        padding: 7px 10px;
    }
    .opening-mode-field .tag-select-value,
    .opening-mode-hint {
        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; }
}

@media (max-width: 768px) {
    .sandbox-workshop {
        padding: 22px 14px 110px;
    }
    .sandbox-grid {
        grid-template-columns: 1fr;
    }
    .sandbox-npc-item {
        grid-template-columns: 1fr;
    }

    .sandbox-char-actions,
    .sandbox-character-npc-actions,
    .story-npc-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        justify-content: stretch;
        align-items: stretch;
    }

    .sandbox-char-actions .btn-sm,
    .sandbox-character-npc-actions .btn-sm,
    .story-npc-actions .btn-sm {
        width: 100%;
        min-height: 38px;
        min-width: 0;
        padding: 0 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: normal;
        line-height: 1.25;
    }

    .sandbox-character-npc-head,
    .story-npc-head {
        align-items: stretch;
    }

    .sandbox-character-npc-name,
    .story-npc-name {
        width: 100%;
    }

    .sandbox-character-npc-grid,
    .story-npc-grid {
        grid-template-columns: 1fr;
    }

    .sandbox-character-npc-preview,
    .story-npc-preview {
        width: 104px;
        height: 104px;
        justify-self: center;
    }

    .story-npc-col {
        align-items: stretch;
    }

    .story-npc-portrait-btns {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: stretch;
    }

    .story-npc-portrait-btns button {
        min-height: 34px;
        padding: 0 8px;
    }

    .sandbox-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ========== 饭团记录 ========== */
.wallet-log-list {
    max-height: min(52vh, 460px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-right: 4px;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}
.wallet-log-hint {
    margin: -2px 0 10px;
    color: #8fa3bd;
    font-size: 12px;
    line-height: 1.5;
}
.wallet-rule-note {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}
.wallet-rule-title {
    color: #ffd38b;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
}
.wallet-rule-item {
    font-size: 12px;
    color: #aeb8c9;
    line-height: 1.6;
}
.wallet-rule-item b {
    color: #eef4fb;
}
.wallet-log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    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-words {
    flex-shrink: 0;
    color: #9fdcff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.preset-npc-list {
    display: grid;
    gap: 12px;
}
.preset-npc-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)), rgba(11, 18, 32, 0.7);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}
.preset-npc-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.preset-npc-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 159, 67, 0.14);
    color: #ffd7a8;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.preset-npc-remove {
    min-width: 74px;
}
.preset-npc-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.preset-npc-field:last-child {
    margin-bottom: 0;
}
.preset-npc-label {
    font-size: 12px;
    color: #cbd5e1;
}
.preset-npc-field input,
.preset-npc-field textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 10px 12px;
    outline: none;
}
.preset-npc-field input:focus,
.preset-npc-field textarea:focus {
    border-color: rgba(255, 159, 67, 0.6);
    background: rgba(255, 159, 67, 0.06);
}
@media (max-width: 768px) {
    .preset-npc-card {
        padding: 12px;
        border-radius: 14px;
    }
}
.wallet-log-item .log-amount {
    font-weight: 700;
    flex-shrink: 0;
    min-width: 34px;
    text-align: right;
}
.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;
    white-space: nowrap;
}
@media (max-width: 640px) {
    .wallet-log-list {
        max-height: min(58vh, 520px);
    }
    .wallet-log-item {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 4px 8px;
    }
    .wallet-log-item .log-desc {
        flex: 1 1 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.35;
    }
}

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

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

.settings-profile-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-profile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.settings-profile-meta {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.settings-rank-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.settings-rank-badge {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-height: 22px;
}

.settings-rank-summary {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
    font-size: 12px;
    color: #b5c0d4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

.settings-rank-track {
    position: relative;
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.settings-rank-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(255,255,255,0.22), var(--primary-soft));
    transition: width 0.2s ease;
}

.settings-profile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.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;
}

/* 物品卡片字体选项 */
.item-font-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.item-font-opt {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.item-font-opt:hover {
    border-color: var(--primary);
    background: var(--primary-dim);
}
.item-font-opt.active {
    border-color: var(--primary);
    background: var(--primary-dim);
    color: var(--primary);
}

.modal-settings {
    padding: 16px;
}

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

.settings-inline-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.settings-inline-value {
    flex: 1 1 auto;
    min-width: 0;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.settings-inline-code {
    padding: 4px 10px;
    font-size: 14px;
    letter-spacing: 1px;
}

.settings-inline-link {
    padding: 4px 8px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-inline-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.settings-redeem-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.settings-redeem-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.settings-redeem-btn {
    flex: 0 0 auto;
    min-width: 68px;
    padding: 8px 12px;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .settings-profile-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .settings-rank-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .settings-rank-summary {
        width: 100%;
        text-align: left;
    }
    .settings-inline-row {
        flex-wrap: wrap;
        align-items: flex-start;
    }
    .settings-inline-value {
        flex: 1 1 100%;
    }
    .settings-redeem-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .settings-redeem-input {
        width: 100%;
        flex: none;
    }
}

/* ========== 生图成功轻提示 ========== */
.image-ready-hint {
    position: fixed;
    left: 50%;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(12, 16, 24, 0.95);
    border: 1px solid rgba(34, 197, 94, 0.45);
    border-radius: 10px;
    padding: 10px 12px;
    color: #dcfce7;
    z-index: 10001;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.image-ready-hint.hidden {
    display: none;
}
.image-ready-text {
    font-size: 13px;
    line-height: 1.2;
}
.image-ready-btn {
    border: 1px solid rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.18);
    color: #bbf7d0;
    border-radius: 7px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.image-ready-btn:hover {
    background: rgba(34, 197, 94, 0.28);
}
.gallery-item-focus {
    outline: 2px solid rgba(34, 197, 94, 0.65);
    outline-offset: 2px;
    animation: gallery-focus-pulse 1.2s ease;
}
@keyframes gallery-focus-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    100% { box-shadow: 0 0 0 14px rgba(34, 197, 94, 0); }
}
@media (max-width: 768px) {
    .image-ready-hint {
        max-width: calc(100vw - 20px);
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
        padding: 9px 10px;
        gap: 8px;
    }
    .image-ready-text {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .sandbox-character-npc-grid {
        grid-template-columns: 1fr;
    }

    .sandbox-character-npc-preview {
        width: 100%;
        max-width: 220px;
        height: 160px;
    }
}

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

/* ========== Button Loading Spinner ========== */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
button.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.85;
}
button.is-loading .btn-spinner {
    display: inline-block;
}

/* ========== Toast 通知 ========== */
.toast-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background:
        linear-gradient(135deg, rgba(128,217,255,0.08), rgba(255,199,108,0.06)),
        rgba(12, 16, 24, 0.96);
    border: 1px solid rgba(255,199,108,0.22);
    border-radius: 8px;
    width: max-content;
    max-width: min(520px, calc(100vw - 28px));
    padding: 10px 18px;
    color: #f2f6fb;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    z-index: 10000;
    box-shadow: 0 14px 34px rgba(0,0,0,0.38), inset 0 1px 0 rgba(255,255,255,0.06);
    transition: opacity 0.3s, transform 0.3s;
    animation: toast-enter .24s ease;
}

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

.toast-notification.toast-ok {
    border-color: rgba(113,211,164,0.50);
    color: #a7f3c8;
}

.toast-notification.toast-error {
    border-color: rgba(255,126,126,0.55);
    color: #ffb4b4;
}

.toast-notification.toast-warn {
    border-color: rgba(255,199,108,0.58);
    color: #ffe2a3;
}

@media (max-width: 768px) {
    .toast-notification {
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100vw - 20px);
        padding: 9px 13px;
        font-size: 13px;
    }
}

@keyframes toast-enter {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

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

.char-design-save-row-sticky {
    position: sticky;
    bottom: -16px;
    z-index: 3;
    margin: 16px -4px -4px;
    padding: 12px 4px 4px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(24, 26, 34, 0.72), var(--panel) 42%);
}

@media (max-width: 768px) {
    .char-design-save-row-sticky {
        bottom: -12px;
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
        margin: 14px -2px -2px;
        padding: 10px 2px 2px;
    }

    .char-design-save-row-sticky .btn-primary,
    .char-design-save-row-sticky .btn-ghost {
        width: 100%;
    }
}

#sandbox-character-npc-body {
    display: grid;
    gap: 10px;
}

.sandbox-character-npc-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
}

.sandbox-character-npc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.sandbox-character-npc-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.sandbox-character-npc-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sandbox-character-npc-actions .btn-sm {
    min-height: 32px;
    min-width: 76px;
}

.sandbox-character-npc-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    align-items: start;
}

.sandbox-character-npc-preview {
    width: 120px;
    height: 120px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 12px;
}

.sandbox-character-npc-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sandbox-character-npc-fields {
    display: grid;
    gap: 8px;
}

.sandbox-character-npc-fields input,
.sandbox-character-npc-fields textarea {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
}

.sandbox-character-npc-fields textarea {
    min-height: 78px;
    resize: vertical;
}

@media (max-width: 768px) {
    .sandbox-character-npc-head {
        align-items: stretch;
        flex-direction: column;
    }

    .sandbox-character-npc-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        justify-content: stretch;
        align-items: stretch;
    }

    .sandbox-character-npc-actions .btn-sm {
        width: 100%;
        min-width: 0;
        min-height: 38px;
        padding: 0 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: normal;
        line-height: 1.25;
    }

    .sandbox-character-npc-grid {
        grid-template-columns: 1fr;
    }

    .sandbox-character-npc-preview {
        width: 104px;
        height: 104px;
        justify-self: center;
    }
}

#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-current-age {
    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;
}
.setting-editing .tag-select-trigger {
    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;
}

/* ========== 官方世界身份帖样式（古代身份证风格） ========== */
.ancient-id-sheet {
    border: 1px solid rgba(210, 176, 120, 0.45);
    border-radius: 10px;
    padding: 12px;
    background:
        linear-gradient(180deg, rgba(58, 42, 26, 0.35) 0%, rgba(34, 25, 17, 0.35) 100%),
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.02) 0px,
            rgba(255, 255, 255, 0.02) 1px,
            transparent 1px,
            transparent 26px
        );
}

.ancient-id-sheet .section-label {
    color: #e2c9a2;
    letter-spacing: 0.5px;
}

.ancient-id-grid .ninja-label {
    color: #d8c3a0;
}

.ancient-id-grid input,
.ancient-id-grid textarea,
.ancient-id-grid .tag-select-trigger {
    background: rgba(22, 16, 11, 0.72);
    border-color: rgba(210, 176, 120, 0.35);
}

.char-id-sheet {
    position: relative;
    margin-bottom: 10px;
}

.char-id-sheet::after {
    content: '验';
    position: absolute;
    right: 12px;
    top: 10px;
    width: 26px;
    height: 26px;
    border: 1px solid rgba(210, 176, 120, 0.52);
    border-radius: 50%;
    color: rgba(226, 201, 162, 0.7);
    font-size: 13px;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.char-id-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-right: 34px;
}

.char-id-title {
    color: #e2c9a2;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.char-id-subtitle {
    color: #b7a07e;
    font-size: 11px;
}

/* ========== 默认设定图标记 ========== */
.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-textarea {
    min-height: 96px;
    max-height: 220px;
    resize: vertical;
    line-height: 1.6;
}

.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);
}

/* ========== 赞赏弹窗 ========== */
.appreciate-intro {
    text-align: center;
    font-size: 14px;
    color: #ccc;
    margin-bottom: 12px;
    line-height: 1.6;
}
.appreciate-hint {
    text-align: center;
    font-size: 13px;
    color: #aaa;
    margin: 12px 0 16px;
}
.appreciate-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.appreciate-plan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.appreciate-section-title {
    font-size: 13px;
    color: #999;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.appreciate-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
/* 爱发电标题行 + UID 复制 */
.ifdian-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 6px;
}
.ifdian-title-text {
    font-size: 14px;
    color: #aaa;
}
.ifdian-copy-uid-btn {
    font-size: 11px !important;
    padding: 2px 10px !important;
    border-color: rgba(255,255,255,0.15);
    color: #999;
    white-space: nowrap;
}
.ifdian-copy-uid-btn:active {
    color: #ff8e3c;
    border-color: #ff8e3c;
}
.ifdian-uid-hint {
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-bottom: 14px;
}
.appreciate-plan-btn {
    display: block;
    width: 100%;
    padding: 10px 16px !important;
    font-size: 15px !important;
    font-weight: 600;
    border: 2px solid var(--border) !important;
    border-radius: 10px !important;
    transition: all 0.2s;
    text-align: left;
}
.appreciate-plan-btn:hover {
    border-color: #ff8e3c !important;
    color: #ff8e3c !important;
    background: rgba(255,142,60,0.1) !important;
}
.appreciate-plan-btn .plan-desc {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #888;
    margin-top: 2px;
}
.appreciate-plan-btn .plan-busy {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: #e0a040;
    margin-top: 2px;
}
.appreciate-plan-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.appreciate-plan-btn.monthly {
    border-color: rgba(218,175,90,0.3) !important;
    background: linear-gradient(135deg, rgba(218,175,90,0.08) 0%, rgba(180,140,60,0.05) 100%) !important;
}
.appreciate-plan-btn.monthly:hover {
    border-color: rgba(218,175,90,0.5) !important;
    background: linear-gradient(135deg, rgba(218,175,90,0.15) 0%, rgba(180,140,60,0.1) 100%) !important;
    color: #dab45a !important;
}
.builder-status {
    text-align: center;
    font-size: 11px;
    color: #888;
    margin: 4px 0 0;
}
/* 排队等待 */
.queue-waiting {
    text-align: center;
    padding: 24px 0;
    color: #80d9ff;
}
.queue-waiting p {
    margin: 8px 0 0;
    font-size: 14px;
}
.queue-countdown {
    font-size: 20px !important;
    font-weight: 700;
    color: #ff8e3c;
}
/* 支付页 */
.appreciate-pay-info {
    text-align: center;
    margin-bottom: 12px;
}
.appreciate-amount {
    font-size: 22px;
    font-weight: 700;
    color: #ff8e3c;
    margin: 0 0 6px;
}
.appreciate-tip {
    font-size: 11px;
    color: #888;
    margin: 4px 0;
}
.appreciate-qrcode {
    text-align: center;
    margin: 12px 0;
}
.appreciate-qrcode img {
    width: 100%;
    max-width: 240px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.appreciate-countdown {
    text-align: center;
    font-size: 12px;
    color: #e0a040;
    margin: 6px 0 4px;
}
#appreciate-waiting {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}
#appreciate-waiting .spinner {
    margin-right: 4px;
}
.appreciate-success {
    text-align: center;
    font-size: 13px;
    color: #4caf50;
    margin-bottom: 4px;
}
.appreciate-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 8px 0;
}
.appreciate-countdown {
    text-align: center;
    font-size: 13px;
    color: #ff8e3c;
    margin: 4px 0 8px;
}
.appreciate-countdown.expiring {
    color: #ff5555;
    animation: pulse-red 1s ease-in-out infinite;
}
@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.appreciate-waiting {
    text-align: center;
    color: #80d9ff;
    font-size: 13px;
    padding: 8px 0;
}
.appreciate-success {
    text-align: center;
    color: #4caf50;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 0;
}
.appreciate-back-btn {
    font-size: 12px;
    padding: 2px 10px !important;
    min-width: auto;
    opacity: 0.5;
}
.appreciate-back-btn:hover {
    opacity: 1;
}

/* ========== 饭团飘字动画 ========== */
@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; }
}

/* ========== iOS 伪全屏 ========== */
body.fake-fullscreen #sidebar {
    display: none !important;
}
body.fake-fullscreen .chat-main {
    width: 100% !important;
    max-width: 100% !important;
}
body.fake-fullscreen:not(.android-shell-app) #btn-fullscreen {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
    background: rgba(255, 142, 60, 0.2);
    border: 1px solid rgba(255, 142, 60, 0.4);
    color: var(--primary);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
body.fake-fullscreen:not(.android-shell-app) #btn-fullscreen svg {
    width: 16px;
    height: 16px;
}

/* ========== 物品卡片移动端适配 ========== */
@media (max-width: 600px) {
    .item-card-heading-main { font-size: 17px; }
    .item-card-heading-sub  { font-size: 13px; }
    .item-card-body {
        font-size: 16px;
        line-height: 2.0;
    }
}

/* ========== 减弱动效（无障碍） ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .marquee-text {
        animation-duration: var(--marquee-duration, 20s) !important;
        animation-iteration-count: infinite !important;
    }
    .wallet-float-text { display: none !important; }
    .appreciate-countdown.expiring { animation: none; }
    .inner-loading-spinner {
        animation-name: inner-spin !important;
        animation-duration: 0.6s !important;
        animation-timing-function: linear !important;
        animation-iteration-count: infinite !important;
    }
    .app-boot-loader-rune {
        animation: none !important;
    }
}

/* ─── 收藏页签 ─── */
.fav-npc-layout {
    display: flex;
    gap: 12px;
    min-height: 200px;
}
.fav-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
}
.fav-toolbar span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}
.fav-npc-list {
    flex: 0 0 120px;
    border-right: 1px solid var(--border);
    padding-right: 8px;
    overflow-y: auto;
    max-height: 400px;
}
.fav-npc-item {
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    color: var(--muted);
    transition: background 0.15s, color 0.15s;
}
.fav-npc-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}
.fav-npc-active {
    background: rgba(255,142,60,0.12);
    color: var(--primary);
}
.fav-npc-detail {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}
.fav-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.fav-avatar-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
}
.fav-avatar,
.relation-avatar {
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--sandbox-accent, var(--primary)) 55%, var(--border));
    background: linear-gradient(145deg, rgba(255,142,60,.22), rgba(80,140,255,.16));
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0,0,0,.22);
}
.relation-avatar {
    width: 44px;
    height: 44px;
    font-size: 17px;
}
.fav-avatar img,
.relation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.fav-avatar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.relation-character-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}
.relation-character-card {
    min-width: 0;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.relation-character-card:hover,
.relation-character-card:focus-visible {
    border-color: color-mix(in srgb, var(--sandbox-accent, var(--primary)) 55%, var(--border));
    background: rgba(255,255,255,0.065);
    transform: translateY(-1px);
    outline: none;
}
.relation-card-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}
.relation-card-name {
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.relation-card-summary {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}
.relation-card-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-width: max-content;
}
.relation-favorite-btn.is-favorited {
    color: #ffb45f !important;
}
.relation-recent-dynamics {
    background: rgba(255,255,255,0.025);
}
.relation-recent-dynamics > summary {
    cursor: pointer;
    list-style: none;
}
.relation-recent-dynamics > summary::-webkit-details-marker {
    display: none;
}
.relation-recent-dynamics > summary::after {
    content: '展开';
    float: right;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}
.relation-recent-dynamics[open] > summary::after {
    content: '收起';
}
.fav-detail-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.fav-detail-actions {
    display: flex;
    gap: 6px;
}
.fav-section {
    margin-bottom: 12px;
}
.fav-section-title {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
}
.fav-field {
    margin-bottom: 6px;
}
.fav-field-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 2px;
}
.fav-field-value {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    white-space: pre-wrap;
}
.fav-field-empty {
    color: #555;
    font-style: italic;
}
.fav-field-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    padding: 4px 6px;
    resize: vertical;
    font-family: inherit;
}
.fav-field-input:focus {
    border-color: var(--primary);
    outline: none;
}
.fav-activity-view {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.fav-activity-chip {
    border: 1px solid var(--sandbox-active-field-border, var(--border));
    border-radius: 6px;
    padding: 4px 7px;
    color: var(--text);
    background: color-mix(in srgb, var(--sandbox-active-field-bg, rgba(255,255,255,0.05)) 88%, transparent);
    font-size: 12px;
}
.fav-activity-note {
    flex-basis: 100%;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}
.fav-activity-edit {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.fav-activity-edit label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
}
.fav-activity-edit input,
.fav-activity-edit select,
.fav-activity-edit textarea {
    width: 100%;
    border: 1px solid var(--sandbox-active-field-border, var(--border));
    border-radius: 6px;
    background: var(--sandbox-active-field-bg, rgba(16, 22, 34, 0.92));
    color: var(--text);
    padding: 5px 7px;
    font: inherit;
    font-size: 12px;
    color-scheme: dark;
}
.fav-activity-edit select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 28px;
}
.fav-activity-edit select option {
    background: #151b26;
    color: var(--text);
}
.fav-activity-edit input:focus,
.fav-activity-edit select:focus,
.fav-activity-edit textarea:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--sandbox-accent, var(--primary)) 60%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sandbox-accent, var(--primary)) 16%, transparent);
    background: color-mix(in srgb, var(--sandbox-active-field-bg, rgba(16,22,34,.92)) 92%, var(--sandbox-accent, var(--primary)) 8%);
}
.fav-activity-note-edit {
    grid-column: 1 / -1;
}
@media (max-width: 640px) {
    .fav-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
    .fav-toolbar .btn-sm {
        width: 100%;
    }
    .fav-npc-layout {
        flex-direction: column;
    }
    .fav-npc-list {
        flex: none;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding-right: 0;
        padding-bottom: 8px;
        max-height: 120px;
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 6px;
    }
    .fav-npc-item {
        flex: 0 0 auto;
        min-width: 72px;
        text-align: center;
    }
    .fav-detail-header,
    .fav-avatar-panel {
        align-items: stretch;
    }
    .fav-detail-header {
        flex-direction: column;
    }
    .fav-detail-actions,
    .fav-avatar-actions {
        width: 100%;
    }
    .fav-detail-actions .btn-sm,
    .fav-avatar-actions .btn-sm {
        flex: 1 1 0;
    }
    .relation-character-card {
        grid-template-columns: auto 1fr;
    }
    .relation-card-actions {
        grid-column: 1 / -1;
    }
    .relation-card-actions .btn-sm {
        width: 100%;
    }
    .fav-activity-edit {
        grid-template-columns: 1fr;
    }
}
.fav-no-profile-hint {
    color: #b8a0ff;
    font-size: 12px;
    margin-bottom: 10px;
    padding: 6px 8px;
    background: rgba(184,160,255,0.08);
    border-radius: 4px;
}
.fav-edit-btn, .fav-save-btn, .fav-cancel-btn {
    font-size: 12px;
}
.fav-unfavorite-btn {
    font-size: 12px;
    color: #e5534b !important;
}
.fav-unfavorite-btn:hover {
    color: #ff6b6b !important;
    background: rgba(229, 83, 75, 0.12);
}
.story-npc-favorited {
    color: #ff8e3c !important;
    pointer-events: auto;
    cursor: pointer;
}
.story-npc-favorited:hover {
    color: #ffc76c !important;
}
@keyframes fav-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); filter: brightness(1.3); }
    100% { transform: scale(1); }
}
.fav-pop {
    animation: fav-pop 0.3s ease-out;
}

/* iOS Safari: 阻止 font-size < 16px 的输入框聚焦时自动放大 */
@supports (-webkit-touch-callout: none) {
    input, textarea, select, [contenteditable="true"] {
        font-size: 16px !important;
    }
    #msg-input {
        font-size: 16px !important;
        line-height: 1.5;
    }
}

/* ========== 邀请每日明细 ========== */
.invite-daily-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px 12px;
}
.invite-daily-item {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}
@media (max-width: 600px) {
    .invite-daily-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px 8px;
    }
    .invite-daily-item {
        font-size: 11px;
        padding: 2px 4px;
    }
}

/* ========== 2026-05-26 Local UI Skin Pass: low-disturbance polish ========== */
:root {
    --ui-gold-line: rgba(255, 199, 108, 0.32);
    --ui-gold-line-soft: rgba(255, 199, 108, 0.18);
    --ui-blue-line: rgba(128, 217, 255, 0.24);
    --ui-press-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.28);
}

.btn-primary,
.btn-ghost,
.sidebar-action,
.user-chip,
.msg-action,
.status-tab,
.inv-chip,
.tag-select-trigger,
.sandbox-settings-tab,
.sandbox-step-dot {
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.24), rgba(255,255,255,0.05) 36%, transparent 37%),
        linear-gradient(135deg, #ff9b43 0%, #ffc76c 100%);
    border-color: rgba(255, 224, 160, 0.34);
    box-shadow:
        0 10px 22px rgba(255, 142, 60, 0.18),
        0 0 0 1px rgba(255, 199, 108, 0.06),
        inset 0 1px 0 rgba(255,255,255,0.32);
}
.btn-primary::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
    transform: translateX(-120%);
    opacity: 0;
    transition: transform .34s ease, opacity .18s ease;
}
.btn-primary:hover::after {
    transform: translateX(120%);
    opacity: 1;
}
.btn-primary:hover {
    opacity: 1;
    box-shadow:
        0 12px 26px rgba(255, 142, 60, 0.24),
        0 0 0 1px rgba(255, 199, 108, 0.12),
        inset 0 1px 0 rgba(255,255,255,0.38);
}
.btn-primary:active {
    filter: saturate(0.98) brightness(0.96);
    box-shadow: var(--ui-press-shadow);
}

.btn-ghost {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.085), rgba(255,255,255,0.028)),
        rgba(11, 17, 28, 0.38);
    border-color: rgba(255, 255, 255, 0.105);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.06),
        0 1px 0 rgba(255,255,255,0.025);
}
.btn-ghost:hover {
    color: #fff8e8;
    border-color: var(--ui-gold-line);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.13), rgba(255,255,255,0.045)),
        rgba(255, 199, 108, 0.055);
    box-shadow:
        0 8px 18px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn-ghost:active {
    box-shadow: var(--ui-press-shadow);
}

.btn-send {
    min-width: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 20px rgba(255, 142, 60, 0.22),
        inset 0 1px 0 rgba(255,255,255,0.30);
}
.btn-stop {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.03)),
        linear-gradient(135deg, #ef4444, #b91c1c) !important;
    border-color: rgba(255, 180, 180, 0.36) !important;
}
.btn-stopping {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
        #5e6675 !important;
    border-color: rgba(255,255,255,0.16) !important;
}
button.is-loading {
    filter: saturate(0.92);
}
button.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(100deg, transparent 0 38%, rgba(255,255,255,0.16) 50%, transparent 62%);
    animation: ui-button-saving 1.1s ease-in-out infinite;
}
@keyframes ui-button-saving {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.topbar {
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}
body.sandbox-app .sandbox-topbar {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.014)),
        var(--panel);
    border-bottom-color: color-mix(in srgb, var(--sandbox-accent, #ff9f43) 24%, var(--border));
}
.topbar-marquee-row {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.045);
}

.user-chip,
.sidebar-action {
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.055),
        0 6px 16px rgba(0,0,0,0.12);
}
.user-chip:hover,
.sidebar-action:hover {
    transform: translateY(-1px);
    box-shadow:
        0 10px 22px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.08);
}
.user-chip:active,
.sidebar-action:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: var(--ui-press-shadow);
}
body.sandbox-app .sandbox-dock {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.035), transparent 34%),
        var(--sidebar-bg);
    border-right-color: color-mix(in srgb, var(--sandbox-accent, #ff9f43) 22%, var(--border));
}
body.sandbox-app #sandbox-new-adventure {
    border-color: rgba(255, 224, 160, 0.42);
    text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}
body.sandbox-app #sandbox-open-gallery {
    background: linear-gradient(135deg, rgba(128,217,255,0.14), rgba(128,217,255,0.045));
    border-color: rgba(128,217,255,0.28);
}
body.sandbox-app #sandbox-world-hub-side {
    background: linear-gradient(135deg, rgba(255,199,108,0.14), rgba(255,142,60,0.045));
    border-color: rgba(255,199,108,0.30);
}
body.sandbox-app #sandbox-community {
    background: linear-gradient(135deg, rgba(113,211,164,0.14), rgba(113,211,164,0.045));
    border-color: rgba(113,211,164,0.30);
}
body.sandbox-app #sandbox-share {
    background: linear-gradient(135deg, rgba(124,138,255,0.14), rgba(124,138,255,0.045));
    border-color: rgba(124,138,255,0.30);
}
.session-item {
    border: 1px solid transparent;
}
.session-item:hover {
    border-color: rgba(255,255,255,0.08);
}
.session-item.active {
    border-color: var(--ui-gold-line);
    box-shadow: inset 3px 0 0 rgba(255,199,108,0.70);
}
.sandbox-session-list .session-item {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.025)),
        rgba(255,255,255,0.035);
}

.input-wrapper {
    border-color: rgba(255,255,255,0.10);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025)),
        rgba(8, 12, 20, 0.30);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.045),
        0 10px 30px rgba(0,0,0,0.12);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.input-wrapper:focus-within {
    border-color: var(--ui-gold-line);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.030)),
        rgba(8, 12, 20, 0.40);
    box-shadow:
        0 0 0 3px rgba(255,199,108,0.08),
        0 12px 30px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.06);
}
.chat-input-bar {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.006)),
        rgba(12, 16, 24, 0.72);
}
body.sandbox-app .sandbox-input-mount .chat-input-bar {
    box-shadow: 0 -14px 30px rgba(0,0,0,0.16);
}
.queue-status {
    border: 1px solid rgba(255,199,108,0.16);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

.msg-action {
    min-height: 26px;
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025)),
        rgba(255, 255, 255, 0.025);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.msg-action:hover {
    color: #f2f6fb;
    filter: saturate(1.08);
}
.msg-action:active {
    transform: translateY(1px) scale(0.97);
    box-shadow: var(--ui-press-shadow);
}
.msg-action:disabled {
    box-shadow: none;
    filter: grayscale(0.18);
}
.msg-action.msg-copy:hover,
.msg-action.msg-rollback:hover {
    border-color: rgba(255,255,255,0.24);
}

.tag-select-trigger,
.ninja-field input,
.ninja-field select,
.ninja-field textarea,
.form-stack input,
.form-stack select {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.tag-select-trigger:hover,
.tag-select.open .tag-select-trigger {
    box-shadow:
        0 0 0 3px rgba(255,199,108,0.055),
        inset 0 1px 0 rgba(255,255,255,0.055);
}
.tag-select-menu {
    border-color: var(--ui-gold-line-soft);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.02)),
        rgba(14, 20, 31, 0.985);
}
.tag-select-option {
    border: 1px solid transparent;
}
.tag-select-option:hover {
    border-color: rgba(255,255,255,0.06);
}
.tag-select-option.active {
    border-color: rgba(255,199,108,0.20);
    box-shadow: inset 3px 0 0 rgba(255,199,108,0.58);
}

.modal {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.050), rgba(255,255,255,0.018)),
        rgba(18, 24, 36, 0.985);
    border-color: rgba(255,199,108,0.16);
    box-shadow:
        0 26px 90px rgba(0, 0, 0, 0.54),
        inset 0 1px 0 rgba(255,255,255,0.06);
}
.modal-header {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 12px;
}
.modal-header h3,
.section-label {
    text-shadow: 0 0 12px rgba(255,199,108,0.10);
}
.greeting-card {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.020)),
        rgba(255, 255, 255, 0.025);
    border-color: rgba(255,255,255,0.10);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.greeting-card:hover {
    box-shadow:
        0 12px 26px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.06);
}
.greeting-card.selected {
    border-color: var(--ui-gold-line);
    box-shadow:
        0 0 0 3px rgba(255,199,108,0.065),
        inset 0 1px 0 rgba(255,255,255,0.07);
}

.sandbox-settings-tab,
.sandbox-step-dot {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.045);
}
.sandbox-settings-tab.active,
.sandbox-step-dot.active {
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--sandbox-accent, #ff9f43) 13%, transparent),
        inset 0 1px 0 rgba(255,255,255,0.07);
}
.sandbox-field-hero,
.sandbox-advanced-toggle,
.sandbox-review-row {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

.status-panel {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.035), transparent 36%),
        var(--sidebar-bg);
}
.status-tab {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.070), rgba(255,255,255,0.022)),
        rgba(255,255,255,0.030);
}
.status-tab:hover {
    transform: translateY(-1px);
}
.status-tab.active {
    color: #eaf8ff;
    box-shadow:
        0 0 0 1px rgba(128, 217, 255, 0.28) inset,
        0 8px 18px rgba(0,0,0,0.16);
}
.status-tab-panel,
.isekai-section {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}
.inv-chip:hover {
    transform: translateY(-1px);
}
.inv-chip.active {
    box-shadow:
        0 0 0 3px rgba(255,142,60,0.055),
        inset 0 1px 0 rgba(255,255,255,0.06);
}
.inv-item:active,
.item-card:active {
    transform: translateY(1px);
}
.item-card {
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, filter .16s ease;
}
.item-card:hover {
    transform: translateY(-1px);
    filter: saturate(1.03);
}
.item-card--world-otherworld.item-card:hover {
    border-color: rgba(255, 199, 108, 0.40);
    box-shadow:
        0 0 18px rgba(128, 217, 255, .10),
        0 12px 26px rgba(0, 0, 0, .22);
}

.toast-notification {
    border-radius: 10px;
    border-color: rgba(255,199,108,0.28);
    padding-left: 20px;
    padding-right: 20px;
}
.toast-notification::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 9px;
    border-radius: 50%;
    vertical-align: 1px;
    background: currentColor;
    box-shadow: 0 0 12px currentColor;
}
.toast-notification.toast-ok {
    background:
        linear-gradient(135deg, rgba(113,211,164,0.10), rgba(255,199,108,0.045)),
        rgba(12, 16, 24, 0.96);
}
.toast-notification.toast-error {
    background:
        linear-gradient(135deg, rgba(255,126,126,0.11), rgba(255,199,108,0.035)),
        rgba(12, 16, 24, 0.96);
}
.toast-notification.toast-warn {
    background:
        linear-gradient(135deg, rgba(255,199,108,0.11), rgba(128,217,255,0.040)),
        rgba(12, 16, 24, 0.96);
}

.app-boot-loader-card {
    border-color: rgba(255, 199, 108, 0.30);
    box-shadow:
        0 22px 66px rgba(0, 0, 0, 0.50),
        0 0 0 1px rgba(128, 217, 255, 0.055),
        inset 0 1px 0 rgba(255,255,255,0.09);
}
.app-boot-loader-rune {
    box-shadow:
        0 0 20px rgba(128, 217, 255, 0.28),
        0 0 34px rgba(255, 199, 108, 0.10),
        inset 0 0 20px rgba(255, 199, 108, 0.10);
}

@media (max-width: 768px) {
    .btn-primary:hover,
    .btn-ghost:hover,
    .sidebar-action:hover,
    .user-chip:hover,
    .msg-action:hover,
    .status-tab:hover,
    .inv-chip:hover,
    .item-card:hover {
        transform: none;
    }
    .input-wrapper {
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.045);
    }
    .toast-notification {
        border-radius: 9px;
    }
}

/* Mobile input bar final layout override.
   Keep the suggestion bulb in its own hit area after all later skin rules. */
@media (max-width: 768px) {
    .chat-input-bar {
        overflow: visible !important;
    }

    .chat-input-bar .input-wrapper {
        position: relative;
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 42px !important;
        align-items: center;
        gap: 6px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: visible !important;
        padding: 6px 8px;
    }

    #btn-suggest {
        position: relative;
        z-index: 12;
        width: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        height: 42px !important;
        min-height: 42px !important;
        padding: 0 !important;
        align-self: center !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 44px !important;
        font-size: 21px;
        line-height: 1;
        isolation: isolate;
    }

    body.sandbox-app.sandbox-chat-active .sandbox-input-mount #btn-suggest {
        z-index: 12;
    }

    #msg-input {
        position: relative;
        z-index: 1;
        min-width: 0;
    }

    .chat-input-bar .btn-send {
        position: relative;
        z-index: 4;
        width: 42px;
        min-width: 42px;
        padding-left: 0;
        padding-right: 0;
    }

    .chat-input-bar .suggest-dropdown {
        left: 0;
        min-width: min(280px, calc(100vw - 28px));
        max-width: calc(100vw - 28px);
        z-index: 80;
    }

    .input-compliance-hint {
        pointer-events: none !important;
    }

    .input-compliance-hint a {
        pointer-events: auto !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn-primary::after,
    button.is-loading::before,
    .inv-item::after {
        animation: none !important;
        transition: none !important;
    }
}
