:root {
  --bg: #efe8f8; --paper: #fdfbff; --ink: #2d2a32; --muted: #6f6874; --line: #ddd1ec;
  --red: #b23a48; --teal: #2a7f86; --gold: #d9a521; --plum: #5b4a9b;
  --photo: #e4e4e2; --radius: 12px;
  --serif: "Fraunces", Georgia, serif; --sans: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--sans); }
a { color: var(--teal); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 700; margin: 0 0 .5em; }
h1 { font-size: clamp(28px, 4vw, 40px); }
main { max-width: 1240px; margin: 0 auto; padding: 0 16px 48px; }

/* header */
header.site { text-align: center; padding: 20px 16px 4px; }
.brand { display: inline-block; text-decoration: none; }
.logo { width: min(400px, 82vw); height: auto; margin: 0 auto; }
.tagline { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 2px 0 10px; font-size: 18px; }
header nav { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
header nav a { text-decoration: none; color: var(--ink); font-weight: 700; padding: 6px 14px; border-radius: 999px; }
header nav a:hover { background: var(--paper); }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; }
.card { background: var(--paper); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit;
        box-shadow: 0 1px 2px rgba(60,40,20,.06), 0 4px 14px rgba(60,40,20,.06); transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(60,40,20,.08), 0 10px 26px rgba(60,40,20,.12); }
.card .frame { background: var(--photo); aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; }
.card .frame img { width: 100%; height: 100%; object-fit: contain; }
.card .cap { padding: 12px 16px 14px; border-top: 3px dashed var(--line); }
.card h2 { font-size: 20px; margin: 0 0 2px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; min-height: 1.4em; }
.empty { text-align: center; padding: 60px 0; color: var(--muted); }

