:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1f2a27;
  --muted: #66736f;
  --line: #e3e0d8;
  --brand: #2f6f5e;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe9;
  --danger: #b3412e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917; --surface: #1d2421; --text: #e8ece9; --muted: #9aa7a2;
    --line: #2d3632; --brand: #5fb39a; --brand-ink: #0c1411; --brand-soft: #24342e; --danger: #e0715d;
    --shadow: none;
  }
}

* { 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.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); }
img { max-width: 100%; display: block; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: .2em 0 .4em; }
h2 { font-size: 1.2rem; margin: 0 0 .6em; }
h3 { font-size: 1rem; margin: 0; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; flex: 1; }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.inline { display: inline; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 12px; align-items: center; }
.topbar .btn, .brand span { white-space: nowrap; }
@media (max-width: 420px) { .brand span { display: none; } }
.nav-link { color: var(--text); text-decoration: none; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.footer { text-align: center; padding: 24px 16px; color: var(--muted); font-size: .875rem; }
.footer a, .linklike { color: var(--muted); }
.linklike { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand);
  padding: 10px 18px; border-radius: 999px; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; min-height: 44px;
}
.btn:hover { filter: brightness(1.06); }
.btn-small { padding: 6px 14px; min-height: 36px; font-size: .9rem; }
.btn-large { padding: 14px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=date], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; width: 18px; height: 18px; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.field-error { color: var(--danger); font-weight: 400; font-size: .875rem; }
.alert { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); padding: 10px 14px; border-radius: 10px; }
.notice { background: var(--brand-soft); padding: 10px 14px; border-radius: 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.flash { max-width: 1200px; margin: 12px auto 0; padding: 12px 16px; border-radius: 10px; background: var(--brand-soft); width: calc(100% - 32px); }
.flash-error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 100; }

/* Landing */
.hero { text-align: center; padding: 40px 0 24px; max-width: 680px; margin: 0 auto; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
.lead { font-size: 1.15rem; color: var(--muted); }
.features { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-top: 24px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.feature p { margin: .5em 0 0; color: var(--muted); }

/* Gallery list */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.storage { display: grid; gap: 2px; justify-items: end; }
meter { width: 180px; height: 10px; }
.meter-wide { width: 100%; height: 14px; }
.searchbar { margin: 8px 0 12px; }
.section-title { margin-top: 24px; }
.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.gcard { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; box-shadow: var(--shadow); transition: transform .15s; }
.gcard:hover { transform: translateY(-2px); }
.gcard-cover { aspect-ratio: 4 / 3; background: var(--brand-soft); display: grid; place-items: center; }
.gcard-cover img { width: 100%; height: 100%; object-fit: cover; }
.gcard-empty { color: var(--muted); font-size: .9rem; }
.gcard-body { padding: 12px 14px; }
.gcard-body p { margin: 4px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag { display: inline-block; background: var(--brand-soft); color: var(--text); border-radius: 999px; padding: 2px 10px; font-size: .8rem; text-decoration: none; }
.tag-filter .tag { padding: 5px 12px; font-size: .875rem; }
.tag-on { background: var(--brand); color: var(--brand-ink); }
.tag-on .muted { color: inherit; opacity: .8; }
.empty { padding: 32px 16px; }

/* Gallery page */
.gallery-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.gallery-head p { margin: 0; }
.description { max-width: 70ch; margin: 8px 0 16px; white-space: normal; }
.share-banner p { margin-top: 0; }
.uploader { margin: 12px 0 16px; }
.dropzone { display: block; position: relative; border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; cursor: pointer; background: var(--surface); font-weight: 400; }
.dropzone.drag, .dropzone:hover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone-text { display: grid; gap: 4px; }
.upload-progress { display: grid; gap: 4px; margin-top: 10px; }
.upload-progress progress { width: 100%; height: 10px; }

.photo-grid { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
@media (min-width: 700px) { .photo-grid { gap: 6px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.tile { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--brand-soft); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.tile:hover img { transform: scale(1.03); }

/* Lightbox */
.lightbox { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; margin: 0; padding: 0; border: 0; background: rgba(8, 10, 9, .96); color: #fff; }
.lightbox[open] { display: grid; grid-template-rows: auto 1fr auto; }
.lightbox::backdrop { background: rgba(0, 0, 0, .9); }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 8px; }
.lb-tools { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.lb-btn { background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: .875rem; cursor: pointer; text-decoration: none; }
.lb-btn:hover { background: rgba(255,255,255,.2); }
.lb-btn[hidden] { display: none; }
.lb-danger { color: #ffb3a6; }
.lb-img { grid-row: 2; width: 100%; height: 100%; object-fit: contain; min-height: 0; user-select: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: 0; width: 48px; height: 64px; font-size: 2rem; cursor: pointer; border-radius: 8px; }
.lb-prev { left: 8px; } .lb-next { right: 8px; }
@media (hover: none) { .lb-nav { display: none; } }
.lb-caption { text-align: center; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); margin: 0; min-height: 1.5em; color: #dfe5e2; }

/* People & links */
.people, .links { list-style: none; padding: 0; margin: 0; }
.people li, .links li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.people li:first-child, .links li:first-child { border-top: 0; }
.people select { width: auto; min-height: 36px; padding: 4px 8px; }
.badge { background: var(--brand-soft); padding: 2px 10px; border-radius: 999px; font-size: .8rem; }
.copy-field { width: min(340px, 100%) !important; font-size: .85rem; }
.links { margin-bottom: 16px; }
.form-inline { border-top: 1px solid var(--line); padding-top: 16px; }
@media (min-width: 760px) { .form-inline { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; } }

.prose { line-height: 1.65; }
.prose h2 { margin-top: 1.6em; }
.prose li { margin-bottom: .4em; }
