/* ============================================================
   RHODES ISLAND TERMINAL — PRTS Holographic UI
   Reference: https://ak.hypergryph.com/ + 腾讯游戏学堂《明日方舟》UI/UX分析
   Dark terminal aesthetic with gold accents, acrylic layers, clipped corners
   ============================================================ */

/* --- Bender Font Faces --- */
@font-face {
    font-family: 'Bender';
    src: url('../fonts/BENDER.OTF') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Bender';
    src: url('../fonts/BENDER-LIGHT-ITALIC.OTF') format('opentype');
    font-weight: 300;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'Bender';
    src: url('../fonts/Bender-Thin.otf') format('opentype');
    font-weight: 100;
    font-style: normal;
    font-display: swap;
}

/* --- CSS Variables / Design Tokens --- */
:root {
    /* Core palette (unchanged) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #0e0e16;
    --bg-tertiary: #15151f;
    --bg-card: #181825;
    --bg-hover: #1e1e2e;
    --bg-input: #12121c;

    --gold: #c9a87c;
    --gold-bright: #d4b88c;
    --gold-dim: #8a7355;
    --gold-glow: rgba(201, 168, 124, 0.15);

    --text-primary: #e8e4e0;
    --text-secondary: #9a9690;
    --text-dim: #5a5650;

    --accent-blue: #5b8cbd;
    --accent-blue-dim: #3a5a7a;
    --danger: #8b4545;
    --danger-bright: #b55a5a;
    --success: #5a8b5a;

    --border: #252535;
    --border-light: #333345;

    /* Acrylic / holographic additions */
    --acrylic-bg: rgba(14, 14, 22, 0.72);
    --acrylic-border: rgba(201, 168, 124, 0.18);
    --holo-gold: rgba(201, 168, 124, 0.35);
    --holo-gold-bright: rgba(212, 184, 140, 0.6);
    --holo-blue: rgba(91, 140, 189, 0.25);

    /* Typography */
    --font-sans: 'Bender', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'Bender', 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --font-serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;

    /* Motion */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-expo: cubic-bezier(0.7, 0, 0.84, 0);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --transition-fast: 150ms var(--ease-out-expo);
    --transition-normal: 250ms var(--ease-out-expo);
    --transition-slow: 500ms var(--ease-out-expo);

    /* Shape */
    --panel-clip: polygon(
        0 0,
        calc(100% - 18px) 0,
        100% 18px,
        100% 100%,
        18px 100%,
        0 calc(100% - 18px)
    );
    --card-clip: polygon(
        0 0,
        calc(100% - 12px) 0,
        100% 12px,
        100% 100%,
        12px 100%,
        0 calc(100% - 12px)
    );
    --input-clip: polygon(
        0 0,
        calc(100% - 8px) 0,
        100% 8px,
        100% 100%,
        8px 100%,
        0 calc(100% - 8px)
    );
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;

    /* Elevation */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-gold: 0 0 24px rgba(201, 168, 124, 0.12);
    --shadow-blue: 0 0 24px rgba(91, 140, 189, 0.10);

    /* Z scale */
    --z-bg: -1;
    --z-grid: 0;
    --z-panel: 10;
    --z-overlay: 100;
    --z-toast: 1000;
}

/* ============================================================
   官网动效 · @keyframes（来源：ak.hypergryph.com）
   ============================================================ */

/* 几何引导线 — 加载时展开 */
@keyframes ak-guide-line-in {
    0%   { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}

/* 引导线 — 加载完成后位移淡出 */
@keyframes ak-guide-line-out-h {
    0%   { top: 6.625rem; opacity: 0.4; }
    100% { top: -0.25rem; opacity: 0; }
}
@keyframes ak-guide-line-out-v {
    0%   { right: 6.625rem; opacity: 0.4; }
    100% { right: -0.25rem; opacity: 0; }
}

/* 滚动暗示 — 淡入→保持→淡出+下移 */
@keyframes ak-scroll-hint {
    0%   { opacity: 0; transform: translateY(0); }
    40%  { opacity: 1; transform: translateY(0); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(30%); }
}

/* 缩放弹出 — 加载内容/弹窗 */
@keyframes ak-scale-in {
    0%   { opacity: 0; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* 闪烁点 — 装饰加载点 */
@keyframes ak-blink {
    0%, to { opacity: 0; }
    50%    { opacity: 1; }
}

/* --- Skip to content (accessibility) --- */
.skip-link {
    position: fixed;
    top: -100px;
    left: 12px;
    z-index: 99999;
    background: var(--gold);
    color: var(--bg-primary);
    padding: 10px 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    clip-path: var(--input-clip);
    transition: top 0.2s var(--ease-out-expo);
    text-decoration: none;
}
.skip-link:focus {
    top: 12px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(201, 168, 124, 0.04) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 70%, rgba(91, 140, 189, 0.03) 0%, transparent 35%),
        var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-normal);
    outline: none;
}
/* 官网式 ::before 背景扫入（所有按钮共用） */
button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--transition-normal);
    z-index: 0;
    pointer-events: none;
}
button:hover::before { opacity: 0.06; }
button:active { transform: translateY(0) scale(0.97); }
/* 键盘焦点可见环 */
button:focus-visible {
    outline: 2px solid var(--gold-dim);
    outline-offset: 2px;
}
/* 底线展开动画（官网式，需要子元素和容器配合时使用 .btn-underline） */
.btn-underline::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 2px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-normal);
    z-index: 1;
    pointer-events: none;
}
.btn-underline:hover::after { transform: scaleX(1); }

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dim);
}

/* --- Global Atmosphere Overlays --- */
#prts-grid,
#grain-overlay,
#scanlines,
#vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-grid);
}

#prts-grid {
    background-image:
        linear-gradient(rgba(201, 168, 124, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(201, 168, 124, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.9) 0%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.9) 0%, transparent 70%);
    opacity: 0.7;
}

#grain-overlay {
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

#scanlines {
    opacity: 0.04;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.35) 2px,
        rgba(0, 0, 0, 0.35) 4px
    );
    animation: scanline-scroll 24s linear infinite;
}

@keyframes scanline-scroll {
    from { background-position: 0 0; }
    to { background-position: 0 100vh; }
}

#vignette {
    background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.55) 100%);
    z-index: var(--z-grid);
}

/* ============================================================
   官网动效 · 几何引导线（加载屏同款）
   ============================================================ */
#geo-guides {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity 1s var(--ease-out);
}
#geo-guides.hidden {
    opacity: 0;
    visibility: hidden;
}
.geo-guide-h,
.geo-guide-v {
    position: absolute;
    background: var(--gold-dim);
    opacity: 0;
    pointer-events: none;
}
/* 水平线 — 顶部 */
.geo-guide-h {
    top: 6.625rem;
    left: 0;
    width: 100%;
    height: 1px;
    transform-origin: left;
    transform: scaleX(0);
}
/* 竖直线 — 右侧 */
.geo-guide-v {
    top: 0;
    right: 6.625rem;
    width: 1px;
    height: 100%;
    transform-origin: top;
    transform: scaleY(0);
}
/* 入场：引导线展开 */
#geo-guides.entering .geo-guide-h {
    animation: ak-guide-line-in 1.4s var(--ease-out) forwards;
    animation-delay: 0.2s;
}
#geo-guides.entering .geo-guide-v {
    animation: ak-guide-line-in 1.4s var(--ease-out) forwards;
    animation-delay: 0.4s;
}
/* 退场：引导线位移+淡出 */
#geo-guides.exiting .geo-guide-h {
    animation: ak-guide-line-out-h 0.8s var(--ease-out) forwards;
}
#geo-guides.exiting .geo-guide-v {
    animation: ak-guide-line-out-v 0.8s var(--ease-out) forwards;
}

/* ============================================================
   官网动效 · 右侧面板滚动暗示
   ============================================================ */
#scroll-hint {
    position: fixed;
    right: calc(30% / 2 - 30px);  /* centered under right panel */
    bottom: 1.5rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--gold-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 2.5px;
    pointer-events: none;
    transition: opacity 0.4s var(--ease-out), visibility 0.4s var(--ease-out);
}
#scroll-hint.hidden {
    opacity: 0;
    visibility: hidden;
}
.scroll-hint-arrow {
    width: 12px;
    height: 12px;
    border-right: 1px solid var(--gold-dim);
    border-bottom: 1px solid var(--gold-dim);
    transform: rotate(45deg);
    animation: ak-scroll-hint 2.6s var(--ease-in-out) infinite;
}

/* ============================================================
   官网动效 · Live2D 背景水印大字
   ============================================================ */
.live2d-watermark {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Bender', 'Noto Sans SC', sans-serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 700;
    letter-spacing: 0.15em;
    color: rgba(201, 168, 124, 0.06);
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    transition: opacity 0.6s var(--ease-out);
}

/* ============================================================
   LOADING SCREEN
   ============================================================ */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s var(--ease-out-expo), visibility 0.6s var(--ease-out-expo);
}
#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    width: 340px;
    clip-path: var(--panel-clip);
    background: var(--acrylic-bg);
    border: 1px solid var(--acrylic-border);
    padding: 28px 24px;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
    animation: ak-scale-in 0.5s 0.15s var(--ease-out) both;
}

.loading-label {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 4px;
    color: var(--gold);
    margin-bottom: 20px;
    text-transform: uppercase;
    text-shadow:
        0 0 6px rgba(201, 168, 124, 0.3),
        2px 0 rgba(201, 168, 124, 0.2),
        -2px 0 rgba(91, 140, 189, 0.15);
    animation: text-glitch 3s infinite;
}

