/* =========== 全局和基础样式 =========== */
:root {
    --font-color: #2f2f2f; 
    --accent-color: #2b2b2b;
    --icon-gradient: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    --widget-bg: rgba(255, 255, 255, 0.82);
    --ins-bg: #f5f3f0;
    --ins-card: rgba(255, 255, 255, 0.94);
    --ins-accent: #e3ddd6;
    --ins-accent-strong: #d0c6bc;
    --ins-text: #2d2b29;
    --ins-border: rgba(120, 112, 104, 0.18);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    background: #f0f0f0;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    background: #f0f0f0; /* 全局背景 */
    overflow: hidden;
    overflow-x: hidden;
}

@media (max-width: 600px) {
    body {
        justify-content: flex-start;
        align-items: stretch;
    }

    #spa-root {
        width: 100%;
        max-width: 100%;
        margin: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100svh;
        height: 100dvh;
    }
}

@media (min-width: 601px) {
    #spa-root {
        max-width: 500px;
    }
}

/* 隐藏无关特效 */
body.not-home::before, 
body.not-home::after {
    display: none !important;
}

/* SPA 页面容器 (限制宽度以兼容PC浏览器，还原白边消除) */
#spa-root {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 100%;
    position: relative;
    overflow: hidden;
    background: #f0f0f0; 
}

.spa-page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto; 
    display: none; 
    background: transparent; 
}

.spa-page.active {
    display: block;
}

/* 手机壳与屏幕 */
.phone-case {
    width: 100%;
    height: 100%;
    min-height: 100%;
    background: #f0f0f0;
    display: flex;
}
.screen {
    flex-grow: 1;
    background: #f0f0f0; 
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: 100%;
    min-height: 100%;
}

/* 顶部状态栏 */
#status-bar {
    height: calc(30px + env(safe-area-inset-top, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: env(safe-area-inset-top, 0px) 15px 0;
    font-size: 12px;
    color: var(--font-color);
    font-weight: bold;
    background: transparent; /* 去除了半透明白底，与主屏幕背景无缝衔接 */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

#save-layout-btn, #cancel-layout-btn {
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 14px rgba(0,0,0,0.18);
    backdrop-filter: blur(10px);
    z-index: 101;
}
#save-layout-btn { background: rgba(216, 232, 221, 0.95); color: var(--ins-text); }
#cancel-layout-btn { background: rgba(244, 226, 210, 0.95); color: var(--ins-text); }

/* 主屏幕网格系统 */
.home-swiper {
    width: 100%; /* 去掉压缩，100% 充满，消除白边 */
    height: calc(100% - 100px);
    overflow: hidden;
    position: relative;
    touch-action: pan-y; 
}

.swiper-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease-out;
}

/* 恢复到均分，不超屏幕 */
.home-page-grid {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(7, 1fr); /* 7行高度均分，绝不溢出 */
    gap: 5px; /* 较小的间距，紧凑显示 */
    padding: 15px 15px; /* 合适内边距 */
    box-sizing: border-box;
    position: relative;
}

/* 背景格子层 */
.grid-slot-bg {
    border: 1px dashed rgba(0,0,0,0.15);
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    pointer-events: none;
    opacity: 0; 
    z-index: 1;
}
body.edit-mode .grid-slot-bg {
    opacity: 1;
    pointer-events: auto;
}

/* --- 网格项通用样式 --- */
.grid-item {
    z-index: 2;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0; /* 防止内容撑高行，严格按格子高度渲染 */
    position: relative;
    border-radius: 22%; 
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease, opacity 0.2s;
    user-select: none;
    -webkit-user-select: none;
    /* 取消 overflow hidden，让右上角删除按钮能够显示出边界 */
}

.grid-item:active {
    transform: scale(0.95);
}

/* --- 应用图标样式 (固定原大小) --- */
.app-item {
    background: transparent;
    box-shadow: none;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    justify-content: center;
}

.app-item .icon-image {
    width: 58px; /* 恢复原先舒适的绝对大小 */
    height: 58px;
    border-radius: 22%; 
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.app-item .icon-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-item .app-name {
    font-size: 11px;
    color: var(--font-color);
    margin-top: 5px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* --- 原有特定组件适配 --- */
.photo-widget {
    background: transparent;
    padding: 0;
    /* Removed overflow: hidden so delete button is visible */
}
.photo-widget img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 22%;
}

/* Custom widgets should have no default background/borders */
.custom-widget {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
    pointer-events: auto;
    touch-action: auto;
}

.custom-widget iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: transparent;
    pointer-events: auto;
    border-radius: inherit;
    overflow: hidden;
    touch-action: auto;
}

body.edit-mode .custom-widget iframe {
    pointer-events: none;
}

