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

:root {
    --bg: #faf9f6;
    --surface: #fff;
    --text: #2c2c2c;
    --text-muted: #888;
    --accent: #4a6fa5;
    --accent-hover: #3a5a8a;
    --border: #e0ddd8;
    --danger: #c0392b;
    --success: #27ae60;
    --radius: 6px;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 800px; margin: 0 auto; padding: 0 1rem; }

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
header h1 { font-size: 1.25rem; font-weight: normal; letter-spacing: 0.05em; }
header h1 a { color: var(--text); }
header nav { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
header nav a { color: var(--text-muted); }

main { padding: 2rem 0; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fde8e8; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* Forms */
input[type="text"], input[type="password"], input[type="search"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    background: var(--surface);
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.flash.error { background: #fde8e8; color: var(--danger); }
.flash.success { background: #e8f8f0; color: var(--success); }

/* Login */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
}
.login-box h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: normal;
}
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: var(--text-muted); }
.login-box .btn { width: 100%; margin-top: 0.5rem; }

/* Entry list */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.search-bar input { flex: 1; }

.entry-list { list-style: none; }
.entry-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
    transition: box-shadow 0.15s;
}
.entry-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.entry-item h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.25rem; }
.entry-item h2 a { color: var(--text); }
.entry-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.entry-excerpt {
    font-size: 0.9rem;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state { text-align: center; color: var(--text-muted); padding: 3rem 0; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}
.pagination a, .pagination span {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.pagination .current {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* View entry */
.entry-view { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.entry-view h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.entry-view .entry-meta { margin-bottom: 1.5rem; }
.entry-body { line-height: 1.8; }
.entry-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.entry-actions { margin-top: 2rem; display: flex; gap: 0.5rem; }

/* Editor */
.editor-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.editor-header .entry-meta { margin: 0; }
.editor-actions { display: flex; gap: 0.5rem; align-items: center; }
#save-status { font-size: 0.8rem; color: var(--text-muted); }

#title-input {
    width: 100%;
    padding: 0.5rem 0;
    border: none;
    border-bottom: 1px solid var(--border);
    font-family: inherit;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: transparent;
}
#title-input:focus { outline: none; border-bottom-color: var(--accent); }

.ql-container { font-family: inherit; font-size: 1rem; }
.ql-editor { min-height: 300px; line-height: 1.8; }
.ql-toolbar { border-color: var(--border) !important; border-radius: var(--radius) var(--radius) 0 0; }
.ql-container.ql-snow { border-color: var(--border) !important; border-radius: 0 0 var(--radius) var(--radius); }

/* Responsive */
@media (max-width: 600px) {
    .editor-header { flex-direction: column; align-items: flex-start; }
    .entry-view { padding: 1.25rem; }
}