@keyframes text-glitch {
    0%, 90%, 100% {
        text-shadow:
            0 0 6px rgba(201, 168, 124, 0.3),
            2px 0 rgba(201, 168, 124, 0.2),
            -2px 0 rgba(91, 140, 189, 0.15);
        transform: translate(0);
    }
    92% {
        text-shadow:
            2px 0 rgba(201, 168, 124, 0.4),
            -2px 0 rgba(91, 140, 189, 0.25);
        transform: translate(-1px, 1px);
    }
    94% {
        text-shadow:
            -2px 0 rgba(201, 168, 124, 0.3),
            2px 0 rgba(91, 140, 189, 0.2);
        transform: translate(1px, -1px);
    }
    96% {
        transform: translate(0);
    }
}

.loading-bar-track {
    width: 100%;
    height: 4px;
    background: var(--border);
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
    overflow: hidden;
    margin-bottom: 14px;
    position: relative;
}
.loading-bar-track::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 6px,
        rgba(0,0,0,0.3) 6px,
        rgba(0,0,0,0.3) 8px
    );
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold-dim), var(--gold), var(--gold-bright));
    clip-path: polygon(0 0, calc(100% - 3px) 0, 100% 3px, 100% 100%, 3px 100%, 0 calc(100% - 3px));
    transition: width 0.3s var(--ease-out-expo);
    position: relative;
}
.loading-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35));
    filter: blur(2px);
}

.loading-counter {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 2px;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
#app-container {
    display: grid;
    grid-template-columns: 30% 40% 30%;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    gap: 12px;
    padding: 12px;
    background: transparent;
    opacity: 0;
    transition: opacity 0.6s var(--ease-out-expo) 0.2s;
    position: relative;
    z-index: var(--z-panel);
}
#app-container.ready {
    opacity: 1;
}

/* --- Panel Base --- */
#left-panel, #middle-panel, #right-panel {
    background: var(--acrylic-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    clip-path: var(--panel-clip);
    border: 1px solid var(--acrylic-border);
    box-shadow:
        var(--shadow-md),
        inset 0 1px 0 rgba(255,255,255,0.04),
        inset 0 -1px 0 rgba(0,0,0,0.3);
    opacity: 0;
    transform: translateY(24px);
    animation: panel-enter 0.7s var(--ease-out-expo) forwards;
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
}
#left-panel { animation-delay: 0.1s; }
#middle-panel { animation-delay: 0.22s; }
#right-panel { animation-delay: 0.34s; }

@keyframes panel-enter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   PANEL LABELS
   ============================================================ */
.panel-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 2.5px;
    color: var(--gold-dim);
    text-transform: uppercase;
    padding: 10px 14px;
    border-bottom: 1px solid var(--acrylic-border);
    background: linear-gradient(90deg, rgba(0,0,0,0.35), transparent);
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-label::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--gold-dim);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    opacity: 0.7;
}

/* ============================================================
   LEFT PANEL — Live2D + Music
   ============================================================ */
#left-panel {
    padding: 0;
}

#live2d-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--acrylic-border);
    min-height: 0;
    position: relative;
}

#live2d-viewport {
    flex: 1;
    position: relative;
    cursor: grab;
    min-height: 0;
    background:
        radial-gradient(ellipse at center, rgba(20, 20, 32, 0.9) 0%, rgba(8, 8, 14, 0.95) 70%);
    overflow: hidden;
    margin: 10px;
    clip-path: var(--card-clip);
    border: 1px solid var(--acrylic-border);
    box-shadow:
        inset 0 0 40px rgba(201, 168, 124, 0.06),
        0 0 24px rgba(201, 168, 124, 0.05);
}

#live2d-viewport::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 55%, rgba(201, 168, 124, 0.08) 100%);
    pointer-events: none;
    z-index: 2;
}

#live2d-viewport:active {
    cursor: grabbing;
}

#live2d-canvas {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    z-index: 1;
}

#live2d-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
#live2d-fallback.hidden {
    display: none;
}
#live2d-fallback img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: float 4s var(--ease-in-out) infinite;
    filter: drop-shadow(0 12px 24px rgba(0,0,0,0.5));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* HUD corners */
.hud-corners {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}
.hud-corners span {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--gold-dim);
    border-style: solid;
    border-width: 0;
    opacity: 0.8;
    transition: all var(--transition-normal);
}
.hud-corners span:nth-child(1) {
    top: 10px;
    left: 10px;
    border-top-width: 2px;
    border-left-width: 2px;
}
.hud-corners span:nth-child(2) {
    top: 10px;
    right: 10px;
    border-top-width: 2px;
    border-right-width: 2px;
}
.hud-corners span:nth-child(3) {
    bottom: 10px;
    right: 10px;
    border-bottom-width: 2px;
    border-right-width: 2px;
}
.hud-corners span:nth-child(4) {
    bottom: 10px;
    left: 10px;
    border-bottom-width: 2px;
    border-left-width: 2px;
}
#live2d-viewport:hover .hud-corners span {
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

/* HUD reticle */
.hud-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
    opacity: 0.12;
    border: 1px dashed var(--gold-dim);
    border-radius: 50%;
    animation: reticle-rotate 20s linear infinite;
}
.hud-reticle::before,
.hud-reticle::after {
    content: '';
    position: absolute;
    border: 1px dashed var(--gold-dim);
    border-radius: 50%;
}
.hud-reticle::before {
    inset: 20px;
    animation: reticle-rotate 14s linear infinite reverse;
}
.hud-reticle::after {
    inset: 40px;
    animation: reticle-rotate 8s linear infinite;
}

@keyframes reticle-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#live2d-status {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    padding: 8px 14px;
    border-top: 1px solid var(--acrylic-border);
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}
#live2d-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--success);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    animation: status-pulse 2s var(--ease-in-out) infinite;
}
@keyframes status-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}
#live2d-status span {
    color: var(--gold-dim);
}

/* --- Bilingual Voice Subtitle --- */
#voice-subtitle {
    padding: 10px 14px;
    border-top: 1px solid var(--acrylic-border);
    min-height: 52px;
    transition: opacity 0.3s var(--ease-out-expo);
    background: rgba(0,0,0,0.25);
    margin: 0 10px 10px;
    clip-path: var(--input-clip);
    border: 1px solid var(--acrylic-border);
}
.subtitle-jp {
    font-family: var(--font-serif);
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.5;
    letter-spacing: 0.5px;
    word-break: break-all;
}
.subtitle-cn {
    font-size: 10px;
    color: var(--gold-dim);
    line-height: 1.4;
    margin-top: 4px;
    letter-spacing: 1px;
}

/* --- Music Player --- */
#music-player {
    padding: 0;
    background: rgba(0,0,0,0.2);
}

.music-info {
    padding: 12px 14px 8px;
}

.music-title {
    font-family: var(--font-serif);
    font-size: 15px;
    color: var(--gold-bright);
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 0 10px rgba(201, 168, 124, 0.15);
}

.music-artist {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 2px;
}

.music-waveform {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 18px;
    margin-top: 10px;
    opacity: 0.5;
}
.music-waveform span {
    width: 3px;
    background: linear-gradient(to top, var(--gold-dim), transparent);
    border-radius: 1px;
    animation: waveform-dance 1.2s var(--ease-in-out) infinite alternate;
}
/* Heights and delays assigned via inline style in music.js for brevity */

@keyframes waveform-dance {
    from { transform: scaleY(0.6); opacity: 0.4; }
    to { transform: scaleY(1); opacity: 0.8; }
}

.music-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
}

.progress-bar-track {
    flex: 1;
    height: 3px;
    background: var(--border);
    clip-path: polygon(0 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 2px 100%, 0 calc(100% - 2px));
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold-dim), var(--gold));
    clip-path: polygon(0 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 2px 100%, 0 calc(100% - 2px));
    transition: width 0.1s linear;
    position: relative;
}
.progress-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 12px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
}
.progress-bar-track:hover .progress-bar-fill {
    background: linear-gradient(90deg, var(--gold), var(--gold-bright));
}

.music-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 4px 14px;
}

.music-btn {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: var(--input-clip);
}
.music-btn svg { position: relative; z-index: 1; }
.music-btn:hover {
    color: var(--gold);
    border-color: var(--gold-dim);
    box-shadow: 0 0 10px var(--gold-glow);
    transform: translateY(-1px);
}
.music-btn-play {
    padding: 9px;
    border-radius: 50%;
    clip-path: circle(50%);
    background: rgba(201, 168, 124, 0.08);
    border-color: var(--gold-dim);
}

.music-volume {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px 8px;
    color: var(--text-dim);
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 3px;
    background: var(--border);
    outline: none;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 2px) 0, 100% 2px, 100% 100%, 2px 100%, 0 calc(100% - 2px));
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: var(--gold);
    border: 1px solid var(--gold-bright);
    cursor: pointer;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.music-playlist {
    padding: 0 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.playlist-item {
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    clip-path: var(--input-clip);
    background: rgba(0,0,0,0.2);
}
/* 底线动画 */
.playlist-item::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 2px;
    background: var(--gold-dim);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-normal);
    z-index: 1;
    pointer-events: none;
}
.playlist-item:hover {
    color: var(--text-secondary);
    border-color: var(--gold-dim);
    transform: translateY(-1px);
}
.playlist-item:hover::after { transform: scaleX(1); }
.playlist-item.active {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--gold-glow);
    box-shadow: 0 0 10px var(--gold-glow);
}
.playlist-item.active::after { background: var(--gold); transform: scaleX(1); }