.notepad-widget {
    background: rgba(255, 255, 255, 0.85);
    padding: 15px;
    align-items: flex-start;
    justify-content: flex-start;
}
.notepad-widget textarea {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    color: #444;
    line-height: 1.5;
}
.notepad-widget textarea:focus { outline: none; }

/* 分页指示器 */
.page-indicators {
    position: absolute;
    bottom: 95px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 6px;
    z-index: 90;
}

.page-transfer-zone{
    position: absolute;
    right: 14px;
    bottom: 92px; /* 夹在第7行与底栏之间 */
    width: 92px;
    height: 26px;
    border-radius: 14px;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 260;
    display: none;
    pointer-events: none; /* 绝不遮挡格子触摸 */
}
body.edit-mode .page-transfer-zone{
    display: block;
}
.page-transfer-zone.active{
    background: rgba(176,143,120,0.65);
    border-color: rgba(176,143,120,0.9);
    box-shadow: 0 10px 24px rgba(176,143,120,0.25);
    transform: scale(1.04);
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0,0,0,0.2);
    transition: all 0.3s;
}
.dot.active {
    background: rgba(0,0,0,0.6);
    width: 12px;
    border-radius: 4px;
}

/* --- 抽屉与编辑工具栏 --- */
.edit-toolbar {
    position: absolute;
    top: 32px;
    left: 12px;
    right: 12px;
    transform: none;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    z-index: 200;
    background: transparent;
    padding: 0;
}

.edit-btn {
    flex: 1;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--ins-border);
    background: var(--ins-card);
    color: var(--ins-text);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    backdrop-filter: blur(12px);
}
.edit-btn:active { transform: scale(0.97); }
.edit-btn.danger { background: var(--ins-accent-strong); border-color: var(--ins-border); color: var(--ins-text); }

body.edit-mode .home-swiper {
    height: calc(100% - 100px);
}

.widget-drawer {
    position: absolute;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 60%;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    z-index: 300;
    transition: bottom 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.widget-drawer.open { bottom: 0; }

.drawer-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.drawer-header h3 { font-size: 16px; color: #333; margin:0; }

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    align-content: start;
}

.lib-item {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 10px;
    text-align: center;
    cursor: grab;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    position: relative;
}
.lib-item.fixed-item {
    border: 1px dashed #ff8787;
    background: #fff0f5;
    cursor: pointer;
}
.lib-item span { font-size: 10px; color: #666; margin-top: 5px; }

/* 移除按钮 */
.remove-widget-btn {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 28px;
    height: 28px;
    background: #ff3b30;
    color: white;
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    z-index: 99; /* 保证它最高 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    border: 2px solid #fff;
}
.edit-mode .grid-item .remove-widget-btn { display: flex; }
.edit-mode .app-item .remove-widget-btn { display: none; }


/* =========== 底部导航栏 (Dock) =========== */
#bottom-bar {
    position: absolute;
    bottom: 14px; 
    left: 14px; 
    right: 14px;
    width: calc(100% - 28px); 
    height: 72px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 12px;
    padding: 8px 10px;
    align-items: center;
    z-index: 100;
}

/* 拖拽时仅做淡化，不再屏蔽 pointer-events，保证第八行可以作为落点 */
body.dragging #bottom-bar {
    opacity: 0.6;
}

/* 白色半透明栏栏，第8行背景 */
#bottom-bar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.78);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 26px; 
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    z-index: -1; 
}

/* 确保它在底栏中垂直居中并大小一致 */
.dock-item {
    display: flex;
    align-items: center;
    justify-content: center;
}

.dock-item .icon-image {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: rgba(255,255,255,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
    border: 1px solid rgba(255,255,255,0.9);
}

.dock-item .icon-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
}

.dock-item .app-name {
    display: none !important; 
}

/* =========== 编辑模式动画 =========== */
@keyframes jiggle {
    0% { transform: rotate(-1deg); }
    50% { transform: rotate(1deg); }
    100% { transform: rotate(-1deg); }
}

.edit-mode .grid-item {
    animation: jiggle 0.3s infinite;
    cursor: grab;
    z-index: 10;
}

/* 拖拽时的样式 (Ghost element) */
.dragging-ghost {
    position: absolute;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.8;
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transition: none !important;
}

.grid-item.drag-source {
    opacity: 0.3;
}

/* =========== 设置页面样式 =========== */
.settings-page {
    padding: 20px;
    color: var(--font-color);
    overflow-y: auto;
    height: 100%;
}

#page-settings .settings-page,
#page-beautify .beautify-page,
#page-world-book .worldbook-page,
#page-regex .regex-page {
    background: var(--ins-bg);
    color: var(--ins-text);
}

#page-settings .settings-header,
#page-beautify .settings-header,
#page-world-book .settings-header,
#page-regex .settings-header {
    color: var(--ins-text);
}

