/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    background: #f5f4ef;
    overflow: hidden;
    height: 100vh;
}

.app {
    height: 100%;
    min-height: 100vh;       /* 确保容器至少占满视口高度 */
    background: white;
    display: flex;
    flex-direction: column;
}

.panels-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* 通用面板样式 */
.panel {
    background: white;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.2s ease;
}

.panel-a {
    background: #fefaf5;
    border-right: 1px solid #e2ddd2;
}
.panel-b {
    background: #ffffff;
}
.panel-c {
    background: #fbf9f6;
    border-left: 1px solid #e2ddd2;
}

/* 侧边栏内部结构 */
.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem 0 1rem 0;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.8rem 0.8rem 0.8rem;
    border-bottom: 1px solid #e2ddd2;
}
.logo-area {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
}
.logo {
    font-size: 1.8rem;
    flex-shrink: 0;
}
.team-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #5a6e4a;
    letter-spacing: 1px;
}
.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.2s;
}
.icon-btn:hover {
    background: #e8e2d8;
}

/* 侧边栏收起样式（窄栏） */
.panel-a.collapsed {
    width: 70px !important;
    flex: 0 0 70px !important;
    min-width: 70px;
}
.panel-a.collapsed .toc-title,
.panel-a.collapsed .toc-list,
.panel-a.collapsed .team-intro {
    display: none;
}
.panel-a.collapsed .sidebar-header {
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 0.8rem 0;
}
.panel-a.collapsed .logo-area {
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
}
.panel-a.collapsed .team-name {
    font-size: 0.8rem;
    writing-mode: horizontal-tb;
    margin-top: 4px;
}
.panel-a.collapsed .header-actions {
    justify-content: center;
    margin: 0 auto;
}
.panel-a.collapsed .icon-btn {
    font-size: 1rem;
}
.panel-a.collapsed #searchBtn {
    display: inline-block;
}
.panel-a.collapsed .team-intro {
    display: none;
}

.toc-title {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 1rem 0.8rem 0.5rem 0.8rem;
    color: #7c6e54;
    letter-spacing: 1px;
}

.toc-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.4rem;
    margin-bottom: 1rem;
}
.toc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.6rem;
    margin: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #3e3a33;
    transition: all 0.1s;
}
.toc-item:hover {
    background: #ece5db;
}
.toc-item.active {
    background: #dde4d4;
    color: #2c5234;
    font-weight: 500;
    border-left: 3px solid #8faa7b;
}
.toc-item .toc-text {
    flex: 1;
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
}
.toc-item .toc-actions {
    display: none;
    gap: 5px;
    margin-left: 8px;
}
body.admin-mode .toc-item .toc-actions {
    display: flex;
}
.toc-actions button {
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    color: #7c6e54;
}
.toc-actions button:hover {
    background: #d9cfbf;
    color: #3a5a2e;
}

.team-intro {
    padding: 0.8rem;
    border-top: 1px solid #e2ddd2;
}
.contact-icons {
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.contact-icons .icon-btn {
    font-size: 1.5rem;
    padding: 6px 12px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}
.contact-icons .icon-btn:hover {
    background: #e8e2d8;
}

.panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 76px 1.5rem 1.2rem 0.8rem;
    overflow: hidden;
}

.current-chapter {
    font-size: 1.2rem;
    font-weight: 500;
    color: #5a6e4a;
    padding-left: 0;
    margin-bottom: 1rem;
    margin-left: -2px;
}
.original-text, .commentary-text {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    font-size: 1.05rem;
    line-height:2.1;
}
.original-text {
    font-family: "Courier New", "宋体", monospace;
    white-space: pre-wrap;
}
.commentary-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    margin-top: 0.2rem;
    color: #7a6747;
}
.commentary-text {
    font-size: 1rem;
}
.placeholder {
    color: #bbb094;
    text-align: center;
    padding: 2rem;
}

.resizer {
    width: 6px;
    background: #d9d4ca;
    cursor: ew-resize;
    transition: background 0.1s;
    position: relative;
    z-index: 10;
}
.resizer:hover, .resizer.active {
    background: #b0aa98;
}
.panel-a.collapsed + .resizer-ab {
    display: none;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: #fffef7;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 30px rgba(0,0,0,0.2);
    position: relative;
}
.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}
.close-btn:hover {
    color: black;
}
.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #5a6e4a;
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd2c0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #fefcf8;
}
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 1rem;
}
.submit-btn, .export-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 500;
}
.submit-btn {
    background: #7c9a6e;
    color: white;
}
.export-btn {
    background: #d9cba3;
    color: #4a5b3a;
}
.modal-tip {
    font-size: 0.8rem;
    color: #b97f4b;
    margin-top: 1rem;
    border-top: 1px dashed #e2d5c0;
    padding-top: 0.8rem;
}
.delete-chapter-btn {
    background: #d97a6e;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
    margin-left: auto;
}

/* 搜索结果样式 */
.search-result-item {
    padding: 10px;
    border-bottom: 1px solid #e2ddd2;
    cursor: pointer;
    transition: background 0.2s;
}
.search-result-item:hover {
    background: #f0ede5;
}
.search-result-title {
    font-weight: 600;
    color: #5a6e4a;
    margin-bottom: 4px;
}
.search-result-snippet {
    font-size: 0.85rem;
    color: #5a5a4a;
    line-height: 1.4;
}
.search-result-snippet mark {
    background: #ffeb3b;
    padding: 0 2px;
    border-radius: 3px;
}
.original-text mark {
    background: #ffeb3b;
    padding: 0 2px;
    border-radius: 3px;
}

/* 强制显示 footer 备案号 */
footer {
    display: block !important;
    position: relative !important;
    bottom: auto !important;
    height: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    clear: both !important;
    width: 100% !important;
    text-align: center !important;
    padding: 1.5rem 0 !important;
    background: #fefcf8 !important;
    border-top: 1px solid #e2ddd2 !important;
}
footer a {
    color: #8f8c7e !important;
    text-decoration: none !important;
    font-size: 0.85rem !important;
}
footer a:hover {
    text-decoration: underline !important;
}

/* 移动端适配 */
@media (max-width: 800px) {
    .panels-container {
        flex-direction: column;
    }
    .resizer {
        display: none;
    }
    .panel {
        width: 100% !important;
        height: 33vh;
    }
    .panel-a.collapsed {
        width: 100% !important;
        height: auto;
    }
    .panel-a.collapsed .sidebar-header {
        flex-direction: row;
        justify-content: space-between;
        padding: 0.5rem 0.8rem;
    }
    .panel-a.collapsed .logo-area {
        flex-direction: row;
    }
    .panel-a.collapsed .team-name {
        display: inline-block;
    }
    .panel-content {
        padding-top: 2rem;
        padding-left: 0.8rem;
    }
    .contact-icons .icon-btn {
        font-size: 1.2rem;
        padding: 4px 8px;
    }
    footer {
        padding: 1rem 0 !important;
    }
}
/* 解读区域段落间距 */
.commentary-text p {
    margin-bottom: 1rem;
}
/* 解读区域列表样式 */
.commentary-text ul {
    list-style-type: disc;      /* 显示小黑点 */
    padding-left: 1.5rem;       /* 缩进 */
    margin: 0.4rem 0 0.8rem 0;
}

.commentary-text li {
    margin-bottom: 0.2rem;
}