/* --- Music Title Row (title + fav button) --- */
.music-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.music-btn-fav {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.music-btn-fav svg { position: relative; z-index: 1; }
.music-btn-fav:hover {
    color: var(--gold);
    transform: scale(1.15);
}
.music-btn-fav #icon-fav-solid {
    color: var(--gold);
}

/* --- Music Search Row --- */
.music-search-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-top: 1px solid var(--acrylic-border);
}

.music-search-icon {
    color: var(--text-dim);
    flex-shrink: 0;
}

.music-search-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    clip-path: var(--input-clip);
    padding: 5px 10px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 10px;
    outline: none;
    transition: all var(--transition-fast);
    min-width: 0;
}
.music-search-input::placeholder {
    color: var(--text-dim);
    font-family: var(--font-mono);
}
.music-search-input:focus {
    border-color: var(--gold-dim);
    box-shadow: 0 0 8px var(--gold-glow);
}

.music-btn-filter {
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    padding: 5px 7px;
    display: flex;
    align-items: center;
    clip-path: var(--input-clip);
    transition: all var(--transition-fast);
}
.music-btn-filter svg { position: relative; z-index: 1; }
.music-btn-filter:hover {
    color: var(--gold);
    border-color: var(--gold-dim);
}
.music-btn-filter.active {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--gold-glow);
    box-shadow: 0 0 8px var(--gold-glow);
}

/* --- EP Filter Tabs --- */
.music-ep-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 14px 4px;
}

.ep-tab {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 1px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    clip-path: var(--input-clip);
    background: rgba(0,0,0,0.2);
    transition: all var(--transition-fast);
    position: relative;
}
.ep-tab:hover {
    color: var(--text-secondary);
    border-color: var(--gold-dim);
}
.ep-tab.active {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--gold-glow);
    box-shadow: 0 0 6px var(--gold-glow);
}

/* --- Track Count --- */
.music-track-count {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--text-dim);
    padding: 2px 14px 4px;
    text-align: right;
}

/* --- Music Library (scrollable track list) --- */
.music-library {
    padding: 0 10px 10px;
    max-height: 340px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lib-track {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid transparent;
    cursor: pointer;
    clip-path: var(--input-clip);
    transition: all var(--transition-fast);
    position: relative;
}
.lib-track:hover {
    background: rgba(201, 168, 124, 0.04);
    border-color: var(--border);
}
.lib-track.active {
    background: var(--gold-glow);
    border-color: var(--gold-dim);
}
.lib-track.active .lib-track-title {
    color: var(--gold-bright);
}
.lib-track.unavailable {
    opacity: 0.4;
    cursor: not-allowed;
}
.lib-track.unavailable:hover {
    background: transparent;
    border-color: transparent;
}

.lib-track-star {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    width: 18px;
    text-align: center;
    transition: all var(--transition-fast);
    user-select: none;
    position: relative;
    z-index: 2;
}
.lib-track-star:hover {
    color: var(--gold);
    transform: scale(1.2);
}
.lib-track-star.fav {
    color: var(--gold);
}

.lib-track-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.lib-track-title {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
}

.lib-track-sub {
    font-size: 9px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-track-ep {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 7px;
    color: var(--text-dim);
    letter-spacing: 1px;
    background: rgba(0,0,0,0.25);
    padding: 2px 6px;
    clip-path: var(--input-clip);
    border: 1px solid var(--border);
}

.lib-empty {
    text-align: center;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* Scrollbar for music library */
.music-library::-webkit-scrollbar {
    width: 3px;
}
.music-library::-webkit-scrollbar-track {
    background: transparent;
}
.music-library::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}
.music-library::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dim);
}

/* ============================================================
   MIDDLE PANEL — Chat
   ============================================================ */
#chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* --- Rotating Chat Background --- */
#chat-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.chat-bg-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transform: scale(1.05);
    transition: opacity 1.4s var(--ease-in-out), transform 8s var(--ease-out-expo);
}

.chat-bg-layer.active {
    opacity: 0.35;
    transform: scale(1);
}

.chat-bg-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(10, 10, 15, 0.55) 0%, rgba(10, 10, 15, 0.25) 40%, rgba(10, 10, 15, 0.35) 100%),
        radial-gradient(ellipse at center, transparent 30%, rgba(10, 10, 15, 0.65) 100%);
    z-index: 1;
}

#chat-container > *:not(#chat-bg) {
    position: relative;
    z-index: 2;
}

@media (prefers-reduced-motion: reduce) {
    .chat-bg-layer {
        transition: opacity 0.6s var(--ease-in-out);
        transform: none;
    }
    .chat-bg-layer.active {
        transform: none;
    }
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    border-bottom: 1px solid var(--acrylic-border);
    background: linear-gradient(90deg, rgba(0,0,0,0.35), transparent);
}

.chat-header-left .panel-label {
    border-bottom: none;
    padding-bottom: 4px;
}

.chat-character-name {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 700;
    color: var(--gold-bright);
    padding: 0 14px;
    letter-spacing: 1px;
    text-shadow: 0 0 12px rgba(201, 168, 124, 0.15);
}

.chat-character-role {
    font-size: 10px;
    color: var(--text-dim);
    padding: 0 14px 10px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.chat-header-right {
    padding: 0 14px;
}

.btn-ghost {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 5px 12px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
    clip-path: var(--input-clip);
}
.btn-ghost svg, .btn-ghost span { position: relative; z-index: 1; }
.btn-ghost::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 2px;
    background: var(--gold-dim);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-normal);
    z-index: 1;
    pointer-events: none;
}
.btn-ghost:hover {
    color: var(--gold-dim);
    border-color: var(--gold-dim);
    box-shadow: 0 0 10px var(--gold-glow);
    transform: translateY(-1px);
}
.btn-ghost:hover::after { transform: scaleX(1); }

/* --- Messages Area --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    contain: layout style;
    will-change: scroll-position;
}

.chat-welcome {
    text-align: center;
    padding: 48px 24px;
}

.welcome-line {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--gold-dim);
    letter-spacing: 2px;
    margin-bottom: 14px;
}

.welcome-sub {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* --- Message Bubble Row (bubble + TTS button) --- */
.message-bubble-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.message-bubble-row .message-bubble {
    flex: 1;
    min-width: 0;
}

/* --- Message Bubbles --- */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: message-in 0.35s var(--ease-out-expo);
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.user {
    align-self: flex-end;
}

.message.character {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
    clip-path: polygon(
        0 0,
        calc(100% - 10px) 0,
        100% 10px,
        100% 100%,
        10px 100%,
        0 calc(100% - 10px)
    );
}

.message.user .message-bubble {
    background: rgba(24, 24, 37, 0.85);
    border: 1px solid var(--border-light);
    border-left: 2px solid var(--accent-blue-dim);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.message.character .message-bubble {
    background: rgba(21, 21, 31, 0.9);
    border: 1px solid var(--acrylic-border);
    border-left: 2px solid var(--gold-dim);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.message.character .message-bubble::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(201, 168, 124, 0.08),
        transparent
    );
    animation: decode-shimmer 2.2s var(--ease-out-expo) forwards;
}

@keyframes decode-shimmer {
    to { left: 200%; }
}

.message-sender {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1px;
    margin-bottom: 5px;
    padding: 0 2px;
    text-transform: uppercase;
}

.message.user .message-sender {
    color: var(--accent-blue-dim);
    text-align: right;
}

.message.character .message-sender {
    color: var(--gold-dim);
}

.message-time {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 5px;
    padding: 0 2px;
}

.message.user .message-time {
    text-align: right;
}

/* --- TTS Play Button --- */
.btn-tts-play {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--gold-dim);
    background: rgba(21, 21, 31, 0.8);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    margin-bottom: 2px;
    backdrop-filter: blur(4px);
    z-index: 1;
}
.btn-tts-play svg { position: relative; z-index: 1; }
/* 悬停光环扩散 */
.btn-tts-play::before {
    inset: -4px;
    border-radius: 50%;
    border: 1px solid var(--gold-dim);
    opacity: 0;
}
.btn-tts-play:hover {
    background: rgba(201, 168, 124, 0.12);
    border-color: var(--gold-bright);
    color: var(--gold-bright);
    box-shadow: 0 0 16px var(--gold-glow);
    transform: scale(1.08);
}
.btn-tts-play:hover::before {
    opacity: 1;
    inset: -6px;
}

.btn-tts-play.loading {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    animation: tts-pulse 1s var(--ease-in-out) infinite;
    pointer-events: none;
}

.btn-tts-play.translating {
    border-color: var(--gold);
    color: var(--gold);
    animation: tts-pulse 0.8s var(--ease-in-out) infinite;
    pointer-events: none;
}

.btn-tts-play.playing {
    border-color: var(--success);
    color: var(--success);
    background: rgba(90, 139, 90, 0.15);
    box-shadow: 0 0 12px rgba(90, 139, 90, 0.3);
}

.btn-tts-play .playing-icon { display: none; }
.btn-tts-play.playing .play-icon { display: none; }
.btn-tts-play.playing .playing-icon { display: block; }

@keyframes tts-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(91, 140, 189, 0.2); }
    50% { box-shadow: 0 0 16px rgba(91, 140, 189, 0.5); }
}

