:root {
    --gradient-start: #FCAEC1;
    --gradient-middle: #B7A8D6;
    --gradient-end: #ADD9F3;
    --card-bg: rgba(255, 255, 255, 0.5);
    --input-bg: rgba(255, 255, 255, 0.7);
    --button-bg-start: #B7A8D6;
    --button-bg-end: #9A8BBF;
    --button-text-color: white;
    --text-color: #333;
    --link-color: #5C4B80;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
    position: relative;
    background: #FFFFFF;
    color: var(--text-color);
    padding: 20px;
    box-sizing: border-box;
}

.bg-blob {
    position: fixed;
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
}

.blob-1 {
    width: 350px;
    height: 350px;
    background: rgba(252, 209, 219, 0.6);
    filter: blur(80px);
    top: -80px;
    left: -80px;
}

.blob-2 {
    width: 280px;
    height: 280px;
    background: rgba(183, 168, 214, 0.5);
    filter: blur(70px);
    top: -30px;
    right: -60px;
}

.blob-3 {
    width: 220px;
    height: 220px;
    background: rgba(252, 174, 193, 0.35);
    filter: blur(65px);
    top: 40%;
    left: -60px;
}

.blob-4 {
    width: 320px;
    height: 320px;
    background: rgba(173, 217, 243, 0.5);
    filter: blur(80px);
    bottom: -60px;
    right: -60px;
}

.container {
    position: relative;
    z-index: 0;
    max-width: 430px;
    width: 100%;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    text-align: center;
    box-sizing: border-box;
}

/* Bottom-tab pages: centered white column (same width on mobile & desktop) */
body.tab-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 !important;
    padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden;
    overflow-y: auto;
}

.main-shell {
    width: 100%;
    max-width: 430px;
    margin-left: auto;
    margin-right: auto;
    min-height: 100vh;
    position: relative;
    box-sizing: border-box;
    z-index: 0;
    flex-grow: 1;
    padding: 20px;
}

@media (min-width: 768px) {
    .main-shell {
        padding: 30px;
    }
}

/* moments.html：封面顶边贴齐栏目，不外圈留白 */
.main-shell.main-shell--moments {
    padding: 0;
}

/* Responsive rules for body and container */
@media (max-width: 767px) {
    body:not(.tab-layout) {
        padding: 10px;
    }
    .container {
        max-width: 100%;
        width: 100%;
        padding: 20px;
        border-radius: 0;
        margin: 0; /* Remove auto margin on mobile */
        box-shadow: none; /* No shadow on full-width mobile */
    }
}

/* Bottom Navigation Bar styles */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(255, 255, 255, 0.7); /* White semi-transparent */
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom); /* Safe area for modern phones */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000; /* Ensure it's above other content */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #999;
    font-size: 0.8em;
    font-weight: 400;
    padding: 5px 10px;
    border-radius: 12px;
    position: relative;
    background-color: transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item .icon {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
    color: #999;
    transition: color 0.25s, transform 0.25s;
}

.nav-item .icon svg {
    display: block;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: color 0.25s, transform 0.25s;
}

.nav-item > span:not(.icon) {
    color: #999;
    transition: color 0.25s, transform 0.25s;
}

/* 选中 pill：背景色与圆角在项上直接过渡（.selected 为各页现有逻辑，.active 便于语义一致） */
.nav-item.selected,
.nav-item.active {
    color: #b7a8d6;
    font-weight: 500;
    background-color: rgba(183, 168, 214, 0.3);
    border-radius: 15px;
}

.nav-item.selected > span:not(.icon),
.nav-item.active > span:not(.icon) {
    color: #b7a8d6;
}

.nav-item.selected .icon,
.nav-item.active .icon {
    color: #b7a8d6;
    transform: scale(1.15);
}

.nav-item.selected .icon svg,
.nav-item.active .icon svg {
    stroke-width: 2.5;
}

.nav-item:hover:not(.selected):not(.active) {
    color: #b7a8d6;
}

.nav-item:hover:not(.selected):not(.active) > span:not(.icon) {
    color: #b7a8d6;
}

.nav-item:hover:not(.selected):not(.active) .icon {
    color: #b7a8d6;
    transform: scale(1.06);
}



@media (min-width: 768px) {
    .container {
        max-width: 430px;
        width: 100%;
        padding: 30px;
        border-radius: 20px;
    }
}

/* Primary buttons — saturated purple gloss (global) */
button:not(.profile-tab):not(.profile-avatar--clickable):not(.profile-nickname-pencil):not(.moment-like-btn):not(.moment-comment-btn):not(.chat-drawer-tl-restart):not(#chat-drawer-tl-add-btn):not(#chat-drawer-tl-del-btn):not(.back-button):not(.chat-header-import):not(.chat-header-more):not(.chat-tool-icon):not(.avatar-upload-zone):not(.user-char-back):not(.user-char-delete-top):not(.user-char-save-top),
.btn {
    background: rgba(162, 142, 204, 0.75) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.8) !important;
    border-radius: 50px !important;
    color: #fff !important;
    font-weight: 600 !important;
    box-shadow:
        0 8px 24px rgba(162, 142, 204, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.5),
        inset 0 -2px 4px rgba(130, 100, 180, 0.3) !important;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    cursor: pointer !important;
}

