/* ==========================================================================
   Client gallery — cool grey light theme, graphite lightbox.
   Design intent: the interface recedes; the photographs carry the page.
   A neutral grey shell keeps warm and cool images looking equally correct.
   ========================================================================== */

:root {
  /* Cool neutral greys — no warmth, so they never tint the photographs */
  --paper:        #f4f6f8;
  --paper-sunk:   #e4e8ed;
  --paper-raised: #ffffff;
  --ink:          #12161b;
  --ink-soft:     #59626d;
  --ink-faint:    #8b95a1;
  --line:         rgba(18, 22, 27, 0.13);
  --line-soft:    rgba(18, 22, 27, 0.07);
  --accent:       #2b7fd4;   /* clear blue — reads against any photograph */
  --accent-deep:  #1f66b0;
  --accent-wash:  rgba(43, 127, 212, 0.12);
  --danger:       #c0392f;   /* login errors only */

  --dark:         #0c0e11;
  --dark-veil:    rgba(12, 14, 17, 0.94);
  --on-dark:      #eef1f5;
  --on-dark-soft: rgba(238, 241, 245, 0.58);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans:  "Karla", ui-sans-serif, "Helvetica Neue", Arial, sans-serif;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --gutter: clamp(1rem, 3.2vw, 2.75rem);
  --radius: 3px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================ buttons ==== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.62em 1.15em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 0.795rem;
  font-weight: 500;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.22s var(--ease), border-color 0.22s var(--ease),
              color 0.22s var(--ease), opacity 0.22s var(--ease);
}
.btn:hover { background: var(--paper-sunk); border-color: rgba(18, 22, 27, 0.26); }
.btn:disabled { opacity: 0.36; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; border-color: var(--line); }

.btn--solid {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.btn--solid:hover { background: #262c34; border-color: #262c34; }

.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn--quiet {
  border-color: transparent;
  color: var(--ink-soft);
  padding-inline: 0.7em;
}
.btn--quiet:hover { background: var(--paper-sunk); border-color: transparent; color: var(--ink); }

.btn--on-dark { border-color: rgba(238, 241, 245, 0.22); color: var(--on-dark); }
.btn--on-dark:hover { background: rgba(238, 241, 245, 0.12); border-color: rgba(238, 241, 245, 0.42); }

.btn .icon { width: 15px; height: 15px; flex: none; }

/* ============================================================== login ==== */

.login {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  position: relative;
  overflow: hidden;
}

/* Blurred, detail-free backdrop — safe to serve outside the auth boundary */
.login__backdrop {
  position: fixed;
  inset: -8%;
  background: var(--paper-sunk) center/cover no-repeat;
  transform: scale(1.06);
  filter: saturate(1.05);
  z-index: 0;
  animation: drift 38s var(--ease) infinite alternate;
}
.login__backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(244, 246, 248, 0.34), rgba(244, 246, 248, 0.86) 72%),
    linear-gradient(180deg, rgba(18, 22, 27, 0.12), rgba(18, 22, 27, 0.3));
}

@keyframes drift {
  from { transform: scale(1.06) translate3d(0, 0, 0); }
  to   { transform: scale(1.14) translate3d(-1.5%, -1.5%, 0); }
}

.login__card {
  position: relative;
  z-index: 1;
  width: min(28.5rem, 100%);
  padding: clamp(2.25rem, 5vw, 3.25rem);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    0 1px 2px rgba(18, 22, 27, 0.05),
    0 24px 70px -24px rgba(18, 22, 27, 0.35);
  border-radius: 4px;
  text-align: center;
  animation: rise 0.9s var(--ease-out) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.login__eyebrow {
  margin: 0 0 1.4rem;
  font-size: 0.66rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.login__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 7vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
}
.login__title em {
  display: block;
  font-style: italic;
  color: var(--accent);
}

.login__note {
  margin: 1.1rem 0 2rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 22rem;
  margin-inline: auto;
}

.login__form { display: grid; gap: 0.6rem; }

.field {
  position: relative;
  display: flex;
  align-items: center;
}

.field input {
  width: 100%;
  padding: 0.95rem 3.1rem 0.95rem 1rem;
  font: inherit;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease),
              box-shadow 0.2s var(--ease);
}
.field input::placeholder { color: var(--ink-faint); letter-spacing: 0.02em; }
.field input:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.field__reveal {
  position: absolute;
  right: 0.4rem;
  display: grid;
  place-items: center;
  width: 2.35rem; height: 2.35rem;
  border: 0; background: none;
  color: var(--ink-faint);
  cursor: pointer;
  border-radius: var(--radius);
}
.field__reveal:hover { color: var(--ink); background: var(--paper-sunk); }
.field__reveal .icon { width: 17px; height: 17px; }