/* --- TTS Progress Indicator --- */
.tts-progress {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--gold-dim);
    padding: 4px 0 4px 2px;
    letter-spacing: 1.5px;
    animation: progress-blink 1.2s var(--ease-in-out) infinite;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tts-progress::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--gold-dim);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    animation: status-pulse 1.2s var(--ease-in-out) infinite;
}
@keyframes progress-blink {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Replace play icon with equalizer when playing */
.btn-tts-play.playing svg path {
    d: path("M3 17h2V7H3v10zm4-10v10h2V7H7zm4 10h2V3h-2v14zm4-10v10h2V7h-2zm4-4v18h2V3h-2z");
}

/* --- Language Toggle Button --- */
.btn-lang-toggle {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    color: var(--gold-dim);
    padding: 5px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 4px;
    clip-path: var(--input-clip);
    white-space: nowrap;
}
.btn-lang-toggle .lang-char, .btn-lang-toggle .lang-arrow { position: relative; z-index: 1; }
/* 箭头悬停旋转 */
.btn-lang-toggle:hover .lang-arrow {
    transform: rotate(180deg);
}
.btn-lang-toggle:hover {
    color: var(--gold-bright);
    border-color: var(--gold-dim);
    box-shadow: 0 0 10px var(--gold-glow);
    transform: translateY(-1px);
}
.btn-lang-toggle .lang-char { font-weight: 700; font-size: 14px; }
.btn-lang-toggle .lang-arrow { font-size: 10px; opacity: 0.6; transition: transform var(--transition-normal); }

.btn-lang-toggle[data-lang="ja"] {
    border-color: var(--accent-blue-dim);
    color: var(--accent-blue);
}
.btn-lang-toggle[data-lang="ja"]:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(91, 140, 189, 0.25);
}

/* --- Settings Divider --- */
.settings-divider {
    margin: 16px 0 10px;
    padding: 6px 0;
    border-top: 1px solid var(--acrylic-border);
    text-align: center;
}

.settings-divider span {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    background: var(--bg-card);
    padding: 0 10px;
}

/* --- Label Hint --- */
.label-hint {
    font-size: 9px;
    color: var(--text-dim);
    font-weight: 300;
    letter-spacing: 0.5px;
}

/* --- Typing Indicator --- */
.chat-typing {
    display: flex;
    gap: 5px;
    padding: 8px 18px;
    align-items: center;
}
.chat-typing.hidden {
    display: none;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--gold-dim);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    animation: typing-bounce 1.4s var(--ease-in-out) infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-7px); }
}

/* --- Input Area --- */
.chat-input-area {
    border-top: 1px solid var(--acrylic-border);
    padding: 12px 14px;
    background: rgba(0,0,0,0.25);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    clip-path: var(--input-clip);
    padding: 8px 12px;
    transition: all var(--transition-normal);
    position: relative;
}
.chat-input-wrapper::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 1px;
    background: var(--border-light);
    transition: all var(--transition-fast);
}
.chat-input-wrapper:focus-within {
    border-color: var(--gold-dim);
    box-shadow: 0 0 16px var(--gold-glow), inset 0 0 10px rgba(201, 168, 124, 0.03);
}
.chat-input-wrapper:focus-within::before {
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

.input-prompt {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--gold-dim);
    line-height: 1.5;
    user-select: none;
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    position: relative;
    z-index: 1;
}
#chat-input::placeholder {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 12px;
}

.btn-send {
    background: rgba(201, 168, 124, 0.08);
    border: 1px solid var(--gold-dim);
    color: var(--gold-dim);
    padding: 7px 11px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    clip-path: var(--input-clip);
    /* 脉冲光环 — 提示可交互 */
    animation: send-pulse 3s var(--ease-in-out) infinite;
}
.btn-send svg { position: relative; z-index: 1; }
@keyframes send-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--gold-glow); }
    50%      { box-shadow: 0 0 0 6px transparent; }
}
.btn-send:hover {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--gold-glow);
    box-shadow: 0 0 16px var(--gold-glow), 0 0 32px rgba(201, 168, 124, 0.08);
    transform: translateY(-1px);
    animation: none;
}
.btn-send:disabled {
    color: var(--text-dim);
    border-color: var(--border);
    background: rgba(0,0,0,0.2);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    animation: none;
}

.chat-input-hint {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 1px;
    padding-top: 6px;
    text-align: right;
}

/* ============================================================
   RIGHT PANEL — Character Cards + Settings
   ============================================================ */
#right-panel {
    gap: 0;
    overflow-y: auto;
}

/* --- Settings Panel --- */
#settings-panel {
    border-bottom: 1px solid var(--acrylic-border);
    padding: 0;
}

.settings-form {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-group label::before {
    content: '';
    width: 4px;
    height: 4px;
    background: var(--gold-dim);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.form-group input,
.form-group select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    clip-path: var(--input-clip);
    padding: 8px 11px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    outline: none;
    transition: all var(--transition-fast);
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--gold-dim);
    box-shadow: 0 0 10px var(--gold-glow), inset 0 0 8px rgba(201, 168, 124, 0.03);
}
.form-group input::placeholder {
    color: var(--text-dim);
}
.form-group select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a7355'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    cursor: pointer;
}
.form-group select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.password-wrapper {
    display: flex;
    position: relative;
}
.password-wrapper input {
    flex: 1;
    padding-right: 34px;
}

.btn-toggle-pw {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 5px;
    display: flex;
}
.btn-toggle-pw svg { position: relative; z-index: 1; }
.btn-toggle-pw:hover {
    color: var(--gold);
    transform: translateY(-50%) scale(1.1);
}

.btn-save {
    background: rgba(201, 168, 124, 0.08);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 9px 18px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    clip-path: var(--input-clip);
    width: 100%;
    margin-top: 4px;
}
.btn-save span { position: relative; z-index: 1; }
.btn-save:hover {
    background: var(--gold-glow);
    border-color: var(--gold);
    box-shadow: 0 0 14px var(--gold-glow);
    transform: translateY(-1px);
}
/* 保存成功闪烁反馈 */
@keyframes save-flash {
    0%   { border-color: var(--gold); background: var(--gold-glow); }
    50%  { border-color: var(--success); background: rgba(90, 139, 90, 0.15); box-shadow: 0 0 14px rgba(90, 139, 90, 0.25); }
    100% { border-color: var(--gold); background: var(--gold-glow); }
}
.btn-save.saved {
    animation: save-flash 0.8s var(--ease-in-out);
}

.settings-status {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1px;
    text-align: center;
    min-height: 14px;
    transition: color var(--transition-fast);
}
.settings-status.success { color: var(--success); }
.settings-status.error { color: var(--danger-bright); }

/* --- Guide Button --- */
.btn-guide {
    background: rgba(100, 160, 200, 0.08);
    border: 1px solid rgba(100, 160, 200, 0.3);
    color: #8ab4d8;
    padding: 9px 18px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    clip-path: var(--input-clip);
    width: 100%;
    margin-top: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-guide:hover {
    background: rgba(100, 160, 200, 0.15);
    border-color: #8ab4d8;
    box-shadow: 0 0 14px rgba(100, 160, 200, 0.2);
    transform: translateY(-1px);
}

/* --- Guide Overlay --- */
#guide-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out);
}
#guide-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.guide-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}
.guide-panel {
    position: relative;
    width: min(780px, 92vw);
    max-height: 88vh;
    background: var(--bg-panel);
    border: 1px solid var(--gold-dim);
    clip-path: var(--panel-clip);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6), 0 0 20px var(--gold-glow);
    animation: guide-in 0.35s var(--ease-out);
}
@keyframes guide-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gold-dim);
    flex-shrink: 0;
}
.guide-header-label {
    font-family: var(--font-display, 'Bender', sans-serif);
    font-size: 13px;
    letter-spacing: 2px;
    color: var(--gold);
}
.guide-close-btn {
    background: none;
    border: none;
    color: var(--gold-dim);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition-fast);
}
.guide-close-btn:hover { color: var(--text-bright); }

.guide-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
    scroll-behavior: smooth;
}
.guide-body::-webkit-scrollbar { width: 3px; }
.guide-body::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }
.guide-body::-webkit-scrollbar-track { background: transparent; }

.guide-section { margin-bottom: 32px; }
.guide-section:last-child { margin-bottom: 0; }
.guide-section h2 {
    font-family: var(--font-display, 'Bender', sans-serif);
    font-size: 14px;
    color: var(--gold);
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(201, 168, 124, 0.15);
}
.guide-section h3 {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 1px;
    margin: 16px 0 8px;
    text-transform: uppercase;
}
.guide-section p {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.7;
    margin: 6px 0;
}
.guide-section p strong { color: var(--text-bright); }
.guide-section a {
    color: #8ab4d8;
    text-decoration: none;
    border-bottom: 1px dotted rgba(138, 180, 216, 0.3);
    transition: border-color var(--transition-fast);
}
.guide-section a:hover { border-bottom-color: #8ab4d8; }
.guide-section code {
    background: rgba(201, 168, 124, 0.1);
    color: var(--gold);
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 11px;
    border-radius: 2px;
}

.guide-features { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.guide-feature-item {
    display: flex; gap: 12px; align-items: flex-start;
    background: rgba(201, 168, 124, 0.03);
    border: 1px solid rgba(201, 168, 124, 0.08);
    padding: 12px 14px;
    clip-path: var(--input-clip);
}
.guide-feature-item .feature-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.guide-feature-item strong {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-bright, var(--text-primary));
    letter-spacing: 1px;
    margin-bottom: 2px;
}
.guide-feature-item p {
    font-size: 12px;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.5;
}

.guide-steps, .guide-tips {
    padding-left: 20px;
    margin: 8px 0;
}
.guide-steps li, .guide-tips li {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.7;
    margin-bottom: 4px;
}
.guide-steps ul { margin-top: 4px; padding-left: 18px; }
.guide-steps ul li { font-size: 12px; }

.guide-tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.tech-tag {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-dim);
    background: rgba(201, 168, 124, 0.06);
    border: 1px solid rgba(201, 168, 124, 0.15);
    padding: 4px 10px;
    clip-path: var(--input-clip);
}

