* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: "Inter", "PingFang SC", "Microsoft YaHei UI", "Hiragino Sans GB", "Segoe UI", "Helvetica Neue", sans-serif;
    transition: 0.2s;
}

button, .header, .input-area, .settings-panel, .diary-panel, .welcome, .loading-overlay {
    user-select: none;
}

:root {
    --bg: #e1e9f1;
    --text: #111b2d;
    --dim: #667a94;
    --text-muted: #5a6d82;
    --text-accent: #4a6fa5;
    --border-dark: #92a8c1;
    --border-light: #fefeff;
    --accent: #4a6fa5;
    --accent-light: #6b8fc5;
    --gold: #c9a44b;
    --surface: #eef2f7;
    --radius: 28px;
    --radius-sm: 16px;
    --font-display: "Noto Serif SC", "STSong", "SimSun", "Songti SC", serif;
    --font-body: "Inter", "PingFang SC", "Microsoft YaHei UI", "Hiragino Sans GB", sans-serif;
}

body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    background:
        linear-gradient(rgba(225,233,241,0.85), rgba(225,233,241,0.85)),
        url('../back.png') center/contain no-repeat fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

#app {
    width: 100%;
    max-width: 820px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 12px;
    overflow: hidden;
}

.header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 14px 4px 6px;
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-icon { width: 26px; height: 26px; }
.header-brand { font-family: var(--font-display); font-size: 24px; font-weight: 300; color: var(--text); letter-spacing: 8px; }
.header-right { display: flex; align-items: center; gap: 4px; }

