:root {
  color-scheme: light dark;

  --bg: #faf8f5;
  --bg-elevated: #ffffff;
  --text: #1b1a17;
  --muted: #706858;
  --border: #e7e2d8;
  --border-strong: #d9d2c4;
  --accent: #9c6b3f;
  --accent-hover: #7f5731;
  --on-accent: #fff8f0;
  --danger: #ad4a3a;
  --danger-hover: #8f3b2e;
  --on-danger: #fff8f0;
  --shadow: rgba(30, 26, 20, 0.07);
  --shadow-strong: rgba(30, 26, 20, 0.12);

  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18160f;
    --bg-elevated: #221f18;
    --text: #ece7dc;
    --muted: #a89d89;
    --border: #35311f;
    --border-strong: #453f28;
    --accent: #d9a870;
    --accent-hover: #e7bd8c;
    --on-accent: #241b0f;
    --danger: #e08c7a;
    --danger-hover: #eba694;
    --on-danger: #2a140e;
    --shadow: rgba(0, 0, 0, 0.35);
    --shadow-strong: rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 4rem 1.5rem 6rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.7;
  animation: fade-in 500ms ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }
}

main {
  max-width: 640px;
  margin: 0 auto;
}

a {
  color: var(--accent);
  transition: color 200ms ease, opacity 200ms ease;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Header */

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3rem;
  gap: 1rem;
}

header h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

header nav,
header div {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

header a {
  color: var(--muted);
  text-decoration: none;
}

header a:hover {
  color: var(--accent);
}

/* Posts */

article.post {
  padding: 2.5rem 0;
}

article.post:not(:first-of-type) {
  border-top: 1px solid var(--border);
}

article.post:first-of-type {
  padding-top: 0;
}

article.post h2 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

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

.post-meta .dot {
  margin: 0 0.4em;
  opacity: 0.6;
}

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

.post-content > *:first-child {
  margin-top: 0;
}

.post-content img {
  max-width: 100%;
  border-radius: 8px;
}

.post-content pre {
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1rem 1.1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

.post-content code {
  font-family: ui-monospace, Consolas, monospace;
}

.post-content :not(pre) > code {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  font-size: 0.9em;
}

.post-content blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1.1rem;
  border-left: 2px solid var(--border-strong);
  color: var(--muted);
  font-style: italic;
}

.empty {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Forms */

form {
  font-family: var(--font-sans);
}

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

input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text);
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px var(--shadow);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

input[type="password"]:hover,
input[type="text"]:hover,
textarea:hover {
  border-color: var(--muted);
}

input[type="password"]:focus,
input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

textarea {
  min-height: 380px;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.75;
  padding: 1.25rem 1.4rem;
  resize: vertical;
}

button {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.65rem 1.3rem;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  box-shadow: 0 1px 2px var(--shadow);
  transition: background 200ms ease, border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px var(--shadow-strong);
}

button:active {
  transform: none;
  box-shadow: 0 1px 2px var(--shadow);
}

button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: none;
}

button.secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--muted);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: none;
}

button.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

.error {
  font-family: var(--font-sans);
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

/* Auth card */

.auth-wrap {
  min-height: calc(100vh - 10rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.25rem;
  box-shadow: 0 8px 30px var(--shadow);
}

.auth-card header {
  margin-bottom: 1.5rem;
}

.auth-card form {
  margin-top: 0;
}

.auth-card button {
  width: 100%;
}

/* Admin */

.section-label {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: 3rem 0;
}

.admin-post {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
  background: var(--bg-elevated);
  transition: border-color 200ms ease;
}

.admin-post:hover {
  border-color: var(--border-strong);
}

.admin-post h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-family: var(--font-sans);
  font-weight: 600;
}

.admin-post .post-meta {
  margin-bottom: 0;
}

.admin-post .actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
}

@media (max-width: 480px) {
  body {
    padding: 2.5rem 1.25rem 4rem;
  }

  header {
    margin-bottom: 2.25rem;
  }

  textarea {
    min-height: 280px;
  }
}
