:root {
  /* Palette tuned to the backdrop photo: cool blue-grey concrete + muted
     eucalyptus foliage. Neutrals carry a slight blue cast; accent echoes the
     leaves — desaturated, calm, Apple-restrained. */
  --bg: #ffffff;
  --bg-soft: #eef1f3;
  --card: #ffffff;
  --ink: #1e272b;
  --ink-soft: #43525a;
  --muted: #67787f;
  --accent: #2f7d6b;
  --accent-ink: #245e50;
  --line: #e2e7ea;
  --danger: #c0392b;
  --focus-ring: rgba(47, 125, 107, 0.35);
  --radius: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, Cambria, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181b;
    --bg-soft: #1c2429;
    --card: #171e22;
    --ink: #e7ecee;
    --ink-soft: #c3cdd1;
    --muted: #8b9aa1;
    --accent: #5fbfa6;
    --accent-ink: #7fd2bc;
    --line: #2c363b;
    --danger: #e06b5c;
    --focus-ring: rgba(95, 191, 166, 0.42);
  }
}

* { box-sizing: border-box; }

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

/* ---- Top nav ---- */
.nav {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand span { font-family: var(--font-serif); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-right input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  font: inherit;
  width: 200px;
}
@media (max-width: 560px) {
  .nav-right input { width: 120px; }
}

/* ---- Filter bar ---- */
.filterbar {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 57px;
  z-index: 15;
}
.filterbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
}
.filterbar select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  font: inherit;
  flex-shrink: 0;
}
.tag-cloud { display: flex; gap: 8px; }
.tag-chip {
  font-size: 0.82rem;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.tag-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Feed ---- */
.feed {
  max-width: 728px;
  margin: 0 auto;
  padding: 8px 24px 80px;
}
.post-card {
  display: flex;
  gap: 24px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.post-main { flex: 1; min-width: 0; }
.post-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.mood-badge {
  background: var(--bg-soft);
  color: var(--accent-ink);
  padding: 1px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.hidden-badge {
  background: var(--danger);
  color: #fff;
  padding: 1px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.post-card:has(.hidden-badge) { opacity: 0.7; }
.post-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  line-height: 1.25;
  margin: 0 0 6px;
  cursor: pointer;
  color: var(--ink);
}
.post-title:hover { color: var(--accent-ink); }
.post-excerpt {
  color: var(--ink-soft);
  margin: 0 0 12px;
  font-size: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.post-tags span {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg-soft);
  padding: 2px 10px;
  border-radius: 999px;
}
.post-actions { display: flex; align-items: center; gap: 6px; }
.post-thumb {
  flex-shrink: 0;
  width: 112px;
  height: 112px;
  align-self: center;
}
.post-thumb img {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
@media (max-width: 560px) {
  .post-thumb, .post-thumb img { width: 80px; height: 80px; }
  .post-card { gap: 14px; }
}
.attach-note { font-size: 0.78rem; color: var(--muted); margin-left: 6px; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 80px 0;
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

/* ---- Buttons ---- */
.btn {
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); color: #fff; }
.btn.subtle { background: var(--bg-soft); color: var(--accent-ink); border: none; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { color: #fff; background: var(--danger); }
.icon-btn { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); }

/* small text-link style action buttons on cards */
.link-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}
.link-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.link-btn.read { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.link-btn.read:hover { filter: brightness(1.15); }

/* ---- Reader (article) view ---- */
.reader-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  overflow-y: auto;
}
.reader-topbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.reader-topbar-inner {
  max-width: 728px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
}
.article {
  max-width: 728px;
  margin: 0 auto;
  padding: 40px 24px 120px;
}
.article h1.title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  line-height: 1.15;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}
.article-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.article-body {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  line-height: 1.75;
  color: var(--ink);
}
.article-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin: 32px 0;
}
.article-gallery a { display: block; }
.article-gallery img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.article-files { margin-top: 32px; }
.article-files h3 {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
}
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  margin: 0 8px 8px 0;
}
.file-link:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---- Editor modal ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 70;
}
.overlay.hidden, .reader-overlay.hidden { display: none; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.entry-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.entry-form input,
.entry-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--ink);
  font: inherit;
}
.entry-form textarea { resize: vertical; font-family: var(--font-serif); font-size: 1.05rem; }
.row { display: flex; gap: 12px; }
.row input { flex: 1; }
@media (max-width: 520px) { .row { flex-direction: column; } }