button:not(.profile-tab):not(.profile-avatar--clickable):not(.profile-nickname-pencil):not(.moment-like-btn):not(.moment-comment-btn):not(.chat-drawer-tl-restart):not(#chat-drawer-tl-add-btn):not(#chat-drawer-tl-del-btn):not(.back-button):not(.chat-header-import):not(.chat-header-more):not(.chat-tool-icon):not(.avatar-upload-zone):not(.user-char-back):not(.user-char-delete-top):not(.user-char-save-top):hover,
.btn:hover {
    background: rgba(162, 142, 204, 0.88) !important;
    transform: translateY(-2px) !important;
    box-shadow:
        0 12px 32px rgba(162, 142, 204, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.6) !important;
}

button:not(.profile-tab):not(.profile-avatar--clickable):not(.profile-nickname-pencil):not(.moment-like-btn):not(.moment-comment-btn):not(.chat-drawer-tl-restart):not(#chat-drawer-tl-add-btn):not(#chat-drawer-tl-del-btn):not(.back-button):not(.chat-header-import):not(.chat-header-more):not(.chat-tool-icon):not(.avatar-upload-zone):not(.user-char-back):not(.user-char-delete-top):not(.user-char-save-top):active,
.btn:active {
    transform: scale(0.97) !important;
}

/* Secondary: logout text link */
button.logout-button {
    width: auto !important;
    padding: 0 !important;
    font-size: 0.9em !important;
    font-weight: normal !important;
    letter-spacing: normal !important;
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    color: #d9534f !important;
    box-shadow: none !important;
    transform: none !important;
}

button.logout-button:hover {
    text-decoration: underline !important;
    transform: none !important;
    box-shadow: none !important;
    background: none !important;
}

button.logout-button:active {
    transform: none !important;
}

/* Secondary: chat header back + regenerate */
.regenerate-button {
    padding: 8px 12px !important;
    font-size: 0.85em !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 8px !important;
    color: var(--link-color) !important;
    letter-spacing: normal !important;
    box-shadow: none !important;
}

.chat-header .back-button {
    padding: 6px 12px !important;
    font-size: 1.35em !important;
    line-height: 1 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1.25px solid rgba(124, 110, 170, 0.55) !important;
    border-radius: 999px !important;
    color: #5c4b80 !important;
    letter-spacing: normal !important;
    box-shadow: none !important;
}

.chat-header button:not(.back-button) {
    background: transparent !important;
    border: 1.25px solid rgba(124, 110, 170, 0.55) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    color: #5c4b80 !important;
}

.chat-assistant-foot button,
.chat-tool-icon {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.chat-header .back-button:hover {
    background: rgba(183, 168, 214, 0.08) !important;
    transform: none !important;
    box-shadow: none !important;
    color: #5c4b80 !important;
    border-color: rgba(92, 75, 128, 0.8) !important;
}

.regenerate-button:hover {
    background: rgba(183, 168, 214, 0.12) !important;
    transform: none !important;
    box-shadow: none !important;
    color: #8d7bbf !important;
}

.chat-header .back-button:active,
.regenerate-button:active {
    transform: scale(0.96) !important;
}

.chat-input-area button {
    flex: 2 !important;
    min-width: unset !important;
    margin-top: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    font-size: 1.2em !important;
    padding: 10px 15px !important;
}

/* Toast for API test / notices */
.api-toast {
    position: fixed;
    left: 50%;
    bottom: calc(72px + env(safe-area-inset-bottom));
    max-width: min(400px, calc(100vw - 32px));
    padding: 14px 20px;
    border-radius: 14px;
    font-size: 0.95em;
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    z-index: 10001;
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

.api-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.api-toast.success {
    background: rgba(220, 252, 231, 0.96);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.api-toast.error {
    background: rgba(254, 226, 226, 0.96);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.35);
    word-break: break-word;
}

/* Common input styles */
input[type="text"],
input[type="email"],
input[type="password"] {
    width: calc(100% - 24px);
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: var(--input-bg);
    font-size: 1em;
    color: var(--text-color);
    outline: none;
    transition: background-color 0.3s ease;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder {
    color: rgba(51, 51, 51, 0.6);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    background-color: rgba(255, 255, 255, 0.9);
}

/* Common logo styles */
.logo {
    font-size: 1.8em;
    font-weight: bold;
    color: #5C4B80;
}

.logo small {
    font-size: 0.7em;
    letter-spacing: 0.1em;
    color: #9A8BBF;
    display: block; /* Ensure it takes a new line */
}

@media (max-width: 767px) {
    .logo {
        font-size: 1.5em;
    }
    .logo small {
        font-size: 0.6em;
    }
}
