/* ========== 全局与基础 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Microsoft YaHei", "SimSun", sans-serif;
    background-color: #f5f0e6;
    color: #333;
    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"><path d="M0,0 L100,100 M100,0 L0,100" stroke="%23e6d8c7" stroke-width="0.5" fill="none"/></svg>');
    background-size: 100px;
    min-height: 100vh;
}
body:not(.use-simple-cursor) {
    cursor: url('https://s41.ax1x.com/2026/03/26/peQLtqH.png') 0 0, auto;
}
.container { max-width: 1280px; margin: 0 auto; padding: 20px; }

/* ========== 头部美化 ========== */
header {
    position: relative;
    background-color: #fff8e8;
    background-image: 
        linear-gradient(rgba(255, 248, 232, 0.9), rgba(255, 248, 232, 0.9)),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 200"><path d="M0,150 Q200,100 400,150 T800,150 L800,200 L0,200 Z" fill="%23e6d8c7" opacity="0.4"/><path d="M0,170 Q200,120 400,170 T800,170 L800,200 L0,200 Z" fill="%23d2b48c" opacity="0.3"/></svg>');
    background-size: cover, 100% 100%;
    background-repeat: no-repeat;
    color: #8B4513;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(139, 69, 19, 0.15);
    margin-bottom: 25px;
    border: 2px solid #c37e7ed1;
    border-top: 4px solid #8B4513;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}
header::before, header::after {
    content: '✦';
    position: absolute;
    top: 10px;
    font-size: 20px;
    color: #c85a5a;
    opacity: 0.6;
}
header::before { left: 15px; }
header::after { right: 15px; }

header h1 { 
    font-family: "STKaiti", "KaiTi", serif; 
    font-size: 2.8rem; 
    letter-spacing: 6px; 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    z-index: 1;
}
header p { 
    font-family: "STKaiti", "KaiTi", serif; 
    opacity: 0.8; 
    font-size: 1.1rem;
    margin-top: 5px;
    z-index: 1;
}
.user-actions { display: flex; gap: 12px; z-index: 1; }

/* ========== 提示与模态框 ========== */
.toast {
    position: fixed; top: 80px; left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background-color: rgba(51, 51, 51, 0.95);
    color: #fff;
    border-radius: 8px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    font-family: "STKaiti", serif;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; }
.toast.error { background-color: rgba(178, 34, 34, 0.95); }
.toast.info { background-color: rgba(51, 102, 153, 0.95); }
.toast.success { background-color: rgba(34, 139, 34, 0.95); }
.toast.loading { background-color: rgba(255, 165, 0, 0.95); }

.modal-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(60, 40, 20, 0.6);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
    background: #fffdf5;
    border: 2px solid #c85a5a;
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 450px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal-close {
    position: absolute; top: 15px; right: 20px;
    background: none; border: none;
    font-size: 1.8rem; color: #8B4513;
    cursor: pointer;
    transition: transform 0.2s;
}
.modal-close:hover { transform: rotate(90deg); color: #c85a5a; }
.modal-title {
    font-family: "STKaiti", "KaiTi", serif;
    color: #8B4513;
    font-size: 2rem;
    text-align: center;
    margin-bottom: 25px;
    border-bottom: 2px dashed #d2b48c;
    padding-bottom: 15px;
}
.form-group { margin-bottom: 18px; }
.form-label {
    display: block; margin-bottom: 8px;
    color: #8B4513; font-family: "STKaiti", "KaiTi", serif;
    font-weight: bold;
}
.form-input, .form-textarea {
    width: 100%; padding: 12px 15px;
    border: 1px solid #d2b48c;
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    transition: all 0.3s;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: #c85a5a;
    box-shadow: 0 0 0 3px rgba(200, 90, 90, 0.15);
}

.form-actions { 
    display: flex; 
    gap: 12px; 
    margin-top: 25px; 
    justify-content: space-between;
}
.form-actions-left { display: flex; gap: 12px; flex: 1; }
.form-actions-right { display: flex; gap: 12px; }

.form-switch {
    text-align: center; margin-top: 20px;
    color: #8B4513; font-family: "STKaiti", "KaiTi", serif;
}
.form-switch a { color: #c85a5a; text-decoration: none; font-weight: bold; }
.form-switch a:hover { text-decoration: underline; }

/* ========== 主布局 ========== */
.main { display: flex; gap: 25px; min-height: calc(100vh - 200px); }

.sidebar {
    width: 320px;
    background: #fffdf5;
    border: 2px solid #d2b48c;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.08);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar h3 {
    font-family: "STKaiti", "KaiTi", serif;
    color: #8B4513;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #d2b48c;
    font-size: 1.5rem;
}
.create-notebook { display: flex; gap: 10px; margin-bottom: 20px; height: 52px;}
.create-notebook input {
    flex: 1; padding: 14px 12px;
    border: 1px solid #d2b48c;
    border-radius: 8px;
    font-family: "STKaiti", "KaiTi", serif;
    background: #fff;
    font-size: 18px;
    max-width: 180px;
}
.notebook-list { list-style: none; }
.notebook-list-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}
.notebook-list-container::-webkit-scrollbar { width: 6px; }
.notebook-list-container::-webkit-scrollbar-thumb { background: #d2b48c; border-radius: 3px; }

.notebook-item {
    padding: 12px 15px;
    min-height: 50px;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid #e6d8c7;
    border-left: 4px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: "STKaiti", "KaiTi", serif;
    transition: all 0.2s;
    font-size: 1.15rem;
}
.notebook-item:hover { 
    background: #fcf8f0; 
    transform: translateX(5px);
    border-left-color: #d2b48c;
}
.notebook-item.active {
    background: #f5e8d5;
    border-left-color: #c85a5a;
    border-color: #c85a5a;
    box-shadow: 0 2px 8px rgba(200, 90, 90, 0.1);
}
.notebook-name {
    flex: 1;
    margin-right: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
    color: #5d4037;
}
.notebook-actions { display: flex; gap: 8px; opacity: 1; flex-shrink: 0; }

button#saveNoteBtn{ margin: 10px; }
button#shareNoteBtn{ margin-left: 10px; }

.content {
    flex: 1;
    background: #fffdf5;
    border: 2px solid #d2b48c;
    border-radius: 12px;
    padding: 25px 35px;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.08);
    position: relative;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 15px;
    border-bottom: 2px dashed #d2b48c;
    flex-wrap: wrap;
    gap: 10px;
}
.note-header h3 { font-family: "STKaiti", "KaiTi", serif; color: #8B4513; font-size: 1.5rem; }
.note-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.note-card {
    background: #fff;
    border: 1px solid #e6d8c7;
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 160px;
    width: 100%;
    max-width: 228px;
    min-width: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.note-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: #d2b48c;
    transition: width 0.3s;
}
.note-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    transform: translateY(-5px);
}
.note-card:hover::before { width: 8px; background: #c85a5a; }

.note-card-body {
    padding: 20px 16px 20px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    justify-content: flex-start;
}
.note-card h4 {
    font-family: "STKaiti", "KaiTi", serif;
    margin-bottom: 0;
    font-size: 1.3rem;
    color: #8B4513;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.note-card p {
    display: none;
}

.note-card-footer {
    padding: 8px 12px;
    margin-top: auto;
    background: #faf7f0;
    border-top: 1px solid #f0e6d2;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.note-time {
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
    flex: 1;
    min-width: 0;
    padding-right: 8px;
}
.note-actions { display: flex; gap: 8px; opacity: 1; flex-shrink: 0; }

/* ========== 编辑器样式 ========== */

.editor-wrapper { position: relative; }

.editor-sticky-container {
    position: sticky;
    top: -5px;
    z-index: 100;
    background: #fffdf5;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    border-radius: 8px;
    border: 1px solid transparent;
}

.editor-sticky-container.is-sticky {
    box-shadow: 0 8px 20px rgba(139, 69, 19, 0.15);
    border-color: #d2b48c;
}

.editor-title {
    width: 100%;
    padding: 11px;
    border: 2px solid #d2b48c;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1.5rem;
    font-family: "STKaiti", "KaiTi", serif;
    color: #8B4513;
    background: #fff;
}
.editor-title:focus, .editor-title:focus-visible {
    outline: none;
    border-color: #d2b48c;
    background: #fffbf0;
    box-shadow: none;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: #f9f5eb;
    border: 2px solid #d2b48c;
    border-radius: 8px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.03);
    justify-content: center;
    align-content: center;
    user-select: none;
}

.toolbar-group {
    display: flex;
    gap: 6px;
    padding-right: 8px;
    margin-right: 8px;
    border-right: 1px solid #e0d0b0;
    align-items: center;
    flex-wrap: nowrap;
}
.toolbar-group:last-child { border-right: none; padding-right: 0; margin-right: 0; }

.toolbar-btn {
    width: 38px; height: 38px;
    border: 1px solid #d2b48c;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 18px;
    color: #8B4513;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.toolbar-btn:hover { 
    background: linear-gradient(135deg, #f5e8d5 0%, #f9f3e6 100%);
    border-color: #edb175c5;
    transform: translateY(-1px);
    box-shadow: 0 2px 3px rgba(0,0,0,0.05);
}

.toolbar-select {
    height: 36px;
    border: 1px solid #d2b48c;
    border-radius: 6px;
    background: #fff;
    color: #8B4513;
    font-family: "STKaiti", "KaiTi", serif;
    padding: 0 8px;
    cursor: pointer;
    outline: none;
    font-size: 16px;
    flex-shrink: 0;
}
.toolbar-select:focus { border-color: #c85a5a; }

.color-picker-wrapper {
    position: relative;
    width: 36px; height: 36px;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #d2b48c;
    cursor: pointer;
    background: #fff;
    flex-shrink: 0;
}
.color-picker-wrapper input[type="color"] {
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    cursor: pointer;
    border: none;
    padding: 0;
    background: none;
}

.editor-content {
    width: 100%;
    min-height: 400px;
    padding: 20px;
    border: 2px solid #e6d8c7;
    border-radius: 8px;
    background: #fff;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #333;
    outline: none;
    margin-top: 15px;
}
.editor-content:focus, .editor-content:focus-visible {
    border-color: #d2b48c;
    background: #fffbf0;
    outline: none;
    box-shadow: none;
}

.editor-content blockquote {
    border-left: 4px solid #c85a5a;
    margin: 15px 0;
    padding: 10px 20px;
    background: #fff8f8;
    color: #666;
    font-style: italic;
    font-family: "KaiTi", serif;
}
.editor-content .comment-box {
    color: #14a51b;
    font-weight: bold;
    padding: 2px 6px;
    display: inline-block;
    font-family: monospace;
    margin: 0 4px;
    background: rgba(20, 165, 27, 0.05);
    border-radius: 4px;
}

.editor-content pre {
    background: #282c34;
    color: #abb2bf;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
    border: 1px solid #ddd;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: hidden;
    max-width: 100%;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}
.editor-content code {
    font-family: Consolas, Monaco, "Courier New", monospace;
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    color: #c7254e;
}
.editor-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.editor-content ul, .editor-content ol { padding-left: 25px; margin: 15px 0; }

.editor-content img { 
    max-width: 100%; 
    border-radius: 4px; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.1); 
    margin: 10px 0; 
    display: block; 
    cursor: pointer;
    /* 添加懒加载支持 */
    loading: lazy;
}

.editor-content video.selected, .editor-content audio.selected {
    outline: 3px solid #c85a5a;
    outline-offset: 4px;
    box-shadow: 0 0 15px rgba(200, 90, 90, 0.3);
    border-radius: 6px;
}
.editor-content video, .editor-content audio { 
    max-width: 100%; 
    border-radius: 25px; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.1); 
    margin: 10px 0; 
    display: block;
    background: #f5be4f;
    cursor: pointer;
}

.editor-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 1rem;
}
.editor-content th, .editor-content td {
    border: 1px solid #d2b48c;
    padding: 8px 12px;
    text-align: left;
}
.editor-content th {
    background-color: #f5e8d5;
    color: #8B4513;
    font-weight: bold;
    font-family: "STKaiti", serif;
}
.editor-content tr:nth-child(even) { background-color: #fffbf0; }
.editor-content tr:hover { background-color: #fcefe6; }

.editor-content a {
    color: #4b6cb7;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 1px dashed transparent;
}
.editor-content a:hover {
    color: #182848;
    border-bottom: 1px solid #4b6cb7;
    background-color: rgba(75, 108, 183, 0.1);
}

.file-card {
    display: block;
    width: 100%;
    max-width: 600px;
    margin: 15px 0;
    border: 2px dashed #c85a5a;
    background: #fff8f8;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    user-select: none;
}
.file-card:hover {
    background: #fcefe6;
    border-style: solid;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(200, 90, 90, 0.15);
}
.file-card-inner { display: flex; align-items: center; pointer-events: none; }
.file-icon { font-size: 32px; margin-right: 15px; flex-shrink: 0; }
.file-info { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.file-name { font-weight: bold; font-size: 16px; color: #8B4513; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-remark { font-size: 13px; color: #999; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-hint {
    font-size: 12px; color: #c85a5a; background: rgba(200, 90, 90, 0.1);
    padding: 2px 6px; border-radius: 4px; align-self: flex-start; margin-top: 8px;
}

.empty-state { text-align: center; padding: 80px 20px; color: #aaa; font-family: "STKaiti", "KaiTi", serif; }
.empty-state h3 { font-size: 1.6rem; margin-bottom: 10px; color: #8B4513; }

.btn {
    padding: 10px 24px; border: none; border-radius: 8px; cursor: pointer;
    font-family: "STKaiti", "KaiTi", serif; font-size: 16px; font-weight: bold;
    transition: all 0.3s; box-shadow: 0 2px 5px rgba(0,0,0,0.1); white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, #c85a5a, #a04040); color: #fff; }
.btn-danger { background: linear-gradient(135deg, #cd3b3b, #c22e2e); color: #fff; }
.btn-edit { background: linear-gradient(135deg, #d6b257, #e2b951); color: #fff; }
.btn-secondary { background: linear-gradient(135deg, #f5f0e6, #e6d8c7); color: #8B4513; border: 1px solid #d2b48c; }
.btn-open { background: linear-gradient(135deg, #4CAF50, #45a049); color: #fff; }

.btn-notebook-edit, .btn-notebook-delete, .btn-note-edit, .btn-note-delete {
    padding: 6px 10px; font-size: 16px; border-radius: 6px; min-width: 40px; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn-note-edit, .btn-note-delete {
    background: linear-gradient(135deg, #ffffff, #ffffff);
    color: #5d4037;
    border: 1px solid #d2b48c;
}

.loading { display: flex; align-items: center; justify-content: center; padding: 40px; }
.loading::after {
    content: ""; width: 30px; height: 30px;
    border: 3px solid #d2b48c; border-top-color: #c85a5a;
    border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.debug-panel {
    position: fixed; bottom: 10px; right: 10px;
    background: #222; color: #0f0; padding: 10px; border-radius: 5px;
    font-size: 12px; max-width: 300px; max-height: 200px;
    overflow-y: auto; z-index: 99999; display: none; font-family: monospace;
}
.debug-panel.show { display: block; }

.popup-panel {
    position: fixed;
    background: #fff;
    border: 1px solid #d2b48c;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    display: grid;
    gap: 5px;
    max-width: 420px;
    animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.emoji-panel { grid-template-columns: repeat(8, 1fr); }
.kaomoji-panel { grid-template-columns: repeat(4, 1fr); }
.shape-panel { grid-template-columns: repeat(4, 1fr); }

.panel-btn {
    width: 32px; height: 32px; border: none; background: none;
    font-size: 18px; cursor: pointer; border-radius: 4px; transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.kaomoji-btn { width: auto; min-width: 60px; font-size: 14px; font-family: monospace; }
.panel-btn:hover, .kaomoji-btn:hover { background: #f5e8d5; }

.toolbar-more-btn {
    display: none;
    font-weight: bold;
    font-size: 1.25rem;
    line-height: 1;
}
.toolbar-collapsible {
    display: contents;
}

@media (max-width: 768px) {
    .main { flex-direction: column; }
    .sidebar { width: 100%; height: auto; max-height: 300px; }
    header { flex-direction: column; gap: 15px; text-align: center; padding: 20px; }
    header::before, header::after { display: none; }
    .user-actions { justify-content: center; flex-wrap: wrap; }
    .note-list { grid-template-columns: 1fr; justify-items: stretch; }
    .editor-toolbar { justify-content: center; }
    .toolbar-group { border-right: none; margin-right: 0; padding-right: 0; }
    .form-actions { flex-direction: column; }
    .form-actions-left, .form-actions-right { width: 100%; }
    .toolbar-more-btn { display: flex; }
    .toolbar-collapsible {
        display: none;
        flex-basis: 100%;
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }
    .toolbar-collapsible.is-open {
        display: flex;
    }
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100000;
    padding: 12px 20px;
    background: #8B4513;
    color: #fff;
    font-family: "STKaiti", "KaiTi", serif;
    border-radius: 0 0 8px 0;
    text-decoration: none;
}
.skip-link:focus {
    left: 0;
    outline: 3px solid #c85a5a;
    outline-offset: 2px;
}

.form-input:focus-visible, .form-textarea:focus-visible,
.toolbar-btn:focus-visible, .toolbar-select:focus-visible,
.btn:focus-visible, .notebook-item:focus-visible, .note-card:focus-visible {
    outline: 2px solid #c85a5a;
    outline-offset: 2px;
}

body.use-simple-cursor {
    cursor: auto;
}
body:not(.use-simple-cursor) a,
body:not(.use-simple-cursor) button,
body:not(.use-simple-cursor) input,
body:not(.use-simple-cursor) textarea,
body:not(.use-simple-cursor) select,
body:not(.use-simple-cursor) .btn,
body:not(.use-simple-cursor) .notebook-item,
body:not(.use-simple-cursor) .note-card,
body:not(.use-simple-cursor) .toolbar-btn,
body:not(.use-simple-cursor) [contenteditable],
body:not(.use-simple-cursor) .file-card {
    cursor: url('https://s41.ax1x.com/2026/03/26/peQLtqH.png') 0 0, auto !important;
}
