:root {
    /* 浅色模式变量 */
    --primary-color: #165DFF;
    --bg-color: #f8fafc;
    --editor-bg: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --toolbar-bg: #ffffff;
    --navbar-bg: #ffffff;
    --status-bar-bg: #ffffff;
    --btn-hover-bg: #f1f5f9;
    --btn-active-bg: #e2e8f0;
    --modal-bg: #ffffff;
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --toast-bg: rgba(0, 0, 0, 0.8);
    --toast-text: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
}

/* 暗黑模式变量 */
body.dark-mode {
    --primary-color: #3b82f6;
    --bg-color: #0f172a;
    --editor-bg: #1e293b;
    --text-color: #f1f5f9;
    --border-color: #334155;
    --toolbar-bg: #1e293b;
    --navbar-bg: #1e293b;
    --status-bar-bg: #1e293b;
    --btn-hover-bg: #334155;
    --btn-active-bg: #475569;
    --modal-bg: #1e293b;
    --modal-overlay: rgba(0, 0, 0, 0.8);
    --toast-bg: rgba(255, 255, 255, 0.2);
    --toast-text: #f1f5f9;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: var(--transition);
    min-width: 320px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}

/* 顶部导航栏 */
.navbar {
    height: 44px;
    background-color: var(--navbar-bg);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transition: var(--transition);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-left i {
    color: var(--primary-color);
    font-size: 18px;
}

.navbar-left span {
    font-weight: 600;
    font-size: 16px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.navbar-btn:hover {
    background-color: var(--btn-hover-bg);
}

.navbar-btn:active {
    background-color: var(--btn-active-bg);
}

/* 功能工具栏 */
.toolbar {
    background-color: var(--toolbar-bg);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 44px;
    left: 0;
    right: 0;
    z-index: 999;
    transition: var(--transition);
}

.toolbar .container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    border-right: 1px solid var(--border-color);
    padding-right: 12px;
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background-color: var(--toolbar-bg);
    color: var(--text-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.toolbar-btn:hover {
    background-color: var(--btn-hover-bg);
    border-color: var(--primary-color);
}

.toolbar-btn:active {
    background-color: var(--btn-active-bg);
    transform: translateY(1px);
}

.toolbar-btn i {
    font-size: 14px;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 8px;
}

/* 手机端工具栏 */
.toolbar-mobile {
    display: none;
    width: 100%;
    margin-top: 8px;
}

#mobile-toolbar {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--toolbar-bg);
    color: var(--text-color);
    font-size: 14px;
}

/* 主编辑区 */
.main-content {
    flex: 1;
    margin-top: 140px;
    margin-bottom: 32px;
    padding: 0 16px;
    transition: var(--transition);
}

.editor-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
}

#editor {
    min-height: 400px;
    padding: 20px;
    font-size: 16px;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    outline: none;
    transition: var(--transition);
    overflow-y: auto;
}

#editor:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
}

/* 编辑区拖拽调整 */
.editor-resizer {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background-color: var(--border-color);
    border-bottom-right-radius: 8px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-color);
    transition: var(--transition);
}

.editor-resizer:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 底部状态栏 */
.status-bar {
    height: 32px;
    background-color: var(--status-bar-bg);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    transition: var(--transition);
}

.status-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.status-left {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
}

/* 操作提示 */
.toast {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--toast-bg);
    color: var(--toast-text);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1001;
}

.toast.show {
    opacity: 1;
    visibility: visible;
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--modal-bg);
    color: var(--text-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    transition: var(--transition);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--btn-hover-bg);
}

.modal-body {
    padding: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    font-size: 14px;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.modal-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--toolbar-bg);
    color: var(--text-color);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.modal-btn:hover {
    background-color: var(--btn-hover-bg);
    border-color: var(--primary-color);
}

.modal-btn:active {
    background-color: var(--btn-active-bg);
}

