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

:root {
  --text: #1a1a1a;
  --muted: #666;
  --border: #e0e0e0;
  --bg: #fafafa;
  --white: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius: 6px;
}

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

.container {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
header {
  border-bottom: 1px solid var(--border);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-title {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--text);
  text-decoration: none;
}

.site-title:hover { color: var(--accent); }

.admin-btn {
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.admin-btn:hover { color: var(--text); border-color: #aaa; }
.admin-btn.active { color: var(--accent); border-color: var(--accent); }

/* Main */
main { padding: 2.5rem 1.5rem; min-height: calc(100vh - 70px); }

/* Article list */
.article-list { list-style: none; }

.article-list li + li { border-top: 1px solid var(--border); }

.article-card {
  padding: 1.75rem 0;
  cursor: pointer;
}

.article-card:hover .article-card-title { color: var(--accent); }

.article-card-title {
  font-size: 1.35rem;
  font-weight: bold;
  margin-bottom: 0.35rem;
  transition: color 0.15s;
}

.article-card-meta {
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.article-card-excerpt {
  color: #444;
  font-size: 0.95rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  padding: 4rem 0;
}

/* Single article view */
.back-link {
  font-family: system-ui, sans-serif;
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 2rem;
}

.back-link:hover { text-decoration: underline; }

.article-header { margin-bottom: 2rem; }

.article-title {
  font-size: 2rem;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.article-meta {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

.article-content { font-size: 1.05rem; }

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-family: Georgia, serif;
}

.article-content p { margin-bottom: 1.1rem; }
.article-content ul, .article-content ol { margin: 0.75rem 0 1.1rem 1.5rem; }
.article-content li { margin-bottom: 0.25rem; }
.article-content blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  color: var(--muted);
}
.article-content code {
  font-family: 'Courier New', monospace;
  font-size: 0.875em;
  background: #f0f0f0;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.article-content pre {
  background: #f0f0f0;
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1rem 0;
}
.article-content pre code { background: none; padding: 0; }
.article-content a { color: var(--accent); }
.article-content img { max-width: 100%; border-radius: var(--radius); margin: 0.5rem 0; }

.article-admin-actions {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  font-family: system-ui, sans-serif;
}

/* Admin view */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  font-family: system-ui, sans-serif;
}

.admin-header h2 { font-size: 1.25rem; }

.admin-article-list { list-style: none; margin-top: 2rem; }

.admin-article-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  font-family: system-ui, sans-serif;
}

.admin-article-list li:first-child { border-top: 1px solid var(--border); }

.admin-article-info { flex: 1; min-width: 0; }

.admin-article-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-article-date { font-size: 0.78rem; color: var(--muted); }

.admin-article-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* Editor */
.editor-section { margin-top: 2rem; }

.editor-section h3 {
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.editor-title {
  width: 100%;
  font-family: Georgia, serif;
  font-size: 1.2rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.editor-title:focus { border-color: var(--accent); }

.editor-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 600px) {
  .editor-panes { grid-template-columns: 1fr; }
}

.editor-label {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.editor-textarea {
  width: 100%;
  height: 360px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.editor-textarea:focus { border-color: var(--accent); }

.editor-preview {
  height: 360px;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 0.95rem;
  line-height: 1.7;
}

.editor-preview h1, .editor-preview h2, .editor-preview h3 {
  margin-top: 1rem;
  margin-bottom: 0.35rem;
}

.editor-preview p { margin-bottom: 0.75rem; }
.editor-preview code {
  font-family: 'Courier New', monospace;
  font-size: 0.875em;
  background: #f0f0f0;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.editor-preview pre {
  background: #f0f0f0;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0.5rem 0;
}
.editor-preview pre code { background: none; padding: 0; }
.editor-preview blockquote {
  border-left: 3px solid var(--border);
  padding-left: 0.75rem;
  color: var(--muted);
}
.editor-preview ul, .editor-preview ol { margin: 0.5rem 0 0.75rem 1.5rem; }

.editor-actions {
  display: flex;
  gap: 0.75rem;
  font-family: system-ui, sans-serif;
}

/* Buttons */
button, .btn {
  font-family: system-ui, sans-serif;
  font-size: 0.875rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  padding: 0.5rem 1.1rem;
  transition: background 0.15s;
}

.btn-primary, #login-btn {
  background: var(--accent);
  color: white;
}
.btn-primary:hover, #login-btn:hover { background: var(--accent-hover); }

.btn-secondary, button.secondary {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover, button.secondary:hover { background: #f0f0f0; }

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border: 1px solid var(--border);
}
.btn-danger:hover { background: #fff5f5; border-color: var(--danger); }

/* Modal */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#modal-overlay[hidden] { display: none; }

.modal {
  background: var(--white);
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.modal h2 {
  font-family: system-ui, sans-serif;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.modal input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  margin-bottom: 0.5rem;
  transition: border-color 0.15s;
}

.modal input[type="password"]:focus { border-color: var(--accent); }

#login-error {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--danger);
  margin-bottom: 0.5rem;
}

#login-error[hidden] { display: none; }

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.modal-actions button { flex: 1; }