.login__submit { width: 100%; justify-content: center; padding-block: 0.95em; }

.login__error {
  min-height: 1.35rem;
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--danger);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.login__error.is-shown { opacity: 1; }

.login__card.is-shaking { animation: shake 0.42s var(--ease); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.login__footer {
  position: relative;
  z-index: 1;
  margin-top: 2rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: center;
}

/* ============================================================= header ==== */

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(244, 246, 248, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line-soft);
  transition: border-color 0.3s var(--ease);
}
.masthead.is-stuck { border-bottom-color: var(--line); }

.masthead__inner {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.75rem);
  padding: 1.05rem var(--gutter);
  max-width: 2200px;
  margin: 0 auto;
}

.masthead__id { min-width: 0; }

.masthead__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.6rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.masthead__meta {
  margin: 0.1rem 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.masthead__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ================================================================ grid ==== */

.gallery {
  padding: clamp(1.25rem, 3vw, 2.5rem) var(--gutter) 7rem;
  max-width: 2200px;
  margin: 0 auto;
}

.grid { display: flex; flex-direction: column; gap: var(--tile-gap, 10px); }
.grid__row { display: flex; gap: var(--tile-gap, 10px); }

.tile {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: var(--paper-sunk) center/cover no-repeat;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  flex: none;
  /* LQIP sits underneath as a background-image until the real file paints */
  animation: tile-in 0.75s var(--ease-out) both;
  animation-delay: var(--tile-delay, 0ms);
}

@keyframes tile-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* Once the first render has played, drop the animation entirely. Any later
   relayout (rotation, window resize) then repositions tiles silently instead
   of fading all 72 back in. */
.grid.is-settled .tile { animation: none; }

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.55s var(--ease), transform 0.75s var(--ease);
  /* Deliberately NOT `will-change` here. Promoting all 72 thumbnails to their
     own compositor layers exhausts GPU memory on a phone, and evicted layers
     get re-rasterised on scroll — which looks like the images blinking. */
}
.tile img.is-loaded { opacity: 1; }

/* Promote only the tile actually being hovered, and only where hover
   exists at all. */
@media (hover: hover) and (pointer: fine) {
  .tile:hover img { transform: scale(1.035); will-change: transform; }
}

/* Vignette that only appears on hover, so resting state stays flat and quiet */
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(12, 14, 17, 0.42), rgba(12, 14, 17, 0) 42%);
  opacity: 0;
  transition: opacity 0.28s var(--ease);
  pointer-events: none;
}
.tile:hover::after, .tile:focus-visible::after { opacity: 1; }

.tile__index {
  position: absolute;
  left: 0.6rem;
  bottom: 0.5rem;
  z-index: 2;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--on-dark);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
  pointer-events: none;
}
.tile:hover .tile__index, .tile:focus-visible .tile__index { opacity: 1; transform: none; }

/* --- selection checkbox --- */

