:root {
  --bg: #0f1113;
  --panel: #181b1f;
  --panel-2: #20242a;
  --line: #2c3138;
  --text: #e8eaed;
  --muted: #9aa1ab;
  --accent: #f2b233;
  --accent-ink: #1a1400;
  --ok: #3fb97a;
  --warn: #e0a030;
  --bad: #e5534b;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; color: var(--muted); font-weight: 600;
     text-transform: uppercase; letter-spacing: .04em; scroll-margin-top: 64px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem;
        overflow-wrap: anywhere; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; flex-wrap: wrap;
  gap: .4rem 1rem; padding: .5rem 1rem; background: rgba(15,17,19,.94);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(6px);
}
.brand { font-weight: 700; color: var(--text); letter-spacing: .02em; }
.brand span { color: var(--accent); }
.topbar nav { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-left: auto;
              align-items: center; justify-content: flex-end; }
.topbar nav a { color: var(--muted); }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); text-decoration: none; }
.topbar form { margin: 0; }
.topbar nav button { min-height: 32px; padding: .25rem .6rem; }
a.card { display: block; color: var(--text); }
a.card:hover { text-decoration: none; border-color: #465061; }
a.card strong { color: var(--accent); }

main { max-width: 1400px; margin: 0 auto; padding: 1rem; }

.banner { border-radius: var(--radius); padding: .7rem .9rem; margin: 0 0 1rem;
          border: 1px solid var(--line); background: var(--panel); display: flex; gap: .8rem;
          align-items: center; flex-wrap: wrap; }
.banner.error { border-color: #7a2d2a; background: #2a1514; }
.banner.warning { border-color: #6b5220; background: #262010; }
.banner.info { border-color: #25493a; background: #122219; }
.banner form { margin: 0 0 0 auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: .9rem; }
.card + .card { margin-top: .8rem; }
.cards { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.cards > .card + .card { margin-top: 0; }
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.card > .row + .row, .card > table + .row { margin-top: .6rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin: .4rem 0; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { color: var(--muted); font-size: .8rem; }

.btn, button {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 8px; padding: .55rem .9rem; font: inherit; cursor: pointer; min-height: 40px;
}
.btn:hover, button:hover { border-color: #465061; text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink);
                               border-color: var(--accent); font-weight: 700; }
.btn.danger, button.danger { border-color: #7a2d2a; color: #ffb4ae; }
button:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea {
  font: inherit; color: var(--text); background: #0c0e10; border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .6rem; min-height: 40px; max-width: 100%;
}
label { color: var(--muted); font-size: .85rem; }
input[type="checkbox"] { min-height: 0; width: 1.1rem; height: 1.1rem; padding: 0; }
label.check { display: inline-flex; align-items: center; gap: .35rem; }
form.inline { display: inline-flex; gap: .5rem; align-items: center; margin: 0; flex-wrap: wrap; }

.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem;
        border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: #255f41; }
.pill.warn { color: var(--warn); border-color: #6b5220; }
.pill.bad { color: var(--bad); border-color: #7a2d2a; }

/* incoming-photos switch */
.incoming { margin: 1rem 0; border-color: #4a3b12; }
.switch-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .7rem 0; }
.switch-btn { min-height: 48px; min-width: 96px; font-size: 1rem; font-weight: 600; }
.switch-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* reject reasons in the viewer */
.reasons { display: none; flex-wrap: wrap; gap: .35rem; width: 100%; }
.lightbox.is-excluded .reasons { display: flex; }
.reasons .chip.on { background: var(--bad); color: #fff; border-color: var(--bad); }

/* sessions */
.session { border-left: 4px solid var(--line); }
.session.unsorted { border-left-color: var(--warn); }
.session.sorted { border-left-color: var(--ok); }
.session.mixed { border-left-color: #6a7eea; }
.strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: .6rem 0; }
.strip img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px;
             background: #0a0b0c; }
.new-album { display: none; }
.new-album.show { display: inline-flex; }

/* album grid */
.toolbar { padding: .6rem 0; border-bottom: 1px solid var(--line); margin-bottom: .8rem;
           background: var(--bg); }
@media (min-width: 900px) {
  .toolbar { position: sticky; top: 50px; z-index: 10; }
}
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: .3rem .8rem; min-height: 34px; }
.chip.on { background: var(--text); color: #111; border-color: var(--text); }
.grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  /* one line of filters to swipe through, so the photos stay on the first screen */
  #filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  #filters .chip { flex: 0 0 auto; }
}
.tile { position: relative; border-radius: 6px; overflow: hidden; background: #0a0b0c;
        aspect-ratio: 3 / 2; cursor: pointer; outline: 2px solid transparent; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.excluded img { opacity: .22; filter: grayscale(1); }
.tile.excluded::after { content: "✕"; position: absolute; inset: 0; display: grid;
                        place-items: center; font-size: 2rem; color: var(--bad); }
.tile.selected { outline-color: var(--accent); }
.tile .badge { position: absolute; top: 4px; right: 4px; font-size: .7rem; padding: .05rem .4rem;
               border-radius: 999px; background: rgba(0,0,0,.72); }
.tile .badge:empty { display: none; }
.badge.live { color: var(--ok); }
.badge.pending { color: var(--warn); }
.badge.problem { color: var(--bad); }
.badge.hidden { color: var(--muted); }
.badge.sent { color: #8fb4ff; }
.tile .x, .tile .ok { position: absolute; left: 3px; top: 3px; width: 28px; height: 28px;
                      min-height: 0; padding: 0; border-radius: 50%; border: 0;
                      background: rgba(0,0,0,.5); font-size: .85rem; line-height: 28px; }
.tile .x { left: 35px; }
.tile.marked-sharp .ok { background: var(--ok); color: #04130b; font-weight: 700; }
.tile.excluded .x { background: var(--bad); color: #fff; }
/* the sharpness check's reading: edge width of the sharpest spot, lower is sharper */
.tile .reading { position: absolute; left: 4px; bottom: 4px; font-size: .72rem;
                 padding: .05rem .4rem; border-radius: 999px; background: rgba(0,0,0,.72);
                 font-variant-numeric: tabular-nums; }
.v-sharp { color: var(--ok); }
.v-close { color: var(--warn); }
.v-soft { color: var(--bad); }
.v-none, .v-wait { color: var(--muted); }
.lightbox .info.v-sharp { color: var(--ok); }
.lightbox .info.v-close { color: var(--warn); }
.lightbox .info.v-soft { color: var(--bad); }
.tile .processing { position: absolute; inset: 0; display: grid; place-items: center;
                    color: var(--muted); font-size: .8rem; }
.hidden-tile { display: none; }
.select-bar { display: none; }
.select-mode .select-bar { display: flex; }

/* sharp enough to sell? */
.sharp-panel { margin: .8rem 0; }
.sharp-panel summary { cursor: pointer; font-weight: 600; }
.sharp-panel > .row, .sharp-panel > p { margin: .6rem 0 0; }
.sharp-panel form { margin: 0; }
.sharp-panel button { min-height: 36px; padding: .35rem .8rem; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #000; display: none;
            flex-direction: column; }
.lightbox.open { display: flex; }
.lightbox .stage { flex: 1; display: grid; place-items: center; min-height: 0;
                   touch-action: pan-y; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox.is-excluded img { opacity: .35; }
.lightbox.is-excluded.is-close img { opacity: 1; }  /* a close look is for judging */
/* the next picture is on its way: do not judge (or mark) the one still showing */
.lightbox.loading .stage img { opacity: .12; }
.lightbox .stage { position: relative; }
.mark-spot, .mark-af, .mark-helmet { position: absolute; pointer-events: none;
                                     opacity: .85; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.mark-spot { width: 44px; height: 44px; margin: -22px 0 0 -22px; border: 2px solid #fff;
             border-radius: 50%; }
.mark-af { border: 2px solid #6cb2ff; }
.mark-helmet { border: 2px solid #5fe08a; border-radius: 28%; }
.lightbox .stage img { cursor: zoom-in; }
.lightbox.is-close .stage img { cursor: zoom-out; }
/* Helmet is switched on, but this photo is showing something else */
.lightbox #lb-helmet.armed { border-color: var(--accent); color: var(--accent); }
.lightbox #lb-sharp.on-sharp { background: var(--ok); border-color: var(--ok);
                               color: #04130b; font-weight: 700; }
.lightbox #lb-exclude.on-soft { background: var(--bad); border-color: var(--bad);
                                color: #fff; font-weight: 700; }
.lightbox .bar { display: flex; gap: .5rem; align-items: center; padding: .6rem .8rem;
                 flex-wrap: wrap; border-top: 1px solid var(--line); }
.lightbox .info { color: var(--muted); font-size: .85rem; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 1.6rem;
                 background: rgba(0,0,0,.4); border: 0; width: 48px; height: 72px; }
.lightbox .prev { left: 6px; }
.lightbox .next { right: 6px; }
/* The stage comes later in the page and is positioned too, so without a z-index it covers
   these buttons and swallows the taps (the Close button did nothing on the phone). */
.lightbox .close { position: absolute; top: 8px; right: 8px; z-index: 3; }
.lightbox .nav { z-index: 3; }

/* server browser */
.remote main { max-width: none; padding: .5rem .6rem; display: flex; flex-direction: column;
               height: calc(100vh - 50px); height: calc(100dvh - 50px); }
.remote .remote-head h1 { margin: 0; font-size: 1.05rem; }
.remote .remote-head { margin-bottom: .4rem; }
.remote .remote-head button { min-height: 34px; padding: .3rem .8rem; }
.remote-tools { margin-bottom: .4rem; }
.remote-tools input[type="text"], .remote-tools input[type="password"] {
  flex: 1 1 11rem; min-width: 8rem; min-height: 36px; }
.remote-tools button { min-height: 36px; }
.remote-screen { position: relative; flex: 1 1 auto; min-height: 240px; background: #0a0b0c;
                 border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.remote-wait { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
               color: var(--muted); background: rgba(10, 11, 12, .85); text-align: center;
               padding: 1rem; }
.remote-wait[hidden] { display: none; }
.remote .remote-help { margin-top: .4rem; flex: 0 0 auto; max-height: 40vh; overflow: auto; }
.remote-help summary { cursor: pointer; }
.remote-back { display: none; }
@media (max-width: 700px) {
  /* A phone needs every pixel for the remote screen: the site menu makes way. */
  .remote .topbar { display: none; }
  .remote .remote-back { display: inline; }
  .remote main { height: 100vh; height: 100dvh; padding: .3rem .35rem; }
  .remote .remote-head { margin-bottom: .25rem; }
  .remote-tools { margin-bottom: .25rem; }
  .remote-tools form.row { gap: .35rem; }
  .remote-tools .spacer { display: none; }
  .remote-tools .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%;
                         scrollbar-width: none; }
  .remote-tools .chip { flex: 0 0 auto; }
  .remote .remote-help { max-height: 30vh; padding: .5rem .7rem; }
}
#rb-state[data-state="running"] { color: var(--ok); border-color: #255f41; }
#rb-state[data-state="starting"], #rb-state[data-state="stopping"] {
  color: var(--warn); border-color: #6b5220; }

table.compact { width: auto; margin: .5rem 0; }
table.compact td { padding: .3rem .9rem .3rem 0; vertical-align: middle; border-bottom: 0; }
table.compact td:first-child, table.compact button { white-space: nowrap; }
table.compact button { min-height: 34px; padding: .3rem .8rem; }
@media (max-width: 700px) { h2 { scroll-margin-top: 104px; } }
.download-note { color: var(--ok); }
.download-note[hidden] { display: none; }
button.small { min-height: 32px; padding: .25rem .6rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line);
         vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.center-box { max-width: 380px; margin: 12vh auto; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.gallery-thumbs { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.gallery-thumbs figure { margin: 0; font-size: .72rem; color: var(--muted); }
.gallery-thumbs img { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 4px; }