/* Mobile: guide panel */
@media (max-width: 520px) {
    .guide-panel { width: 96vw; max-height: 92vh; }
    .guide-body { padding: 18px 16px; }
    .guide-header { padding: 12px 14px; }
    .guide-header-label { font-size: 11px; }
}

/* --- Character Cards --- */
#character-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
}

.character-card {
    border: 1px solid var(--border);
    clip-path: var(--card-clip);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
}
/* 官网式：卡片底部强调线悬停展开 */
.character-card::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 2px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-normal);
    z-index: 3;
}
.character-card:hover {
    border-color: var(--gold-dim);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.character-card:hover::after {
    transform: scaleX(1);
}
.character-card.active {
    border-color: var(--gold);
    background: rgba(201, 168, 124, 0.05);
    box-shadow:
        0 0 24px var(--gold-glow),
        inset 0 0 24px rgba(201, 168, 124, 0.04);
    animation: card-holo-pulse 3s var(--ease-in-out) infinite;
}

@keyframes card-holo-pulse {
    0%, 100% { box-shadow: 0 0 20px var(--gold-glow), inset 0 0 20px rgba(201, 168, 124, 0.03); }
    50% { box-shadow: 0 0 32px rgba(201, 168, 124, 0.18), inset 0 0 28px rgba(201, 168, 124, 0.06); }
}

.character-card-inner {
    padding: 10px;
}

.character-illustration {
    position: relative;
    overflow: hidden;
    clip-path: var(--card-clip);
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.15s var(--ease-out-expo);
    aspect-ratio: 3/4;
    background: transparent;
    border: 1px solid var(--border);
}
.character-card:hover .character-illustration,
.character-card.active .character-illustration {
    border-color: var(--gold-dim);
}

.character-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: transform 0.15s var(--ease-out-expo), opacity 0.4s var(--ease-out-expo);
    mix-blend-mode: screen;
    filter: contrast(1.15);
}

.character-illustration::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent 55%,
        rgba(201, 168, 124, 0.08) 100%
    );
    pointer-events: none;
    opacity: 0.6;
    transition: opacity var(--transition-normal);
    z-index: 2;
}
.character-card.active .character-illustration::before {
    opacity: 1;
}

/* Dual-image hover swap (Mudrock: armor ↔ unarmored) */
.character-illustration.dual-image {
    position: relative;
}
.character-illustration.dual-image .character-img-primary {
    position: relative;
    z-index: 1;
}
.character-illustration.dual-image .character-img-secondary {
    position: absolute;
    inset: 0;
    z-index: 1;
    opacity: 0;
}
.character-card:hover .character-illustration.dual-image .character-img-primary {
    opacity: 0;
}
.character-card:hover .character-illustration.dual-image .character-img-secondary {
    opacity: 1;
}

/* Dual-image indicator label */
.character-illustration.dual-image::after {
    content: '◈';
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 3;
    font-size: 10px;
    color: var(--gold-dim);
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out-expo);
    background: none;
}
.character-card:hover .character-illustration.dual-image::after {
    opacity: 1;
    color: var(--gold);
}

.character-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    opacity: 0;
}

.character-card.active .character-glow {
    opacity: 1;
    background: linear-gradient(
        135deg,
        rgba(201, 168, 124, 0.1) 0%,
        transparent 50%,
        rgba(201, 168, 124, 0.05) 100%
    );
}

.character-info {
    padding: 10px 4px 2px;
}

.character-code {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 1.5px;
}

.character-card-name {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 3px 0;
    letter-spacing: 0.5px;
}

.character-card.active .character-card-name {
    color: var(--gold-bright);
    text-shadow: 0 0 10px rgba(201, 168, 124, 0.2);
}

.character-card-title {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.character-card-race {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 3px;
}

/* --- Active Indicator --- */
.character-card::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--border);
    border: 1px solid var(--border-light);
    z-index: 2;
    transition: all var(--transition-normal);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.character-card.active::before {
    background: var(--gold);
    border-color: var(--gold-bright);
    box-shadow: 0 0 8px var(--gold-glow);
    animation: status-pulse 2s var(--ease-in-out) infinite;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 11px 18px;
    clip-path: var(--input-clip);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 1px;
    animation: toast-in 0.35s var(--ease-out-expo);
    max-width: 320px;
    border: 1px solid var(--border);
    background: var(--acrylic-bg);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
}
.toast.error {
    border-color: var(--danger);
    color: var(--danger-bright);
}
.toast.success {
    border-color: var(--success);
    color: var(--success);
}
.toast.fade-out {
    animation: toast-out 0.3s var(--ease-in-expo) forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(50px) scale(0.98); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden {
    display: none !important;
}

/* ============================================================
   RESPONSIVE: Stack vertically on small screens
   ============================================================ */

/* --- Tablet / Medium screens (769px - 1100px) --- */
/* Mobile bottom tab bar - hidden on desktop, shown inside media queries */
.mobile-tab-bar { display: none; }

/* Settings gear button in chat header - hidden on desktop */
.btn-settings-gear { display: none !important; }

/* Settings drawer backdrop - hidden on desktop */
.settings-drawer-backdrop { display: none; }

@media (max-width: 1100px) {
    #app-container {
        grid-template-columns: 1fr;
        grid-template-rows: 40vh auto auto;
        overflow-y: auto;
        gap: 10px;
        padding: 10px;
    }
    #left-panel {
        flex-direction: row;
    }
    #live2d-container {
        flex: 1;
        border-bottom: none;
        border-right: 1px solid var(--acrylic-border);
    }
    #music-player {
        width: 260px;
        flex-shrink: 0;
    }
    #right-panel {
        flex-direction: column;
        overflow-y: visible;
        overflow-x: hidden;
    }
    #character-cards {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }
    .character-card {
        min-width: 0;
    }
    /* Show mobile character switcher on small screens */
    #mobile-char-switcher {
        display: flex;
    }
    #vignette {
        opacity: 0.7;
    }
}

