:root {
  --surface: #fdf8f7;
  --surface-container: #f1edec;
  --surface-container-low: #f7f3f2;
  --on-surface: #1c1b1b;
  --on-surface-variant: #464742;
  --primary: #171816;
  --on-primary: #ffffff;
  --secondary: #625e57;
  --secondary-container: #e8e2d9;
  --outline: #777871;
  --outline-variant: #c7c7bf;
  --error: #ba1a1a;
  --stack-xs: 0.5rem;
  --stack-sm: 1rem;
  --stack-md: 2rem;
  --stack-lg: 4rem;
  --stack-xl: 8rem;
  --container-max: 800px;
  --gutter: 24px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: 'Libre Caslon Text', Georgia, serif;
  font-size: 21px;
  line-height: 1.7;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ── Header ── */
header {
  border-bottom: 0.5px solid var(--outline-variant);
  padding: var(--stack-md) 0;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--on-surface);
}

nav > a:last-child {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--on-surface-variant);
}

nav > a:last-child:hover { color: var(--on-surface); }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--stack-sm);
}

.nav-links a {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--on-surface-variant);
}

.nav-links a:hover { color: var(--on-surface); }

/* ── Footer ── */
footer {
  border-top: 0.5px solid var(--outline-variant);
  padding: var(--stack-md) 0;
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
}

/* ── Main ── */
main {
  padding-top: var(--stack-lg);
  padding-bottom: var(--stack-xl);
}

/* ── Type scale ── */
h1 {
  font-family: 'Libre Caslon Text', Georgia, serif;
  font-size: 48px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  font-family: 'Libre Caslon Text', Georgia, serif;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.3;
}

h3 {
  font-family: 'Libre Caslon Text', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.4;
}

/* ── Page header ── */
.page-header {
  padding-bottom: var(--stack-md);
  margin-bottom: var(--stack-lg);
}

/* ── Post list (index & tag pages) ── */
.post-list { list-style: none; }

.post-card {
  padding: var(--stack-lg) 0;
  border-bottom: 0.5px solid var(--outline-variant);
}

.post-list .post-card:first-child {
  border-top: 0.5px solid var(--outline-variant);
}

.post-card .meta {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  margin-bottom: var(--stack-xs);
}

.post-card h2 { margin-bottom: 0; }

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

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

/* ── Tags (slash style) ── */
.tags {
  display: inline-flex;
  gap: var(--stack-sm);
  flex-wrap: wrap;
}

a.tag {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--on-surface-variant);
}

a.tag::before { content: '/'; }

a.tag:hover { color: var(--on-surface); }

/* ── Article (post page) ── */
article .meta {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  margin-bottom: var(--stack-sm);
}

article h1 { margin-bottom: var(--stack-sm); }

article hr {
  border: none;
  border-top: 0.5px solid var(--outline-variant);
  margin: var(--stack-md) 0;
}

.post-content p { margin-bottom: var(--stack-sm); }

.post-content h2,
.post-content h3 {
  margin-top: var(--stack-md);
  margin-bottom: var(--stack-xs);
}

.post-content img {
  width: 100%;
  display: block;
  margin: var(--stack-md) 0;
}

.post-content figcaption {
  font-size: 16px;
  font-style: italic;
  color: var(--on-surface-variant);
  margin-top: calc(-1 * var(--stack-sm));
  margin-bottom: var(--stack-md);
}

.post-content pre {
  background: var(--surface-container);
  padding: var(--stack-sm);
  overflow-x: auto;
  margin-bottom: var(--stack-sm);
  font-size: 14px;
  line-height: 1.5;
  border-radius: 0;
}

.post-content code {
  font-size: 0.82em;
  background: var(--surface-container);
  padding: 0.1em 0.3em;
}

.post-content pre code { background: none; padding: 0; }

.post-content blockquote {
  border-left: 2px solid var(--outline-variant);
  padding-left: var(--stack-sm);
  color: var(--on-surface-variant);
  margin: var(--stack-md) 0;
}

.post-content ul,
.post-content ol {
  padding-left: var(--stack-md);
  margin-bottom: var(--stack-sm);
}

.post-content li { margin-bottom: 0.25rem; }

.post-content a { color: var(--on-surface); }

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--stack-sm);
  font-size: 18px;
}

.post-content th,
.post-content td {
  padding: 0.5rem var(--stack-xs);
  border-bottom: 0.5px solid var(--outline-variant);
  text-align: left;
}

.post-content th {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

/* ── Back link ── */
.back-link {
  display: inline-block;
  margin-top: var(--stack-lg);
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--on-surface-variant);
}

.back-link:hover { color: var(--on-surface); }

/* ── Buttons ── */
button,
a.button {
  display: inline-block;
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  background: var(--primary);
  color: var(--on-primary);
  border: 1px solid var(--primary);
  padding: 0.65rem 1.5rem;
  cursor: pointer;
  border-radius: 0;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}

button:hover,
a.button:hover {
  background: var(--secondary);
  border-color: var(--secondary);
}

button.outline {
  background: none;
  color: var(--on-surface);
  border-color: var(--outline);
}

button.outline:hover {
  background: var(--surface-container);
}

button.danger {
  background: none;
  color: var(--error);
  border-color: var(--error);
}

button.danger:hover {
  background: var(--error);
  color: #fff;
}

/* ── EasyMDE toolbar (reset global button styles) ── */
.editor-toolbar button {
  background: transparent;
  color: var(--on-surface);
  border: 1px solid transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: normal;
  letter-spacing: normal;
  text-transform: none;
}

.editor-toolbar button:hover,
.editor-toolbar button.active {
  background: var(--surface-container);
  border-color: var(--outline-variant);
  color: var(--on-surface);
}

/* ── Forms ── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-md);
  max-width: 600px;
}

label {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input[type="text"],
input[type="password"],
textarea {
  font-family: 'Libre Caslon Text', Georgia, serif;
  font-size: 18px;
  line-height: 1.6;
  border: none;
  border-bottom: 1px solid var(--outline);
  background: transparent;
  padding: 0.4rem 0;
  color: var(--on-surface);
  outline: none;
  border-radius: 0;
  width: 100%;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-bottom: 2px solid var(--primary);
}

textarea {
  resize: vertical;
  min-height: 400px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 0;
  accent-color: var(--primary);
}

/* ── Admin header row ── */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: var(--stack-md);
  margin-bottom: var(--stack-lg);
  border-bottom: 0.5px solid var(--outline-variant);
  gap: var(--stack-sm);
}

/* ── Admin table ── */
table { width: 100%; border-collapse: collapse; }

thead th {
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  text-align: left;
  padding: var(--stack-xs) 0;
  border-bottom: 0.5px solid var(--outline-variant);
}

tbody td {
  padding: var(--stack-xs) 0;
  border-bottom: 0.5px solid var(--surface-container-low, #f7f3f2);
  font-size: 18px;
  vertical-align: middle;
}

tbody td a {
  color: var(--on-surface);
  text-decoration: none;
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

tbody td a:hover { color: var(--secondary); }

.td-actions {
  display: flex;
  align-items: center;
  gap: var(--stack-sm);
}

/* ── Error / notice ── */
.error {
  font-family: 'Work Sans', sans-serif;
  font-size: 14px;
  color: var(--error);
  margin-bottom: var(--stack-sm);
}

/* ── Mobile ── */
@media (max-width: 600px) {
  h1 { font-size: 36px; line-height: 1.2; }
  body { font-size: 18px; line-height: 1.6; }
  main { padding-top: var(--stack-md); }
}
