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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f0;
    min-height: 100vh;
    padding: 40px 20px 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    /* padding-top: 40px; */
}

.header {
    text-align: center;
    margin-bottom: 0px;
}

.header h1 {
    margin-bottom: 10px;
    font-size: 1.8rem;
    color: #333;
    text-shadow: none;
}

.header p {
    color: #bbb;
    font-size: 1.1rem;
}

.new-entry-area {
    background: transparent;
    padding: 2px 20px 20px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    border-bottom: 1px solid #eaeaea;
}

.stats {
    color: #666;
    font-size: 0.95rem;
}

.stats strong {
    color: #667eea;
    font-size: 1.2rem;
}

.btn-new {
    background: transparent;
    color: #2a6d9c;
    border: 1px solid #2a6d9c;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-new:hover {
    background: #2a6d9c;
    color: white;
    transform: none;
    box-shadow: none;
}

.category-section {
    width: 45%;              /* 每个分类占一半宽度 */
    display: inline-block;   /* 让它们并排 */
    vertical-align: top;     /* 顶部对齐 */
    margin: 0 2%;  
    margin-bottom: 40px;
}

.category-title {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid #ccc;
    padding-left: 15px;
}

.category-title span {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.cards-grid {
    display: flex;
    flex-direction: column;
    gap: 0;              /* 去掉间距，用 border-bottom 分隔 */
    max-height: 200px;
    /* max-width: 400px; */
    overflow-y: auto;
    
}

.card {
    padding: 10px 0 0 0;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    border-bottom: 1px solid transparent;  /* 默认透明，看不到 */
    /* transition: border-bottom-color 0.2s;  过渡动画 */
}

.card:hover .card-title,
.card:hover .card-preview,
.card:hover .card-date {
    color: #0441f7;
}
.card:hover .delete-btn {
    color: #c0392b;  /* 删除按钮变深红（可选） */
}
.card:hover {
    border-bottom-color: #0441f7;
}

.card-title {
    font-size: 0.95rem;
    font-weight: normal;
    color: #2a6d9c;
    width: 150px;           /* 从 200px 改成 150px */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-preview {
    color: #aaa;
    font-size: 0.75rem;
    width: 200px;           /* 从 300px 改成 200px */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-date {
    color: #aaa;
    font-size: 0.7rem;
    margin-left: auto;       /* 自动右边距，推到最后 */
    white-space: nowrap;
}

.delete-btn {
    color: #e74c3c;
    cursor: pointer;
    font-size: 0.7rem;
    margin-left: 12px;
}

.delete-btn:hover {
    opacity: 1;
}

.empty-message {
    background: rgba(255,255,255,0.9);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    color: #999;
    font-style: italic;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    /* max-height: 80vh; */
    /* overflow-y: auto; */
    padding: 30px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

.modal-content select,
.modal-content input,
.modal-content textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
}

.modal-content select:focus,
.modal-content input:focus,
.modal-content textarea:focus {
    outline: none;
    border-color: #667eea;
}

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

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.btn-submit {
    background: #667eea;
    color: white;
}

.btn-cancel {
    background: #e0e0e0;
    color: #666;
}

.article-container {
    max-width: 900px;
    margin: 0 auto;
}

.article-card {
    background: white;
    border-radius: 20px;
    padding: 30px;           /* 从 50px 改成 30px */
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.back-link {
    display: inline-block;
    margin-bottom: 30px;
    color: #667eea;
    text-decoration: none;
    font-size: 1rem;
}

.back-link:hover {
    text-decoration: underline;
}

.article-title {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 10px;
    border-left: 3px solid #667eea;
    padding-left: 20px;
    font-weight: normal; 
}

.article-meta {
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.article-content {
    color: #333;
    line-height: 1.6;        /* 与编辑框一致 */
    font-size: 1rem;         /* 与编辑框一致 */
    font-family: monospace;  /* 与编辑框一致，等宽字体 */

    max-width: 800px;       /* 限制最大宽度 */
    margin: 0 auto;         /* 居中 */
    padding: 0 20px;        /* 左右留白 */
    min-height: 45vh;
}

.article-content h1 {
    font-size: 1.8rem;
    margin: 30px 0 15px 0;
    color: #333;
}

.article-content h2 {
    font-size: 1.5rem;
    margin: 25px 0 12px 0;
    color: #444;
}

.article-content h3 {
    font-size: 1.3rem;
    margin: 20px 0 10px 0;
    color: #555;
}

.article-content p {
    margin-bottom: 16px;
}

.article-content ul,
.article-content ol {
    margin: 15px 0 15px 30px;
}

.article-content li {
    margin-bottom: 8px;
}

.article-content code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.article-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
}

.article-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.article-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 20px;
    margin: 20px 0;
    color: #666;
}
/* 文章导航按钮 */
.article-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.nav-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-home {
    background: #f0f0f0;
    color: #666;
}

.nav-home:hover {
    background: #e0e0e0;
    color: #333;
}

.nav-prev, .nav-next {
    background: #667eea;
    color: white;
}

.nav-prev:hover, .nav-next:hover {
    background: #5a67d8;
    transform: translateX(-2px);
}

.nav-next:hover {
    transform: translateX(2px);
}

.nav-pages {
    display: flex;
    gap: 15px;
}

/* 禁用状态（没有上一篇/下一篇时） */
.nav-btn.disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    pointer-events: none;
}
.nav-edit {
    background: #2a6d9c;
    color: white;
    border: none;
    cursor: pointer;
}

.nav-edit:hover {
    background: #1a4d6e;
}

.nav-save {
    background: #27ae60;
    color: white;
    border: none;
    cursor: pointer;
}

.nav-save:hover {
    background: #219a52;
}

/* 编辑模式下的输入框样式 */
.edit-title-input {
    width: 100%;
    font-size: 1.0rem;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin: 0;
    /* font-weight: bold; */
    box-sizing: border-box;
    border-left: 2px solid #ddd;     /* 覆盖原来的左边框 */
    padding-left: 15px;                /* 确保是块级元素 */
}

.edit-content-textarea {
    width: 100% !important;
    min-height: 500px;
    padding: 15px;
    font-size: 1rem;
    line-height: 1.6;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: monospace;
    resize: vertical;
    box-sizing: border-box !important;
}
.article-card {
    overflow: hidden;
}
@media (max-width: 768px) {
    .cards-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
        max-height: 400px;
        overflow-y: auto;
        grid-template-columns: 1fr;
    }
    
    .new-entry-area {
        flex-direction: column;
        text-align: center;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .article-card {
        background: white;
        border-radius: 20px;
        padding: 30px 40px;     /* 调整内边距 */
        box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    }
    
    .article-title {
        font-size: 1.8rem;
    }
    
}
/* ============================================
   移动端适配 (手机 & 平板)
   ============================================ */

/* 平板设备 (宽度 ≤ 1024px)
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .category-section {
        width: 46%;
        margin: 0 2% 30px 2%;
    }
} */

/* 手机设备 (宽度 ≤ 768px) */
@media (max-width: 1024px) {
    /* 整体间距 */
    body {
        padding: 20px 10px;
    }
    
    .container {
        padding: 0 5px;
    }
    
    /* 头部 */
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header p {
        font-size: 0.9rem;
    }
    
    /* 分类布局：改为单列 */
    .category-section {
        width: 100%;
        margin: 0 0 30px 0;
        display: block;
    }
    
    .category-title {
        font-size: 1rem;
        padding-left: 12px;
    }
    
    /* 新建记录区域 */
    .new-entry-area {
        flex-direction: column;
        text-align: center;
        padding: 15px 20px;
    }
    
    .stats {
        font-size: 0.85rem;
    }
    
    .btn-new {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    /* 卡片列表 */
    .cards-grid {
        max-height: none;
    }
    
    /* 卡片样式：改为垂直排列，更易点击 */
    .card {
        flex-wrap: wrap;
        gap: 5px;
        padding: 12px 12px;
    }
    
    .card-title {
        width: 100%;
        font-size: 0.9rem;
        white-space: normal;
        overflow: visible;
    }
    
    .card-preview {
        width: 70%;
        font-size: 0.7rem;
        white-space: normal;
        overflow: visible;
    }
    
    .card-date {
        font-size: 0.65rem;
        /* margin-left: 0; */
    }
    
    .delete-btn {
        font-size: 0.65rem;
        margin-left: 8px;
    }
    
    /* 文章详情页 */
    .article-container {
        padding: 0 5px;
    }
    
    .article-card {
        padding: 20px 15px;
        border-radius: 12px;
    }
    
    .article-title {
        font-size: 1.2rem;
        padding-left: 12px;
    }
    
    .article-meta {
        font-size: 0.8rem;
    }
    
    .article-content {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    /* 导航按钮 */
    .article-nav {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    
    .nav-btn {
        padding: 6px 14px;
        font-size: 0.75rem;
    }
    
    .nav-pages {
        gap: 10px;
    }
    
    /* 弹窗 */
    .modal-content {
        padding: 20px;
        width: 95%;
    }
    
    .modal-content h2 {
        font-size: 1.2rem;
    }
    
    .modal-content input,
    .modal-content textarea {
        font-size: 0.9rem;
        padding: 10px;
    }
    
    .modal-content textarea {
        min-height: 150px;
    }
    
    .modal-buttons button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    /* 编辑模式 */
    .edit-title-input {
        font-size: 1.2rem;
        padding: 8px 12px;
    }
    
    .edit-content-textarea {
        font-size: 0.9rem;
        min-height: 300px;
        padding: 10px;
    }
}

/* 小屏手机 (宽度 ≤ 480px) */
@media (max-width: 480px) {
    body {
        padding: 10px 5px;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header p {
        font-size: 0.75rem;
    }
    
    .card-title {
        font-size: 0.8rem;
    }
    
    .card-preview {
        font-size: 0.65rem;
        width: 60%;
    }
    
    .article-title {
        font-size: 1rem;
    }
    
    .article-content {
        font-size: 0.8rem;
    }
    
    .nav-btn {
        padding: 5px 10px;
        font-size: 0.65rem;
    }
    
    .modal-content {
        padding: 15px;
    }
}
/* ============================================
   主页布局样式
   ============================================ */

.main-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部导航 */
.top-nav {
    background: white;
    border-bottom: 1px solid #eaeaea;
    padding: 12px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    text-decoration: none;
}

.nav-brand span {
    color: #2a6d9c;
}

.nav-menu {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-menu a {
    color: #666;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-menu a:hover {
    background: #f0f0f0;
    color: #333;
}

.nav-menu a.active {
    background: #2a6d9c;
    color: white;
}

.nav-menu a.active:hover {
    background: #1a4d6e;
}

.nav-user {
    color: #666;
    font-size: 0.9rem;
    margin-right: 10px;
}

.nav-user strong {
    color: #2a6d9c;
}

.btn-logout {
    background: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c;
    padding: 4px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #e74c3c;
    color: white;
}

.btn-login {
    background: #2a6d9c;
    color: white;
    border: none;
    padding: 6px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
}

.btn-login:hover {
    background: #1a4d6e;
}

.btn-register {
    background: transparent;
    color: #2a6d9c;
    border: 1px solid #2a6d9c;
    padding: 6px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
}

.btn-register:hover {
    background: #2a6d9c;
    color: white;
}

/* 内容区域 */
.content-area {
    flex: 1;
    padding: 20px 0px;
    background: #f5f5f0;
}

/* 未登录欢迎页 */
.welcome-page {
    max-width: 600px;
    margin: 60px auto;
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.welcome-page h1 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #333;
}

.welcome-page p {
    color: #888;
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 30px;
}

.welcome-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}
/* 笔记页头部 */
/* ============================================
   笔记页头部样式
   ============================================ */

.notes-header {
    padding: 0px 0 10px 0;
}

.notes-header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    position: relative;
}

.notes-header-top h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
}

.notes-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    position: absolute;
    right: 0;
}

.notes-header-user {
    font-size: 0.85rem;
    color: #888;
}

.notes-header-user strong {
    color: #333;
    font-weight: 600;
}

.btn-home {
    background: #f0f0f0;
    color: #555;
    padding: 6px 14px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
    width: 100px;
    white-space: nowrap;
}

.btn-home:hover {
    background: #e0e0e0;
}

.notes-subtitle {
    margin: 40px 0 0 0;
    font-size: 0.85rem;
    color: #bbb;
}
@media (max-width: 600px) {
    .notes-header-top {
        flex-direction: column;
        align-items: center;
        position: static;
    }
    .notes-header-right {
        position: static;
    }
}
/* ============================================
   下拉菜单样式
   ============================================ */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: transparent;
    /* padding: 4px 0; */
    z-index: 100;
    border: none;
    box-shadow: none;
    flex-direction: column;
    align-items: center;  /* 子元素居中 */
}

.dropdown-menu a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 20px;
    background: #f0f0f0;
    margin: 1px 0;
    transition: background 0.15s;
    line-height: 1.4;
    width: 100px;
    white-space: nowrap;
}

.dropdown-menu a:hover {
    background: #e0e0e0;
    color: #2a6d9c;
}


.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown:hover .btn-home {
    background: #e0e0e0;
}