/* --- Phone / Small screens (up to 768px) --- */
@media (max-width: 768px) {

    /* === FOUNDATION: Body & HTML === */
    html {
        -webkit-text-size-adjust: 100%;
    }
    html, body {
        touch-action: manipulation;
        overscroll-behavior: none;
        overflow: hidden;
    }

    /* ================================================================
       DRAWER LAYOUT RESTRUCTURE
       - Single-column: chat fills the screen
       - Bottom tab bar: Chat / Characters / Music
       - Left panel → music tab overlay
       - Right panel → characters tab overlay / settings drawer
       ================================================================ */

    /* === APP CONTAINER: Single column, chat-only === */
    #app-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        gap: 0;
        padding: 0;
        padding-top: env(safe-area-inset-top);
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    /* === LEFT PANEL: Hidden from grid, shown as music tab overlay === */
    #left-panel {
        position: fixed;
        inset: 0;
        top: 0;
        z-index: 50;
        flex-direction: column;
        overflow-y: auto;
        background: var(--bg-primary);
        padding-bottom: 80px;
        padding-top: env(safe-area-inset-top);
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s, visibility 0.2s;
    }
    #left-panel.mobile-panel-visible {
        visibility: visible;
        pointer-events: auto;
        opacity: 1;
        display: flex;
    }
    #live2d-container {
        flex: none;
        border-bottom: 1px solid var(--acrylic-border);
        border-right: none;
        max-height: 35vh;
    }

    /* === MIDDLE PANEL: Primary view — fills available space === */
    #middle-panel {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    #middle-panel.mobile-panel-hidden {
        display: none;
    }
    #chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .chat-messages {
        flex: 1;
        padding: 10px;
        gap: 8px;
    }
    .message {
        max-width: 92%;
    }
    .message-bubble {
        font-size: 14px;
        padding: 10px 12px;
        overflow-wrap: break-word;
        word-break: break-word;
        overflow-x: auto;
    }
    .chat-character-name {
        font-size: 16px;
    }
    .chat-character-role {
        font-size: 8px;
        max-width: 50vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* === RIGHT PANEL: Hidden from grid, shown as characters tab overlay === */
    #right-panel {
        position: fixed;
        inset: 0;
        top: 0;
        z-index: 50;
        flex-direction: column;
        overflow-y: auto;
        background: var(--bg-primary);
        padding-bottom: 80px;
        padding-top: env(safe-area-inset-top);
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s, visibility 0.2s;
    }
    #right-panel.mobile-panel-visible {
        visibility: visible;
        pointer-events: auto;
        opacity: 1;
        display: flex;
    }

    /* ================================================================
       SETTINGS DRAWER — slides from top over everything
       ================================================================ */
    #settings-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
        max-height: 70vh;
        overflow-y: auto;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--acrylic-border);
        box-shadow: 0 8px 32px rgba(0,0,0,0.5);
        transform: translateY(-100%);
        transition: transform 0.35s var(--ease-out-expo);
        padding: 0;
        visibility: visible;
    }
    #settings-panel.drawer-open {
        transform: translateY(0);
    }
    #settings-panel .panel-label {
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--bg-secondary);
    }
    #settings-panel .settings-form {
        padding: 10px 14px;
        padding-bottom: 20px;
    }

    /* Settings drawer backdrop */
    .settings-drawer-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 190;
        background: rgba(0,0,0,0.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s var(--ease-out-expo);
    }
    .settings-drawer-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Hide old settings toggle button */
    .settings-toggle-btn {
        display: none !important;
    }

    /* Show settings gear in chat header */
    .btn-settings-gear {
        display: flex !important;
    }

    /* ================================================================
       MOBILE BOTTOM TAB BAR
       ================================================================ */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        height: 64px;
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(10, 10, 15, 0.94);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--acrylic-border);
        align-items: stretch;
    }
    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: none;
        border: none;
        color: var(--text-dim);
        cursor: pointer;
        font-family: var(--font-mono);
        font-size: 10px;
        letter-spacing: 0.08em;
        transition: color var(--transition-fast);
        -webkit-tap-highlight-color: transparent;
        padding: 0;
        min-height: 44px;
    }
    .mobile-tab.active {
        color: var(--gold);
    }
    .mobile-tab svg {
        opacity: 0.7;
        transition: opacity var(--transition-fast);
    }
    .mobile-tab.active svg {
        opacity: 1;
    }

    /* ================================================================
       CHARACTERS TAB — full-screen character grid
       ================================================================ */
    #character-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 12px;
        padding-bottom: 80px;
    }
    .character-card {
        min-width: 0;
    }
    .character-card-inner {
        padding: 10px;
    }
    .character-card-name {
        font-size: 14px;
    }
    .character-card-title {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .character-card-race {
        font-size: 9px;
    }
    .character-code {
        font-size: 9px;
    }
    /* Disable mix-blend-mode on mobile (rendering bugs) */
    .character-img {
        mix-blend-mode: normal;
        filter: contrast(1.05);
    }

    /* ================================================================
       MUSIC TAB — full-screen music player
       ================================================================ */
    #music-player {
        width: 100%;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }
    #music-player .panel-label {
        font-size: 9px;
        letter-spacing: 2px;
        padding: 10px 12px;
    }
    .music-info {
        padding: 10px 14px 4px;
    }
    .music-title {
        font-size: 16px;
    }
    .music-artist {
        font-size: 11px;
    }
    .music-waveform {
        display: flex;
    }
    .music-controls {
        gap: 16px;
        padding: 8px 14px;
        justify-content: center;
    }
    .music-progress {
        padding: 8px 14px;
    }
    .music-volume {
        padding: 4px 14px 8px;
        gap: 8px;
    }
    .volume-slider {
        width: auto;
        flex: 1;
    }
    .music-library {
        flex: 1;
        max-height: none;
        overflow-y: auto;
        padding-bottom: 80px;
    }
    .lib-track {
        padding: 10px 12px;
    }
    .lib-track-title {
        font-size: 14px;
    }
    .lib-track-star {
        font-size: 16px;
        width: 28px;
        min-width: 28px;
        min-height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .music-ep-tabs {
        gap: 4px;
        padding: 6px 12px 4px;
    }
    .ep-tab {
        font-size: 10px;
        padding: 6px 12px;
    }
    .music-search-row {
        padding: 8px 12px;
    }
    .music-search-input {
        font-size: 14px;
        padding: 8px 12px;
    }
    .music-btn-filter {
        min-width: 40px;
        min-height: 40px;
        padding: 10px;
    }
    .music-search-icon {
        width: 18px;
        height: 18px;
    }
    .music-track-count {
        font-size: 10px;
        padding: 4px 12px 6px;
    }
    .music-btn-fav {
        min-width: 40px;
        min-height: 40px;
        padding: 10px;
    }

    /* ================================================================
       TOUCH TARGETS: Minimum 44px
       ================================================================ */
    .music-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .music-btn svg {
        width: 22px;
        height: 22px;
    }
    .music-btn-play {
        min-width: 48px;
        min-height: 48px;
        padding: 12px;
    }
    .btn-send {
        min-width: 44px;
        min-height: 44px;
        padding: 10px 14px;
    }
    .btn-send svg {
        width: 22px;
        height: 22px;
    }
    .btn-ghost {
        min-height: 44px;
        padding: 8px 12px;
        font-size: 9px;
    }
    .btn-save {
        min-height: 44px;
        padding: 12px 18px;
        font-size: 12px;
    }
    .btn-toggle-pw {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }
    .playlist-item {
        font-size: 12px;
        padding: 10px 14px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        white-space: nowrap;
    }
    .mobile-char-select {
        min-height: 44px;
        padding: 8px 28px 8px 10px;
        font-size: 11px;
    }
    .form-group input,
    .form-group select {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 16px;
    }
    .volume-slider {
        height: 6px;
    }
    .volume-slider::-webkit-slider-thumb {
        width: 22px;
        height: 22px;
    }
    .progress-bar-track {
        height: 10px;
        min-height: 10px;
    }
    .panel-label {
        min-height: 32px;
        padding: 8px 10px;
    }

    /* === MOBILE CHARACTER SWITCHER (dropdown in chat header) === */
    #mobile-char-switcher {
        display: flex;
    }
    .chat-header-right {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 0 6px;
    }

    /* === SMALLER PANEL LABELS === */
    .panel-label {
        font-size: 8px;
        letter-spacing: 1.5px;
        padding: 6px 10px;
    }

    /* === iOS SAFE AREAS === */
    #toast-container {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
    }

    /* === TOASTS: Responsive sizing === */
    .toast {
        font-size: 10px;
        padding: 10px 14px;
        max-width: min(320px, calc(100vw - 40px));
    }

    /* === CHAT INPUT OPTIMIZATION === */
    .chat-input-area {
        padding: 8px 10px;
        border-top: 1px solid var(--acrylic-border);
    }
    .chat-input-wrapper {
        padding: 7px 10px;
        gap: 8px;
    }
    #chat-input {
        font-size: 16px;
    }
    .input-prompt {
        font-size: 16px;
    }
    #chat-input::placeholder {
        font-size: 14px;
    }
    .chat-input-hint {
        display: none;
    }

    /* === KATEX MATH MOBILE SIZING === */
    .katex {
        font-size: 1.15em !important;
    }
    .katex-display {
        margin: 0.6em 0;
        padding: 0.5em 0.6em;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .katex-display > .katex {
        font-size: 1em !important;
    }
    .message-bubble .katex {
        font-size: 1.15em !important;
    }
    .katex-display::-webkit-scrollbar {
        height: 4px;
    }

    /* === LOADING SCREEN === */
    .loading-content {
        width: min(340px, 88vw);
        padding: 22px 18px;
    }
    .loading-label {
        font-size: 10px;
        letter-spacing: 3px;
    }

    /* === ATMOSPHERE: Reduce overhead === */
    #vignette {
        opacity: 0.75;
    }
    #grain-overlay {
        opacity: 0.02;
    }

    /* === iOS SAFE AREA: Bottom-anchored toasts on notched phones === */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        #toast-container {
            top: auto;
            bottom: max(80px, calc(env(safe-area-inset-bottom) + 64px));
            right: max(10px, env(safe-area-inset-right));
        }
    }

    /* Show mobile-only elements */
    .mobile-tab-bar { display: flex; }
    .btn-settings-gear { display: flex !important; }

    /* Hide desktop-only elements */
    .deck-hint { display: none; }
}

/* ============================================================
   EXTRA-SMALL PHONES (iPhone SE, sub-380px)
   ============================================================ */
@media (max-width: 380px) {
    #app-container {
        gap: 2px;
    }
    .chat-messages {
        padding: 6px;
        gap: 4px;
    }
    .message {
        max-width: 98%;
    }
    .message-bubble {
        font-size: 13px;
        padding: 8px 10px;
    }
    #character-cards {
        gap: 6px;
        padding: 8px;
    }
    .character-card-inner {
        padding: 6px;
    }
    .character-card-name {
        font-size: 12px;
    }
    .chat-character-name {
        font-size: 14px;
    }
    .chat-character-role {
        font-size: 7px;
        max-width: 45vw;
    }
    #chat-input {
        font-size: 14px;
    }
    .btn-ghost {
        padding: 6px 8px;
        font-size: 8px;
    }
    .toast {
        font-size: 9px;
        padding: 8px 10px;
        max-width: min(280px, calc(100vw - 32px));
    }
    .katex-display {
        padding: 0.4em 0.5em;
    }
    #settings-panel {
        max-height: 80vh;
    }
}

/* Hide mobile character switcher on desktop by default */
#mobile-char-switcher {
    display: none;
}

/* Settings toggle button - hidden on desktop, shown on mobile */
.settings-toggle-btn {
    display: none;
}

/* Settings gear button in chat header - hidden on desktop */
/* Mobile character dropdown in chat header */
.mobile-char-select {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 1px;
    padding: 5px 24px 5px 10px;
    clip-path: var(--input-clip);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a7355'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all var(--transition-fast);
    max-width: 140px;
}
.mobile-char-select:hover,
.mobile-char-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
}
.mobile-char-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    #scanlines {
        animation: none;
        opacity: 0.02;
    }
    #left-panel,
    #middle-panel,
    #right-panel {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .loading-label {
        animation: none;
    }
    .hud-reticle {
        animation: none;
    }
    .hud-reticle::before,
    .hud-reticle::after {
        animation: none;
    }
    #live2d-status::before {
        animation: none;
    }
    .music-waveform span {
        animation: none;
    }
    .message.character .message-bubble::after {
        animation: none;
    }
    .character-card.active {
        animation: none;
    }
    .character-card.active::before {
        animation: none;
    }
    .typing-dot {
        animation: none;
    }
    .toast {
        animation: none;
    }
}