.tile__check {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 3;
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(12, 14, 17, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease),
              background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.tile__check .icon { width: 13px; height: 13px; opacity: 0; transition: opacity 0.15s var(--ease); }

.tile:hover .tile__check,
.tile:focus-within .tile__check,
.is-selecting .tile__check { opacity: 1; transform: none; }

.tile.is-selected .tile__check {
  opacity: 1;
  transform: none;
  background: var(--accent);
  border-color: var(--accent);
}
.tile.is-selected .tile__check .icon { opacity: 1; }

.tile.is-selected {
  box-shadow: 0 0 0 3px var(--accent);
}
.tile.is-selected img { transform: scale(1.02); }

/* When selecting, clicking the tile body toggles rather than zooms */
.is-selecting .tile { cursor: pointer; }

/* --------------------------------------------------------- action bar --- */

.actionbar {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 60;
  transform: translate(-50%, 160%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  /* Uniform padding is what makes the inner pills sit concentrically inside
     the outer one. Any asymmetry here and the buttons look wedged. */
  padding: 0.45rem;
  background: var(--dark-veil);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  color: var(--on-dark);
  border: 1px solid rgba(238, 241, 245, 0.09);
  border-radius: 999px;
  box-shadow:
    0 20px 55px -14px rgba(0, 0, 0, 0.66),
    0 2px 10px -3px rgba(0, 0, 0, 0.45);
  transition: transform 0.42s var(--ease-out);
  max-width: calc(100vw - 1.5rem);
}
.actionbar.is-open { transform: translate(-50%, 0); }

/* Buttons inherit the pill so their curve is concentric with the container's.
   Clear is a ghost, so only the primary action carries weight. */
.actionbar .btn {
  border-radius: 999px;
  padding: 0.62em 1.05em;
}

.actionbar .btn--on-dark {
  border-color: transparent;
  color: var(--on-dark-soft);
}
.actionbar .btn--on-dark:hover {
  background: rgba(238, 241, 245, 0.1);
  border-color: transparent;
  color: var(--on-dark);
}

.actionbar .btn--accent {
  padding-inline: 1.15em;
  /* Holds its width while the label counts up during a download, so the bar
     doesn't shuffle on every file. */
  min-width: 11.5rem;
  justify-content: center;
  /* The label also carries "12 / 47" progress while zipping. */
  font-variant-numeric: tabular-nums;
}

.actionbar__count {
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  margin: 0;
  padding-inline: 0.95rem 0.4rem;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--on-dark-soft);
  white-space: nowrap;
}
.actionbar__count strong {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--on-dark);
  letter-spacing: 0;
  /* Fixed-width digits: 9 -> 10 -> 100 doesn't nudge the layout. */
  font-variant-numeric: tabular-nums;
}

.actionbar__sep {
  width: 1px;
  height: 1.35rem;
  background: rgba(238, 241, 245, 0.13);
  margin-inline: 0.1rem;
}

/* The byte total is supporting detail, not the label. */
.actionbar__size {
  margin-left: 0.15em;
  opacity: 0.66;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ progress -- */

.progress {
  position: fixed;
  left: 0; right: 0; top: 0;
  z-index: 200;
  height: 2px;
  background: transparent;
  pointer-events: none;
}
.progress__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s var(--ease), opacity 0.4s var(--ease) 0.2s;
}

/* ============================================================ lightbox === */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  /* minmax(0, 1fr): a plain 1fr has an automatic minimum, so a tall photo
     would stretch the stage past the viewport instead of being scaled down. */
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--dark);
  color: var(--on-dark);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.32s var(--ease), visibility 0.32s;
}
.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox__bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem var(--gutter);
  background: linear-gradient(to bottom, rgba(12, 14, 17, 0.85), transparent);
}

.lightbox__caption { min-width: 0; }
.lightbox__counter {
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}
.lightbox__counter span { color: var(--on-dark-soft); }
.lightbox__filename {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-dark-soft);
}