/* quilt page */
.quilt { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.viewer .main { margin: 0; background: var(--photo); border-radius: var(--radius); overflow: hidden; }
.viewer .main img { width: 100%; max-height: 78vh; object-fit: contain; margin: 0 auto; }
.viewer figcaption { padding: 0 14px; color: var(--muted); font-size: 15px; background: var(--paper); }
.viewer figcaption:not(:empty) { padding: 8px 14px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb { border: 2px solid transparent; padding: 0; background: var(--photo); border-radius: 8px; cursor: pointer; width: 78px; height: 78px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.on { border-color: var(--red); }
.info h1 { margin-top: 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 0 0 18px; padding: 14px 16px;
         background: var(--paper); border-radius: var(--radius); border: 1px dashed var(--line); }
.facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; }
.story p { margin: 0 0 1em; }

/* comments */
.comments { max-width: 760px; margin: 44px auto 0; }
.comment { background: var(--paper); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px; }
.comment p { margin: 0 0 .6em; }
.who { margin-bottom: 4px !important; }
.who span { color: var(--muted); font-size: 14px; margin-left: 6px; }
.reply { margin: 8px 0 0 14px; padding: 8px 14px; border-left: 3px solid var(--red); background: #f6f0fc; border-radius: 0 8px 8px 0; }
.cform { margin-top: 22px; background: var(--paper); border-radius: var(--radius); padding: 18px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.pager { display: flex; justify-content: space-between; gap: 12px; max-width: 760px; margin: 36px auto 0; font-weight: 700; flex-wrap: wrap; }
.pager a { text-decoration: none; }

/* forms + buttons */
label { display: block; font-weight: 700; font-size: 15px; margin: 0 0 14px; }
input:not([type=checkbox]):not([type=file]), textarea, select {
  display: block; width: 100%; margin-top: 4px; font: 16px/1.4 var(--sans); padding: 10px 12px; color: var(--ink);
  border: 1px solid #d6cbe6; border-radius: 8px; background: #fff; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
input[type=file] { display: block; margin-top: 6px; font-size: 15px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 20px; height: 20px; }
.check.big { font-size: 18px; }
.btn, .pbtns button { display: inline-block; font: 700 16px var(--sans); background: var(--red); color: #fff; border: 0; border-radius: 999px;
       padding: 10px 22px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.small { padding: 7px 16px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger, .pbtns .danger { background: #8e2430; }
.linkbtn { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.flashes { max-width: 760px; margin: 0 auto 18px; }
.flash { padding: 10px 16px; border-radius: 10px; margin-bottom: 8px; font-weight: 600; }
.flash.ok { background: #e4f1ec; color: #1f5c45; } .flash.err { background: #f8e1e1; color: #8e2430; }
.flash.warn { background: #fdf1cf; color: #6b4e00; max-width: 1240px; margin: 0 auto 16px; }
.prose { max-width: 700px; margin: 0 auto; background: var(--paper); border-radius: var(--radius); padding: 28px 32px; }

/* footer */
footer.site { text-align: center; color: var(--muted); font-size: 14px; padding: 10px 16px 30px; }
footer .stitch { max-width: 600px; margin: 0 auto 14px; border-top: 3px dashed var(--line); }
footer p { margin: 4px 0; } .quiet { color: var(--muted); }

/* admin */
.adminbar { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; background: var(--ink); color: #f3eee6; padding: 8px 16px; font-size: 15px; }
.adminbar a, .adminbar .linkbtn { color: #f3eee6; }
.adminbar form { margin: 0; }
.badge { display: inline-block; background: var(--red); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 13px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--paper); border-radius: var(--radius); padding: 22px 24px; max-width: 980px; margin: 0 auto 22px; }
.panel.narrow { max-width: 440px; }
.alist { display: grid; gap: 10px; }
.arow { display: flex; gap: 14px; align-items: center; background: var(--paper); border-radius: var(--radius); padding: 10px; text-decoration: none; color: inherit; }
.arow:hover { outline: 2px solid var(--line); }
.arow.draft { background: #f8f4fd; }
.athumb { width: 76px; height: 76px; flex: none; background: var(--photo); border-radius: 8px; overflow: hidden; }
.athumb img { width: 100%; height: 100%; object-fit: cover; }
.ameta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ameta span { color: var(--muted); font-size: 14px; }
.ameta small { color: var(--muted); font-style: italic; }
.tag { font-style: normal; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: #e6ddf2; color: var(--muted); margin-right: 4px; }
.tag.pub { background: #dcefe7; color: #1f5c45; } .tag.feat { background: #fbe9c4; color: #6b4e00; }
.pubrow { display: flex; gap: 24px; flex-wrap: wrap; padding: 12px 16px; background: #f1ebf9; border-radius: 10px; margin-bottom: 16px; }
.pubrow label { margin: 0; }
.note { background: #fdf1cf; padding: 8px 12px; border-radius: 8px; }
.grid2, .grid3 { display: grid; gap: 0 16px; } .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr 1fr; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.pcard { position: relative; background: #f1ebf9; border-radius: 10px; padding: 8px; border: 2px solid transparent; }
.pcard.cover { border-color: var(--red); }
.pcard img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--photo); border-radius: 6px; }
.pcard input { font-size: 14px !important; padding: 6px 8px !important; margin: 6px 0 !important; }
.maintag { position: absolute; top: 12px; left: 12px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.pbtns button { padding: 5px 10px; font-size: 13px; background: var(--ink); }
.pmove { display: flex; gap: 6px; margin-top: 6px; }
.pmove select { font-size: 13px !important; padding: 4px 6px !important; margin: 0 !important; }
.pmove button { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.savebar { position: sticky; bottom: 0; z-index: 5; margin: 0 -24px -22px; padding: 12px 24px; background: var(--paper);
           border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 14px rgba(60,40,20,.06); }
.dangerzone h2 { font-size: 20px; }
.tabs { display: flex; gap: 6px; }
.tabs a { text-decoration: none; padding: 6px 14px; border-radius: 999px; color: var(--ink); font-weight: 700; background: var(--paper); }
.tabs a.on { background: var(--ink); color: #fff; }
.ccard .cbody { background: #fff; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }

@media (max-width: 860px) {
  .quilt { grid-template-columns: 1fr; gap: 20px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .gallery { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card .cap { padding: 8px 10px 10px; } .card h2 { font-size: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .panel, .prose { padding: 18px 16px; }
  .thumb { width: 62px; height: 62px; }
}

body.admin .logo { width: min(220px, 60vw); }
body.admin .tagline { display: none; }
.credit { font-size: 14px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 8px; }
.prose h2 { font-size: 21px; margin-top: 1.4em; }
footer.site p { max-width: 640px; margin-left: auto; margin-right: auto; }

/* visitor counter (admin only) */
.statlink { text-decoration: none; color: inherit; display: block; }
.statstrip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 6px 0 18px; }
.statstrip div { background: var(--paper); border-radius: var(--radius); padding: 12px 14px; }
.statstrip b { display: block; font: 800 28px/1.1 var(--serif); color: var(--plum); }
.statstrip span { font-size: 13px; color: var(--muted); }
.statstrip small { display: block; font-size: 11px; }
.statlink:hover .statstrip div { outline: 2px solid var(--line); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-bottom: 22px; position: relative; }
.bar { flex: 1; height: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; }
.bar .v, .bar .u { position: absolute; bottom: 0; width: 100%; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar .v { background: #d6c8ec; } .bar .u { background: var(--plum); width: 60%; }
.bar small { position: absolute; bottom: -20px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; font-style: normal; }
.legend .sw.v { background: #d6c8ec; } .legend .sw.u { background: var(--plum); }
.stable { width: 100%; border-collapse: collapse; font-size: 15px; }
.stable th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 6px; }
.stable td { padding: 6px; border-top: 1px dashed var(--line); }
.stable td + td, .stable th + th { text-align: right; width: 80px; }
.grid2.gap { gap: 22px; max-width: 980px; margin: 0 auto; } .grid2.gap .panel { margin: 0 0 22px; max-width: none; }
.okc { color: #1f5c45; } .errc { color: #8e2430; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace !important; }
@media (max-width: 760px) { .statstrip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px) { .statstrip { grid-template-columns: repeat(2, 1fr); } }