#page-settings .settings-section,
#page-beautify .settings-section,
#page-beautify .theme-selection,
#page-beautify .icon-customization,
#page-beautify .css-customization,
#page-world-book .wb-category,
#page-regex .rx-item {
    background: var(--ins-card);
    border: 1px solid var(--ins-border);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
    backdrop-filter: blur(16px);
}

#page-settings .settings-button,
#page-beautify .settings-button,
#page-world-book .settings-button,
#page-regex .settings-button,
#page-regex .rx-btn-row .edit-btn {
    background: var(--ins-accent) !important;
    color: var(--ins-text) !important;
    border: 1px solid var(--ins-border) !important;
    border-radius: 999px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
    font-weight: 600;
}

#page-settings .back-button,
#page-beautify .back-button,
#page-world-book .back-button,
#page-regex .back-button {
    color: var(--ins-text);
}

#page-settings .settings-item input,
#page-settings .settings-item select,
#page-beautify .settings-item input,
#page-beautify .settings-item select,
#page-beautify textarea,
#page-world-book .form-group input,
#page-world-book .form-group textarea,
#page-world-book .form-group select,
#page-regex .form-group input,
#page-regex .form-group textarea,
#page-regex .form-group select {
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--ins-border);
    color: var(--ins-text);
}

#page-beautify .slider,
#page-settings .slider {
    background-color: rgba(217, 199, 184, 0.6);
}
#page-beautify input:checked + .slider,
#page-settings input:checked + .slider {
    background-color: var(--ins-accent-strong);
}

.settings-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
    padding-left: 40px; 
}

.settings-header h1 {
    font-size: 24px;
    margin: 0 auto;
}

.back-button {
    font-size: 30px;
    color: var(--font-color);
    text-decoration: none;
    position: absolute;
    left: 0;
    cursor: pointer;
}

.settings-section {
    background: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.settings-section h2 {
    font-size: 18px;
    margin-bottom: 5px;
}

.settings-section p {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 20px;
}

.settings-item {
    margin-bottom: 15px;
}

.settings-item label {
    display: block;
    font-size: 14px;
    margin-bottom: 5px;
}

.settings-item input,
.settings-item select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    background: #f5f5f5;
    color: var(--font-color);
}

.settings-button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background-color: var(--accent-color);
    color: white;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
}

.button-group {
    display: flex;
    gap: 10px;
}

/* --- chat.html Styles --- */
#page-chat .screen {
    background-color: var(--ins-bg);
    display: flex;
    flex-direction: column;
}

#page-chat .chat-header {
    height: 64px;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--ins-border);
    z-index: 100;
}

#page-chat .user-avatar-container {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--ins-border);
    background: #fff;
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
    cursor: pointer;
}

#page-chat .user-avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#page-chat .chat-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ins-text);
    letter-spacing: 0.5px;
}

#page-chat .header-actions {
    width: 48px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

#page-chat .chat-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#page-chat .chat-tabs {
    height: 56px;
    background: rgba(255,255,255,0.96);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--ins-border);
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 0 38px;
    gap: 18px;
    box-shadow: 0 -10px 24px rgba(0,0,0,0.06);
}

#page-chat .chat-tab-item {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8d7c6f;
    cursor: pointer;
    transition: all 0.2s ease;
}

#page-chat .chat-tab-item.active {
    color: #b08f78;
    background: var(--ins-card);
    border: 1px solid var(--ins-border);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

#page-chat .chat-tab-item span {
    display: none;
}

#page-chat .chat-tab-icon {
    width: 22px;
    height: 22px;
    position: relative;
    color: currentColor;
}

#page-chat .chat-tab-icon.icon-message {
    border: 2px solid currentColor;
    border-radius: 6px;
}
#page-chat .chat-tab-icon.icon-message::after {
    content: "";
    position: absolute;
    left: 4px;
    bottom: -4px;
    width: 6px;
    height: 6px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    background: transparent;
}

#page-chat .chat-tab-icon.icon-channel {
    background:
        linear-gradient(currentColor, currentColor) 6px 4px/2px 14px no-repeat,
        linear-gradient(currentColor, currentColor) 14px 4px/2px 14px no-repeat,
        linear-gradient(currentColor, currentColor) 4px 8px/14px 2px no-repeat,
        linear-gradient(currentColor, currentColor) 4px 14px/14px 2px no-repeat;
    border-radius: 4px;
}

#page-chat .chat-tab-icon.icon-contacts::before {
    content: "";
    position: absolute;
    top: 1px;
    left: 6px;
    width: 10px;
    height: 10px;
    border: 2px solid currentColor;
    border-radius: 50%;
}
#page-chat .chat-tab-icon.icon-contacts::after {
    content: "";
    position: absolute;
    bottom: 1px;
    left: 3px;
    width: 16px;
    height: 8px;
    border: 2px solid currentColor;
    border-top: none;
    border-radius: 0 0 8px 8px;
}