.lightbox__tools { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

.lightbox__stage {
  position: relative;
  display: grid;
  /* A single explicit track that the frame stretches into. The frame must end
     up with a DEFINITE height, otherwise the image's percentage max-height
     below has nothing to resolve against and computes to `none` — which lets
     a portrait photo run to full width and overflow the viewport. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  padding: 0 clamp(0.5rem, 5vw, 4.5rem);
  min-height: 0;
  overflow: hidden;
}

.lightbox__frame {
  position: relative;
  /* Stretches to fill the stage track (the default align/justify behaviour),
     giving it the definite box the image sizes against. */
  min-width: 0;
  min-height: 0;
  display: grid;
  /* These tracks must be declared explicitly. Without them the image lands in
     an IMPLICIT auto-sized row, which grows to the image's own height — so
     max-height:100% below resolves against the image itself and constrains
     nothing. minmax(0, 1fr) pins the track to the frame's definite height. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  box-shadow: 0 30px 90px -30px rgba(0, 0, 0, 0.9);
}
.lightbox__img.is-loaded { opacity: 1; }

.lightbox__spinner {
  position: absolute;
  width: 26px; height: 26px;
  border: 2px solid rgba(238, 241, 245, 0.22);
  border-top-color: var(--on-dark);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}
.lightbox__spinner.is-shown { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox__nav {
  position: absolute;
  top: 50%;
  /* Above the frame. Both are positioned with z-index:auto otherwise, so they
     would paint in DOM order — and the frame follows the prev button in the
     markup, which left the image covering it. */
  z-index: 3;
  transform: translateY(-50%);
  width: 3rem; height: 3rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(238, 241, 245, 0.16);
  border-radius: 50%;
  background: rgba(12, 14, 17, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--on-dark);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease),
              opacity 0.2s var(--ease);
}
.lightbox__nav:hover { background: rgba(238, 241, 245, 0.16); border-color: rgba(238, 241, 245, 0.4); }
.lightbox__nav:disabled { opacity: 0.22; cursor: default; }
.lightbox__nav--prev { left: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox__nav--next { right: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox__nav .icon { width: 19px; height: 19px; }

/* Filmstrip */
.filmstrip {
  display: flex;
  gap: 6px;
  padding: 0.85rem var(--gutter) 1.15rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(238, 241, 245, 0.25) transparent;
  background: linear-gradient(to top, rgba(12, 14, 17, 0.85), transparent);
}
.filmstrip::-webkit-scrollbar { height: 4px; }
.filmstrip::-webkit-scrollbar-thumb { background: rgba(238, 241, 245, 0.25); border-radius: 2px; }

.filmstrip__item {
  position: relative;
  flex: none;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: #1c1a18;
  cursor: pointer;
  opacity: 0.42;
  transition: opacity 0.22s var(--ease), box-shadow 0.22s var(--ease);
}
.filmstrip__item img { height: 100%; width: auto; object-fit: cover; }
.filmstrip__item:hover { opacity: 0.8; }
.filmstrip__item.is-current { opacity: 1; box-shadow: 0 0 0 2px var(--on-dark); }
.filmstrip__item.is-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: 2px;
}

/* ============================================================== toast ==== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  z-index: 300;
  transform: translate(-50%, 1rem);
  padding: 0.7rem 1.15rem;
  background: var(--dark-veil);
  color: var(--on-dark);
  font-size: 0.84rem;
  border-radius: 100px;
  box-shadow: 0 14px 40px -12px rgba(12, 14, 17, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease), visibility 0.28s;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.is-shown { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* ============================================================== empty ==== */

.empty {
  padding: 6rem var(--gutter);
  text-align: center;
  color: var(--ink-soft);
}
.empty h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

/* ========================================================= responsive ==== */

@media (max-width: 760px) {
  .masthead__inner { flex-wrap: wrap; row-gap: 0.75rem; padding-block: 0.9rem; }
  .masthead__title { font-size: 1.35rem; }
  .masthead__actions { width: 100%; margin-left: 0; }
  .masthead__actions .btn { flex: 1; justify-content: center; }
  .btn__label--long { display: none; }
  .lightbox__bar { padding-inline: 1rem; }
  .lightbox__nav { width: 2.5rem; height: 2.5rem; }
  .filmstrip { display: none; }

  .actionbar { gap: 0.25rem; padding: 0.4rem; }
  .actionbar__count { padding-inline: 0.75rem 0.25rem; font-size: 0.75rem; }
  .actionbar .btn { padding: 0.62em 0.85em; }
  /* Let the primary button size to its label rather than reserving width
     we can't spare on a phone. */
  .actionbar .btn--accent { min-width: 0; padding-inline: 0.95em; }
}

/* Very narrow: drop the word, keep the number. "12" still reads as a count
   next to the buttons, and the bar stays on one line. */
@media (max-width: 400px) {
  .actionbar__count .actionbar__word { display: none; }
  .actionbar__sep { margin-inline: 0; }
}

@media (hover: none) {
  /* Touch devices have no hover, so affordances stay visible */
  .tile__check { opacity: 1; transform: none; }
  .tile__index { opacity: 1; transform: none; }

  /* A blurred sticky header has to re-composite the content behind it on
     every scroll frame, which is a common source of stutter on phones.
     Opaque costs nothing and looks the same over a light background. */
  .masthead {
    background: var(--paper);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .actionbar {
    background: #14181d;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Touch devices can latch :hover after a tap, leaving a tile stuck in its
     hover state. Nothing here should respond to hover at all. */
  .tile:hover img { transform: none; }
  .tile:hover::after { opacity: 0; }
  .tile:focus-visible::after { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .tile:hover img { transform: none; }
}

@media print {
  .masthead, .actionbar, .lightbox, .toast { display: none !important; }
}
