/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0066cc;
    --primary-hover: #0052a3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --background-color: #ffffff;
    --surface-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-muted: #6c757d;
    --link-color: #0066cc;
    --link-hover: #004080;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.15);
    --border-radius: 6px;
    --font-family: 'Microsoft YaHei', 'SimSun', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Source Han Sans SC' !important;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

/* Force Chinese fonts for all text */
* {
    font-family: 'Microsoft YaHei', 'SimSun', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Source Han Sans SC' !important;
}

/* Override any other font declarations */
body, html, div, span, p, h1, h2, h3, h4, h5, h6, a, button, input, textarea {
    font-family: 'Microsoft YaHei', 'SimSun', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Source Han Sans SC' !important;
}

/* App Layout */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    max-width: 100%;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    max-height: 60px;
    width: auto;
    border-radius: 12px;
    object-fit: contain;
    border: 3px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.logo h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--surface-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.search-result {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.search-result:hover {
    background: var(--surface-color);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 500;
    color: var(--text-color);
}

.search-result-snippet {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Settings Dropdown */
.settings-dropdown {
    position: relative;
}

.settings-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 280px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-section {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-item {
    margin-bottom: 0.75rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color);
}

.setting-checkbox {
    display: none;
}

.setting-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    transition: background 0.3s;
}

.setting-slider:before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.setting-checkbox:checked + .setting-slider {
    background: var(--primary-color);
}

.setting-checkbox:checked + .setting-slider:before {
    transform: translateX(20px);
}

.setting-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    border: none;
    background: none;
    color: var(--text-color);
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: background 0.2s;
    margin-bottom: 0.25rem;
}

.setting-button:last-child {
    margin-bottom: 0;
}

.setting-button:hover {
    background: var(--surface-color);
}

.setting-button.danger {
    color: #ef4444;
}