/* ============================================================
   KATEX MATH RENDERING — Terminal Dark Theme Overrides
   ============================================================ */

/* --- Inline math --- */
.katex {
    font-size: 1.05em !important;
    color: var(--text-primary);
}

/* --- Block / display math --- */
.katex-display {
    margin: 1em 0;
    padding: 0.8em 1em;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(0, 0, 0, 0.25);
    clip-path: polygon(
        0 0,
        calc(100% - 8px) 0,
        100% 8px,
        100% 100%,
        8px 100%,
        0 calc(100% - 8px)
    );
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-blue-dim);
    border-radius: 2px;
}

.katex-display > .katex {
    font-size: 1.1em !important;
    text-align: center;
    white-space: normal;
}

/* --- Scrollbar for wide formulas --- */
.katex-display::-webkit-scrollbar {
    height: 3px;
}
.katex-display::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

/* --- Error fallback --- */
.katex-error {
    color: var(--danger-bright);
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: rgba(139, 69, 69, 0.1);
    padding: 2px 5px;
    border-radius: 2px;
    border: 1px dashed var(--danger);
}

/* --- Color overrides for dark theme --- */
.message-bubble .katex {
    color: var(--text-primary);
}

/* Make Greek letters, operators more visible */
.message-bubble .katex .mathnormal,
.message-bubble .katex .mord {
    color: inherit;
}

/* Fraction lines and brackets in gold tint */
.message-bubble .katex .mfrac {
    color: var(--text-primary);
}

/* Operators (∑, ∫, etc.) */
.message-bubble .katex .mop {
    color: var(--gold);
}

/* Relations (=, ≤, ≥, ≈, etc.) */
.message-bubble .katex .mrel {
    color: var(--accent-blue);
}

/* Binaries (+, -, ×, ÷, etc.) */
.message-bubble .katex .mbin {
    color: var(--accent-blue-dim);
}

/* Unary operators */
.message-bubble .katex .mord.mtight {
    color: var(--text-primary);
}

/* Text inside math */
.message-bubble .katex .mord.text {
    color: var(--text-primary);
}

/* Delimiters (brackets, braces, etc.) */
.message-bubble .katex .mopen,
.message-bubble .katex .mclose {
    color: var(--text-primary);
}

/* Punctuation */
.message-bubble .katex .mpunct {
    color: var(--text-secondary);
}

/* Superscript / subscript numbers */
.message-bubble .katex .msupsub {
    color: var(--text-primary);
}

/* Overline / underline (vectors, averages) */
.message-bubble .katex .mover,
.message-bubble .katex .munder {
    color: var(--text-primary);
}

/* Physics notation: arrows, hats, dots over vars */
.message-bubble .katex .accent {
    color: var(--text-primary);
}

/* Special characters like ∞, ∂, ∇ */
.message-bubble .katex .mord.amsrm {
    color: var(--text-primary);
}

/* ============================================================
   ATTACHMENT UPLOAD UI
   ============================================================ */
.btn-attach {
    background: none;
    border: 1px solid var(--acrylic-border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-attach:hover {
    color: var(--gold-bright);
    border-color: var(--gold-dim);
    background: var(--gold-glow);
}

.attachment-preview {
    margin-bottom: 8px;
    padding: 8px;
    background: var(--bg-input);
    border: 1px solid var(--acrylic-border);
    border-radius: 4px;
}

.image-preview-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.attach-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--acrylic-border);
}

.attach-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-remove-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: #ff6b6b;
    border: none;
    cursor: pointer;
    font-size: 14px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 4px 0 4px;
    line-height: 1;
    padding: 0;
}

.attach-remove-btn:hover {
    background: rgba(255, 0, 0, 0.7);
    color: #fff;
}

.file-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.attach-file-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--acrylic-border);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    position: relative;
}

.attach-file-icon {
    font-size: 14px;
}

.attach-file-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Image/File display in messages ── */
.msg-image-gallery {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.msg-image-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--acrylic-border);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.msg-image-thumb:hover {
    transform: scale(1.05);
    border-color: var(--gold-dim);
}

.msg-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.msg-file-tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    background: var(--bg-card);
    border: 1px solid var(--acrylic-border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ============================================================
   CODE BLOCK & SCIENCE FORMULA
   ============================================================ */
.code-block, .science-block {
    margin: 8px 0;
    border: 1px solid var(--acrylic-border);
    border-radius: 6px;
    overflow: hidden;
    background: #1E1E1E;
    font-family: var(--font-mono);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: #2D2D2D;
    border-bottom: 1px solid #3E3E3E;
}

.code-lang-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: #808080;
    text-transform: uppercase;
}

.code-block-actions {
    display: flex;
    gap: 4px;
}

.code-btn {
    background: none;
    border: 1px solid transparent;
    color: #808080;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.15s ease;
    line-height: 1;
}

.code-btn:hover {
    background: #3E3E3E;
    color: #CCCCCC;
    border-color: #555;
}

.code-btn-copy {
    font-size: 12px;
}

.code-block-body, .science-block-body {
    overflow-x: auto;
    max-height: 360px;
    overflow-y: auto;
}

.code-block-body pre, .science-block-body pre {
    margin: 0;
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.65;
    color: var(--text-primary);
    white-space: pre;
    tab-size: 4;
}

.code-line {
    display: block;
    min-height: 1.4em;
}

/* Folded state */
.code-block[data-folded="true"] .code-block-body {
    display: none;
}

.code-block[data-folded="true"] .code-btn-fold {
    color: var(--gold);
}

/* Science formula special styles */
.science-block {
    background: #1a1a2e;
    border-color: rgba(91, 140, 189, 0.3);
}

.science-block .code-block-header {
    background: #1e1e35;
    border-bottom-color: rgba(91, 140, 189, 0.2);
}

.science-block .code-lang-label {
    color: var(--accent-blue);
}

.science-sub { font-size: 0.78em; vertical-align: sub; }
.science-sup { font-size: 0.78em; vertical-align: super; }

.science-block-body pre {
    font-size: 13px;
    line-height: 1.8;
}

.science-line {
    display: block;
    min-height: 1.4em;
}

/* Message text wrapper */
.msg-text {
    /* allow inline content to flow naturally */
}

/* ============================================================
   自定义角色导入（CUSTOM CHARACTER IMPORT）
   ============================================================ */

/* 选择区标题行 + 导入按钮 */
.panel-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.panel-label-row .panel-label { margin-bottom: 0; }
/* ═══════════════════════════════════════════════════════════
   IMPORT BUTTON (panel header)
   ═══════════════════════════════════════════════════════════ */
.btn-import-char {
    background: rgba(201, 168, 124, 0.08);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 4px 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 1px;
    white-space: nowrap;
    cursor: pointer;
    clip-path: var(--input-clip);
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-import-char:hover {
    background: var(--gold-glow);
    border-color: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════
   IMPORT OVERLAY · Arknights Terminal Redesign
   ═══════════════════════════════════════════════════════════ */
#import-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out-expo);
}
#import-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.import-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* ── Panel shell ── */
.import-panel {
    position: relative;
    width: min(960px, 96vw);
    max-height: 90vh;
    background: linear-gradient(180deg,
        #12121c 0%,
        #0e0e18 40%,
        #0a0a12 100%
    );
    border: 1px solid var(--gold-dim);
    clip-path: var(--panel-clip);
    display: flex;
    flex-direction: column;
    box-shadow:
        0 0 80px rgba(0, 0, 0, 0.7),
        0 0 30px var(--gold-glow),
        inset 0 1px 0 rgba(201, 168, 124, 0.04);
    animation: imp-panel-in 0.4s var(--ease-out-expo);
}
@keyframes imp-panel-in {
    0%   { opacity: 0; transform: scale(1.04) translateY(-8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Top accent line ── */
.import-top-accent {
    position: absolute;
    top: 0; left: 20px; right: 20px;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(201, 168, 124, 0.25) 15%,
        var(--gold) 50%,
        rgba(201, 168, 124, 0.25) 85%,
        transparent 100%
    );
    z-index: 1;
    pointer-events: none;
}

/* ── Header ── */
.import-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 24px 12px;
    flex-shrink: 0;
}
.import-header-deco {
    position: absolute;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ihd-l, .ihd-r {
    width: 16px;
    height: 1px;
    background: var(--gold-dim);
}
.ihd-dot {
    width: 4px; height: 4px;
    background: var(--gold);
    transform: rotate(45deg);
}
.import-header-label {
    font-family: 'Bender', 'JetBrains Mono', monospace;
    font-size: 14px;
    letter-spacing: 3px;
    color: var(--gold-bright);
    text-shadow: 0 0 12px var(--gold-glow);
    text-align: center;
}
.import-close-btn {
    position: absolute;
    right: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    color: var(--gold-dim);
    cursor: pointer;
    padding: 6px;
    display: grid;
    place-items: center;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.import-close-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--gold-dim);
}

/* ── Body · Two-column layout ── */
.import-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    padding: 6px 24px 18px;
    overflow-y: auto;
    flex: 1;
    scroll-behavior: smooth;
}
.import-body::-webkit-scrollbar { width: 4px; }
.import-body::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }
.import-body::-webkit-scrollbar-track { background: transparent; }

/* ── Form column ── */
.import-form-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── Fieldset sections ── */
.imp-section {
    border: 1px solid rgba(201, 168, 124, 0.08);
    padding: 14px 16px 8px;
    margin: 0;
    background: rgba(201, 168, 124, 0.015);
    clip-path: polygon(
        0 10px, 10px 0,
        calc(100% - 10px) 0, 100% 10px,
        100% calc(100% - 10px), calc(100% - 10px) 100%,
        10px 100%, 0 calc(100% - 10px)
    );
}
.imp-section + .imp-section { margin-top: 8px; }

