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

html, body {
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 容器样式 */
.container {
    width: 100%;
    height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
}

/* 编辑器内部控制按钮 */
.editor-controls {
    position: absolute;
    top: 30px;
    right: 30px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    backdrop-filter: blur(5px);
    opacity: 0.3;
    transition: opacity 0.2s;
}

.editor-controls:hover {
    opacity: 1;
}

.control-btn {
    padding: 6px 12px;
    background: transparent;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    display: inline-block;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1;
}

.control-btn:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.control-text {
    font-size: 13px;
    color: #666;
    padding: 0 4px;
}

/* 编辑器样式 */
#editor {
    flex: 1;
    background: white;
    border: none;
    border-radius: 8px;
    padding: 25px;
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow-y: auto;
    outline: none;
    min-height: 400px;
    white-space: pre-wrap;
    word-wrap: break-word;
    letter-spacing: 0.3px;
    font-weight: 400;
}

#editor:empty:before {
    content: attr(data-placeholder);
    color: #999;
}

/* 拖拽样式 */
#editor.dragover {
    background: #f0f8ff;
    border: 2px dashed #007cba;
}

/* 上传的图片样式 */
.uploaded-image-container {
    position: relative;
    display: inline-block;
    margin: 15px 0;
}

.uploaded-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s;
    display: inline-block;
    user-select: none;
}

.uploaded-image:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* 图片删除按钮 */
.image-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
    z-index: 10;
    padding: 0;
}

.uploaded-image-container:hover .image-delete-btn {
    opacity: 1;
}

.image-delete-btn:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

/* 附件链接样式 */
.uploaded-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    margin: 8px 0;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #007cba;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.uploaded-file:hover {
    background: #e9ecef;
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 保存状态提示 */
#save-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    background: rgba(40, 167, 69, 0.95);
    color: white;
    border-radius: 25px;
    font-size: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 1000;
}

#save-status.show {
    opacity: 1;
    transform: translateY(0);
}

/* 通知样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s;
    z-index: 2000;
    max-width: 300px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-info {
    background: #17a2b8;
    color: white;
}

.notification-success {
    background: #28a745;
    color: white;
}

.notification-error {
    background: #dc3545;
    color: white;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    #editor {
        padding: 15px;
        font-size: 15px;
    }

    .editor-controls {
        top: 15px;
        right: 15px;
        padding: 4px 6px;
        gap: 4px;
        flex-wrap: wrap;
        max-width: calc(100% - 30px);
    }

    .control-btn {
        padding: 5px 8px;
        font-size: 12px;
    }
}

/* 打印样式 */
@media print {
    .editor-controls,
    #save-status,
    .notification {
        display: none;
    }

    #editor {
        box-shadow: none;
        border: none;
    }
}

/* 选中文本样式 */
::selection {
    background: #b3d4fc;
    color: #000;
}

/* 滚动条样式 */
#editor::-webkit-scrollbar {
    width: 8px;
}

#editor::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#editor::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

#editor::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 文字选择工具栏样式 */
.text-selection-toolbar {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 5px;
    background: #2c3e50;
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 3000;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.text-selection-toolbar.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.toolbar-btn {
    padding: 6px 12px;
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
}

.color-picker-container {
    position: relative;
}

.color-icon {
    font-weight: bold;
    color: #ffc107;
}

.color-palette {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: white;
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    z-index: 3001;
}

.color-palette.show {
    display: grid;
}

.color-palette::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid white;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-option:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 视频容器样式 */
.uploaded-video-container {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    background: #f8f9fa;
    max-width: 100%;
    display: inline-block;
    position: relative;
    transition: box-shadow 0.2s;
    user-select: all; /* 允许整体选中 */
    -webkit-user-select: all;
    -moz-user-select: all;
    -ms-user-select: all;
}

.uploaded-video-container:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.uploaded-video {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    background: #000;
    pointer-events: auto; /* 允许视频控件交互 */
}

.video-caption {
    padding: 8px 12px;
    background: #f8f9fa;
    color: #495057;
    font-size: 13px;
    border-top: 1px solid #dee2e6;
    user-select: text; /* 标题文字可以选择 */
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 文件删除按钮（视频和附件） */
.file-delete-btn {
    width: 20px;
    height: 20px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
}

.file-delete-btn:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.15);
}

/* 可编辑文件名样式 */
.file-name-editable {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.file-name-editable:hover {
    color: #007cba;
}

.file-name-input {
    padding: 2px 6px;
    border: 1px solid #007cba;
    border-radius: 3px;
    font-size: inherit;
    font-family: inherit;
    outline: none;
    background: white;
}

/* 分享模态框样式 */
.share-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.share-modal.show {
    display: block;
}

.share-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.share-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.share-close:hover,
.share-close:focus {
    color: #000;
}

.share-modal h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

.share-modal h4 {
    margin-top: 25px;
    margin-bottom: 15px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #007cba;
}

.share-link-box {
    display: flex;
    gap: 10px;
}

.share-link-box input {
    flex: 1;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #007cba;
    color: white;
}

.btn-primary:hover {
    background: #005a87;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-refresh {
    padding: 4px 8px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #f0f0f0;
}

.share-result {
    margin-top: 20px;
    padding: 15px;
    background: #f0f8ff;
    border-radius: 5px;
}

.share-history {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.share-history-list {
    max-height: 300px;
    overflow-y: auto;
}

.share-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    gap: 15px;
}

.share-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.share-item-permission {
    font-weight: 500;
    color: #333;
}

.share-item-expiry {
    font-size: 13px;
    color: #666;
}

.share-item-link input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: white;
}

.share-item-actions {
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy {
    background: #17a2b8;
    color: white;
}

.btn-copy:hover {
    background: #138496;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.loading, .empty, .error {
    text-align: center;
    padding: 20px;
    color: #666;
}

.error {
    color: #dc3545;
}

@media (max-width: 768px) {
    .share-modal-content {
        width: 95%;
        padding: 20px;
    }

    .share-item {
        flex-direction: column;
        align-items: stretch;
    }

    .share-item-actions {
        justify-content: flex-end;
    }
}
