:root {
  --bg: #fbfaf8;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2ded7;
  --accent: #9a1f1f;
  --accent-fg: #ffffff;
  --card-bg: #ffffff;
  --danger: #b3261e;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --fg: #ede9e3;
    --muted: #9a958d;
    --border: #35322e;
    --accent: #e05a5a;
    --accent-fg: #17161a;
    --card-bg: #201f23;
    --danger: #ff7a70;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
}

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

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

header.site-header {
  border-bottom: 3px solid var(--fg);
  padding: 28px 20px 16px;
  margin-bottom: 32px;
}

header.site-header .wrap {
  padding: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.brand .accent { color: var(--accent); }

nav.site-nav {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.92rem;
  display: flex;
  gap: 18px;
  align-items: center;
}

nav.site-nav a, nav.site-nav button.link-btn {
  color: var(--muted);
  font-family: inherit;
}
nav.site-nav a:hover, nav.site-nav button.link-btn:hover { color: var(--accent); }

button.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.tagline {
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  margin-top: 4px;
}

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

.article-card {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.article-card:first-child { padding-top: 0; }

.article-card h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.article-meta {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.article-excerpt { color: var(--fg); }

.draft-badge {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 2px 7px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: middle;
}

.empty-state {
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 40px 0;
  text-align: center;
}

article.full h1 {
  font-size: 2.1rem;
  margin: 0 0 8px;
  line-height: 1.2;
}

.article-body { font-size: 1.08rem; margin-top: 24px; }
.article-body p { margin: 0 0 1.1em; }
.article-body h2 { margin: 1.4em 0 0.5em; }
.article-body h3 { margin: 1.3em 0 0.5em; }
.article-body blockquote {
  margin: 1.2em 0;
  padding: 4px 0 4px 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.article-body ul, .article-body ol { margin: 0 0 1.1em; padding-left: 1.4em; }

.back-link { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.9rem; }

/* Forms & buttons (admin / login) */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
input[type="text"]:focus, input[type="password"]:focus, .editor-body:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: inline-block;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-danger { background: var(--danger); }

.error-msg {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--danger);
  font-size: 0.88rem;
  margin: -6px 0 16px;
  min-height: 1em;
}

.success-msg {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f7a3c;
  font-size: 0.88rem;
  margin: -6px 0 16px;
}

/* Rich text editor */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px;
  background: var(--bg);
}

.editor-toolbar button {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}
.editor-toolbar button:hover { border-color: var(--border); }
.editor-toolbar button.active { background: var(--accent); color: var(--accent-fg); }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 4px 4px; }

.editor-body {
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  padding: 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  background: var(--card-bg);
  color: var(--fg);
}
.editor-body p { margin: 0 0 1em; }
.editor-body:empty:before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.admin-list { list-style: none; margin: 24px 0 0; padding: 0; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.admin-row .title { font-weight: 600; }
.admin-row .meta { color: var(--muted); font-size: 0.82rem; }
.admin-row .actions { display: flex; gap: 8px; flex-shrink: 0; }
.admin-row .actions button { font-size: 0.82rem; padding: 6px 10px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
}

.section-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 40px 0 4px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}

@media (max-width: 480px) {
  .brand { font-size: 1.5rem; }
  .panel { padding: 16px; }
  article.full h1 { font-size: 1.6rem; }
}
