.diary-app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f8f9fa;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: relative; /* 确保子元素绝对定位正确 */
    overflow: hidden;
}

.diary-header {
    padding: 45px 20px 15px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

.diary-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.diary-back-btn {
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

.diary-back-btn.small {
    font-size: 14px;
    font-weight: 500;
}

.diary-title {
    font-size: 18px;
    font-weight: 600;
}

.diary-title.centered {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.diary-tabs {
    display: flex;
    background: #fff;
    padding: 0 20px;
    border-bottom: 2px solid #333;
}

.diary-tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-size: 15px;
    color: #888;
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
}

.diary-tab.active {
    color: #333;
    font-weight: 600;
}

.diary-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 5%;
    right: 5%;
    height: 3px;
    background: #333;
    border-radius: 2px 4px 1px 3px; /* 不规则圆角模拟手绘线条 */
    transform: rotate(-0.5deg);
}

.diary-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.diary-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diary-card {
    background: #fff;
    padding: 15px;
    border: 2px solid #333;
    border-radius: 4px 12px 4px 12px; /* 不规则圆角模拟手绘 */
    box-shadow: 3px 3px 0px #333; /* 硬阴影模拟简笔画 */
    cursor: pointer;
    transition: all 0.1s;
}

.diary-card:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #333;
}

.diary-card.selected {
    background: #fff9e6;
    border-color: #333;
}

.diary-list.select-mode .diary-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.diary-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #333;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    background: #fff;
}

.diary-checkbox.checked {
    background: #333;
    color: #fff;
}

.diary-card-main {
    flex: 1;
    min-width: 0;
}

.diary-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.diary-card-date {
    font-size: 12px;
    color: #999;
}

.diary-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.diary-card-preview {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.diary-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #ccc;
}

.diary-empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.diary-fab {
    position: absolute;
    right: 20px;
    bottom: 30px;
    width: 56px;
    height: 56px;
    background: #fff;
    color: #333;
    border: 2px solid #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 3px 3px 0px #333;
    cursor: pointer;
    z-index: 100;
    transition: all 0.1s;
}

.diary-fab:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #333;
}

/* 编辑/详情页 */
.diary-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
}

.diary-editor-header {
    padding: 45px 20px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #333;
    position: relative;
}

.diary-header-right {
    min-width: 40px;
    display: flex;
    justify-content: flex-end;
}

.diary-save-btn {
    color: #333;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 12px;
    border: 2px solid #333;
    border-radius: 4px 8px;
    box-shadow: 2px 2px 0px #333;
    transition: all 0.1s;
}

.diary-save-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 0px 0px 0px #333;
}

.diary-editor-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fff;
    overflow-y: auto; /* 允许详情页上下滚动 */
}

.diary-input-title {
    font-size: 18px;
    font-weight: 600;
    padding: 10px;
    border: 2px solid #333;
    border-radius: 6px 4px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    height: auto;
    resize: none;
    display: block;
}

.diary-input-body {
    flex: 1;
    font-size: 16px;
    line-height: 1.6;
    padding: 12px;
    border: 2px solid #333;
    border-radius: 4px 10px;
    outline: none;
    width: 100%;
    resize: none;
    box-sizing: border-box;
    background: transparent;
    min-height: 300px; /* 确保编辑器有足够高度 */
}

.diary-content-display {
    flex: none; /* 在详情页中由内容撑开高度，由父容器控制滚动 */
    height: auto;
    min-height: auto;
}

/* 详情页查看模式下的标题框，保留边框和内边距 */
div.diary-input-title.diary-content-display {
    border: 2px solid #333;
    padding: 12px;
    margin-bottom: 5px;
}

.diary-detail-time {
    font-size: 13px;
    color: #999;
    margin-bottom: 10px;
}

/* 角色选择网格 */
.diary-partner-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 10px 5px;
}

.diary-partner-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    padding: 15px 10px;
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: 2px 2px 0px #333;
    cursor: pointer;
    transition: all 0.1s;
}

.diary-partner-item:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #333;
}

.diary-partner-avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    margin-bottom: 8px;
    background-color: #fff;
    border: 2px solid #333;
}

.diary-partner-name {
    font-size: 13px;
    color: #333;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    font-weight: 500;
}

/* 角色日记列表头部 */
.diary-partner-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

.diary-partner-back {
    font-size: 13px;
    color: #333;
    cursor: pointer;
    display: inline-block;
    margin-bottom: 8px;
    text-decoration: underline;
    font-weight: 500;
}

.diary-partner-info {
    font-size: 14px;
    color: #666;
    font-weight: 600;
}

.diary-manage-btn {
    font-size: 13px;
    color: #333;
    cursor: pointer;
    font-weight: 600;
    padding: 2px 8px;
    border: 1.5px solid #333;
    border-radius: 4px;
}

.diary-batch-actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
}

.diary-batch-actions span {
    cursor: pointer;
    text-decoration: underline;
}

.diary-batch-actions .delete-btn {
    text-decoration: none;
    border: 1.5px solid currentColor;
    padding: 1px 8px;
    border-radius: 4px;
}

/* 生成按钮样式 */
.diary-fab-generate {
    position: absolute;
    right: 20px;
    bottom: 30px;
    width: 56px;
    height: 56px;
    background: #fff;
    color: #333;
    border: 2px solid #333;
    border-radius: 50%;
    display: none; /* 默认隐藏，由 JS 控制 */
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 3px 3px 0px #333;
    cursor: pointer;
    z-index: 100;
    transition: all 0.1s;
}

.diary-fab-generate:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #333;
}

.diary-fab-generate.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* 加载动画 */
@keyframes diary-spin {
    to { transform: rotate(360deg); }
}

.diary-loading-icon {
    animation: diary-spin 1s linear infinite;
}
