:root {
    --bg-url: url('background.png');
    --text-color: #222;
    --muted: #666;
    --card-bg: #fff;
    --overlay: rgba(255, 255, 255, 0);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 优化渲染性能 */
.bg-overlay,
.topbar,
.card {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Quill 编辑器样式 - 仅在需要时加载 */
.ql-container {
    font-size: 14px;
    line-height: 1.6;
}

.ql-editor {
    min-height: 400px;
    padding: 16px;
}

.ql-editor img {
    max-width: 100%;
    height: auto;
    cursor: pointer;
}

/* 图片缩放控制样式 */
.ql-editor .ql-image-resize {
    position: relative;
    display: inline-block;
}

.ql-editor .ql-image-resize img {
    display: block;
}

.ql-toolbar {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.ql-container {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Markdown 内容样式 */
.markdown-body {
    line-height: 1.6;
    word-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1 {
    font-size: 2em;
    border-bottom: 1px solid #e6e6e6;
    padding-bottom: 0.3em;
}

.markdown-body h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #e6e6e6;
    padding-bottom: 0.3em;
}

.markdown-body h3 {
    font-size: 1.25em;
}

.markdown-body p {
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-body ul,
.markdown-body ol {
    margin-top: 0;
    margin-bottom: 16px;
    padding-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.25em;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(175, 184, 193, 0.2);
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-body pre code {
    display: inline;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
    background-color: transparent;
    border: 0;
}

.markdown-body blockquote {
    padding: 0 1em;
    color: #57606a;
    border-left: 0.25em solid #d0d7de;
    margin-bottom: 16px;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.markdown-body a {
    color: #0969da;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body table {
    border-spacing: 0;
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
}

.markdown-body table th,
.markdown-body table td {
    padding: 6px 13px;
    border: 1px solid #d0d7de;
}

.markdown-body table th {
    font-weight: 600;
    background-color: #f6f8fa;
}

.markdown-body hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #d0d7de;
    border: 0;
}

/* 自定义对话框 */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.dialog-box {
    background: #fff;
    border-radius: 12px;
    min-width: 320px;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    overflow: hidden;
}

.dialog-header {
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 600;
    color: #222;
    border-bottom: 1px solid #e6e6e6;
}

.dialog-body {
    padding: 24px;
}

.dialog-message {
    color: #555;
    line-height: 1.6;
    margin-bottom: 16px;
    white-space: pre-wrap;
}

.dialog-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.dialog-input:focus {
    outline: none;
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.dialog-footer {
    padding: 16px 24px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #f8f8f8;
    border-top: 1px solid #e6e6e6;
}

.dialog-btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.dialog-btn-ok {
    background: #0969da;
    color: white;
}

.dialog-btn-ok:hover {
    background: #0860ca;
}

.dialog-btn-cancel {
    background: #fff;
    color: #555;
    border: 1px solid #d0d0d0;
}

.dialog-btn-cancel:hover {
    background: #f3f3f3;
}

/* Modal editor */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    max-width: 900px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    color: var(--text-color);
}

.modal .row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}

.modal label {
    width: 100px;
    flex-shrink: 0;
    color: var(--muted);
}

.modal input[type="text"],
.modal input[type="url"],
.modal textarea,
.modal select {
    flex: 1;
    padding: 8px;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
}

.modal textarea {
    min-height: 200px;
    resize: vertical;
}

.modal .actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

.small-muted {
    font-size: 12px;
    color: var(--muted);
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-url) center/cover no-repeat fixed;
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.bg-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(var(--overlay), var(--overlay));
    backdrop-filter: blur(6px);
    pointer-events: none;
}

.container {
    position: relative;
    z-index: 2;
    max-width: 1000px;
    margin: 5rem auto;
    padding: 2rem;
    color: var(--text-color);
}

.topbar {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    z-index: 3;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nav {
    display: flex;
    gap: 12px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-item {
    color: var(--text-color);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
    will-change: background;
}

.nav-item:hover {
    background: #f0f0f0;
}

.actions {
    position: absolute;
    right: 1rem;
    display: flex;
    align-items: center;
}

#langBtn {
    background: #f7f7f7;
    border: 1px solid #e6e6e6;
    color: var(--text-color);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

#langBtn:hover {
    background: #e6e6e6;
}

.back-btn {
    position: fixed;
    left: 18px;
    top: 18px;
    z-index: 6;
    background: #fff;
    border: 1px solid #e6e6e6;
    color: var(--text-color);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: #f0f0f0;
    transform: translateX(-2px);
}

.card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 18px;
    border: 1px solid #e9e9e9;
    box-shadow: 0 6px 20px rgba(20, 20, 20, 0.06);
    contain: layout style paint;
}

.home-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 18px;
    align-items: start;
}

.avatar {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    object-fit: cover;
    background: linear-gradient(45deg, #ddd, #eee);
}

.contact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* project styles removed (projects page was removed) */

.categories {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.cat-btn {
    padding: 10px 14px;
    border-radius: 999px;
    background: #f5f5f5;
    border: 1px solid #eee;
    cursor: pointer;
    transition: all 0.2s ease;
    will-change: transform;
}

.cat-btn:hover {
    background: #e6e6e6;
    transform: translateY(-1px);
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.post {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    will-change: transform;
}

.post:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(20, 20, 20, 0.1);
}

.post img {
    width: 120px;
    height: 78px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    loading: lazy;
    will-change: transform;
}

/* 图片懒加载优化 */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e6e6e6;
    background: #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    background: #e6e6e6;
}

button:active {
    transform: scale(0.98);
}

.board-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.board-form input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e6e6e6;
    background: #fff;
    color: var(--text-color);
}

.board-form button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 0;
    background: #f0f0f0;
    cursor: pointer;
}

.board-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.message {
    background: #ffffff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

.message small {
    color: var(--muted);
    margin-left: 8px;
}

.del-btn {
    margin-left: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
}

/* 响应式设计优化 */
@media (max-width: 720px) {
    .home-grid {
        grid-template-columns: 1fr;
    }

    .posts-grid {
        grid-template-columns: 1fr;
    }

    .avatar {
        width: 140px;
        height: 140px;
    }

    .topbar {
        height: 56px;
    }

    .nav {
        position: static;
        transform: none;
        justify-content: center;
        gap: 8px;
    }

    .nav-item {
        padding: 6px 10px;
        font-size: 14px;
    }

    .container {
        margin: 4.5rem 1rem;
        padding: 1rem;
    }

    .board-form {
        flex-direction: column;
        align-items: stretch;
    }

    .board-form input {
        width: 100%;
    }

    .post {
        flex-direction: column;
    }

    .post img {
        width: 100%;
        height: auto;
        min-height: 150px;
    }
}

/* 打印样式优化 */
@media print {
    .topbar,
    .back-btn,
    button {
        display: none;
    }

    .container {
        margin: 0;
        padding: 1rem;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* 同步状态提示 */
.sync-status {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.sync-status.show {
    opacity: 1;
    transform: translateX(0);
}

.sync-status.sync-info {
    background: #0969da;
    color: white;
}

.sync-status.sync-success {
    background: #2da44e;
    color: white;
}

.sync-status.sync-error {
    background: #cf222e;
    color: white;
}

/* 响应式同步状态 */
@media (max-width: 720px) {
    .sync-status {
        top: 70px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
}