#page-chat .chat-tab-icon.icon-moments {
    border: 2px solid currentColor;
    border-radius: 50%;
}
#page-chat .chat-tab-icon.icon-moments::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    top: 4px;
    left: 4px;
}

#page-chat .chat-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 14px 0 70px;
    position: relative;
    height: calc(100% - 120px);
}

#page-chat .message-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#page-chat .message-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--ins-border);
    box-shadow: none;
    cursor: pointer;
}
#page-chat .message-item:last-child {
    border-bottom: none;
}

#page-chat .msg-avatar {
    width: 46px;
    height: 46px;
    background: #f1eeea;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--ins-border);
}

#page-chat .msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#page-chat .msg-info {
    flex: 1;
}

#page-chat .msg-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ins-text);
    margin-bottom: 4px;
}

#page-chat .msg-preview {
    font-size: 12px;
    color: #8f827a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#page-chat .contact-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#page-chat .contact-group-title {
    font-size: 12px;
    color: #9d9086;
    margin: 10px 5px 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#page-chat .contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--ins-border);
    cursor: pointer;
}
#page-chat .contact-item:last-child {
    border-bottom: none;
}

#page-chat .contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #f1eeea;
    overflow: hidden;
    border: 1px solid var(--ins-border);
}

#page-chat .contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#page-chat .contact-info {
    flex: 1;
}

#page-chat .contact-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--ins-text);
    margin-bottom: 2px;
}

#page-chat .contact-remark {
    font-size: 11px;
    color: #9a8f87;
}

.hidden {
    display: none !important;
}

.header-btn {
    text-decoration: none;
    color: #6b5f57;
    font-size: 20px;
    padding: 5px;
    cursor: pointer;
}

body.chat-beautify-custom #page-chat .screen,
body.chat-beautify-custom #page-chat-window #chat-container {
    background: var(--chat-bg, #f5f3f0);
}

body.chat-beautify-custom #page-chat .chat-header,
body.chat-beautify-custom #page-chat .chat-tabs,
body.chat-beautify-custom #page-chat-window .chat-header,
body.chat-beautify-custom #page-chat-window .input-wrapper {
    background: var(--chat-surface, #ffffff);
    border-color: var(--chat-border, rgba(120,112,104,0.18));
    box-shadow: none;
}

body.chat-beautify-custom #page-chat .message-item,
body.chat-beautify-custom #page-chat .contact-item {
    background: transparent;
    border-bottom-color: var(--chat-border, rgba(120,112,104,0.18));
    box-shadow: none;
}

body.chat-beautify-custom #page-chat-window .msg-bubble {
    background: var(--chat-surface, #ffffff);
    border: 1px solid var(--chat-border, rgba(120,112,104,0.18));
    box-shadow: none;
}

body.chat-beautify-custom #page-chat-window #input-box {
    background: var(--chat-input, #f9f6f2);
    border-color: var(--chat-border, rgba(120,112,104,0.18));
}

body.chat-beautify-custom #page-chat-window .send-btn {
    background: var(--chat-accent, #2b2b2b);
    color: #fff;
    box-shadow: none;
}

body.chat-beautify-custom #page-chat .chat-tab-icon {
    border: none;
    background-color: transparent;
}
body.chat-beautify-custom #page-chat .icon-message::after,
body.chat-beautify-custom #page-chat .icon-contacts::before,
body.chat-beautify-custom #page-chat .icon-contacts::after,
body.chat-beautify-custom #page-chat .icon-moments::after {
    content: none;
}

body.chat-beautify-custom #page-chat .msg-avatar,
body.chat-beautify-custom #page-chat .contact-avatar,
body.chat-beautify-custom #page-chat-window .msg-avatar {
    border-radius: 50%;
    overflow: hidden;
}
body.chat-beautify-custom #page-chat .msg-avatar img,
body.chat-beautify-custom #page-chat .contact-avatar img,
body.chat-beautify-custom #page-chat-window .msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- chat_window.html Styles --- */
#page-chat-window #chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: var(--ins-bg);
    background-size: cover;
    background-position: center;
    transition: background 0.3s;
}
#page-chat-window .chat-header {
    height: 60px;
    background: rgba(255,255,255,0.94);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--ins-border);
}
#page-chat-window .chat-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ins-text);
}
#page-chat-window .header-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b5f57;
    border: 1px solid var(--ins-border);
    background: rgba(255,255,255,0.8);
}
#page-chat-window .header-btn.icon-back {
    font-size: 18px;
    font-weight: 600;
}

#page-chat-window #msg-area { 
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px; 
    scroll-behavior: smooth; 
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#page-chat-window #msg-area::-webkit-scrollbar { display: none; }

