:root {
  color-scheme: light dark;
  --bg: #fbfaf8;
  --fg: #1c1917;
  --muted: #6b6560;
  --accent: #8a4b2a;
  --border: #e5e1db;
  --card: #ffffff;
  --illustration: #1c1917;
}

/* OS preference applies only when the visitor hasn't made an explicit
   choice via the toggle (that choice is recorded as data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f;
    --fg: #f2eee7;
    --muted: #a39c93;
    --accent: #e0935f;
    --border: #3a352c;
    --card: #201c16;
    --illustration: #f2eee7;
  }
}

:root[data-theme="dark"] {
  --bg: #17140f;
  --fg: #f2eee7;
  --muted: #a39c93;
  --accent: #e0935f;
  --border: #3a352c;
  --card: #201c16;
  --illustration: #f2eee7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Georgia", "Iowan Old Style", serif;
  line-height: 1.6;
}

header.site-header {
  position: relative;
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.hero-illustration {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.1;
  pointer-events: none;
}

.hero-illustration svg {
  width: 100%;
  height: 100%;
  max-width: 720px;
}

.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tech-icons {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.tech-icons .icon-medallion {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.tech-icons .icon-medallion svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

header.site-header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.02em;
}

header.site-header h1 a {
  color: inherit;
  text-decoration: none;
}

header.site-header p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-style: italic;
}

.site-nav {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
}

.author-photo {
  display: block;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 1.5rem;
  border: 2px solid var(--border);
}

.author-name {
  text-align: center;
  margin: 0 0 0.25rem;
}

.author-title {
  text-align: center;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.post-card {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
}

.post-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
}

.post-card h2 a {
  color: var(--fg);
  text-decoration: none;
}

.post-card h2 a:hover {
  color: var(--accent);
}

.post-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

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

article.post-body h1, article.post-body h2, article.post-body h3 {
  color: var(--fg);
}

article.post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 4px;
}

article.post-body pre {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
}

article.post-body code {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 0.9em;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin-right: 0.4rem;
}

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

a.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

/* --- admin --- */
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.admin-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.status-badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.status-draft { background: #e5e1db; color: #6b6560; }
.status-published { background: #d9ead0; color: #2f5228; }

textarea, input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--fg);
  margin-bottom: 0.75rem;
}

textarea.body-editor {
  min-height: 260px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 0.9rem;
}

button {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button.danger {
  background: transparent;
  border-color: #a33;
  color: #a33;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.field {
  margin-bottom: 1rem;
}

/* --- responsive breakpoints --- */

/* small phones */
@media (max-width: 420px) {
  header.site-header {
    padding: 1.75rem 1rem 1.25rem;
  }

  header.site-header h1 {
    font-size: 1.6rem;
  }

  .hero-illustration {
    display: none;
  }

  main {
    padding: 1.5rem 1rem 3rem;
  }

  .post-card h2 {
    font-size: 1.2rem;
  }

  .admin-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .admin-list-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* tablets and up */
@media (min-width: 600px) {
  header.site-header {
    padding: 3rem 2rem 2rem;
  }

  main {
    padding: 2.5rem 2rem 4rem;
  }
}

/* larger desktop screens */
@media (min-width: 1024px) {
  body {
    font-size: 1.0625rem;
  }

  main {
    max-width: 760px;
  }

  header.site-header h1 {
    font-size: 2.25rem;
  }
}
