:root {
  --bg: #ffffff;
  --ink: #14171a;
  --ink-soft: #55595e;
  --accent: #2c5f6f;
  --ochre: #a8763e;
  --border: #e4e2dc;
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: 640px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
  text-decoration: none;
  color: var(--ink);
}

.admin-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
}

.admin-nav a {
  text-decoration: none;
  color: var(--accent);
}

.admin-nav a:hover {
  text-decoration: underline;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.feed {
  display: flex;
  flex-direction: column;
}

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

.post-card:first-child {
  padding-top: 0;
}

.post-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 2rem 0;
}

.post-date {
  display: block;
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.post-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 0 0 0.6rem;
  background-image: linear-gradient(var(--ochre), var(--ochre));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 2px;
  transition: background-size 0.25s ease;
}

.post-card-link:hover .post-title {
  background-size: 100% 2px;
}

.post-thumb {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  margin: 0.9rem 0;
  border-radius: 2px;
}

.post-excerpt {
  color: var(--ink-soft);
  margin: 0;
}

.empty {
  color: var(--ink-soft);
  padding: 2.5rem 0;
}

/* Single post page */

.post-full .post-title {
  font-size: 2rem;
  background-image: none;
}

.post-body p {
  margin: 0 0 1.1rem;
}

.post-image {
  display: block;
  width: 100%;
  border-radius: 2px;
  margin: 1.25rem 0;
}

.back-link {
  display: inline-block;
  margin-top: 1rem;
  text-decoration: none;
  color: var(--accent);
}

.back-link:hover {
  text-decoration: underline;
}

/* Photo gallery (post page) */

.gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 0 0 0.6rem;
  border-radius: 2px;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.gallery img {
  flex: 0 0 100%;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  scroll-snap-align: start;
  display: block;
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.gallery-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
}

.gallery-dot.active {
  background: var(--accent);
}

/* Fullscreen photo lightbox */

body.lightbox-locked {
  overflow: hidden;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.94);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.lightbox.open {
  display: flex;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.4rem;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

/* Manage posts list */

.manage-list {
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
}

.manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.manage-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.manage-title {
  font-weight: 500;
}

.manage-date {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.manage-actions {
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
}

.manage-actions a {
  color: var(--accent);
  text-decoration: none;
}

.manage-actions a:hover {
  text-decoration: underline;
}

.link-button {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: #a3372f;
  cursor: pointer;
  text-decoration: none;
}

.link-button:hover {
  text-decoration: underline;
}

/* Existing photos on the edit form */

.existing-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.4rem 0 0.2rem;
}

.existing-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.existing-image img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Forms: login + admin */

.login-form,
.post-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 480px;
  margin: 2.5rem 0;
}

.login-form label,
.post-form label {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 1rem;
}

.login-form label:first-child,
.post-form label:first-child {
  margin-top: 0;
}

.login-form input,
.post-form input[type="text"],
.post-form input[type="password"],
.post-form textarea {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
}

.post-form textarea {
  resize: vertical;
  font-family: var(--sans);
}

.post-form input[type="file"] {
  font: inherit;
  padding: 0.4rem 0;
}

.login-form button,
.post-form button {
  margin-top: 1.5rem;
  align-self: flex-start;
  font: inherit;
  font-weight: 500;
  padding: 0.7rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.login-form button:hover,
.post-form button:hover {
  background: #234b58;
}

.form-error {
  color: #a3372f;
  font-size: 0.9rem;
  margin: 0.75rem 0 0;
}

.form-success {
  background: #eef3f0;
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
  border-radius: 4px;
  margin: 2rem 0 0;
}

.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--ink-soft);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }
  .site-title {
    font-size: 1.25rem;
  }
  .post-title {
    font-size: 1.4rem;
  }
  .post-full .post-title {
    font-size: 1.7rem;
  }
}
