* { box-sizing: border-box; }
html {
    /* Keep the scrollbar's space reserved whether or not one is showing.
       Without this, locking the page for a save (which sets overflow:hidden)
       removes the scrollbar, the viewport grows by its width, and everything
       centred — the full-size photo above all — jumps sideways by half that,
       then jumps back when the save finishes. */
    scrollbar-gutter: stable;
}
/* Links in page content.
   Nothing set a colour, so every link that did not belong to a styled
   component fell back to the browser's default blue — which on these dark
   green panels is close to unreadable. "See the log" on the Account page was
   effectively invisible.
   An element selector, so every component that sets its own colour — the nav,
   the pager, the share note — still wins on specificity. */
a { color: #7ab55c; }
a:hover { color: #9fd67a; }

body {
    font-family: system-ui, sans-serif;
    margin: 0;
    background: #1a2417;
    color: #e8e4d8;
}
/* Leaflet stacks its own furniture high — panes climb to 700 and the zoom
   control sits at 1000 — and none of that is inside a stacking context of its
   own, so on a phone the map and its +/- buttons punched straight through the
   open hamburger menu. Giving the map container a z-index makes it a stacking
   context: everything Leaflet does now happens inside it, under the topbar's
   10, and no map added later has to remember this. */
.leaflet-container { position: relative; z-index: 0; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: 0.7rem 1.5rem;
    background: #141c12; border-bottom: 1px solid #2e3c28;
}
.topbar h1 {
    font-size: 1.1rem; margin: 0;
    display: flex; align-items: center; gap: 0.5rem;
}
.brand { display: flex; line-height: 0; }
.brand img { width: 28px; height: 28px; border-radius: 6px; }
@media (max-width: 760px) { .brand img { width: 24px; height: 24px; } }
.navmenu { display: contents; }   /* on a wide screen it is not a box at all */
.navlinks { display: flex; gap: 0.85rem; flex: 1; }
.navlinks a { color: #a8b39a; text-decoration: none; font-size: 0.9rem; }
.navlinks a:hover, .navlinks a.on { color: #e8e4d8; }
.navlinks a.on { border-bottom: 2px solid #7ab55c; }
.who { font-size: 0.8rem; color: #a8b39a; }
.signout { font-size: 0.8rem; color: #a8b39a; text-decoration: none; }
.signout:hover { color: #e8e4d8; }
.navtoggle { display: none; }
/* Count of photos someone else has tagged since you last looked. */
.navbadge {
    display: inline-block; margin-left: 0.3rem;
    background: #d9b451; color: #241f0c;
    font-size: 0.65rem; font-weight: 700; line-height: 1;
    padding: 0.15rem 0.32rem; border-radius: 999px; vertical-align: 1px;
}
/* display:contents drops .navmenu out of the layout, so its children sit
   directly in the top bar — but that puts them ahead of the page's own
   controls in source order. Order pushes them back to the right-hand end,
   where they were before the menu wrapper existed. */
.navmenu .who { order: 90; }
.navmenu .signout { order: 91; }

/* A secondary control in the top bar: "Clear old…" on Review, "Upload" on the
   Library. Styled for both a <button> and an <a>, because one of them goes to a
   page and the other does something here, and they should not look different
   for that reason. Lived in review.php's own styles until the Library needed
   one too. */
.navbtn {
    background: transparent; border: 1px solid #3a4a33; color: #a8b39a;
    border-radius: 5px; font-size: 0.75rem; padding: 0.32rem 0.6rem; cursor: pointer;
    display: inline-block; text-decoration: none; line-height: 1.5;
}
.navbtn:hover { background: #2e3c28; color: #e8e4d8; }

/* Tablet and below: the site links, account name and sign-out fold into a
   hamburger so the row belongs to the page's own controls. The cut-off is
   well above phone width on purpose — an iPad is too narrow for eleven links
   PLUS the page's own controls, and the bar was wrapping onto four rows. */
@media (max-width: 1100px) {
    .topbar h1 { flex: 1; }
    .navtoggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 2.2rem; height: 2.2rem; flex: none;
        background: transparent; border: 1px solid #2e3c28; border-radius: 6px;
        color: #cdd6c0; font-size: 1.15rem; line-height: 1; cursor: pointer;
    }
    .navtoggle[aria-expanded="true"] { background: #2e3c28; color: #e8e4d8; }

    .navmenu {
        display: none;
        position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        padding: 0.35rem;
        background: #141c12; border-bottom: 1px solid #2e3c28;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
    }
    .navmenu.on { display: flex; }
    .navmenu .navlinks { flex-direction: column; gap: 0; flex: none; }
    .navmenu .navlinks a {
        padding: 0.65rem 0.6rem; border-radius: 6px; font-size: 0.95rem;
    }
    .navmenu .navlinks a.on {
        border-bottom: 0; background: #2e3c28; color: #e8e4d8;
    }
    .navmenu .who, .navmenu .signout {
        padding: 0.5rem 0.6rem;
        border-top: 1px solid #2e3c28;
    }
}

/* Narrow screens: tighter spacing and controls on top of the collapse above. */
@media (max-width: 760px) {
    /* Tucked out of the way while scrolling down — see assets/topbar.js. */
    .topbar { transition: transform 0.18s ease; will-change: transform; }
    .topbar.tucked { transform: translateY(-100%); }
    @media (prefers-reduced-motion: reduce) { .topbar { transition: none; } }

    .topbar { gap: 0.6rem; padding: 0.6rem 0.85rem; }
    .topbar h1 { font-size: 1rem; }
    .grid { padding: 0.7rem 0.85rem 2rem; gap: 8px; }

    /* Every row the bar wraps onto is a row of photos lost, so the page
       controls get tighter and the standing totals drop out. Anything marked
       sm-hide is a number you read occasionally, not one you act on. */
    .topbar .sm-hide { display: none; }
    .topbar .stat { font-size: 0.78rem; }
    .topbar .tagfilter {
        font-size: 0.75rem; padding: 0.25rem 0.35rem; max-width: 44vw;
    }
    .topbar .primary, .topbar .navbtn { font-size: 0.75rem; padding: 0.32rem 0.55rem; }
    .thumbctl input[type=range] { width: 84px; }
}
.stat { font-size: 0.85rem; color: #a8b39a; }
.tagfilter {
    background: #1f2a1b; color: #cdd6c0; border: 1px solid #2e3c28;
    border-radius: 6px; padding: 0.28rem 0.5rem; font-size: 0.8rem; cursor: pointer;
}
.stat b { color: #e8e4d8; }
/* Note: the track size cannot come from a CSS variable — Chrome rejects
   var() inside repeat(auto-fill, minmax(...)). The pages write a literal
   grid-template-columns inline, and ui.js updates it as the slider moves. */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px; padding: 1rem 1.5rem 2rem;
}
.thumbctl {
    display: flex; align-items: center; gap: 0.4rem;
    color: #7f8a76; cursor: pointer;
}
.thumbctl input[type=range] {
    width: 110px; accent-color: #7ab55c; cursor: pointer;
}
.card {
    position: relative;   /* the New and comment badges sit over the photo */
    background: #243020; border-radius: 8px; overflow: hidden;
    border: 2px solid transparent; transition: border-color 0.15s;
}
.card.keep { border-color: #7ab55c; }

/* Added to a shared tag by someone else since you last opened it. */
.card.isnew { border-color: #d9b451; }
/* Somebody has said something about this photo. The blue the comment buttons
   already use, on the frame itself, so a thread reads across a grid the way a
   new tag does; brighter while there is something in it you have not read.
   Declared after .isnew because the thread is what people go looking for. */
.card.hascomments { border-color: #6f8fd4; }
.card.unreadcomments { border-color: #a9c8ff; }
/* Chosen for deletion beats everything: it is about to go. */
.card.selected { border-color: #c46a5c; }
.newflag {
    position: absolute; top: 6px; left: 6px; z-index: 2;
    background: #d9b451; color: #241f0c;
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em;
    padding: 0.12rem 0.4rem; border-radius: 4px; text-transform: uppercase;
}
.commentflag {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    background: #6f8fd4; color: #0f1a2e; font-weight: 700;
    font-size: 0.68rem; padding: 0.12rem 0.4rem; border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.card.unreadcomments .commentflag { background: #a9c8ff; }
/* Where you were when you closed the full-size viewer. Deliberately a ring
   rather than a border colour so it reads on top of keep/selected states. */
.card.lastseen { box-shadow: 0 0 0 3px #d9b451; }
.sellabel {
    display: flex; align-items: center; gap: 0.35rem;
    font-size: 0.78rem; cursor: pointer; user-select: none;
    color: #a8b39a; padding: 0.25rem 0.35rem; border-radius: 6px;
}
.sellabel:hover { background: #2e3c28; color: #e8e4d8; }
.sellabel input { width: 1.05rem; height: 1.05rem; accent-color: #c46a5c; cursor: pointer; }

/* HD sits ON the photo, top right, because it describes the picture rather
   than being something you do to it. Matches how the shared ribbon and the
   comment count already sit on the frame. */
.hdflag {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    background: #d9b451; color: #241f0c;
    font-size: 0.62rem; font-weight: 800; letter-spacing: 0.04em;
    padding: 0.1rem 0.3rem; border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
/* The comment count already owns that corner, so HD drops below it rather than
   landing on top — only when there is actually a count to clear. */
.card:has(.commentflag) .hdflag { top: 30px; }

/* Ask the camera for the 4K original. Once asked it goes quiet and says so —
   the frame arrives on the camera's next check-in, which may be hours, and a
   button that still looked pressable would invite asking twice. */
.hqbtn {
    font-size: 0.72rem; padding: 0.22rem 0.45rem; border-radius: 6px;
    background: transparent; border: 1px solid #3a4a33; color: #a8b39a;
    cursor: pointer; white-space: nowrap;
}
.hqbtn:hover:not(:disabled) { background: #2e3c28; color: #e8e4d8; }
.hqbtn.waiting, .hqbtn:disabled {
    background: transparent; border-color: #5c5220; color: #d9b451; cursor: default;
}
button.primary.danger { background: #8d4034; }
button.primary.danger:hover { background: #a84e40; }
button.primary.danger:disabled { background: #3a4634; }
.cm-note { font-size: 0.8rem; color: #d2a79f; margin: 0 0 1rem; }

/* Library pager */
.pager {
    display: flex; align-items: center; justify-content: center; gap: 1rem;
    padding: 0.5rem 1.5rem 2.5rem;
}
.pagebtn {
    background: #243020; border: 1px solid #3a4a33; color: #cdd6c0;
    border-radius: 6px; padding: 0.5rem 1.1rem; font-size: 0.88rem;
    text-decoration: none;
}
a.pagebtn:hover { background: #2e3c28; color: #e8e4d8; border-color: #7ab55c; }
.pagebtn.disabled { opacity: 0.35; }
.pageinfo { font-size: 0.85rem; color: #a8b39a; font-variant-numeric: tabular-nums; }
/* Trail cameras shoot 16:9, so match it — a 4:3 box cropped the frame. */
.card img {
    width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
    display: block; cursor: zoom-in; background: #1a2417;
}
.cardbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.45rem 0.65rem;
}
/* Holds the caption and, on a photo reached through a shared tag, whose it is.
   min-width:0 lets the caption's ellipsis work inside the flex row. */
.metawrap { min-width: 0; flex: 1; }
.sharedby {
    font-size: 0.68rem; color: #8fa9c4; line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* "Somebody else has this frame too" — across the corner of the photo.

   The line of text below said the same thing and got scrolled straight past,
   which is how two people end up tagging the same buck on the same evening.
   Blue, like everything else here belonging to another account.

   The wrapper clips the band to the corner; the band itself is wider than the
   corner so its ends run off under the clip rather than showing as points. */
.sharedribbon {
    position: absolute; top: 0; left: 0; z-index: 3;
    width: 92px; height: 92px; overflow: hidden; pointer-events: none;
}
.sharedribbon > span {
    position: absolute; left: -34px; top: 20px; width: 150px;
    transform: rotate(-45deg);
    background: #2b6cb0; color: #fff;
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.09em;
    text-transform: uppercase; text-align: center; padding: 3px 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}
.sharedribbon[hidden] { display: none; }
/* In the viewer the ribbon hangs off the panel, not the photo: the image is
   centred and letterboxed, so a corner of the image is not a fixed place. */
.lb-ribbon { top: 0; left: 0; z-index: 6; }
@media (max-width: 760px) {
    .sharedribbon { width: 74px; height: 74px; }
    .sharedribbon > span { left: -30px; top: 15px; width: 124px; font-size: 0.55rem; }
}

/* What somebody else already did with this same frame. Blue, like everything
   else here that belongs to another account, so it reads as theirs at a
   glance rather than as a label on your own photo. */
.alreadyseen {
    font-size: 0.68rem; color: #8fa9c4; line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* What the model made of the photo. Deliberately quiet — it is a hint, not a
   verdict, and it sits under every single card. A buck is the one answer worth
   catching the eye, because that is what gets kept. */
.ailabel {
    font-size: 0.68rem; color: #9aa48f; line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ailabel.buck { color: #9fd67a; font-weight: 600; }
.aicount { color: #7f8a76; font-weight: 400; }
/* A backlog reads as "not yet", never as "nothing here". */
.ainotice {
    margin: 0; padding: 0.6rem 1.5rem; background: #1f2a38;
    border-bottom: 1px solid #33455c; color: #cfe0f2; font-size: 0.84rem;
}
@media (max-width: 760px) { .ainotice { padding: 0.55rem 0.85rem; } }

/* The model's label in the viewer's bar. Same restraint as on the card: a
   buck is worth the colour, everything else stays out of the way. */
.lb-ai { font-size: 0.82rem; color: #9aa48f; white-space: nowrap; }
.lb-ai.buck { color: #9fd67a; font-weight: 600; }
.lb-ai[hidden] { display: none; }

/* The same note in the viewer's bar, where the decision usually gets made. */
.lb-seen {
    font-size: 0.78rem; color: #8fa9c4;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-seen[hidden] { display: none; }
/* A photo you can see but do not own — no Keep, no Select, no Delete. */
.card.notmine { border-color: #3a4a6a; }

/* Copy-to-clipboard in the full-size viewer. Same family as the comments
   button beside it; green while the "Copied" confirmation shows. */
.lb-copybtn {
    background: transparent; border: 1px solid #4a5f42; color: #cdd6c0;
    border-radius: 5px; font-size: 0.78rem; padding: 0.2rem 0.5rem; cursor: pointer;
}
.lb-copybtn:hover { border-color: #7ab55c; color: #fff; }
.lb-copybtn.done { border-color: #7ab55c; color: #9fd487; }
.lb-copybtn[hidden] { display: none; }

/* Choosing the second photo for a side-by-side: a strip under the bar saying
   so, with the first photo in it so you remember what you are matching. */
.pickbar {
    display: flex; align-items: center; gap: 0.8rem;
    margin: 0; padding: 0.55rem 1.5rem;
    background: #2a2f1f; border-bottom: 1px solid #5a6b3a;
    color: #e8e4d8; font-size: 0.9rem;
}
.pickbar img { height: 52px; border-radius: 4px; flex: none; }
.pickbar a { color: #9fd487; margin-left: auto; }
@media (max-width: 760px) { .pickbar { padding: 0.5rem 0.85rem; font-size: 0.84rem; } }
.grid.pickmode .card img { cursor: copy; }
.grid.pickmode .card:hover { border-color: #9fd487; }

/* Two photos side by side (sidebyside.php): columns while there is width for
   them, stacked on a portrait phone where two across would be postage
   stamps. The frames keep their own shape rather than being cropped to fit. */
.grid.compare { grid-template-columns: 1fr 1fr; align-items: start; }
.grid.compare .card img { aspect-ratio: auto; object-fit: contain; }
.grid.compare .meta.sub { color: #9aa48f; font-size: 0.78rem; margin-top: 0.15rem; }
@media (max-width: 760px) and (orientation: portrait) {
    .grid.compare { grid-template-columns: 1fr; }
}

/* Comment thread inside the full-size viewer. */
.lb-commentsbtn {
    background: transparent; border: 1px solid #4a5f42; color: #cdd6c0;
    border-radius: 5px; font-size: 0.78rem; padding: 0.2rem 0.5rem; cursor: pointer;
}
.lb-commentsbtn:hover { border-color: #7ab55c; color: #fff; }
.lb-commentsbtn.has { border-color: #6f8fd4; color: #cfe0f2; }
.lb-commentsbtn.on { background: #2b3a4c; color: #fff; }
.lb-comments {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 65;
    width: min(360px, 92vw);
    display: flex; flex-direction: column;
    background: #1b2418; border-left: 1px solid #33455c;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}
.lb-comments[hidden] { display: none; }
.lbc-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 0.9rem; border-bottom: 1px solid #2e3c28;
    font-size: 0.9rem; color: #e8e4d8;
}
.lbc-close {
    background: none; border: 0; color: #a8b39a;
    font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.lbc-close:hover { color: #fff; }
.lbc-list { flex: 1; overflow-y: auto; padding: 0.6rem 0.9rem; }
.lbc-empty { color: #8f9a86; font-size: 0.82rem; margin: 0.5rem 0; }
.lbc-item { margin-bottom: 0.85rem; }
.lbc-who {
    display: flex; align-items: baseline; gap: 0.4rem;
    font-size: 0.7rem; color: #8fa9c4; margin-bottom: 0.15rem;
}
.lbc-item.mine .lbc-who { color: #9ec48a; }
.lbc-del {
    background: none; border: 0; color: #7f8a76; cursor: pointer;
    font-size: 0.95rem; line-height: 1; padding: 0 0.15rem; margin-left: auto;
}
.lbc-del:hover { color: #d97a6c; }
.lbc-body {
    font-size: 0.86rem; color: #e8e4d8; line-height: 1.4;
    white-space: pre-wrap; word-break: break-word;
}
.lbc-form {
    display: flex; gap: 0.4rem; align-items: flex-end;
    padding: 0.6rem 0.9rem; border-top: 1px solid #2e3c28;
}
.lbc-form textarea {
    flex: 1; resize: vertical; min-height: 2.4rem; max-height: 40vh;
    background: #141c12; border: 1px solid #3a4a33; border-radius: 6px;
    color: #e8e4d8; padding: 0.45rem 0.55rem;
    /* 16px keeps iOS from zooming the page when the box takes focus. */
    font-size: 16px; font-family: inherit;
}
.lbc-form textarea:focus { outline: none; border-color: #7ab55c; }
.lbc-form button { flex: none; }

/* Banner above a shared tag's photos, saying whose collection this is. */
.sharenote {
    margin: 0; padding: 0.65rem 1.5rem;
    background: #1f2a38; border-bottom: 1px solid #33455c;
    color: #cfe0f2; font-size: 0.84rem;
}
.sharenote b { color: #fff; }
.sharenote a { color: #8fc0f0; }
/* "Mark all read", sitting in the banner's own line rather than under it. The
   form is inline so the banner still reads as one sentence with a button on
   the end; it is a form and not a link because it changes something. */
.sharenote .markall { display: inline; margin-left: 0.5rem; }
.sharenote .markall button {
    background: transparent; border: 1px solid #3c5069; color: #cfe0f2;
    border-radius: 5px; font-size: 0.72rem; padding: 0.15rem 0.6rem;
    cursor: pointer; line-height: 1.5;
}
.sharenote .markall button:hover { background: #3c5069; color: #fff; }
@media (max-width: 760px) { .sharenote { padding: 0.6rem 0.85rem; } }
/* The caption is just the camera location now — the frame carries its own
   timestamp and temperature, so repeating them underneath said nothing new.
   Styled as the label it is rather than as the muted sub-line it used to be. */
.meta {
    font-size: 0.8rem; color: #e8e4d8; line-height: 1.35;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty { padding: 3rem 1.5rem; color: #a8b39a; }

/* Tags beside a photo's camera name, sharing the caption bar rather than
   taking a row of their own — that row cost real height on a phone, under
   every photo, whether or not anything was tagged. */
.phototags {
    display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center;
    padding: 0 0.65rem 0.55rem;
}
/* Inside the caption bar the bar's own padding already applies. */
.metawrap .phototags { padding: 0; }
/* Where they fit — a full-width card on a phone — the tags sit on the name's
   line. Where they do not, on a narrow desktop thumbnail, they wrap underneath
   rather than squeezing the name: a tag on a second line is still readable,
   half a camera name is not. */
.metarow {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 0.2rem 0.4rem;
}
.metarow .meta { flex: 0 1 auto; min-width: 0; }
.tagchip {
    display: inline-flex; align-items: center; gap: 0.2rem;
    background: #3a5a2c; color: #d6ecc9;
    font-size: 0.68rem; padding: 0.12rem 0.25rem 0.12rem 0.45rem;
    border-radius: 4px; line-height: 1.5;
}
/* A tag somebody else owns. Blue is already this app's colour for "belongs to
   another account" — it is what marks a shared photo's card — so a tag of
   theirs on your photo reads the same way. Hover says whose. */
.tagchip.theirs { background: #2b3a4c; color: #cfe0f2; }
.tagchip.theirs .tagx { color: #8fa9c4; }
/* No remove button on a tag that is not yours to take off — so it needs the
   padding back that the button was standing in. */
.tagchip.fixed { padding-right: 0.45rem; }
.tagx {
    background: none; border: 0; color: #a9c79a; cursor: pointer;
    font-size: 0.85rem; line-height: 1; padding: 0 0.15rem;
}
.tagx:hover { color: #fff; }
.addtag {
    background: transparent; border: 1px dashed #3a4a33; color: #8f9a86;
    font-size: 0.68rem; padding: 0.12rem 0.4rem; border-radius: 4px; cursor: pointer;
}
.addtag:hover { border-color: #7ab55c; color: #cdd6c0; }

#tagPicker {
    position: absolute; z-index: 90; width: 232px;
    background: #243020; border: 1px solid #4a7c3a; border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    padding: 0.5rem; font-size: 0.82rem;
}
#tagPicker[hidden] { display: none; }
/* Revealed by "+ Add a tag" rather than sitting there permanently: an input
   already on screen when the picker opens pulls up the on-screen keyboard on a
   tablet, covering the tag list you opened the picker to read. */
.tp-addrow {
    display: flex; gap: 0.35rem; align-items: center;
    margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px solid #2e3c28;
}
.tp-addrow[hidden] { display: none; }
#tagSearch {
    flex: 1 1 auto; min-width: 0; box-sizing: border-box;
    padding: 0.4rem 0.55rem;
    background: #1a2417; border: 1px solid #3a4a33; border-radius: 6px;
    color: #e8e4d8;
    /* iOS Safari zooms the whole page when focusing an input under 16px.
       Anything smaller here throws the layout about on an iPad. */
    font-size: 16px;
}
#tagSearch:focus { outline: none; border-color: #7ab55c; }
.tp-save {
    flex: none; background: #4a7c3a; color: #fff; border: 0;
    border-radius: 5px; padding: 0.45rem 0.75rem; font-size: 0.8rem;
    cursor: pointer;
}
.tp-save:hover { background: #5c9349; }
.tp-save:disabled { opacity: 0.6; cursor: wait; }
.tp-body {
    max-height: 260px; overflow-y: auto;
    display: flex; flex-direction: column;
}
/* Who a brand-new tag goes to, shown with the name field and only then. */
.tp-share {
    display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center;
    padding: 0 0.35rem 0.4rem;
}
.tp-share[hidden] { display: none; }
.tp-sharelabel { font-size: 0.68rem; color: #7f8a76; width: 100%; }
.tp-contact {
    display: inline-flex; align-items: center; gap: 0.3rem;
    background: #2b3a4c; color: #cfe0f2; border: 1px solid #3c5069;
    border-radius: 999px; font-size: 0.72rem; padding: 0.15rem 0.6rem;
    cursor: pointer;
}
.tp-contact:hover { background: #3c5069; }
.tp-contact input { width: 0.95rem; height: 0.95rem; accent-color: #7ab55c; flex: none; }
#tagPicker label.tp-opt {
    display: flex; align-items: center; gap: 0.45rem;
    padding: 0.3rem 0.35rem; border-radius: 5px; cursor: pointer; color: #e8e4d8;
}
#tagPicker label.tp-opt:hover { background: #2e3c28; }
#tagPicker label.tp-opt[hidden] { display: none; }
#tagPicker input[type=checkbox] { width: 1rem; height: 1rem; accent-color: #7ab55c; flex: none; }
.tp-text { line-height: 1.25; }
.tp-none { margin: 0.3rem 0; text-align: center; color: #8f9a86; font-size: 0.78rem; }
.tp-foot {
    display: flex; gap: 0.5rem; align-items: center; justify-content: space-between;
    margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px solid #2e3c28;
}
.tp-addbtn {
    background: #3a5a2c; color: #eaf3e4; border: 0; border-radius: 5px;
    padding: 0.38rem 0.65rem; font-size: 0.78rem; cursor: pointer;
}
.tp-addbtn:hover { background: #4a7c3a; }
.tp-manage { color: #7ab55c; font-size: 0.75rem; text-decoration: none; }
.tp-manage:hover { text-decoration: underline; }

/* Save indicator, driven by assets/busy.js. Above the lightbox (70) and the
   tag picker (90) so it stays visible while either is open. */
/* While a save runs the page is locked: this covers everything and swallows
   clicks, so a photo cannot be opened or a checkbox flipped between the save
   starting and the page reloading. It goes up the instant the save starts, but
   stays transparent until .visible is added ~150ms later, so a quick save
   blocks input without anything flashing on screen. */
#baBusy {
    display: none; position: fixed; inset: 0; z-index: 200;
    align-items: center; justify-content: center;
    background: transparent;
    cursor: progress;
}
#baBusy.on { display: flex; }
#baBusy.visible { background: rgba(0, 0, 0, 0.55); }
.ba-busycard {
    display: flex; align-items: center; gap: 0.6rem;
    visibility: hidden;
    background: #243020; border: 1px solid #4a7c3a; border-radius: 999px;
    padding: 0.6rem 1.2rem 0.6rem 0.9rem;
    color: #d6ecc9; font-size: 0.9rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}
#baBusy.visible .ba-busycard { visibility: visible; }
.ba-spin {
    width: 14px; height: 14px; flex: none; border-radius: 50%;
    border: 2px solid #3a5a2c; border-top-color: #7ab55c;
    animation: ba-spin 0.7s linear infinite;
}
@keyframes ba-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .ba-spin { animation-duration: 2.4s; }
}
.tp-empty { margin: 0; padding: 0.6rem; color: #a8b39a; text-align: center; font-size: 0.8rem; }
.tp-empty a { color: #7ab55c; }
.empty a { color: #7ab55c; }
button.primary {
    background: #4a7c3a; color: #fff; border: 0; border-radius: 6px;
    padding: 0.55rem 1.3rem; font-size: 0.92rem; cursor: pointer;
}
button.primary:hover:not(:disabled) { background: #5a9147; }
/* Disabled here means "not applicable yet" — Delete sits disabled until you
   tick a photo — not "busy". A wait cursor told you the app was working when
   it was idle, and the hover lift implied a button you could press. The busy
   overlay owns the wait cursor. */
button.primary:disabled { background: #3a4634; cursor: not-allowed; }
/* While the viewer is up the page behind it holds still. Set by ui.js on
   open, removed on close. overscroll-behavior kills the rubber-band, which is
   what let iOS draw the viewer's fixed layer halfway up the screen when a
   photo was tapped mid-scroll. */
.lb-lock, .lb-lock body { overflow: hidden; overscroll-behavior: none; }

#lightbox {
    display: none; position: fixed; inset: 0; z-index: 50;
    background: rgba(0, 0, 0, 0.93);
    align-items: center; justify-content: center;
    overflow: hidden;
    touch-action: none; /* we handle pinch, pan and swipe ourselves */
}
#lightbox.open { display: flex; }
/* Set by ui.js from the bar's measured height. The photo is centred inside
   what is left, so it never slides under the bar and loses the camera's own
   timestamp strip along the bottom of the frame. */
#lightbox { padding-bottom: var(--lb-bar-h, 0px); }
/* A photo slow enough to notice says so, so a wait is never mistaken for a
   press that did nothing — which is what made people tap Next again and skip
   the frame that was still arriving. */
#lightbox.loading img { opacity: 0.45; transition: opacity 0.15s; }
#lightbox.loading::after {
    content: "Loading…";
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(20, 28, 18, 0.9); color: #e8e4d8;
    padding: 0.4rem 0.9rem; border-radius: 999px;
    font-size: 0.8rem; letter-spacing: 0.02em; pointer-events: none;
}
/* ui.js measures each photo and sets an explicit width/height so a
   low-resolution frame is scaled UP to fill the same box as a high-resolution
   one — these caps only ever shrink, which is what left the smaller cameras
   marooned in the middle of the screen. Keep the percentages in step with
   BOX_W / BOX_H in ui.js; they stay here as a guard for the moment before a
   photo has loaded. */
#lightbox img {
    /* Guard for the moment before ui.js measures; it then sets an explicit
       width/height that accounts for the bar. Keep 92vw in step with BOX_W. */
    max-width: 92vw; max-height: 88vh;
    user-select: none; -webkit-user-drag: none;
    transform-origin: center center;
    cursor: zoom-in;
}
#lightbox.zoomed img { cursor: grab; }
#lightbox.zoomed img:active { cursor: grabbing; }
/* Chrome fires no dblclick without this on some touch devices */
#lightbox img { touch-action: none; }
.lb-zoom { color: #7ab55c; font-variant-numeric: tabular-nums; }
.lb-nav:disabled { opacity: 0.25; cursor: default; }
.lb-nav:disabled:hover { background: rgba(36, 48, 32, 0.75); }

/* End-of-batch panel, shown when you reach the last photo. */
.lb-end {
    display: none; position: fixed; z-index: 60;
    left: 50%; top: 50%; transform: translate(-50%, -50%);
    background: #243020; border: 1px solid #4a7c3a; border-radius: 12px;
    padding: 1.5rem 1.75rem; text-align: center;
    width: min(340px, 88vw); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.lb-end.on { display: block; }
.lb-end h3 { margin: 0 0 0.35rem; font-size: 1.15rem; color: #e8e4d8; }
.lb-end p { margin: 0 0 1.1rem; font-size: 0.85rem; color: #a8b39a; }
.lb-end-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.lb-end-back {
    background: transparent; border: 1px solid #3a4a33; color: #a8b39a;
    border-radius: 6px; padding: 0.5rem; font-size: 0.85rem; cursor: pointer;
}
.lb-end-back:hover { background: #2e3c28; color: #e8e4d8; }

/* Confirmation dialogs: before a batch of photos is deleted, and before the
   unreviewed backlog is cleared out by date. */
#confirmModal, #purgeModal {
    display: none; position: fixed; inset: 0; z-index: 70;
    background: rgba(0, 0, 0, 0.75);
    align-items: center; justify-content: center;
}
#confirmModal.on, #purgeModal.on { display: flex; }
.cm-box {
    background: #243020; border: 1px solid #2e3c28; border-radius: 12px;
    padding: 1.5rem 1.75rem; width: min(400px, 90vw);
}
.cm-box h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.cm-box p { margin: 0 0 1rem; font-size: 0.88rem; color: #cdd6c0; }
.cm-again {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.82rem; color: #a8b39a; margin-bottom: 1.1rem; cursor: pointer;
}
.cm-again input { width: 1.05rem; height: 1.05rem; accent-color: #7ab55c; }
.cm-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }
.cm-cancel {
    background: transparent; border: 1px solid #3a4a33; color: #a8b39a;
    border-radius: 6px; padding: 0.5rem 1rem; font-size: 0.88rem; cursor: pointer;
}
.cm-cancel:hover { background: #2e3c28; color: #e8e4d8; }
/* z-index, or the photo swallows the Previous button.
   ui.js puts a transform on the image for pan and zoom, and a transform makes
   a stacking context — so the image paints in the same layer as these fixed
   buttons and DOM order decides. It sits between Previous and Next in the
   markup, so Next survived and Previous did not. Only visible where the photo
   reaches the edges: at 92vw on a tablet there is nothing to spare. */
.lb-nav {
    position: fixed; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 3rem; height: 4.5rem; border: 0; border-radius: 8px;
    background: rgba(36, 48, 32, 0.75); color: #e8e4d8;
    font-size: 2.2rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.lb-nav:hover { background: rgba(74, 124, 58, 0.9); }
.lb-prev { left: 0.6rem; }
.lb-next { right: 0.6rem; }
.lb-close {
    /* Inside the safe area, or the status bar eats it.
       On an iPad this button sat 12px from the top -- directly underneath the
       clock and battery -- so it could not be seen or tapped. With no Escape
       key on a tablet and no tap-to-dismiss, that left the viewer with no way
       out at all. max() keeps the old spacing on hardware that has no inset. */
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top, 0px));
    right: max(0.9rem, env(safe-area-inset-right, 0px));
    width: 2.75rem; height: 2.75rem; border: 0; border-radius: 6px;
    background: rgba(36, 48, 32, 0.85); color: #e8e4d8;
    font-size: 1.6rem; line-height: 1; cursor: pointer;
    z-index: 2;   /* above the image, which is the thing it sits over */
}
.lb-close:hover { background: rgba(124, 58, 58, 0.9); }

/* Installed to the home screen, the app runs without browser chrome and the
   status bar sits over the top of the page. env(safe-area-inset-*) would say so
   -- but only with viewport-fit=cover, which this app does not set, so it
   resolves to 0 and the close button ends up under the clock.
   Adding viewport-fit globally would push every page's content into the unsafe
   area, which is a much larger change than the bug warrants. Nudging this one
   button, only when standalone, fixes exactly the case that is broken and
   leaves the browser alone. */
@media (display-mode: standalone) {
    .lb-close { top: max(2.9rem, env(safe-area-inset-top, 0px)); }
    .lb-bar   { padding-bottom: max(0.7rem, env(safe-area-inset-bottom, 0px)); }
}
.lb-bar {
    /* Same reasoning as the close button: the home indicator overlaps the
       bottom of the screen, and Keep lives down here. */
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0px); left: 0; right: 0;
    display: flex; align-items: center; justify-content: center;
    gap: 1.25rem; flex-wrap: wrap;
    padding: 0.7rem 1rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    color: #cdd6c0; font-size: 0.85rem;
}
.lb-count { color: #8f9a86; font-variant-numeric: tabular-nums; }
/* The camera's name under the photo. The date and time used to sit here too,
   which the camera already burns into the frame — so that part went and the
   name stayed, at every size. */
.lb-keep {
    display: flex; align-items: center; gap: 0.4rem;
    cursor: pointer; user-select: none;
    background: rgba(36, 48, 32, 0.85); padding: 0.35rem 0.8rem; border-radius: 6px;
}
.lb-keep input { width: 1.1rem; height: 1.1rem; accent-color: #7ab55c; cursor: pointer; }
.lb-hint { color: #7f8a76; font-size: 0.75rem; }
/* Tag row inside the viewer's bottom bar */
.lb-tags {
    padding: 0; gap: 0.3rem;
    background: rgba(36, 48, 32, 0.85);
    border-radius: 6px; padding: 0.28rem 0.5rem;
    max-width: min(60vw, 640px);
}
.lb-tags .addtag { border-color: #4a5f42; color: #cdd6c0; }
@media (max-width: 600px) {
    .lb-nav { width: 2.4rem; height: 3.5rem; font-size: 1.7rem; }
}

/* Launch screen — see includes/splash.php. Fixed and above everything, so it
   covers the page while it settles rather than sitting in the layout. */
#baSplash {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: #141c12;
    opacity: 1; transition: opacity 0.35s ease;
}
#baSplash[hidden] { display: none; }
#baSplash.gone { opacity: 0; pointer-events: none; }
#baSplash img { width: min(86vw, 620px); height: auto; }
/* Nothing scrolls underneath while it is up. */
html.ba-splashing, html.ba-splashing body { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { #baSplash { transition: none; } }

/* Comment control on a grid card. Mirrors the viewer's button so the same
   thread is reachable without opening the photo first. */
.cardcomments {
    flex: none; background: none; border: 1px solid #3a4a33; border-radius: 5px;
    color: #a8b39a; font-size: 0.72rem; padding: 0.2rem 0.4rem;
    cursor: pointer; line-height: 1.3;
}
.cardcomments:hover { background: #2e3c28; color: #e8e4d8; }
.cardcomments.has { border-color: #6f8fd4; color: #cfe0f2; }
.cardcomments.on { background: #2b3a4c; color: #fff; }
/* Above the grid now that the panel is no longer inside the viewer. */
.lb-comments { z-index: 60; }

/* An invitation waiting on you, as opposed to the amber "new photos" count —
   a different colour because it is a different thing: this one wants an answer. */
.navbadge.invite { background: #6f8fd4; color: #0d1524; }
/* The review queue is work in hand, not news: green rather than the gold used
   for "somebody did something you have not seen". */
.navbadge.queue { background: #4a7c3a; color: #fff; }

/* On a phone the thread was a full-height rail, which runs under iOS's own
   toolbars — the compose box ended up off-screen and you had to scroll a long
   way to reach it. A bottom sheet instead: fixed height, the thread scrolling
   inside it, the box always in view.
   dvh rather than vh so the height follows the toolbars as they hide.
   Up to 1024px, not the usual 760: an iPad is wider than a phone breakpoint
   and had exactly the same problem. Above that there is room for the rail. */
@media (max-width: 1024px) {
    .lb-comments {
        top: auto; left: 0; right: 0; bottom: 0;
        /* Stated, not auto: the base rule sets an explicit width for the
           desktop rail and auto does not reliably override it here. */
        width: 100%; max-width: none;
        height: 68vh;
        height: 68dvh;
        max-height: 68dvh;
        border-left: 0; border-top: 1px solid #33455c;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.55);
    }
    /* Reaching the end of the thread must not start scrolling the page behind. */
    .lbc-list { overscroll-behavior: contain; }
}


/* A photo that did not arrive. The browser's own broken-image icon says
   nothing and offers nothing, so the card says what happened and invites a
   tap. */
.card.failed img { opacity: 0; }
.card.failed {
    position: relative;
    background: #1b2416;
    cursor: pointer;
}
.card.failed::after {
    content: "Did not load — tap to retry";
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 1rem;
    color: #a8b39a; font-size: 0.82rem; line-height: 1.5;
    border: 1px dashed #3a4a33; border-radius: 8px;
}
.card img.retrying { opacity: 0.35; transition: opacity 0.15s; }

/* Floats above the page so it is reachable wherever you have scrolled to,
   and clear of the home indicator on a phone. */
.retryall {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 40; cursor: pointer;
    background: #7c3a3a; color: #fff; border: 0; border-radius: 999px;
    padding: 0.55rem 1.1rem; font-size: 0.84rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.retryall:hover { background: #944646; }
