:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #1d1b19;
  --muted: #6b665f;
  --line: #e6e2dc;
  --accent: #1d1b19;
  --accent-text: #ffffff;
  --danger: #a3261b;
  --ok: #2f6b3a;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --surface: #1d1c1a;
    --text: #efece7;
    --muted: #a39d94;
    --line: #2f2d2a;
    --accent: #efece7;
    --accent-text: #141312;
    --danger: #ef8a7f;
    --ok: #8fcf9b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
}
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 16px 20px;
}
.name {
  font: 600 clamp(1.5rem, 4vw, 2rem)/1.1 var(--serif);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-header nav { display: flex; gap: 20px; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a[aria-current="page"], .site-header nav a:hover { color: var(--text); }

main { max-width: 1200px; margin: 0 auto; padding: 0 16px 48px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.filters a {
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
}
.filters a[aria-current="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.grid { columns: 3 300px; column-gap: 16px; }
.tile { display: block; break-inside: avoid; margin: 0 0 16px; text-decoration: none; }
.tile img { width: 100%; background: var(--line); }
.tile-title { display: block; padding: 8px 2px 0; font-size: 0.9rem; color: var(--muted); }
.tile:hover .tile-title { color: var(--text); }
.empty { color: var(--muted); padding: 48px 0; }

.piece figure { margin: 0 0 24px; }
.piece figure img { margin: 0 auto; max-height: 85vh; width: auto; background: var(--line); }
.piece-text { max-width: 640px; margin: 0 auto; }
.piece h1, .prose h1 { font: 600 clamp(1.6rem, 4vw, 2.2rem)/1.15 var(--serif); margin: 0 0 8px; }
.meta { color: var(--muted); margin: 0 0 16px; font-size: 0.95rem; }
.meta a { color: inherit; }
.piece-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  max-width: 640px;
  margin: 40px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.piece-nav a { color: var(--muted); }

.prose { max-width: 640px; }
.form { display: grid; gap: 16px; max-width: 520px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }
input, textarea, select {
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.button {
  display: inline-block;
  font: 600 1rem var(--sans);
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 8px;
  padding: 12px 20px;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.button:disabled { opacity: 0.5; cursor: default; }
.error { color: var(--danger); margin: 0; }
.ok { color: var(--ok); margin: 0; }

.site-footer { max-width: 1200px; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }

.login { max-width: 400px; padding-top: 15vh; }
.login h1 { font: 600 2rem var(--serif); margin: 0 0 4px; }
