:root {
  color-scheme: light dark;
  --paper: #f7f2e8;
  --ink: #28322c;
  --muted: #667068;
  --accent: #315b46;
  --accent-dark: #214332;
  --line: #d9d1c2;
  --surface: rgb(255 255 255 / 45%);
  --surface-soft: rgb(255 255 255 / 35%);
  --surface-strong: #fff;
  --error-bg: #f8e5e1;
  --error-ink: #73231f;
  --success-bg: #e3efe7;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

:root[data-theme="light"] { color-scheme: light; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171b19;
  --ink: #eef2ed;
  --muted: #aab6ad;
  --accent: #85b99d;
  --accent-dark: #a8d1bb;
  --line: #3b4540;
  --surface: rgb(255 255 255 / 7%);
  --surface-soft: rgb(255 255 255 / 5%);
  --surface-strong: #252b28;
  --error-bg: #472724;
  --error-ink: #ffd2cc;
  --success-bg: #203b2b;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --paper: #171b19;
    --ink: #eef2ed;
    --muted: #aab6ad;
    --accent: #85b99d;
    --accent-dark: #a8d1bb;
    --line: #3b4540;
    --surface: rgb(255 255 255 / 7%);
    --surface-soft: rgb(255 255 255 / 5%);
    --surface-strong: #252b28;
    --error-bg: #472724;
    --error-ink: #ffd2cc;
    --success-bg: #203b2b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

a { color: inherit; }

.site-header,
.site-footer,
main {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.theme-picker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.theme-picker select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface-strong);
  color: var(--ink);
}

.header-logout-form { margin: 0; }

.header-logout-form button {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
}

.header-logout-form button:hover { color: var(--ink); background: var(--surface); }

.brand {
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
}

nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--ink); }

main { min-height: 70vh; }

.hero,
.page-heading,
.panel {
  padding-block: clamp(4rem, 10vw, 8rem);
}

.hero { max-width: 760px; }
.page-heading { padding-bottom: 2rem; }
.narrow { max-width: 640px; }

h1,
h2 {
  margin: 0 0 1rem;
  font-family: Georgia, serif;
  line-height: 1.05;
}

h1 { font-size: clamp(2.6rem, 7vw, 3rem); }
h2 { font-size: 1.5rem; }

p { color: var(--muted); line-height: 1.7; }
.hero > p:not(.eyebrow) { max-width: 62ch; font-size: 1.1rem; }

.eyebrow {
  margin-bottom: 0.75rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.8rem 1.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.button:hover { background: var(--accent-dark); }

.button-secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.button-secondary:hover { background: rgb(255 255 255 / 55%); }

.button-danger {
  border: 1px solid #a64139;
  background: transparent;
  color: #a64139;
  cursor: pointer;
}

.button-danger:hover { background: var(--error-bg); }

.stacked-form {
  display: grid;
  gap: 1.25rem;
  margin-top: 2rem;
}

.stacked-form label {
  display: grid;
  gap: 0.5rem;
  font-weight: 700;
}

.stacked-form input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
}

.stacked-form select {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
}

.stacked-form .button { justify-self: start; border: 0; cursor: pointer; }

.form-error {
  padding: 0.8rem 1rem;
  border-left: 4px solid #9d342f;
  background: var(--error-bg);
  color: var(--error-ink);
}

.form-success {
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--success-bg);
  color: var(--accent-dark);
}

.stacked-form textarea {
  width: 100%;
  resize: vertical;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
}

.admin-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}

.admin-heading h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  padding-bottom: 4rem;
}

.admin-grid .panel { margin: 0; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1.25rem;
  padding-bottom: 4rem;
}

.settings-grid .panel { margin: 0; }
.account-details dl { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem 1.25rem; }
.account-details dt { color: var(--muted); font-weight: 700; }
.account-details dd { margin: 0; }

.message-list { display: grid; gap: 1rem; padding-bottom: 4rem; }

.message-card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface-soft);
}

.message-card.unread { border-left: 5px solid var(--accent); background: var(--surface); }

.message-card-header,
.message-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.message-card-header h2 { margin-top: 0.75rem; }
.message-card-header p { margin-bottom: 0; }
.message-card-header time { flex: none; color: var(--muted); font-size: 0.85rem; }

