
:root {
    --md-primary: #1a73e8;
    --md-primary-dark: #1557b0;
    --md-surface: #ffffff;
    --md-background: #f0f4f9;
    --md-text: #1f1f1f;
    --md-text-secondary: #5f6368;
    --md-elevation-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --md-elevation-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --md-elevation-4: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
    --md-radius: 12px;
    --md-radius-sm: 8px;
}

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

body {
    background: var(--md-background);
    color: var(--md-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


.header {
    background: var(--md-surface);
    padding: 8px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--md-elevation-1);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.header .nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}


.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 10px 44px 10px 16px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--md-surface);
    height: 44px;
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

.search-input:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}

.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.search-button {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--md-text-secondary);
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    min-width: 36px;
}

.search-button:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--md-primary);
}

.search-button:active {
    background: rgba(0, 0, 0, 0.08);
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--md-surface);
    border-radius: 8px;
    box-shadow: var(--md-elevation-2);
    display: none;
    max-height: 350px;
    overflow-y: auto;
    z-index: 200;
    padding: 4px 0;
}

.search-results a {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--md-text);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 0.15s;
    font-size: 14px;
}

.search-results a:hover {
    background: rgba(26, 115, 232, 0.06);
}

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

.search-results .result-icon {
    margin-right: 10px;
    vertical-align: middle;
}

.search-results .no-results {
    padding: 16px;
    color: var(--md-text-secondary);
    font-size: 14px;
    text-align: center;
}

.search-results .create-page-link {
    display: block;
    padding: 10px 16px;
    color: var(--md-primary);
    text-decoration: none;
    font-size: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    transition: background 0.15s;
}

.search-results .create-page-link:hover {
    background: rgba(26, 115, 232, 0.06);
}

.search-results .result-highlight {
    color: var(--md-primary);
    font-weight: 500;
}

.search-results .result-count {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--md-text-secondary);
    background: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.search-results .more-results {
    padding: 10px 16px;
    color: var(--md-text-secondary);
    font-size: 13px;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}


.main {
    flex: 1;
    padding: 24px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}


.content {
    background: var(--md-surface);
    border-radius: var(--md-radius);
    box-shadow: var(--md-elevation-1);
    padding: 32px 40px;
    min-height: 400px;
}


.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}


.img-wrapper { margin: 16px 0; display: inline-block; }
.img-wrapper img { border-radius: 8px; box-shadow: var(--md-elevation-1); max-width: 100%; height: auto; }
.img-caption { display: block; font-size: 13px; color: var(--md-text-secondary); text-align: center; margin-top: 6px; }
.img-mini img { max-width: 80px; }
.img-small img { max-width: 160px; }
.img-medium img { max-width: 320px; }
.img-large img { max-width: 640px; }
.img-left { float: left; margin: 4px 20px 8px 0; }
.img-right { float: right; margin: 4px 0 8px 20px; }
.img-center { display: block; margin: 16px auto; text-align: center; float: none; }


.content h1 { font-size: 32px; font-weight: 400; margin: 24px 0 16px; border-bottom: 1px solid rgba(0,0,0,0.06); padding-bottom: 8px; }
.content h2 { font-size: 26px; font-weight: 400; margin: 20px 0 12px; }
.content h3 { font-size: 22px; font-weight: 400; margin: 16px 0 10px; }
.content p { margin: 12px 0; line-height: 1.7; }
.content ul, .content ol { margin: 12px 0 12px 24px; }
.content ul li, .content ol li { margin: 4px 0; }
.content pre { background: #f8f9fa; padding: 16px; border-radius: 8px; overflow-x: auto; margin: 12px 0; border: 1px solid rgba(0,0,0,0.04); font-family: monospace; font-size: 14px; }
.content code { background: #f8f9fa; padding: 2px 8px; border-radius: 4px; font-family: monospace; font-size: 13px; }
.content a { color: var(--md-primary); text-decoration: none; }
.content a:hover { text-decoration: underline; }


.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.dialog-overlay.active { display: flex; }

.dialog {
    background: var(--md-surface);
    border-radius: var(--md-radius);
    box-shadow: var(--md-elevation-4);
    max-width: 520px;
    width: 90%;
    padding: 32px;
    animation: dialogSlide 0.25s ease;
}
@keyframes dialogSlide {
    from { transform: translateY(-20px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.dialog .dialog-title {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dialog .dialog-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--md-text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: background 0.2s;
}
.dialog .dialog-close:hover { background: rgba(0,0,0,0.06); }


.auth-form {
    max-width: 380px;
    margin: 60px auto;
    padding: 32px;
    background: var(--md-surface);
    border-radius: var(--md-radius);
    box-shadow: var(--md-elevation-1);
}
.auth-form h2 { margin-top: 0; font-weight: 400; border-bottom: 1px solid rgba(0,0,0,0.06); padding-bottom: 12px; }
.auth-form .form-group { margin: 16px 0; }
.auth-form .form-group label { display: block; font-weight: 500; font-size: 13px; color: var(--md-text-secondary); margin-bottom: 4px; }
.auth-form .form-group input { width: 100%; padding: 10px 14px; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; font-size: 14px; }
.auth-form .form-group input:focus { outline: none; border-color: var(--md-primary); box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2); }
.auth-form .links { margin-top: 16px; text-align: center; font-size: 14px; color: var(--md-text-secondary); }


.page-list { list-style: none; padding: 0; }
.page-list li { padding: 10px 14px; border-radius: 8px; transition: background 0.15s; border-bottom: 1px solid rgba(0,0,0,0.04); }
.page-list li:hover { background: rgba(0,0,0,0.03); }
.page-list li a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--md-text); font-size: 15px; }
.page-list li a:hover { color: var(--md-primary); }


.flash { padding: 12px 16px; margin: 12px 0; border-radius: 8px; border: 1px solid; }
.flash-success { background: #e6f4ea; color: #1e7e34; border-color: #b7e1cd; }
.flash-error { background: #fce8e6; color: #d93025; border-color: #f5c6cb; }
.flash-info { background: #e8f0fe; color: #1a73e8; border-color: #d2e3fc; }


.footer {
    text-align: center;
    padding: 16px 24px;
    color: var(--md-text-secondary);
    font-size: 13px;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: var(--md-surface);
    margin-top: auto;
}


@media (max-width: 768px) {
    .content { padding: 16px 20px; }
    .main { padding: 12px 16px; }
    .img-left, .img-right { float: none; display: block; margin: 12px auto; }
    .header { padding: 8px 16px; }
    
    .search-wrapper {
        min-width: 120px;
    }
    
    .search-input {
        font-size: 13px;
        padding: 8px 40px 8px 12px;
        height: 40px;
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    .header .nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .search-wrapper {
        max-width: 200px;
    }
}