.editor-tabs { display: flex; align-items: center; gap: 4px; }
.tab {
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--bg-soft);
  color: var(--muted);
  cursor: pointer;
}
.tab.active { background: var(--card); color: var(--ink); font-weight: 600; }
.md-hint { margin-left: auto; font-size: 0.72rem; color: var(--muted); }
.preview-pane {
  min-height: 12em;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.attach-block { display: flex; align-items: center; gap: 12px; }
.muted { color: var(--muted); font-size: 0.85rem; }
.attach-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.attach-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  width: 84px;
}
.attach-item img { width: 84px; height: 84px; object-fit: cover; display: block; }
.attach-item .file-box {
  width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; text-align: center; padding: 4px;
  color: var(--muted); word-break: break-all;
}
.attach-item .del {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0, 0, 0, 0.6); color: #fff;
  border: none; border-radius: 50%;
  width: 18px; height: 18px; cursor: pointer; font-size: 0.7rem; line-height: 1;
}
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---- Auth gating ---- */
/* Locked (logged out): hide all edit affordances, show Log in. */
body.readonly #newEntryBtn,
body.readonly #recipientsBtn,
body.readonly #logoutBtn,
body.readonly .link-btn.edit,
body.readonly .link-btn.hide,
body.readonly #readerEdit,
body.readonly #deleteEntry {
  display: none !important;
}
body:not(.readonly) #loginBtn { display: none !important; }
.login-modal { max-width: 380px; }
.login-error { color: var(--danger); font-size: 0.9rem; margin: 0; }

/* ---- Notification recipients ---- */
.recipients-modal { max-width: 460px; }
.recipients-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.recipients-hint { margin: 0; font-size: 0.9rem; }
.recipient-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.recipient-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.recipient-list .email { flex: 1; word-break: break-all; font-size: 0.95rem; }
.recipient-list .muted { flex: 1; font-size: 0.9rem; }
.recipient-del {
  flex: none;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
.recipient-del:hover { background: var(--bg); color: var(--danger); }
.recipient-add { display: flex; gap: 8px; }
.recipient-add input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font: inherit;
  font-size: 0.95rem;
}
.recipient-add input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.recipient-add .btn { flex: none; }

/* ---- Rendered markdown (shared) ---- */
.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.25; margin: 1.2em 0 0.4em; font-family: var(--font-serif); }
.markdown h1 { font-size: 1.7em; }
.markdown h2 { font-size: 1.4em; }
.markdown h3 { font-size: 1.15em; }
.markdown p { margin: 0.9em 0; }
.markdown ul, .markdown ol { margin: 0.9em 0; padding-left: 1.4em; }
.markdown li { margin: 0.3em 0; }
.markdown a { color: var(--accent-ink); }
.markdown code {
  background: var(--bg-soft);
  padding: 2px 6px; border-radius: 4px;
  font-size: 0.85em; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.markdown pre {
  background: var(--bg-soft);
  padding: 14px 16px; border-radius: var(--radius); overflow-x: auto;
}
.markdown pre code { background: none; padding: 0; }
.markdown blockquote {
  margin: 1em 0; padding-left: 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted); font-style: italic;
}
.markdown img { max-width: 100%; border-radius: var(--radius); }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 1.5em 0; }
.markdown table { border-collapse: collapse; font-family: var(--font-sans); font-size: 0.95rem; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 6px 10px; }