.message-body {
  margin-block: 1.25rem;
  padding: 1rem;
  border-radius: 0.7rem;
  background: var(--surface-strong);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-actions { align-items: center; justify-content: flex-start; flex-wrap: wrap; }
.message-actions > span { margin-right: auto; color: var(--muted); font-size: 0.85rem; }
.message-actions form { margin: 0; }
.message-actions .button { margin: 0; }

.status-label {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.featured-section { padding-block: 1rem 5rem; }
.section-heading { margin-bottom: 1.5rem; }
.section-heading h2 { font-size: clamp(2rem, 5vw, 3.5rem); }

.home-landing {
  min-height: calc(100svh - 105px);
  display: grid;
  align-items: center;
}

.home-landing.has-featured {
  grid-template-columns: minmax(280px, 0.8fr) minmax(480px, 1.4fr);
  gap: clamp(2rem, 5vw, 5rem);
}

.home-hero { padding-block: 2rem; }
.home-hero h1 { font-size: clamp(2rem, 3vw, 3.8rem); }
.home-hero .button { margin-top: 0.5rem; }

.home-featured {
  min-width: 0;
  padding-block: 2rem;
}

.home-featured .section-heading { margin-bottom: 1rem; }
.home-featured .section-heading h2 { font-size: clamp(1.6rem, 2.6vw, 2.5rem); }

.featured-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(210px, 1fr);
  gap: 1rem;
  overflow-x: auto;
  padding: 0.15rem 0.15rem 0.75rem;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
}

.featured-card { scroll-snap-align: start; }
.featured-card img { aspect-ratio: 4 / 3; max-height: 38svh; }
.featured-card figcaption { display: grid; gap: 0.35rem; padding: 0.75rem; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  padding-bottom: 4rem;
}

.featured-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.photo-card {
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-card figcaption { padding: 1rem; }
.photo-card figcaption p { margin-bottom: 0.5rem; }
.photo-card time { color: var(--muted); font-size: 0.85rem; }

.upload-panel { margin-top: 0; }
.upload-panel .stacked-form { max-width: 620px; }

.admin-photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  padding-block: 2rem 5rem;
}

.admin-photo-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}

.admin-photo-card > img {
  width: 100%;
  height: 180px;
  border-radius: 0.7rem;
  object-fit: cover;
}

.photo-selection {
  position: absolute;
  z-index: 1;
  top: 1.6rem;
  left: 1.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: 0 2px 10px rgb(0 0 0 / 20%);
  color: var(--ink);
  font-size: 0.8rem;
}

.bulk-photo-toolbar {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--surface-strong);
}

.bulk-photo-toolbar .button { margin: 0 0 0 auto; }
.bulk-photo-toolbar button:disabled { cursor: not-allowed; opacity: 0.45; }

.photo-edit-form { margin-top: 0; }
.delete-photo-form { margin-top: -0.25rem; }
.delete-photo-form .button { margin-top: 0; }
.photo-options { display: grid; gap: 0.9rem; }
.checkbox-label { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.checkbox-label input { width: auto; }

.photo-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.visibility-status {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.visibility-status.published { background: #dcecdf; color: #245437; }
.visibility-status.private { background: #ece7dd; color: #685f51; }

.empty-state,
.panel {
  margin-block: 2rem;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface-soft);
}

.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  h1 { font-size: clamp(2.4rem, 14vw, 4rem); }
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .admin-photo-list { grid-template-columns: 1fr; }
  .bulk-photo-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .bulk-photo-toolbar .button { width: 100%; margin-left: 0; }
  .admin-photo-card > img { min-height: 220px; }
  .photo-card-actions { align-items: flex-start; flex-direction: column; }
  .message-card-header { flex-direction: column; }
  .message-actions { align-items: stretch; flex-direction: column; }
  .message-actions > span { margin-right: 0; }
}

@media (max-width: 850px) {
  .home-landing.has-featured {
    min-height: calc(100svh - 145px);
    align-content: start;
    grid-template-columns: 1fr;
    gap: 0;
  }

  .home-hero { padding-block: 1.35rem 0.75rem; }
  .home-hero h1 { margin-bottom: 0.65rem; font-size: clamp(2rem, 9vw, 3.2rem); }
  .home-hero p { margin-block: 0.5rem; }
  .home-featured { padding-block: 0.75rem 1.5rem; }
  .home-featured .section-heading { margin-bottom: 0.65rem; }
  .home-featured .section-heading h2 { margin-bottom: 0; font-size: 1.45rem; }
  .featured-strip { grid-auto-columns: minmax(190px, 72vw); }
  .featured-card img { max-height: 24svh; }
}
