* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #eef2f7;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.wiki-app {
    max-width: 1200px;
    width: 100%;
    background: #ffffff;
    border-radius: 32px;
    box-shadow: 0 30px 60px -20px rgba(0, 20, 40, 0.3);
    padding: 24px 28px 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.wiki-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #e3ebf5;
}

.wiki-brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wiki-brand h1 { font-size: 1.9rem; font-weight: 700; color: #0b1e33; }
.wiki-brand .version-tag { background: #dce6f2; padding: 4px 16px; border-radius: 60px; font-size: 0.7rem; font-weight: 600; color: #1f3a57; }
.badge-github { background: #24292f; color: white; padding: 2px 12px; border-radius: 40px; font-size: 0.7rem; }

.nav-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f2f6fc;
    padding: 4px 16px 4px 12px;
    border-radius: 60px;
    border: 1px solid #d5e0ed;
}
.user-info .avatar { font-size: 1.4rem; color: #4a6a85; }
.user-info .username { font-weight: 600; color: #0b1e33; }
.user-info .role-tag {
    font-size: 0.7rem;
    background: #1f3a57;
    color: white;
    padding: 2px 14px;
    border-radius: 60px;
    font-weight: 600;
}
.role-tag.owner { background: #b3413d; }
.role-tag.admin { background: #2c5f7a; }
.role-tag.member { background: #4b6f8c; }

.btn {
    border: none;
    padding: 8px 20px;
    border-radius: 60px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.12s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecf2fa;
    color: #1f3a57;
    border: 1px solid #d3dfee;
}
.btn:hover { background: #dce6f4; border-color: #a8bdd7; }
.btn.primary { background: #1f3a57; color: white; border-color: #1f3a57; }
.btn.primary:hover { background: #122b44; }
.btn.outline { background: transparent; border-color: #bccbd9; }
.btn.danger { background: #b3413d; color: white; border-color: #b3413d; }
.btn.danger:hover { background: #8f2e2a; }

.page-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e3ebf5;
    align-items: center;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 8px 22px;
    border-radius: 60px;
    font-weight: 500;
    font-size: 0.95rem;
    color: #3d5775;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab-btn:hover { background: #f0f5fc; }
.tab-btn.active {
    background: #ffffff;
    border-color: #c4d3e6;
    box-shadow: 0 4px 12px rgba(0, 20, 40, 0.06);
    color: #0b1e33;
    font-weight: 600;
}
.tab-btn .delete-page-btn {
    background: none;
    border: none;
    color: #b3413d;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 4px;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.tab-btn .delete-page-btn:hover { opacity: 1; }
.tab-btn .path-hint { font-size: 0.65rem; color: #8aa0b9; margin-left: 4px; opacity: 0.7; }
.tab-btn .lock-icon { font-size: 0.7rem; opacity: 0.6; margin-left: 4px; }

.page-container {
    background: #fafcff;
    border-radius: 20px;
    padding: 24px 28px;
    border: 1px solid #e3ebf5;
    min-height: 320px;
}

.wiki-page { display: none; animation: fadeIn 0.25s ease; }
.wiki-page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0.4; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e6edf6;
}

.page-title-wrapper h2 { font-size: 1.8rem; font-weight: 600; color: #112433; }
.page-title-wrapper .sub { font-size: 0.9rem; color: #5b7593; font-weight: 400; }
.page-title-wrapper .path-display { font-size: 0.8rem; color: #8aa0b9; margin-top: 4px; font-family: monospace; }

.page-meta { font-size: 0.8rem; color: #5b7593; background: #edf3fa; padding: 4px 16px; border-radius: 60px; }

.wiki-content { font-size: 1.05rem; line-height: 1.8; color: #1d3349; }
.wiki-content p { margin-bottom: 16px; }
.wiki-content ul, .wiki-content ol { padding-left: 28px; margin: 10px 0 18px; }
.wiki-content li { margin-bottom: 4px; }

[contenteditable="true"] {
    outline: none;
    border-radius: 4px;
    padding: 0 3px;
    transition: background 0.1s;
}
[contenteditable="true"]:hover { background: rgba(60, 120, 200, 0.06); }
[contenteditable="true"]:focus {
    background: rgba(60, 120, 200, 0.08);
    box-shadow: 0 0 0 2px rgba(60, 120, 200, 0.15);
}
[contenteditable="false"] { cursor: default; opacity: 0.85; }
[contenteditable="false"]:hover { background: transparent !important; box-shadow: none !important; }

.admin-locked {
    border-left: 4px solid #b3413d;
    padding-left: 16px;
    background: #fdf6f4;
    border-radius: 8px;
    padding: 10px 18px;
    margin: 12px 0;
}
.admin-editable {
    border-left: 4px solid #2c5f7a;
    padding-left: 16px;
    background: #f2f8fe;
    border-radius: 8px;
    padding: 10px 18px;
    margin: 12px 0;
}

.wiki-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e3eaf3;
}
.footer-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.footer-info { color: #3f5c7a; font-size: 0.9rem; }

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 999;
}
.modal-overlay.show { display: flex; }

.modal-box {
    background: #ffffff;
    border-radius: 32px;
    padding: 36px 40px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.modal-box h2 { font-size: 1.6rem; margin-bottom: 6px; color: #0b1e33; }
.modal-box .sub { color: #5b7593; margin-bottom: 20px; font-size: 0.95rem; }
.modal-box label { display: block; font-weight: 500; margin-top: 14px; margin-bottom: 4px; color: #1f3a57; }
.modal-box input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 60px;
    border: 1px solid #d5e0ed;
    font-size: 1rem;
    font-family: inherit;
    transition: border 0.15s;
}
.modal-box input:focus {
    outline: none;
    border-color: #7f9bc0;
    box-shadow: 0 0 0 3px rgba(60, 110, 180, 0.1);
}
.modal-box .form-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.modal-box .form-actions .btn { flex: 1; justify-content: center; }
.modal-box .switch-link { text-align: center; margin-top: 16px; color: #3d5775; cursor: pointer; }
.modal-box .switch-link span { color: #1f3a57; font-weight: 600; }
.modal-box .switch-link span:hover { text-decoration: underline; }
.modal-close {
    float: right;
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #8aa0b9;
    line-height: 1;
}
.modal-close:hover { color: #0b1e33; }

@media (max-width: 700px) {
    .wiki-app { padding: 16px; }
    .wiki-nav { flex-direction: column; align-items: stretch; gap: 12px; }
    .nav-right { justify-content: space-between; }
    .page-tabs { gap: 4px; }
    .tab-btn { padding: 6px 14px; font-size: 0.8rem; }
    .page-container { padding: 16px; }
    .modal-box { padding: 24px 20px; }
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #f8fafc;
    border-radius: 60px;
    margin-bottom: 6px;
    border: 1px solid #e3ebf5;
    flex-wrap: wrap;
    gap: 6px;
}
.user-item .user-name { font-weight: 500; }
.user-item .user-role {
    font-size: 0.8rem;
    padding: 2px 14px;
    border-radius: 60px;
    font-weight: 600;
}
.user-item .user-role.owner { background: #b3413d; color: white; }
.user-item .user-role.admin { background: #2c5f7a; color: white; }
.user-item .user-role.member { background: #4b6f8c; color: white; }
.user-item .user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-item .user-actions .btn { padding: 4px 14px; font-size: 0.8rem; }

.page-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 6px;
    border: 1px solid #e3ebf5;
    flex-wrap: wrap;
    gap: 6px;
}
.page-list-item .page-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-list-item .page-path {
    font-size: 0.8rem;
    color: #2c5f7a;
    background: #e8edf4;
    padding: 2px 12px;
    border-radius: 40px;
    font-family: monospace;
}
.page-list-item .page-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.page-list-item .page-actions .btn { padding: 4px 14px; font-size: 0.8rem; }

.github-config {
    background: #f6f8fa;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #d0d7de;
}
.github-config label {
    display: block;
    font-weight: 500;
    margin-top: 8px;
    margin-bottom: 4px;
    color: #1f3a57;
}
.github-config input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #d0d7de;
    font-size: 0.9rem;
    font-family: monospace;
}
.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 40px;
}
.sync-status.online { background: #dafbe1; color: #1a7f37; }
.sync-status.offline { background: #ffe3e6; color: #cf222e; }
.sync-status.syncing { background: #fff8c5; color: #9a6700; }

.save-btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.save-btn-disabled:hover {
    opacity: 0.5;
    background: #ecf2fa;
    border-color: #d3dfee;
}