.btn-icon {
    width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: none; color: var(--dim);
    box-shadow: 0 1px 2px transparent, 0 -1px 2px transparent, inset 0 1px 1px transparent;
    position: relative;
}
.btn-icon:hover { color: var(--text); box-shadow: 0 2px 4px #8899ac, 0 -2px 4px #f9fdff, inset 0 2px 2px #8899ac, inset 0 2px 2px #f9fdff; }
.btn-icon:active { transform: scale(0.93); }
.btn-icon svg { width: 18px; height: 18px; }

.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.welcome { display: flex; flex-direction: column; align-items: center; padding-top: 60px; text-align: center; }
.welcome-greeting { font-family: var(--font-body); font-size: 13px; font-weight: 300; color: var(--dim); letter-spacing: 5px; text-transform: uppercase; margin-bottom: 16px; }
.welcome-title { font-family: "Playfair Display", "Georgia", serif; font-style: italic; font-size: 40px; font-weight: 400; color: var(--text); letter-spacing: 1px; margin-bottom: 24px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.welcome-sub { font-family: var(--font-display); font-size: 15px; font-weight: 300; color: var(--dim); letter-spacing: 2px; margin-bottom: 90px; line-height: 1.6; }

.world-carousel { display: flex; flex-direction: column; align-items: center; margin-bottom: 20px; }
.world-chips { display: none; }
.world-window { width: 220px; height: 50px; border-radius: 18px; padding: 4px; background: linear-gradient(to bottom, var(--border-dark), var(--border-light)); cursor: pointer; position: relative; overflow: hidden; user-select: none; -webkit-tap-highlight-color: transparent; box-shadow: 0 2px 4px rgba(136,153,172,0.2), inset 0 0 0 1px rgba(255,255,255,0.3); transition: box-shadow 0.2s; }
.world-window:hover { box-shadow: 0 3px 8px rgba(136,153,172,0.3), inset 0 0 0 1px rgba(255,255,255,0.4); }
.world-window:active .world-window-inner { transform: scale(0.96); }
.world-window-inner { width: 100%; height: 100%; border-radius: 14px; background: linear-gradient(to bottom, #f9fcfd, #eef2f7); box-shadow: inset 0 0 8px rgba(2,33,67,0.06), inset 0 -3px 3px rgba(255,255,255,0.5), inset 0 2px 2px rgba(154,169,184,0.2); display: flex; align-items: center; justify-content: center; transition: transform 0.15s; }
.world-window-inner.slide-up { animation: windowSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.world-window-inner.slide-down { animation: windowSlideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes windowSlideUp { 0% { transform: translateY(0); opacity: 1; } 49% { transform: translateY(-50%); opacity: 0; } 50% { transform: translateY(50%); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes windowSlideDown { 0% { transform: translateY(0); opacity: 1; } 49% { transform: translateY(50%); opacity: 0; } 50% { transform: translateY(-50%); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
.world-window-name { font-family: var(--font-display); font-size: 17px; font-weight: 300; letter-spacing: 4px; color: var(--text); }

.welcome-or { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; width: 100%; max-width: 460px; }
.or-line { flex: 1; height: 1px; background: var(--border-dark); }
.or-text { font-size: 12px; color: var(--dim); }
.custom-world-row { display: flex; gap: 10px; width: 100%; max-width: 460px; align-items: center; }
.custom-world-outer { flex: 1; padding: 4px; border-radius: 999px; background: linear-gradient(to bottom, var(--border-dark), var(--border-light)); transition: background 0.25s; }
.custom-world-outer:focus-within { background: linear-gradient(to bottom, var(--accent), var(--accent-light)); }
.custom-world-input { width: 100%; padding: 12px 20px; border-radius: 999px; border: none; outline: none; font-size: 15px; color: var(--text); background: linear-gradient(to bottom, #f9fcfd, #eef2f7); box-shadow: inset 0 0 10px rgba(2,33,67,0.08), inset 0 -5px 4px rgba(255,255,255,0.55), inset 0 3px 3px rgba(154,169,184,0.25); transition: box-shadow 0.25s; }
.custom-world-outer:focus-within .custom-world-input { box-shadow: inset 0 0 10px rgba(2,33,67,0.12), inset 0 -5px 4px rgba(255,255,255,0.45), inset 0 4px 3px rgba(35,82,133,0.2); }
.custom-world-input::placeholder { color: #8899ac; font-size: 14px; letter-spacing: 0.5px; }

.btn-start { width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 4px; background: linear-gradient(to bottom, var(--border-dark), var(--border-light)); color: var(--text); box-shadow: none; position: relative; transition: transform 0.2s, box-shadow 0.2s; }
.btn-start::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: linear-gradient(to bottom, #f9fcfd, #adc1d3); box-shadow: inset 0 0 6px rgba(2,33,67,0.15), inset 0 -4px 3px rgba(255,255,255,0.5), inset 0 3px 2px rgba(35,82,133,0.2); transition: box-shadow 0.2s; }
.btn-start svg { position: relative; z-index: 1; color: var(--accent); transition: color 0.2s, transform 0.2s; }
.btn-start:hover::before { box-shadow: inset 0 0 8px rgba(2,33,67,0.2), inset 0 -5px 3px rgba(255,255,255,0.45), inset 0 4px 3px rgba(35,82,133,0.25); }
.btn-start:hover svg { color: #2c5282; transform: scale(1.1); }
.btn-start:active { transform: scale(0.93); }
.btn-start:active::before { box-shadow: inset 0 0 8px rgba(2,33,67,0.3), inset 0 -3px 2px rgba(255,255,255,0.3), inset 0 5px 4px rgba(35,82,133,0.4); }

.chat-area { flex: 1; overflow-y: auto; padding: 8px 4px 16px; display: flex; flex-direction: column; }
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
.chat-area::-webkit-scrollbar-thumb { background: rgba(146,168,193,0.45); border-radius: 999px; border: 1px solid rgba(255,255,255,0.3); }
.chat-area::-webkit-scrollbar-thumb:hover { background: rgba(146,168,193,0.7); }
.chat-area { scrollbar-width: thin; scrollbar-color: rgba(146,168,193,0.45) transparent; }
.chat-messages { display: flex; flex-direction: column; gap: 20px; padding-bottom: 8px; }
.msg-bubble { max-width: 82%; animation: fadeUp 0.4s ease; }

.msg-bubble.narrator { align-self: flex-start; padding: 16px 22px; border-radius: var(--radius) var(--radius) var(--radius) 4px; background: linear-gradient(180deg, var(--surface), #e1e9f1); box-shadow: 0 2px 8px rgba(136,153,172,0.2), inset 0 1px 1px rgba(255,255,255,0.6); font-size: 15px; font-weight: 400; line-height: 2; letter-spacing: 0.5px; color: var(--text); }

.msg-bubble.player { align-self: flex-end; padding: 10px 18px; border-radius: var(--radius) var(--radius) 4px var(--radius); background: linear-gradient(180deg, #dce7f5, #c5d5e8); box-shadow: 0 2px 6px rgba(74,111,165,0.15); font-size: 14px; font-weight: 400; line-height: 1.7; letter-spacing: 0.3px; color: var(--text); }
.msg-bubble.player::before { content: "你说："; font-size: 11px; color: var(--accent); display: block; margin-bottom: 2px; font-weight: 600; }

.msg-bubble.ending { align-self: center; text-align: center; padding: 24px 28px; border-radius: var(--radius); background: linear-gradient(180deg, #fdf8ed, #f0e4c8); box-shadow: 0 4px 16px rgba(201,164,75,0.2); }
.ending-title { font-family: var(--font-display); font-size: 32px; font-weight: 300; color: var(--text); letter-spacing: 5px; margin-bottom: 20px; }
.ending-emotion { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.emo-bar { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; color: var(--dim); }
.emo-track { width: 48px; height: 5px; border-radius: 999px; background: #dce4ed; overflow: hidden; }
.emo-fill { height: 100%; border-radius: 999px; transition: width 0.6s ease; }
.ending-desc { font-size: 15px; line-height: 2; color: var(--text); margin-bottom: 16px; }
.btn-restart { padding: 10px 28px; border-radius: 999px; border: none; cursor: pointer; font-size: 14px; font-weight: 600; color: #fff; background: linear-gradient(135deg, var(--accent-light), var(--accent)); box-shadow: 0 4px 12px rgba(74,111,165,0.35); }
.btn-restart:hover { box-shadow: 0 6px 18px rgba(74,111,165,0.45); transform: translateY(-1px); }
.btn-restart:active { transform: scale(0.97); }

.input-area { padding: 0 0 28px; flex-shrink: 0; }
.chat-box-outer { width: 100%; padding: 4px; background: linear-gradient(to bottom, var(--border-dark), var(--border-light)); border-radius: 35px; }
.chat-box-inner { width: 100%; display: flex; flex-direction: column; padding: 14px 22px 12px 22px; border-radius: 32px; box-shadow: inset 0 0 12px #022143, inset 0 -7px 4px rgba(255,255,255,0.6), inset 0 4px 3px rgba(154,169,184,0.6); background: var(--bg); }
.chat-input { width: 100%; padding: 4px 6px; outline: none; border: none; background: none; font-size: 16px; color: var(--text); }
.chat-input::placeholder { color: #8899ac; font-size: 15px; }
.chat-input:disabled { opacity: 0.5; }
.chat-row { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.chat-left { display: flex; align-items: center; gap: 8px; }
.world-badge, .layer-badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 500; color: var(--accent); background: rgba(74,111,165,0.08); }
.world-badge:empty, .layer-badge:empty { display: none; }
.chat-right { display: flex; align-items: center; }

.send-btn { width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 4px; background: linear-gradient(to bottom, var(--border-dark), var(--border-light)); position: relative; transition: transform 0.2s, box-shadow 0.2s; }
.send-btn::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: linear-gradient(to bottom, #f9fcfd, #adc1d3); box-shadow: inset 0 0 4px rgba(2,33,67,0.12), inset 0 -3px 2px rgba(255,255,255,0.5), inset 0 2px 1px rgba(35,82,133,0.15); transition: box-shadow 0.2s; }
.send-btn svg { position: relative; z-index: 1; width: 16px; height: 16px; color: var(--accent); transition: color 0.2s, transform 0.2s; }
.send-btn:hover:not(:disabled)::before { box-shadow: inset 0 0 6px rgba(2,33,67,0.18), inset 0 -4px 3px rgba(255,255,255,0.45), inset 0 3px 2px rgba(35,82,133,0.22); }
.send-btn:hover:not(:disabled) svg { color: #2c5282; transform: scale(1.1); }
.send-btn:active:not(:disabled) { transform: scale(0.9); }
.send-btn:active:not(:disabled)::before { box-shadow: inset 0 0 6px rgba(2,33,67,0.28), inset 0 -2px 2px rgba(255,255,255,0.3), inset 0 4px 3px rgba(35,82,133,0.35); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.settings-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3); backdrop-filter: blur(2px); z-index: 200; display: flex; justify-content: center; align-items: center; animation: fadeIn 0.2s ease; }
.settings-panel { width: 420px; max-width: 92vw; padding: 0; border-radius: var(--radius); background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.10'/%3E%3C/svg%3E"), rgba(238,242,247,0.72); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 16px 40px rgba(2,33,67,0.18), 0 0 0 1px rgba(146,168,193,0.25), inset 0 0 0 1px rgba(255,255,255,0.4); animation: scaleIn 0.25s ease; }
.settings-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid rgba(146,168,193,0.2); font-size: 16px; font-weight: 700; color: var(--text); }
.settings-close { width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer; font-size: 20px; color: var(--dim); background: linear-gradient(to bottom, var(--border-light), #d5dde8); box-shadow: 0 1px 2px rgba(136,153,172,0.15), inset 0 1px 1px rgba(255,255,255,0.5); display: flex; align-items: center; justify-content: center; transition: box-shadow 0.2s, color 0.2s, transform 0.15s; }
.settings-close:hover { box-shadow: 0 2px 4px #8899ac, 0 -1px 2px #f9fdff, inset 0 1px 1px rgba(255,255,255,0.5); color: var(--text); }
.settings-close:active { transform: scale(0.9); }
.settings-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.settings-row { display: flex; flex-direction: column; gap: 6px; }
.settings-label { font-size: 13px; font-weight: 600; color: var(--text); }
.settings-input { width: 100%; padding: 10px 16px; border-radius: 999px; border: none; outline: none; font-size: 14px; color: var(--text); background: linear-gradient(to bottom, #f9fcfd, #eef2f7); box-shadow: inset 0 0 8px rgba(2,33,67,0.06), inset 0 -3px 3px rgba(255,255,255,0.5), inset 0 2px 2px rgba(154,169,184,0.2); transition: box-shadow 0.2s; }
.settings-input:focus { box-shadow: inset 0 0 8px rgba(2,33,67,0.1), inset 0 -3px 3px rgba(255,255,255,0.4), inset 0 3px 2px rgba(35,82,133,0.15); }
.apikey-group { display: flex; gap: 6px; }
.apikey-group .settings-input { flex: 1; }
.apikey-toggle { width: 42px; border-radius: 999px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: linear-gradient(to bottom, var(--border-light), #d5dde8); box-shadow: 0 1px 2px rgba(136,153,172,0.2), inset 0 1px 1px rgba(255,255,255,0.5); color: var(--dim); transition: box-shadow 0.2s, color 0.2s, transform 0.15s; }
.apikey-toggle:hover { box-shadow: 0 2px 4px #8899ac, 0 -1px 2px #f9fdff, inset 0 1px 1px rgba(255,255,255,0.5); color: var(--text); }
.apikey-toggle:active { transform: scale(0.93); }
.provider-list { display: flex; flex-wrap: wrap; gap: 6px; }
.provider-chip { padding: 7px 16px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); border: none; background: linear-gradient(to bottom, var(--border-light), #d5dde8); box-shadow: 0 1px 2px rgba(136,153,172,0.15), inset 0 1px 1px rgba(255,255,255,0.5); transition: box-shadow 0.2s, background 0.2s, transform 0.15s; }
.provider-chip:hover { box-shadow: 0 2px 4px #8899ac, 0 -1px 2px #f9fdff, inset 0 1px 1px rgba(255,255,255,0.5); transform: translateY(-1px); }
.provider-chip:active { transform: scale(0.95) translateY(0); }
.provider-chip.selected { background: linear-gradient(to bottom, #e3ecf7, #c5d5e8); box-shadow: 0 2px 4px rgba(74,111,165,0.2), inset 0 1px 1px rgba(255,255,255,0.5); color: var(--accent); font-weight: 600; }
.settings-actions { display: flex; gap: 8px; margin-top: 4px; }
.btn-save { flex: 1; padding: 10px 0; border-radius: 999px; border: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); position: relative; background: linear-gradient(to bottom, var(--border-dark), var(--border-light)); transition: transform 0.15s; }
.btn-save::before { content: ''; position: absolute; inset: 3px; border-radius: 999px; background: linear-gradient(to bottom, #e3ecf7, #c5d5e8); box-shadow: inset 0 0 6px rgba(2,33,67,0.1), inset 0 -3px 2px rgba(255,255,255,0.5), inset 0 2px 1px rgba(35,82,133,0.15); transition: box-shadow 0.2s; }
.btn-save span { position: relative; z-index: 1; }
.btn-save:hover::before { box-shadow: inset 0 0 8px rgba(2,33,67,0.15), inset 0 -4px 3px rgba(255,255,255,0.45), inset 0 3px 2px rgba(35,82,133,0.2); }
.btn-save:active { transform: scale(0.96); }
.btn-save:active::before { box-shadow: inset 0 0 8px rgba(2,33,67,0.25), inset 0 -2px 2px rgba(255,255,255,0.25), inset 0 4px 3px rgba(35,82,133,0.35); }
.btn-test { padding: 10px 20px; border-radius: 999px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); background: linear-gradient(to bottom, var(--border-light), #d5dde8); box-shadow: 0 1px 2px rgba(136,153,172,0.2), inset 0 1px 1px rgba(255,255,255,0.5); white-space: nowrap; transition: box-shadow 0.2s, color 0.2s, transform 0.15s; }
.btn-test:hover { box-shadow: 0 2px 4px #8899ac, 0 -1px 2px #f9fdff, inset 0 1px 1px rgba(255,255,255,0.5); transform: translateY(-1px); }
.btn-test:active { transform: scale(0.95) translateY(0); }
.btn-test:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-test.testing { color: var(--accent); box-shadow: 0 2px 4px rgba(74,111,165,0.15), inset 0 1px 1px rgba(255,255,255,0.5); }
.btn-test.success { color: #27ae60; background: linear-gradient(to bottom, #eafaf1, #d5f5e3); box-shadow: 0 2px 4px rgba(39,174,96,0.15), inset 0 1px 1px rgba(255,255,255,0.5); }
.btn-test.fail { color: #e74c3c; background: linear-gradient(to bottom, #fdedec, #fadbd8); box-shadow: 0 2px 4px rgba(231,76,60,0.15), inset 0 1px 1px rgba(255,255,255,0.5); }
.settings-status { text-align: center; font-size: 12px; color: var(--dim); min-height: 18px; }
.settings-status.success { color: #27ae60; }
.settings-status.error { color: #e74c3c; }

.diary-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3); backdrop-filter: blur(2px); z-index: 200; display: flex; justify-content: flex-end; animation: fadeIn 0.2s ease; }
.diary-panel { width: 380px; max-width: 90vw; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.10'/%3E%3C/svg%3E"), rgba(238,242,247,0.72); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: -4px 0 24px rgba(0,0,0,0.12), inset -1px 0 0 rgba(255,255,255,0.35); animation: slideIn 0.3s ease; }
.diary-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid rgba(146,168,193,0.2); font-size: 16px; font-weight: 700; color: var(--text); }
.diary-close { width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer; font-size: 20px; color: var(--dim); background: linear-gradient(to bottom, var(--border-light), #d5dde8); box-shadow: 0 1px 2px rgba(136,153,172,0.15), inset 0 1px 1px rgba(255,255,255,0.5); display: flex; align-items: center; justify-content: center; transition: box-shadow 0.2s, color 0.2s, transform 0.15s; }
.diary-close:hover { box-shadow: 0 2px 4px #8899ac, 0 -1px 2px #f9fdff, inset 0 1px 1px rgba(255,255,255,0.5); color: var(--text); }
.diary-close:active { transform: scale(0.9); }
.diary-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.diary-body::-webkit-scrollbar { width: 5px; }
.diary-body::-webkit-scrollbar-track { background: transparent; margin: 4px 0; }
.diary-body::-webkit-scrollbar-thumb { background: rgba(146,168,193,0.4); border-radius: 999px; border: 1px solid rgba(255,255,255,0.3); }
.diary-body::-webkit-scrollbar-thumb:hover { background: rgba(146,168,193,0.65); }
.diary-body { scrollbar-width: thin; scrollbar-color: rgba(146,168,193,0.4) transparent; }
.diary-entry { font-size: 13px; line-height: 1.9; color: var(--text); padding: 12px 16px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border-left: 3px solid var(--accent-light); animation: fadeUp 0.3s ease; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
.diary-entry:hover { background: rgba(255,255,255,0.7); border-left-color: var(--accent); transform: translateX(2px); }
.diary-empty { color: var(--dim); font-size: 14px; text-align: center; padding-top: 40px; }

.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(225,233,241,0.7); backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 300; gap: 16px; animation: fadeIn 0.2s ease; }
.loading-ring { width: 40px; height: 40px; border: 2px solid rgba(146,168,193,0.3); border-top-color: var(--accent-light); border-radius: 50%; animation: spin 0.9s linear infinite; }
.loading-text { font-family: var(--font-display); font-size: 16px; font-weight: 300; color: var(--dim); letter-spacing: 3px; animation: fadeIn 0.3s ease; }

.confirm-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.25); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 250; display: flex; justify-content: center; align-items: center; animation: fadeIn 0.2s ease; }
.confirm-dialog { width: 340px; max-width: 88vw; padding: 28px 28px 20px; border-radius: var(--radius); background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.10'/%3E%3C/svg%3E"), rgba(238,242,247,0.78); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 16px 40px rgba(2,33,67,0.18), 0 0 0 1px rgba(146,168,193,0.25), inset 0 0 0 1px rgba(255,255,255,0.4); animation: scaleIn 0.25s ease; text-align: center; }
.confirm-msg { font-family: var(--font-display); font-size: 16px; font-weight: 300; color: var(--text); letter-spacing: 1px; line-height: 1.6; margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-btn { padding: 10px 32px; border-radius: 999px; border: none; cursor: pointer; font-size: 14px; font-weight: 400; letter-spacing: 1px; transition: all 0.2s; }
.confirm-btn.cancel { background: linear-gradient(to bottom, var(--border-light), #d5dde8); box-shadow: 0 1px 2px rgba(136,153,172,0.2), inset 0 1px 1px rgba(255,255,255,0.5); color: var(--dim); }
.confirm-btn.cancel:hover { box-shadow: 0 2px 4px #8899ac, 0 -1px 2px #f9fdff, inset 0 1px 1px rgba(255,255,255,0.5); }
.confirm-btn.ok { background: linear-gradient(to bottom, var(--border-dark), var(--border-light)); color: var(--text); position: relative; }
.confirm-btn.ok::before { content: ''; position: absolute; inset: 3px; border-radius: 999px; background: linear-gradient(to bottom, #e3ecf7, #c5d5e8); box-shadow: inset 0 0 6px rgba(2,33,67,0.1), inset 0 -3px 2px rgba(255,255,255,0.5); transition: box-shadow 0.2s; }
.confirm-btn.ok span { position: relative; z-index: 1; }
.confirm-btn.ok:hover::before { box-shadow: inset 0 0 8px rgba(2,33,67,0.15), inset 0 -4px 3px rgba(255,255,255,0.45); }
.confirm-btn:active { transform: scale(0.95); }

.toast { position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(100px); padding: 12px 24px; border-radius: 999px; background: var(--text); color: #fff; font-size: 14px; z-index: 400; opacity: 0; pointer-events: none; transition: all 0.3s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

@media (max-width: 640px) {
    .welcome-title { font-size: 22px; letter-spacing: 1px; white-space: normal; }
    .welcome-sub { font-size: 13px; }
    .msg-bubble { max-width: 92%; }
    .diary-panel { width: 100vw; }
    .settings-panel { width: 96vw; }
    .header { padding: 10px 4px 4px; }
    .input-area { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
    .chat-input { font-size: 16px; }
}

/* ========== 难度弹窗 ========== */
.difficulty-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.3s ease;
}
.difficulty-modal {
    background: rgba(225,233,241,0.82);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 28px;
    padding: 40px 36px 32px;
    max-width: 520px; width: 90%;
    text-align: center;
    box-shadow:
        0 20px 50px rgba(2,33,67,0.15),
        0 0 0 1px rgba(146,168,193,0.3),
        inset 0 0 0 1px rgba(255,255,255,0.5);
    animation: scaleIn 0.35s ease;
}
.difficulty-modal h3 {
    color: var(--text);
    font-size: 20px;
    margin-bottom: 28px;
    letter-spacing: 4px;
    font-weight: 400;
    font-family: var(--font-display);
    text-shadow: 0 1px 1px rgba(255,255,255,0.6);
}
.difficulty-cards {
    display: flex;
    justify-content: center;
    gap: 12px;
}
.diff-card {
    flex: 1; max-width: 152px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px;
    min-height: 130px;
    border-radius: 22px;
    cursor: pointer;
    background: linear-gradient(to bottom, var(--border-dark), var(--border-light));
    transition: all 0.3s;
    position: relative;
    color: var(--text);
}
.diff-card::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 18px;
    background: linear-gradient(to bottom, #f9fcfd, #c0d0e0);
    box-shadow:
        inset 0 0 10px rgba(2,33,67,0.10),
        inset 0 -6px 3px rgba(255,255,255,0.55),
        inset 0 4px 3px rgba(35,82,133,0.18);
    z-index: 0;
    transition: all 0.3s;
}
.diff-card:hover {
    transform: translateY(-3px);
}
.diff-card:hover::before {
    background: linear-gradient(to bottom, #f9fcfd, #b0c5da);
    box-shadow:
        inset 0 0 12px rgba(2,33,67,0.15),
        inset 0 -6px 3px rgba(255,255,255,0.5),
        inset 0 5px 4px rgba(35,82,133,0.22);
}
.diff-card:active {
    transform: scale(0.96);
}
.diff-card:active::before {
    box-shadow:
        inset 0 0 12px rgba(2,33,67,0.25),
        inset 0 -4px 2px rgba(255,255,255,0.25),
        inset 0 6px 5px rgba(35,82,133,0.35);
}
.diff-icon {
    font-size: 28px;
    font-weight: 200;
    color: var(--accent);
    position: relative; z-index: 1;
    font-family: var(--font-display);
    line-height: 1;
}
.diff-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 3px;
    position: relative; z-index: 1;
    text-shadow: 0 1px 1px rgba(255,255,255,0.5);
    font-family: var(--font-display);
    line-height: 1;
}
.diff-desc {
    font-size: 11px;
    color: var(--dim);
    letter-spacing: 1px;
    position: relative; z-index: 1;
    line-height: 1.5;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

/* ========== 选项按钮（紧跟气泡内） ========== */
.option-row {
    display: flex; flex-direction: column; gap: 10px;
    padding: 4px 0 16px 0;
    max-width: 82%;
    animation: fadeUp 0.5s ease;
}
.option-btn {
    display: flex; flex-direction: column; gap: 6px;
    padding: 14px 20px;
    border-radius: var(--radius);
    border: none;
    background: linear-gradient(180deg, #f4f8fc, #e8eef5);
    box-shadow:
        0 2px 6px rgba(136,153,172,0.15),
        inset 0 1px 1px rgba(255,255,255,0.7);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: all 0.25s;
    position: relative;
}
.option-btn:hover {
    background: linear-gradient(180deg, #eaf0f8, #dce6f2);
    box-shadow:
        0 4px 12px rgba(74,111,165,0.12),
        inset 0 1px 1px rgba(255,255,255,0.6);
    transform: translateX(4px);
}
.option-btn:active {
    transform: scale(0.98) translateX(2px);
    box-shadow:
        inset 0 2px 4px rgba(136,153,172,0.2),
        inset 0 -1px 1px rgba(255,255,255,0.3);
}
.option-btn .opt-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-accent);
    letter-spacing: 0.3px;
}
.option-btn .opt-meta {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    font-weight: 300;
}