/* ===== Scenic backdrop ===== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url("/bg.jpg") center / cover no-repeat;
}
/* Contrast scrim so text panels always read well over the photo.
   Cool blue-grey tint keeps the scrim in the same colour world as the concrete. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(rgba(233, 238, 240, 0.30), rgba(224, 231, 234, 0.48));
}
body { background: transparent; }

/* Frosted floating column for the feed. */
.feed {
  background: rgba(250, 252, 253, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  margin: 28px auto 60px;
  padding: 10px 28px 36px;
  box-shadow: 0 12px 44px rgba(30, 50, 70, 0.22);
}

/* Translucent nav + filter bar. */
.nav, .filterbar {
  background: rgba(248, 251, 252, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Reader: frosted full-screen with a solid-ish article card for long reading. */
.reader-overlay {
  background: rgba(240, 244, 246, 0.58);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.reader-topbar { background: transparent; }
.article {
  background: rgba(251, 252, 253, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  margin: 24px auto;
  padding: 44px 44px 80px;
  box-shadow: 0 12px 44px rgba(30, 50, 70, 0.18);
}

@media (prefers-color-scheme: dark) {
  body::after {
    background: linear-gradient(rgba(16, 18, 24, 0.5), rgba(16, 18, 24, 0.66));
  }
  .feed { background: rgba(24, 24, 27, 0.74); border-color: rgba(255, 255, 255, 0.08); }
  .nav, .filterbar { background: rgba(22, 22, 25, 0.55); }
  .reader-overlay { background: rgba(16, 16, 20, 0.6); }
  .article { background: rgba(26, 26, 29, 0.82); border-color: rgba(255, 255, 255, 0.08); }
}

@media (max-width: 560px) {
  .feed { margin: 14px auto 40px; padding: 6px 16px 24px; border-radius: 12px; }
  .article { padding: 28px 20px 60px; margin: 14px auto; }
}

/* ---- Comments ---- */
.comments {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.comments-title {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 20px;
}
.comment-list { list-style: none; margin: 0 0 28px; padding: 0; }
.comment {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.comment:last-child { border-bottom: none; }
.comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.comment-author {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}
.comment-date { font-size: 0.78rem; color: var(--muted); }
.comment-del {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
.comment-del:hover { color: #fff; background: var(--danger); }
.comment-body {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--ink-soft);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.comment-name, .comment-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-family: var(--font-sans);
}
.comment-name { max-width: 260px; }
.comment-input { resize: vertical; }
.comment-name:focus, .comment-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.comment-actions { display: flex; align-items: center; gap: 10px; }

/* ============================================================
   Interaction & motion polish — Apple HIG pass
   Clarity, deference, depth: soft consistent easing, tactile
   press feedback, keyboard focus rings, restrained entrance
   motion, and a reduced-motion guard.
   ============================================================ */

/* One easing vocabulary across every interactive element. */
.btn, .link-btn, .icon-btn, .tab, .tag-chip, .file-link,
.nav-right input, .filterbar select,
.entry-form input, .entry-form textarea,
.comment-name, .comment-input, .comment-del,
.post-thumb img, .post-title {
  transition: background-color 0.18s ease, border-color 0.18s ease,
    color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease,
    filter 0.18s ease;
}

/* Buttons read as buttons: medium weight + tactile press. */
.btn { font-weight: 500; }
.btn:active, .link-btn:active, .tag-chip:active, .tab:active,
.icon-btn:active, .file-link:active, .comment-del:active { transform: scale(0.96); }

/* Keyboard focus ring — shown only for keyboard navigation. */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
/* Pill controls keep their pill shape around the ring. */
.btn:focus-visible, .link-btn:focus-visible, .tag-chip:focus-visible,
.nav-right input:focus-visible, .filterbar select:focus-visible {
  border-radius: 999px;
}

/* Text inputs: soft accent ring on any focus (mouse or keyboard). */
.nav-right input:focus, .filterbar select:focus,
.entry-form input:focus, .entry-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Tag chips gain a clear hover affordance. */
.tag-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.tag-chip.active:hover { color: #fff; }

/* Feed card: quiet depth cue — thumbnail eases in on hover. */
.post-thumb { overflow: hidden; border-radius: var(--radius); }
.post-card:hover .post-thumb img { transform: scale(1.03); }

/* Softer, rounder modals (continuous-radius feel). */
.modal { border-radius: 14px; }

/* Entrance motion — content settles in rather than snapping. */
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes surfaceIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.overlay:not(.hidden), .reader-overlay:not(.hidden) {
  animation: overlayIn 0.2s ease both;
}
.overlay:not(.hidden) .modal {
  animation: surfaceIn 0.24s cubic-bezier(0.32, 0.72, 0, 1) both;
}
.reader-overlay:not(.hidden) .article {
  animation: surfaceIn 0.3s cubic-bezier(0.32, 0.72, 0, 1) both;
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Responsive layout — desktop · laptop · tablet · mobile
   Content columns are already capped for a comfortable reading
   measure; this layer tunes gutters, the nav, tap targets, and
   the feed card across widths.
   ============================================================ */

/* Fluid page gutters: roomy on desktop, tight on phones. */
.nav-inner, .filterbar-inner, .reader-topbar-inner {
  padding-left: clamp(16px, 4vw, 28px);
  padding-right: clamp(16px, 4vw, 28px);
}

/* Never let a long word or media force sideways page scroll. */
.post-excerpt, .comment-body, .article-body { overflow-wrap: anywhere; }
.markdown table { display: block; max-width: 100%; overflow-x: auto; }

/* Large desktop: let the image gallery use the extra room. */
@media (min-width: 1200px) {
  .article-gallery {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* Small laptop / large tablet: keep the search box from crowding buttons. */
@media (max-width: 820px) {
  .nav-right input { width: 160px; }
}

/* Tablet & below: nav wraps to two rows, search spans full width. */
@media (max-width: 640px) {
  .nav-inner { flex-wrap: wrap; row-gap: 10px; }
  .nav-right { width: 100%; }
  .nav-right input { flex: 1 1 auto; width: auto; min-width: 0; }
  /* Nav can now be two rows tall, so stop pinning the filter bar to a
     fixed offset — let it scroll with the page instead of overlapping. */
  .filterbar { position: static; top: auto; }
}

/* Phone: Apple ~44px tap targets, roomier form, wrapping actions. */
@media (max-width: 560px) {
  .btn, .link-btn { padding: 9px 15px; }
  .icon-btn { padding: 6px; font-size: 1.2rem; }
  .post-actions { flex-wrap: wrap; }
  .comment-name { max-width: 100%; }
  .article h1.title { font-size: 1.9rem; }
  .article-body { font-size: 1.12rem; }
}

/* Small phone: stack the card image above the text, full width. */
@media (max-width: 430px) {
  .post-card { flex-direction: column-reverse; gap: 12px; }
  .post-thumb, .post-thumb img { width: 100%; height: 180px; }
  .article-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