#page-chat-window #load-more-btn { 
    text-align: center;
    color: #b08f78;
    cursor: pointer;
    padding: 8px 14px;
    font-size: 12px; 
    background: rgba(255,255,255,0.7);
    border-radius: 999px;
    width: fit-content;
    margin: 0 auto;
    border: 1px solid var(--ins-border);
}

#page-chat-window .msg-row {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
    position: relative;
    transition: transform 0.2s;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

#page-chat-window .msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
#page-chat-window .msg-row.ai { align-self: flex-start; }

#page-chat-window .msg-avatar { 
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--ins-border);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    cursor: pointer; 
    transition: transform 0.2s;
    margin-top: 2px; 
}
#page-chat-window .msg-avatar:active { transform: scale(0.9); }
#page-chat-window .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

#page-chat-window .msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 6px 14px rgba(0,0,0,0.05);
    max-width: 100%;
    user-select: text;
    border: 1px solid var(--ins-border);
    background: rgba(255,255,255,0.96);
    color: var(--ins-text);
}
#page-chat-window .msg-row.user .msg-bubble { 
    background: #f1e7dd;
    color: #4f3e34;
    border-top-right-radius: 6px; 
}
#page-chat-window .msg-row.ai .msg-bubble { 
    background: #ffffff;
    color: var(--ins-text);
    border-top-left-radius: 6px; 
}

#page-chat-window .select-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #b08f78;
    display: none;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}
#page-chat-window .select-checkbox.checked { background: #b08f78; }
#page-chat-window .select-checkbox.checked::after { content: '✔'; color: white; font-size: 12px; }

body.select-mode .msg-row.user { flex-direction: row-reverse; }
body.select-mode .select-checkbox { display: flex; }
body.select-mode .msg-bubble { user-select: none; pointer-events: none; }

#page-chat-window .input-wrapper {
    background: rgba(255,255,255,0.98);
    border-top: 1px solid var(--ins-border);
    z-index: 100;
    width: 100%;
}

#page-chat-window .input-area {
    padding: 10px 14px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 60px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

#page-chat-window .icon-btn {
    font-size: 24px;
    cursor: pointer;
    color: #6b5f57;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#page-chat-window .strawberry-btn { font-size: 26px; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.08)); }
.icon-unified {
    width: 22px;
    height: 22px;
    border: 1.6px solid currentColor;
    border-radius: 6px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b5f57;
}
#btn-settings.icon-unified {
    border-radius: 7px;
}
#btn-settings.icon-unified::before {
    content: "";
    position: absolute;
    inset: 4px;
    border: 1.6px solid currentColor;
    border-radius: 50%;
}
#btn-settings.icon-unified::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 1.6px;
    background: currentColor;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}
#btn-strawberry.icon-unified {
    border-radius: 50%;
}
#btn-strawberry.icon-unified::before {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.18;
}
#btn-strawberry.icon-unified::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 1.6px;
    background: currentColor;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#page-chat-window #input-box {
    flex: 1;
    border: 1.5px solid var(--ins-border);
    border-radius: 18px;
    padding: 10px 14px;
    font-size: 15px;
    max-height: 120px;
    overflow-y: auto;
    background: #f9f6f2;
    resize: none;
    color: var(--ins-text);
    user-select: text;
}
#page-chat-window #input-box:focus { outline: none; border-color: #b08f78; }

#page-chat-window .send-btn {
    background: #b08f78;
    color: white;
    border: none;
    border-radius: 18px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    height: 38px;
    align-self: center;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(176,143,120,0.25);
}

#quote-bar { display: none; padding: 8px 15px; background: #fff0f5; font-size: 12px; color: #888; border-bottom: 1px solid #ffecec; justify-content: space-between; align-items: center; }