.setting-button.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.setting-button i {
    width: 16px;
    height: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn i {
    width: 16px;
    height: 16px;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    overflow-y: auto;
    height: calc(100vh - 80px);
    position: sticky;
    top: 80px;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-section h3 {
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.page-list,
.recent-list {
    list-style: none;
}

.page-link,
.recent-link {
    display: block;
    padding: 0.5rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    transition: background-color 0.2s;
    font-size: 0.875rem;
}

.page-link:hover,
.recent-link:hover {
    background: rgba(0, 102, 204, 0.1);
}

.page-link.active {
    background: var(--primary-color);
    color: white;
    font-weight: 500;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    max-width: calc(100vw - 280px);
}

/* Page View */
.page-view {
    max-width: 800px;
}

.page-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2.25rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.page-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.page-content {
    line-height: 1.7;
}

/* Typography in content */
.page-content h1,
.preview-content h1 {
    font-size: 2rem;
    font-weight: 400;
    margin: 2rem 0 1rem 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.page-content h2,
.preview-content h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin: 1.5rem 0 0.75rem 0;
}

.page-content h3,
.preview-content h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 1.25rem 0 0.5rem 0;
}

.page-content p,
.preview-content p {
    margin-bottom: 1rem;
}

.page-content ul,
.page-content ol,
.preview-content ul,
.preview-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.page-content li,
.preview-content li {
    margin-bottom: 0.25rem;
}

.page-content a,
.preview-content a {
    color: var(--link-color);
    text-decoration: none;
}

.page-content a:hover,
.preview-content a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.page-content code,
.preview-content code {
    background: var(--surface-color);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.page-content pre,
.preview-content pre {
    background: var(--surface-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin-bottom: 1rem;
}

.page-content pre code,
.preview-content pre code {
    background: none;
    padding: 0;
}

.page-content hr,
.preview-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

.page-content strong,
.preview-content strong {
    font-weight: 600;
}

.page-content em,
.preview-content em {
    font-style: italic;
}

/* Page Edit */
.page-edit {
    max-width: 100%;
}

.edit-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1.5rem;
    font-weight: 400;
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    height: calc(100vh - 300px);
}

.editor-panel,
.preview-panel {
    display: flex;
    flex-direction: column;
}

.editor-panel h4,
.preview-panel h4 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.page-editor {
    flex: 1;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    resize: none;
}

.page-editor:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.preview-content {
    flex: 1;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--background-color);
    overflow-y: auto;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--background-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content.modal-large {
    min-width: 600px;
    max-width: 800px;
    width: 90vw;
}

/* History List */
.history-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 1rem 0;
}

.history-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    background: var(--surface-color);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.history-content {
    max-height: 100px;
    overflow-y: auto;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.4;
}

/* Stats Content */
.stats-content {
    margin: 1rem 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.stats-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.stats-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stats-list li:last-child {
    border-bottom: none;
}

/* Image Management */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
    max-height: 400px;
    overflow-y: auto;
}

.image-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--surface-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.image-preview {
    width: 100%;
    height: 120px;
    object-fit: cover;
    background: var(--background-color);
    display: block;
}

.image-info {
    padding: 0.75rem;
}

.image-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.image-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.image-actions {
    display: flex;
    gap: 0.5rem;
}

.image-action-btn {
    flex: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--background-color);
    color: var(--text-color);
    border-radius: calc(var(--border-radius) / 2);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.image-action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.image-action-btn.danger {
    color: #ef4444;
    border-color: #ef4444;
}

.image-action-btn.danger:hover {
    background: #ef4444;
    color: white;
}

.empty-images {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.empty-images i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Image upload progress */
.upload-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    min-width: 300px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s;
}

/* Image in content */
.page-content img,
.preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin: 1rem 0;
    box-shadow: var(--shadow);
}

.page-content .image-caption,
.preview-content .image-caption {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-style: italic;
}

.modal-content h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.new-page-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile First Responsive Design - 삼성 A16 최적화 */

/* 삼성 A16 화면 크기: 412x915px (대략 360-412px 너비) */
@media (max-width: 768px) {
    /* 헤더 모바일 최적화 */
    .header-content {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .logo {
        justify-content: center;
        margin-bottom: 0.5rem;
    }
    
    .logo-icon {
        max-height: 45px;
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    /* 검색 영역 */
    .search-container {
        order: 2;
        max-width: none;
        width: 100%;
    }
    
    .search-input {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    /* 헤더 액션 버튼들 */
    .header-actions {
        order: 3;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .btn {
        flex: 1;
        min-width: 80px;
        justify-content: center;
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
    
    /* 메인 콘텐츠 레이아웃 */
    .main-content {
        flex-direction: column;
        min-height: calc(100vh - 140px);
    }
    
    /* 사이드바 모바일 적응 */
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 200px;
        overflow-y: auto;
        padding: 1rem 0;
    }
    
    .nav-section {
        margin-bottom: 1rem;
    }
    
    .nav-section h3 {
        padding: 0 1rem;
        font-size: 0.8rem;
    }
    
    .page-link,
    .recent-link {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }
    
    /* 콘텐츠 영역 */
    .content-area {
        max-width: 100%;
        padding: 1rem;
        overflow-x: hidden;
    }
    
    /* 페이지 제목 */
    .page-title {
        font-size: 1.8rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    /* 편집기 레이아웃 */
    .editor-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        height: auto;
    }
    
    .edit-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .page-title-input {
        font-size: 1.25rem;
        padding: 0.75rem;
    }
    
    .edit-actions {
        justify-content: center;
    }
    
    .page-editor {
        min-height: 300px;
        font-size: 0.9rem;
    }
    
    /* 모달 최적화 */
    .modal-content {
        margin: 0.5rem;
        min-width: auto;
        width: calc(100% - 1rem);
        max-width: none;
        padding: 1.5rem;
        max-height: 90vh;
    }
    
    .modal-content.modal-large {
        min-width: auto;
        width: calc(100% - 1rem);
    }
    
    /* 설정 메뉴 */
    .settings-menu {
        width: calc(100vw - 2rem);
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        max-height: 70vh;
    }
    
    /* 이미지 그리드 */
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .image-preview {
        height: 100px;
    }
}

/* 삼성 A16 및 소형 모바일 디바이스 (360-412px) */
@media (max-width: 480px) {
    /* 헤더 최적화 */
    .header-content {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    
    .logo {
        margin-bottom: 0.25rem;
    }
    
    .logo-icon {
        max-height: 40px;
    }
    
    .logo h1 {
        font-size: 1.1rem;
    }
    
    /* 버튼들 더 작게 */
    .btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
        min-width: 70px;
    }
    
    .btn i {
        width: 14px;
        height: 14px;
    }
    
    /* 페이지 제목 더 작게 */
    .page-title {
        font-size: 1.5rem;
    }
    
    /* 콘텐츠 패딩 줄이기 */
    .content-area {
        padding: 0.75rem;
    }
    
    .page-header {
        padding-bottom: 0.75rem;
        margin-bottom: 1.5rem;
    }
    
    /* 편집기 최적화 */
    .editor-container {
        gap: 0.75rem;
    }
    
    .page-editor {
        min-height: 250px;
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    /* 모달 더 작게 */
    .modal-content {
        margin: 0.25rem;
        width: calc(100% - 0.5rem);
        padding: 1rem;
    }
    
    /* 검색 결과 */
    .search-result {
        padding: 0.6rem 0.75rem;
    }
    
    .search-result-title {
        font-size: 0.9rem;
    }
    
    .search-result-snippet {
        font-size: 0.8rem;
    }
    
    /* 이미지 그리드 작은 화면용 */
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }
    
    .image-preview {
        height: 80px;
    }
    
    .image-info {
        padding: 0.5rem;
    }
    
    .image-name {
        font-size: 0.8rem;
    }
    
    .image-size {
        font-size: 0.7rem;
    }
    
    /* 사이드바 축소 */
    .sidebar {
        max-height: 150px;
        padding: 0.75rem 0;
    }
    
    .nav-section {
        margin-bottom: 0.75rem;
    }
    
    .page-link,
    .recent-link {
        padding: 0.3rem 1rem;
        font-size: 0.8rem;
    }
}

/* 매우 작은 화면 (320px 이하) */
@media (max-width: 360px) {
    .header-content {
        padding: 0.5rem;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
        min-width: 60px;
    }
    
    .page-title {
        font-size: 1.3rem;
    }
    
    .content-area {
        padding: 0.5rem;
    }
    
    .modal-content {
        padding: 0.75rem;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .image-preview {
        height: 70px;
    }
}

/* 터치 최적화 - 삼성 A16용 */
@media (pointer: coarse) {
    /* 터치 타겟 크기 최소 44px 보장 */
    .btn,
    .page-link,
    .recent-link,
    .search-result,
    .setting-button {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .footnote-ref {
        padding: 8px;
        margin: -8px;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 터치 스크롤 개선 */
    .sidebar,
    .content-area,
    .search-results,
    .modal-content {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* 터치 피드백 개선 */
    .btn:active,
    .page-link:active,
    .recent-link:active,
    .search-result:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* PWA 지원 및 노치 대응 */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .content-area {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* 한글 폰트 최적화 */
@media (max-width: 768px) {
    body {
        font-family: 'Microsoft YaHei', 'SimSun', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans SC', 'Source Han Sans SC' !important;
        word-break: keep-all;
        word-wrap: break-word;
    }
    
    .page-content,
    .preview-content {
        line-height: 1.8;
        font-size: 0.95rem;
    }
    
    /* 한글 텍스트 가독성 개선 */
    .page-content p,
    .preview-content p {
        margin-bottom: 1.2rem;
        text-align: justify;
        text-justify: inter-word;
    }
}

/* 다크모드 모바일 최적화 */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .page-content,
    .preview-content {
        color: #e8e8e8;
    }
    
    .page-content code,
    .preview-content code {
        background: #2a2a2a;
        color: #ff6b6b;
    }
}

/* Print styles */
@media print {
    .header,
    .sidebar,
    .edit-header,
    .modal {
        display: none !important;
    }
    
    .main-content {
        flex-direction: column;
    }
    
    .content-area {
        max-width: 100%;
        padding: 0;
    }
    
    .page-content {
        font-size: 12pt;
        line-height: 1.5;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-muted: #333333;
        --surface-color: #f0f0f0;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1a1a1a;
        --surface-color: #2d2d2d;
        --border-color: #404040;
        --text-color: #e0e0e0;
        --text-muted: #a0a0a0;
        --link-color: #4da6ff;
        --link-hover: #66b3ff;
        --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4);
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible improvements */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Dark mode override */
body.dark-mode {
    --background-color: #1a1a1a;
    --surface-color: #2d2d2d;
    --border-color: #404040;
    --text-color: #e0e0e0;
    --text-muted: #a0a0a0;
    --link-color: #4da6ff;
    --link-hover: #66b3ff;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Selection styling */
::selection {
    background: rgba(0, 102, 204, 0.2);
}

/* Wiki-specific styles */
.wiki-category {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #0ea5e9;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    display: inline-block;
    font-size: 0.875rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.wiki-category.category-link {
    cursor: pointer;
    user-select: none;
}

.wiki-category.category-link:hover {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border-color: #0284c7;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.category-label {
    font-weight: 600;
    color: #0369a1;
}

.category-name {
    color: #1e40af;
    font-weight: 500;
}

.wiki-toc {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    max-width: 350px;
    box-shadow: var(--shadow);
}

.wiki-toc h4 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.wiki-toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wiki-toc li {
    margin: 0.5rem 0;
    padding-left: 1rem;
    position: relative;
}

.wiki-toc li:before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-size: 0.8rem;
    top: 0.1rem;
}

.wiki-toc a {
    color: var(--link-color);
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: color 0.2s;
}

.wiki-toc a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Enhanced strikethrough text */
del {
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-style: solid;
    text-decoration-thickness: 2px;
    opacity: 0.7;
}

/* Enhanced page content typography */
.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4,
.page-content h5,
.page-content h6,
.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    color: var(--text-color);
    font-weight: 600;
    line-height: 1.3;
}

.page-content h1,
.preview-content h1 {
    font-size: 2.25rem;
    margin: 2rem 0 1.5rem 0;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.page-content h2,
.preview-content h2 {
    font-size: 1.75rem;
    margin: 2rem 0 1rem 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.page-content h3,
.preview-content h3 {
    font-size: 1.5rem;
    margin: 1.75rem 0 0.75rem 0;
}

.page-content h4,
.preview-content h4 {
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem 0;
}

.page-content h5,
.preview-content h5 {
    font-size: 1.125rem;
    margin: 1.25rem 0 0.5rem 0;
}

.page-content h6,
.preview-content h6 {
    font-size: 1rem;
    margin: 1rem 0 0.5rem 0;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Enhanced code and pre styling */
.page-content code,
.preview-content code {
    background: var(--surface-color);
    color: #e11d48;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.875em;
    border: 1px solid var(--border-color);
}

.page-content pre,
.preview-content pre {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid #374151;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.page-content pre code,
.preview-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
    border-radius: 0;
}

/* Footnotes styling */
.footnote-ref {
    font-size: 0.75rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    padding: 0 2px;
    transition: color 0.2s;
    cursor: pointer;
}

.footnote-ref:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.footnote-backref {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    margin-left: 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.footnote-backref:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Footnote popup (Namuwiki style) */
.footnote-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: var(--background-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 500px;
    animation: footnote-popup-appear 0.2s ease-out;
}

@keyframes footnote-popup-appear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.footnote-popup-content {
    padding: 0;
}

.footnote-popup-header {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.footnote-popup-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.footnote-popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.footnote-popup-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.footnote-popup-body {
    padding: 1rem;
    line-height: 1.5;
    border-bottom: 1px solid var(--border-color);
}

.footnote-popup-footer {
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: flex-end;
}

.footnote-popup-goto {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.footnote-popup-goto:hover {
    background: var(--border-color);
}

/* Update history modal styles */
.update-history-content {
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem;
    line-height: 1.6;
}

.update-history-content h1,
.update-history-content h2,
.update-history-content h3,
.update-history-content h4 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.update-history-content h1 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.update-history-content ul,
.update-history-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.update-history-content li {
    margin-bottom: 0.25rem;
}

.update-history-content code {
    background: var(--surface-color);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.update-history-content pre {
    background: var(--surface-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 1rem 0;
}

.loading-text {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.error-message {
    text-align: center;
    color: var(--text-color);
    padding: 2rem;
}

.error-details {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.footnotes-section {
    margin-top: 3rem;
    border-top: 2px solid var(--border-color);
    padding-top: 2rem;
}

.footnotes-section h4 {
    color: var(--text-color);
    font-size: 1.1rem;
    margin: 0 0 1rem 0;
    font-weight: 600;
}

.footnotes-list {
    padding-left: 2rem;
    margin: 0;
    list-style: decimal;
}

.footnotes-list li {
    margin: 0.75rem 0;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color-subtle);
    font-size: 0.9rem;
    line-height: 1.5;
}

.footnotes-list li:last-child {
    border-bottom: none;
}

.footnote-content {
    color: var(--text-color);
}

.footnote-backref {
    margin-left: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 2px 4px;
    border-radius: 3px;
    background: var(--surface-color);
    transition: all 0.2s;
}

.footnote-backref:hover {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
}

.footnote {
    scroll-margin-top: 100px;
    transition: background-color 0.3s;
}

.footnote.highlighted {
    background-color: var(--accent-bg);
    border-radius: 4px;
    padding: 0.75rem;
    margin: 0.5rem -0.5rem;
}

/* Enhanced blockquotes */
.page-content blockquote,
.preview-content blockquote {
    border-left: 4px solid var(--primary-color);
    background: var(--surface-color);
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    font-style: italic;
    color: var(--text-muted);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    box-shadow: var(--shadow);
}

/* Enhanced links */
.page-content a,
.preview-content a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.page-content a:hover,
.preview-content a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

.page-content .internal-link,
.preview-content .internal-link {
    color: #7c3aed;
    font-weight: 500;
    background: rgba(124, 58, 237, 0.1);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
}

.page-content .internal-link:hover,
.preview-content .internal-link:hover {
    color: #5b21b6;
    background: rgba(124, 58, 237, 0.2);
    border-bottom-color: #5b21b6;
}

/* Namuwiki-style links [[target|display]] */
.page-content .namuwiki-link,
.preview-content .namuwiki-link {
    background: linear-gradient(90deg, rgba(0, 102, 204, 0.15) 0%, rgba(0, 102, 204, 0.08) 100%);
    border-radius: 4px;
    padding: 2px 5px;
    border-bottom: 1px dotted var(--primary-color);
    font-weight: 500;
}

.page-content .namuwiki-link:hover,
.preview-content .namuwiki-link:hover {
    background: var(--primary-color);
    color: white;
    border-bottom: 1px solid var(--primary-color);
    text-decoration: none;
}

/* YouTube embed styles */
.youtube-embed-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.youtube-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.youtube-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.youtube-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.youtube-thumbnail:hover .youtube-play-button {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.youtube-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* Responsive YouTube embeds */
@media (max-width: 768px) {
    .youtube-embed-container {
        margin: 0.75rem 0;
        border-radius: 8px;
    }
}

/* Category page styling */
.category-page-list {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.category-page-list h3 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.category-pages {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}

.category-pages li {
    margin: 0;
    padding: 0.5rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s;
}

.category-pages li:hover {
    background: rgba(0, 102, 204, 0.1);
    border-color: var(--primary-color);
}

.category-pages a {
    display: block;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.category-pages a:hover {
    color: var(--primary-color);
}

.category-count {
    margin-top: 1rem;
}

/* Tags styling */
.wiki-tag {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    margin: 0.125rem;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.wiki-tag:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.page-tags {
    margin: 1.5rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}

.page-tags h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popular-tags {
    margin: 0.5rem 0;
}

.popular-tags .wiki-tag {
    margin: 0.25rem 0.25rem 0.25rem 0;
    background: var(--surface-color);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    font-size: 0.7rem;
}

.popular-tags .wiki-tag:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.popular-tags .wiki-tag::after {
    content: attr(data-count);
    margin-left: 0.25rem;
    opacity: 0.7;
    font-size: 0.65rem;
}

/* Page footer styling */
.page-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.page-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.backlinks, .outgoing-links {
    background: var(--surface-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.backlinks h4, .outgoing-links h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.backlinks-list, .outgoing-links-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.backlinks-list li, .outgoing-links-list li {
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s;
}

.backlinks-list li:hover, .outgoing-links-list li:hover {
    background: rgba(0, 102, 204, 0.05);
    border-color: var(--primary-color);
}

.backlinks-list a, .outgoing-links-list a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    display: block;
}

.backlinks-list a:hover, .outgoing-links-list a:hover {
    color: var(--primary-color);
}

.link-count {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.show-more-links {
    display: block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--primary-color);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.show-more-links:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Tagged pages modal styling */
.tagged-pages-list, .backlinks-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.tagged-page-item, .backlink-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    transition: all 0.2s;
}

.tagged-page-item:hover, .backlink-item:hover {
    background: rgba(0, 102, 204, 0.05);
    border-color: var(--primary-color);
}

.tagged-page-item h4, .backlink-item h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.tagged-page-item a, .backlink-item a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.tagged-page-item a:hover, .backlink-item a:hover {
    color: var(--primary-hover);
}

.page-excerpt {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.5rem 0;
    line-height: 1.4;
}

.page-meta-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive adjustments for new features */
@media (max-width: 768px) {
    .page-links {
        grid-template-columns: 1fr;
    }
    
    .tagged-pages-list, .backlinks-list {
        grid-template-columns: 1fr;
    }
}

/* Favorites and Templates */
.favorite-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorite-btn:hover {
    background-color: var(--hover-color);
    border-color: var(--accent-color);
}

.favorite-btn.favorite-active {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.favorites-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.favorites-list li {
    margin-bottom: 0.25rem;
}

.favorites-list .page-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.2s ease;
}

.favorites-list .page-link:hover {
    background-color: var(--hover-color);
}

.favorites-list .page-link.active {
    background-color: var(--accent-color);
    color: white;
}

.no-favorites {
    color: var(--text-muted);
    font-style: italic;
    padding: 0.5rem;
    text-align: center;
}

.template-selection {
    margin: 1rem 0;
}

.template-selection h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-color);
}

.template-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 0.9rem;
}

.template-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Enhanced search results */
.search-result-excerpt {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    line-height: 1.4;
}

.search-result-excerpt mark {
    background-color: var(--accent-color);
    color: white;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
}

.search-result-matches {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.search-match-tag {
    background-color: var(--hover-color);
    color: var(--text-muted);
    padding: 0.2rem 0.4rem;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
}

/* Comments Section */
.comments-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.comments-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.comments-list {
    margin-bottom: 1.5rem;
}

.comment {
    background-color: var(--hover-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 3px solid var(--accent-color);
}

.comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.comment-author {
    font-weight: 600;
    color: var(--accent-color);
}

.comment-date {
    color: var(--text-muted);
}

.comment-actions {
    display: flex;
    gap: 0.25rem;
}

.comment-edit-btn,
.comment-delete-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 3px;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.comment-edit-btn:hover {
    color: var(--accent-color);
    background-color: var(--background-color);
}

.comment-delete-btn:hover {
    color: #dc3545;
    background-color: var(--background-color);
}

.comment-content {
    line-height: 1.5;
    color: var(--text-color);
}

.comment-form {
    background-color: var(--hover-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.comment-input {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.comment-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.comment-form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.comment-author-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 0.9rem;
}

.comment-author-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.no-comments {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Enhanced lists */
.page-content ul,
.page-content ol,
.preview-content ul,
.preview-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.page-content ul li,
.preview-content ul li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    position: relative;
}

.page-content ol li,
.preview-content ol li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Enhanced horizontal rules */
.page-content hr,
.preview-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 2.5rem 0;
}

/* Enhanced emphasis */
.page-content strong,
.preview-content strong {
    font-weight: 700;
    color: var(--text-color);
}

.page-content em,
.preview-content em {
    font-style: italic;
    color: var(--text-muted);
}

/* Mark/highlight styling */
.page-content mark,
.preview-content mark {
    background: #fef08a;
    color: #92400e;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
}

/* Dark mode adjustments for wiki styles */
@media (prefers-color-scheme: dark) {
    .wiki-category {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        border-color: #3b82f6;
    }
    
    .category-label {
        color: #60a5fa;
    }
    
    .category-name {
        color: #93c5fd;
    }
    
    .page-content code,
    .preview-content code {
        background: #374151;
        color: #fbbf24;
        border-color: #4b5563;
    }
    
    .page-content mark,
    .preview-content mark {
        background: #451a03;
        color: #fbbf24;
    }
    
    .page-content .internal-link,
    .preview-content .internal-link {
        background: rgba(147, 51, 234, 0.2);
    }
    
    .page-content .internal-link:hover,
    .preview-content .internal-link:hover {
        background: rgba(147, 51, 234, 0.3);
    }
    
    .category-page-list {
        background: var(--surface-color);
        border-color: var(--border-color);
    }
    
    .category-pages li {
        background: var(--background-color);
        border-color: var(--border-color);
    }
    
    .category-pages li:hover {
        background: rgba(59, 130, 246, 0.1);
        border-color: #3b82f6;
    }
}