.imp-section-legend {
    font-family: 'Bender', 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--gold);
    text-transform: uppercase;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.isl-icon {
    font-size: 8px;
    color: var(--gold-dim);
    display: inline-block;
    transform: rotate(45deg);
}

/* ── Fields ── */
.import-field { margin-bottom: 10px; }
.import-field > label,
.import-asset > label {
    display: block;
    font-family: 'Bender', 'JetBrains Mono', 'Noto Sans SC', monospace;
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 5px;
}
.import-field .req { color: var(--danger-bright); font-weight: bold; }
.import-field .label-hint,
.import-asset .label-hint {
    text-transform: none;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    font-size: 9px;
    margin-left: 2px;
}
.import-row {
    display: flex;
    gap: 10px;
}
.import-row .import-field { flex: 1; min-width: 0; }

/* Inputs */
.import-field input[type="text"],
.import-asset input[type="text"],
.import-field textarea {
    width: 100%;
    background: rgba(10, 10, 18, 0.7);
    border: 1px solid rgba(201, 168, 124, 0.12);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Noto Sans SC', monospace;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 2px;
    box-sizing: border-box;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    clip-path: var(--input-clip);
}
.import-field input[type="text"]:focus,
.import-asset input[type="text"]:focus,
.import-field textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold-glow), 0 0 10px var(--gold-glow);
    background: rgba(10, 10, 18, 0.9);
}
.import-field textarea {
    resize: vertical;
    line-height: 1.6;
    min-height: 100px;
}

/* ── Upload zones ── */
.imp-upload-zone {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(201, 168, 124, 0.04);
    border: 1px dashed rgba(201, 168, 124, 0.2);
    border-radius: 2px;
    color: var(--gold-dim);
    font-family: 'Bender', 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    clip-path: var(--input-clip);
}
.imp-upload-zone:hover {
    background: rgba(201, 168, 124, 0.08);
    border-color: var(--gold-dim);
    color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}
.imp-upload-zone svg { flex-shrink: 0; }

/* Hide the native file input — label controls it */
.import-asset-controls input[type="file"] {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.import-asset-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.import-asset-controls input[type="text"] { flex: 1 1 160px; }
.import-or {
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 1px;
    flex-shrink: 0;
}

/* ── Preview images ── */
.import-preview {
    display: block;
    max-width: 100%;
    max-height: 130px;
    margin-top: 8px;
    border: 1px solid rgba(201, 168, 124, 0.12);
    border-radius: 2px;
    object-fit: contain;
    background: #08080f;
    clip-path: var(--input-clip);
}
.import-audio-preview {
    display: block;
    width: 100%;
    margin-top: 8px;
    height: 36px;
    filter: grayscale(0.3);
}

/* ── Copy field row ── */
.import-with-copy {
    display: flex;
    align-items: stretch;
    gap: 6px;
}
.import-with-copy textarea,
.import-with-copy input { flex: 1; min-width: 0; }
.btn-copy {
    flex: 0 0 auto;
    background: rgba(201, 168, 124, 0.04);
    border: 1px solid rgba(201, 168, 124, 0.15);
    color: var(--gold-dim);
    padding: 0 10px;
    cursor: pointer;
    clip-path: var(--input-clip);
    transition: all var(--transition-fast);
    display: grid;
    place-items: center;
}
.btn-copy:hover {
    background: var(--gold-glow);
    border-color: var(--gold);
    color: var(--gold-bright);
    box-shadow: 0 0 8px var(--gold-glow);
}

/* ═══ PREVIEW CARD COLUMN ═══ */
.import-preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 4px;
}
.imp-preview-label {
    font-family: 'Bender', 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 3px;
    color: var(--text-dim);
    width: 100%;
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(201, 168, 124, 0.08);
}
.imp-preview-hint {
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    letter-spacing: 0.5px;
    line-height: 1.5;
    max-width: 200px;
}

/* ── Preview card ── */
.imp-preview-card {
    position: relative;
    width: 220px;
    background: linear-gradient(180deg,
        #151520 0%,
        #0e0e18 50%,
        #08080f 100%
    );
    border: 1px solid rgba(201, 168, 124, 0.2);
    clip-path: polygon(
        0 14px, 14px 0,
        calc(100% - 14px) 0, 100% 14px,
        100% calc(100% - 14px), calc(100% - 14px) 100%,
        14px 100%, 0 calc(100% - 14px)
    );
    overflow: hidden;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.5),
        0 0 12px var(--gold-glow);
    transition: box-shadow var(--transition-normal);
}
.imp-preview-card:hover {
    box-shadow:
        0 6px 32px rgba(0, 0, 0, 0.6),
        0 0 20px var(--gold-glow);
}

/* Frame corners */
.imp-card-frame { pointer-events: none; }
.icf-corner {
    position: absolute;
    width: 20px; height: 20px;
    z-index: 2;
    pointer-events: none;
}
.icf-tl { top: 3px; left: 3px;
    border-top: 1px solid var(--gold-dim); border-left: 1px solid var(--gold-dim); }
.icf-tr { top: 3px; right: 3px;
    border-top: 1px solid var(--gold-dim); border-right: 1px solid var(--gold-dim); }
.icf-bl { bottom: 3px; left: 3px;
    border-bottom: 1px solid var(--gold-dim); border-left: 1px solid var(--gold-dim); }
.icf-br { bottom: 3px; right: 3px;
    border-bottom: 1px solid var(--gold-dim); border-right: 1px solid var(--gold-dim); }

/* Card image area */
.imp-card-img-wrap {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #08080f;
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
}
.imp-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.imp-card-img-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 1px;
}
.imp-card-img-placeholder svg { opacity: 0.2; }

/* Card info */
.imp-card-info {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.imp-card-name {
    font-family: 'Bender', 'JetBrains Mono', 'Noto Sans SC', monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
    line-height: 1.3;
}
.imp-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
}
.icm-sep { color: var(--gold-dim); font-size: 8px; }
.imp-card-role {
    font-family: 'Bender', 'JetBrains Mono', 'Noto Sans SC', monospace;
    font-size: 11px;
    color: var(--gold);
    letter-spacing: 1px;
    margin-top: 2px;
}
.imp-card-idline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(201, 168, 124, 0.08);
}
.icil-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 7px;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-transform: uppercase;
}
.icil-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--gold-dim);
}

/* ═══ FOOTER ═══ */
.import-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid rgba(201, 168, 124, 0.1);
    flex-shrink: 0;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.15);
}
.import-footer .btn-save {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
    padding: 9px 20px;
    font-size: 11px;
    letter-spacing: 1.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.import-footer .btn-ghost { margin-top: 0; }
.btn-del-import {
    margin-left: auto;
    border-color: rgba(181, 90, 90, 0.3) !important;
    color: var(--danger-bright) !important;
}
.btn-del-import:hover {
    background: rgba(139, 69, 69, 0.15) !important;
    border-color: var(--danger-bright) !important;
}

/* 自定义角色卡片标识 + 编辑/删除按钮 */
.character-card.custom {
    position: relative;
}
.custom-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 3;
    background: var(--gold-dim);
    color: #1a1a24;
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 1px;
    padding: 1px 5px;
    border-radius: 2px;
    pointer-events: none;
}
.card-edit-btn,
.card-del-btn {
    position: absolute;
    top: 4px;
    z-index: 3;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gold-dim);
    background: rgba(14, 14, 22, 0.85);
    color: var(--gold);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    border-radius: 3px;
    opacity: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}
.card-edit-btn { right: 36px; }
.card-del-btn { right: 4px; color: var(--danger-bright); border-color: var(--danger); }
.character-card.custom:hover .card-edit-btn,
.character-card.custom:hover .card-del-btn,
.character-card.custom:focus-within .card-edit-btn,
.character-card.custom:focus-within .card-del-btn {
    opacity: 1;
}
.card-edit-btn:hover { background: var(--gold-glow); color: var(--gold-bright); }
.card-del-btn:hover { background: rgba(139, 69, 69, 0.2); color: #fff; }

/* 移动端：按钮常驻可见，避免无 hover */
@media (max-width: 768px) {
    .card-edit-btn,
    .card-del-btn {
        opacity: 1;
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    .import-row { flex-direction: column; gap: 0; }

    /* Import panel → single-column on mobile */
    .import-panel {
        width: 100vw;
        max-height: 100vh;
        clip-path: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .import-body {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 6px 14px 14px;
    }
    .import-preview-col {
        display: none;  /* 移动端隐藏预览列，节省空间 */
    }
    .import-header { padding: 14px 14px 8px; }
    .import-header-label { font-size: 11px; letter-spacing: 2px; }
    .import-header-deco { left: 10px; }
    .import-close-btn { right: 10px; }
    .import-footer { padding: 10px 14px; gap: 6px; }
    .import-footer .btn-save { padding: 8px 14px; font-size: 10px; }
    .imp-section { padding: 10px 10px 4px; }
    .imp-preview-card { width: 100%; }
}

/* ============================================================
   HIGH CONTRAST / ACCESSIBILITY
   ============================================================ */
@media (prefers-contrast: more) {
    :root {
        --acrylic-border: rgba(201, 168, 124, 0.45);
        --border-light: #555566;
    }
    .message-bubble {
        border-width: 2px;
    }
}