#context-menu {
    position: absolute; background: #fff; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    padding: 5px; display: none; z-index: 200; flex-direction: column; min-width: 100px;
}
.ctx-item { padding: 10px 15px; font-size: 14px; color: #333; cursor: pointer; border-radius: 5px; }
.ctx-item:active { background: #f5f5f5; }

#delete-bar {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 60px;
    background: #fff; display: none; align-items: center; justify-content: space-between;
    padding: 0 20px; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); z-index: 101;
}

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 200; justify-content: center; align-items: center; backdrop-filter: blur(2px); }
.modal.active { display: flex !important; }
.modal-content { background: #fff; width: 90%; max-width: 380px; border-radius: 25px; padding: 25px; max-height: 85vh; overflow-y: auto; }
#page-chat-window #modal-settings {
    align-items: stretch;
    justify-content: stretch;
}
#page-chat-window #modal-settings .modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding: 24px;
}
.modal h3 { margin-top: 0; margin-bottom: 20px; border-bottom: 2px dashed #ffecec; padding-bottom: 10px; color: #5d3a3a; display:flex; justify-content:space-between; }

.modal .setting-item { margin-bottom: 18px; }
.modal .setting-item label { display: block; font-size: 14px; color: #888; margin-bottom: 8px; font-weight: bold; }
.modal .setting-item input, .modal .setting-item textarea { width: 100%; padding: 10px; border: 1px solid #eee; border-radius: 10px; background: #fdfdfd; font-size: 14px; }

.range-input { display: flex; align-items: center; gap: 5px; }
.range-input input { width: 60px !important; text-align: center; }

#plus-menu {
    position: absolute; bottom: 70px; right: 15px; width: 160px;
    background: #fff; border-radius: 15px; padding: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1); display: none; z-index: 150;
    flex-direction: column; gap: 5px;
}
.menu-item { padding: 10px; border-radius: 10px; cursor: pointer; color: #5d3a3a; font-size: 14px; }
.menu-item:active { background: #fff0f5; }

.summary-card { background: #fff9c4; border-radius: 10px; padding: 10px; margin-bottom: 10px; font-size: 13px; color: #5d4037; }

#debug-toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(255, 135, 135, 0.9); color: white; padding: 8px 16px; border-radius: 20px; font-size: 13px; display: none; z-index: 999; }
.bg-preview { width: 100%; height: 100px; object-fit: cover; border-radius: 10px; margin-top: 5px; display: none; }

/* --- user_settings.html Styles --- */
.preset-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.preset-item { background: var(--ins-card); padding: 16px; border-radius: 14px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--ins-border); cursor: pointer; box-shadow: 0 8px 18px rgba(0,0,0,0.04); }
.preset-info h3 { font-size: 16px; margin-bottom: 5px; color: var(--ins-text); }
.preset-info p { font-size: 12px; color: #7c726a; margin: 0; }
.preset-actions button { background: none; border: none; font-size: 18px; cursor: pointer; padding: 5px; color: #7c726a; }
.add-preset-btn { background: #222; color: white; border: none; width: 100%; padding: 12px; border-radius: 999px; font-size: 15px; margin-bottom: 20px; cursor: pointer; letter-spacing: 0.5px; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 14px; color: #555; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
.relationship-list { margin-top: 10px; border-top: 1px dashed #eee; padding-top: 10px; }
.relation-item { background: #f5f5f5; padding: 10px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; display: flex; justify-content: space-between; }
.ai-gen-section { background: #e3f2fd; padding: 15px; border-radius: 10px; margin-top: 15px; }
.ai-gen-btn { background: #2196f3; color: white; border: none; padding: 8px 15px; border-radius: 20px; font-size: 12px; cursor: pointer; }
#debug-info { font-size: 10px; color: red; background: #ffe; padding: 5px; margin-bottom: 10px; border: 1px solid red; display: none; }

.wb-select-container { border: 1px solid #eee; border-radius: 10px; padding: 10px; background: #f9f9f9; max-height: 300px; overflow-y: auto; }
.wb-category-item { margin-bottom: 10px; }
.wb-cat-header { display: flex; align-items: center; padding: 8px; background: #eef; border-radius: 6px; cursor: pointer; }
.wb-cat-header input[type="checkbox"] { width: auto; margin-right: 10px; }
.wb-entries-list { padding-left: 20px; margin-top: 5px; display: none; }
.wb-entries-list.expanded { display: block; }
.wb-entry-item { display: flex; align-items: center; padding: 5px 0; font-size: 13px; }
.wb-entry-item input[type="checkbox"] { width: auto; margin-right: 8px; }
.floating-save-btn { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); width: 90%; background: #ff8787; color: white; border: none; padding: 15px; border-radius: 30px; font-size: 18px; box-shadow: 0 4px 15px rgba(255, 135, 135, 0.4); z-index: 100; }

.beautify-page {
    padding: 20px;
    color: var(--ins-text);
    overflow-y: auto;
    height: 100%;
}
.chat-beautify-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}
.chat-beautify-panel {
    background: var(--ins-card);
    border: 1px solid var(--ins-border);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-beautify-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--ins-text);
}
#chat-beautify-template,
#chat-beautify-code {
    width: 100%;
    min-height: 200px;
    border-radius: 12px;
    border: 1px solid var(--ins-border);
    background: rgba(255,255,255,0.9);
    color: var(--ins-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
#page-user-settings .settings-page {
    background: var(--ins-bg);
    color: var(--ins-text);
}
#page-user-settings .settings-section,
#page-user-settings .preset-item,
#page-user-settings .ai-gen-section {
    background: var(--ins-card);
    border: 1px solid var(--ins-border);
    box-shadow: 0 10px 22px rgba(0,0,0,0.04);
}
#page-user-settings .settings-button {
    background: #2b2b2b;
    color: #fff;
    border-radius: 999px;
    border: 1px solid #2b2b2b;
}
#page-user-settings .back-button {
    color: var(--ins-text);
}
#page-user-settings #edit-modal .modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding: 24px;
}
#page-user-settings #edit-modal {
    align-items: stretch;
    justify-content: stretch;
}
.theme-selection, .icon-customization, .css-customization {
    background: var(--widget-bg);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}
.theme-selection h2, .icon-customization h2, .css-customization h2 {
    font-size: 18px;
    margin-bottom: 15px;
}
.theme-buttons {
    display: flex;
    justify-content: space-around;
    gap: 10px;
}
.theme-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: white;
    flex-grow: 1;
}
#theme-strawberry { background-color: #ffb3b3; }
#theme-orange { background-color: #ffc8a9; }
#theme-watermelon { background-color: #a8d8b5; }

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 15px;
}
.icon-setter {
    text-align: center;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.icon-setter .icon-preview-container {
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
}
.icon-setter .icon-preview {
    width: 50px;
    height: 50px;
    background: var(--icon-gradient);
    border-radius: 50%;
    cursor: pointer;
    transition: width 0.1s, height 0.1s;
}
.icon-size-slider {
    width: 80%;
    margin-top: 5px;
}
#custom-css {
    width: 100%;
    height: 150px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.5);
    color: var(--font-color);
    font-family: monospace;
    resize: vertical;
}

.worldbook-page {
    padding: 20px;
    color: var(--font-color);
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.wb-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.wb-category-list {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.wb-category {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(0,0,0,0.05);
}

.wb-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
}

.wb-category-title {
    font-weight: bold;
    font-size: 16px;
}

.wb-entries {
    display: none; 
    flex-direction: column;
    gap: 10px;
    padding-left: 10px;
    border-left: 2px solid rgba(0,0,0,0.1);
}

.wb-category.expanded .wb-entries {
    display: flex;
}

.wb-entry {
    background: rgba(255, 255, 255, 0.8);
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wb-tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    color: white;
}
.tag-global { background-color: #28a745; }
.tag-role { background-color: #007bff; }
.tag-pos-top { background-color: #dc3545; }
.tag-pos-pre { background-color: #ffc107; color: black; }
.tag-pos-post { background-color: #17a2b8; }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
    border: 1px solid #eee;
    padding: 5px;
    border-radius: 8px;
    min-height: 40px;
}
.role-chip {
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
}
.role-chip.selected {
    background: #007bff;
    color: white;
}

.regex-page {
    padding: 20px;
    color: var(--font-color);
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.rx-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.rx-list {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 80px;
}

.rx-item {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
    overflow: hidden;
    transition: all 0.3s ease;
}

.rx-item.disabled {
    background: rgba(240, 240, 240, 0.9);
    opacity: 0.8;
}

.rx-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(255,255,255,0.5);
}

.rx-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
}

.rx-name {
    font-weight: bold;
    font-size: 15px;
    color: #333;
}

.rx-preview-text {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.rx-expand-icon {
    transition: transform 0.3s;
    font-size: 12px;
    color: #999;
    margin-left: 10px;
}
.rx-item.expanded .rx-expand-icon {
    transform: rotate(180deg);
}

.rx-body {
    display: none;
    padding: 15px;
    border-top: 1px solid rgba(0,0,0,0.05);
    background: rgba(255,255,255,0.3);
}
.rx-item.expanded .rx-body {
    display: block;
}

.rx-detail-row {
    margin-bottom: 10px;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rx-label { color: #666; font-size: 12px; }
.rx-code {
    font-family: monospace;
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 4px;
    color: #d63384;
    word-break: break-all;
}

.rx-test-zone {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #ccc;
}
.rx-test-input, .rx-test-output {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 5px;
    box-sizing: border-box;
}
.rx-test-output {
    background: #f8f9fa;
    color: #28a745;
    min-height: 20px;
}

.rx-btn-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}
.rx-btn-row .edit-btn {
    padding: 6px 15px;
    background: var(--ins-accent);
    color: var(--ins-text);
    border: 1px solid var(--ins-border);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: #28a745; }
input:checked + .slider:before { transform: translateX(14px); }

.thought-modal-content {
    display: flex;
    flex-direction: column;
    padding: 0; 
    background-size: cover;
    background-position: center;
    border-radius: 20px;
    overflow: hidden;
    width: 90%;
    max-width: 340px;
    min-height: 400px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.thought-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    z-index: 2;
}

.kaomoji-btn {
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.kaomoji-btn:hover { opacity: 1; transform: scale(1.1); }

.thought-header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.thought-title {
    font-size: 14px;
    font-weight: bold;
}

.thought-style-name {
    font-size: 10px;
    opacity: 0.7;
}

.thought-separator {
    height: 1px;
    width: 80%;
    margin: 0 auto;
    opacity: 0.3;
}

.thought-display-area {
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100px;
    flex-grow: 1;
    overflow-y: auto;
    white-space: pre-wrap;
    text-align: justify;
    z-index: 2;
}

.thought-history-toggle {
    padding: 10px;
    text-align: center;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.8;
    z-index: 2;
}

.thought-history-list {
    max-height: 150px;
    overflow-y: auto;
    padding: 10px 20px 20px;
    background: rgba(255,255,255,0.3);
    font-size: 12px;
}

.thought-history-item {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
}
.thought-history-time { font-size: 10px; opacity: 0.6; display: block; margin-bottom: 2px; }

.close-btn-round {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    font-size: 14px;
    z-index: 10;
}

/* --- THEMES --- */
.theme-cat {
    background-color: #fff0f5;
    color: #5d3a3a;
    font-family: "Rounded Mplus 1c", sans-serif;
    border: 3px solid #ffb7b2;
}
.theme-cat .thought-title { color: #ff8787; }
.theme-cat .thought-separator { background: #ffb7b2; }
.theme-cat::before {
    content: "🐾"; position: absolute; bottom: 10px; left: 10px; font-size: 40px; opacity: 0.1;
}

.theme-ins {
    background-color: #ffffff;
    color: #222;
    font-family: Helvetica, Arial, sans-serif;
    border: 1px solid #ddd;
}
.theme-ins .thought-title { letter-spacing: 2px; text-transform: uppercase; }
.theme-ins .thought-separator { background: #000; height: 2px; width: 40px; }

.theme-angry {
    background-color: #fff0f0;
    color: #d32f2f;
    border: 2px solid #ff5252;
}
.theme-angry .thought-title { font-weight: 900; }
.theme-angry::before { content: "💢"; position: absolute; top: 10px; left: 10px; opacity: 0.2; font-size: 24px; }
.theme-angry .thought-separator { background: #ff5252; transform: rotate(-2deg); }

.theme-snow {
    background: linear-gradient(to bottom, #e3f2fd, #bbdefb);
    color: #1565c0;
    border: 2px solid #90caf9;
}
.theme-snow .thought-separator { background: #fff; height: 2px; box-shadow: 0 0 5px #fff; }
.theme-snow::after { content: "❄️"; position: absolute; top: 50px; right: 20px; font-size: 20px; opacity: 0.3; }

.theme-water {
    background: linear-gradient(180deg, #e0f7fa 0%, #b2ebf2 100%);
    color: #006064;
    border-radius: 30px 30px 40px 40px;
    border: none;
}
.theme-water .thought-display-area { background: rgba(255,255,255,0.4); border-radius: 15px; margin: 10px; }
.theme-water .thought-separator { background: #00bcd4; opacity: 0.2; }

.theme-ink {
    background-color: #f5f5f5;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><g fill="none" stroke="%23ccc" stroke-width="1"><path d="M0 0 L100 100 M100 0 L0 100"/></g></svg>'); 
    color: #000;
    font-family: "Songti SC", "SimSun", serif;
    border: 4px double #333;
}
.theme-ink .thought-title { font-size: 16px; border-bottom: 1px solid #000; padding-bottom: 5px; }
.theme-ink .thought-separator { display: none; }

.theme-wind {
    background: #f1f8e9;
    color: #33691e;
    font-style: italic;
    border: 1px solid #c5e1a5;
}
.theme-wind .thought-display-area { letter-spacing: 1px; }
.theme-wind::before { content: "🍃"; position: absolute; top: 10%; left: -10px; font-size: 20px; opacity: 0.5; animation: float 3s infinite; }
@keyframes float { 0% {transform:translateX(0)} 50% {transform:translateX(10px)} 100% {transform:translateX(0)} }

.theme-star {
    background: #1a237e;
    color: #fff9c4;
    border: 2px solid #ffeb3b;
}
.theme-star .thought-title { color: #fff; text-shadow: 0 0 5px #ffeb3b; }
.theme-star .close-btn-round { background: rgba(255,255,255,0.2); }
.theme-star .thought-separator { background: linear-gradient(90deg, transparent, #ffeb3b, transparent); height: 1px; }

.theme-sakura {
    background-color: #fff;
    background-image: radial-gradient(#fce4ec 20%, transparent 20%);
    background-size: 20px 20px;
    color: #880e4f;
    border: 2px solid #f48fb1;
}
.theme-sakura .thought-display-area { background: rgba(255,255,255,0.9); border-radius: 10px; margin: 10px; padding: 15px; }
.theme-sakura::before { content: "🌸"; position: absolute; bottom: 5px; right: 5px; font-size: 24px; }

.theme-neon {
    background: #000;
    color: #0f0;
    font-family: monospace;
    border: 2px solid #0f0;
    box-shadow: 0 0 10px #0f0;
}
.theme-neon .thought-title { color: #f0f; text-shadow: 0 0 5px #f0f; }
.theme-neon .thought-separator { background: #0f0; box-shadow: 0 0 5px #0f0; }
.theme-neon .close-btn-round { color: #000; background: #0f0; }