/* 一键回到顶部 */
.back-to-top {
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 998;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(22, 93, 255, 0.3);
}

/* 分享弹窗样式 */
.share-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.share-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--toolbar-bg);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.share-btn:hover {
    background-color: var(--btn-hover-bg);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.share-btn i {
    font-size: 20px;
    color: var(--primary-color);
}

.share-btn span {
    font-size: 14px;
    font-weight: 500;
}

/* 图片样式选项 */
.image-options {
    display: none;
    margin-top: 20px;
}

.image-options.show {
    display: block;
}

.image-options h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.style-options {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.style-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--toolbar-bg);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
    font-size: 14px;
}

.style-btn:hover {
    background-color: var(--btn-hover-bg);
}

.style-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 预览区域 */
.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--editor-bg);
    min-height: 300px;
}

.share-canvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* 图片操作按钮 */
.image-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.image-actions .modal-btn {
    flex: 1;
    max-width: 200px;
}

/* 表单操作区域 */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.form-actions .modal-btn {
    flex: 1;
}

/* 云备份操作区域 */
.cloud-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    margin-bottom: 24px;
}

.cloud-actions .modal-btn {
    flex: 1;
    min-width: 120px;
}

/* 已备份文件列表 */
.backup-files {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.backup-files h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.files-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.files-list li {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    background-color: var(--toolbar-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.files-list li:hover {
    background-color: var(--btn-hover-bg);
}

.files-list .file-name {
    font-size: 14px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.files-list .file-actions {
    display: flex;
    gap: 4px;
}

.files-list .file-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.files-list .file-action-btn:hover {
    background-color: var(--btn-hover-bg);
    color: var(--primary-color);
}

/* 次要按钮样式 */
.modal-btn.secondary {
    background-color: var(--toolbar-bg);
    color: var(--text-color);
    border-color: var(--border-color);
}

.modal-btn.secondary:hover {
    background-color: var(--btn-hover-bg);
    border-color: var(--primary-color);
}

/* 表单提示样式 */
.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 4px;
}

.form-note {
    margin-top: 16px;
    padding: 12px;
    background-color: var(--btn-hover-bg);
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.form-note p {
    margin: 0 0 8px 0;
    font-weight: 500;
}

.form-note ol {
    margin: 0;
    padding-left: 20px;
}

.form-note li {
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 1.4;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background-color: var(--bg-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
    transition: var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .toolbar .container {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .toolbar-group {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 8px;
        width: 100%;
    }

    .main-content {
        margin-top: 200px;
    }
}

@media (max-width: 768px) {
    .toolbar-group {
        display: none;
    }

    .toolbar-mobile {
        display: block;
    }

    .main-content {
        margin-top: 120px;
    }

    #editor {
        min-height: 300px;
        padding: 16px;
    }

    .status-right {
        gap: 8px;
    }

    .status-right span {
        font-size: 11px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .toolbar-group {
        flex-wrap: wrap;
        gap: 4px;
    }

    .toolbar-btn {
        font-size: 12px;
        padding: 4px 8px;
    }

    .toolbar-btn span {
        display: none;
    }

    .main-content {
        margin-top: 100px;
    }

    #editor {
        width: 90%;
        margin: 0 auto;
    }
}

@media (min-width: 1025px) {
    .main-content {
        margin-top: 100px;
    }

    #editor {
        max-width: 1000px;
        margin: 0 auto;
    }
}

/* 编辑区内容样式 */
#editor h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 16px 0;
}

#editor h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 14px 0;
}

#editor h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 12px 0;
}

#editor p {
    margin: 8px 0;
}

#editor ul,
#editor ol {
    margin: 8px 0;
    padding-left: 24px;
}

#editor li {
    margin: 4px 0;
}

#editor strong {
    font-weight: 600;
}

#editor em {
    font-style: italic;
}

#editor u {
    text-decoration: underline;
}

#editor s {
    text-decoration: line-through;
}