@font-face {
  font-family: "TWK Lausanne";
  src: url("fonts/TWKLausanne-350.woff2") format("woff2"),
       url("fonts/TWKLausanne-350.ttf") format("truetype");
  font-weight: 350;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --fg: #ffffff;
  --dim: #666666;
  --label: #323232; /* field labels: project / tags / add */
  --pad: 24px;
  --bar-h: 67px;   /* top bar height (pad 24 + logo 39 + pad 4) — info page uses it */
  --gap: 24px;     /* horizontal gap between tiles */
  --rowgap: 32px;  /* vertical gap between tiles */
  --ease: cubic-bezier(0.16, 1, 0.3, 1); /* ease-out-expo-ish */
}

html { background: #000; }
body {
  background: #000;
  color: var(--fg);
  font-family: "TWK Lausanne", system-ui, -apple-system, sans-serif;
  font-weight: 350;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  /* footer sticks to the viewport bottom even when the grid is short.
     dvh tracks the real visible height on iOS (url bar); vh is the fallback */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
#grid { flex: 1 0 auto; }

input, button, label, textarea { font-family: inherit; font-weight: inherit; font-size: 13px; }

/* generic hover for interactive text: dim -> white. one list for every
   dim-grey interactive element; element-specific extras stay at their rules */
.hoverable, #cols button, #modes button, .chip, #detail-close, #f-delete,
#f-public, .suggest div, .chip-x, #auth-links button, #auth-code-ok,
#btn-logout, .tag-chip, #f-url-link, #branding button, .meta-og button,
.info-add, #le-delete, #legal-footer a, #legal-footer button {
  color: var(--dim);
  cursor: pointer;
  transition: color 0.2s var(--ease);
}
.hoverable:hover, #cols button:hover, #modes button:hover, .chip:hover,
#detail-close:hover, #f-delete:hover, #f-public:hover, .suggest div:hover, .chip-x:hover,
#auth-links button:hover, #auth-code-ok:hover,
#btn-logout:hover, .tag-chip:hover, #f-url-link:hover, #branding button:hover,
.meta-og button:hover, .info-add:hover, #le-delete:hover,
#legal-footer a:hover, #legal-footer button:hover {
  color: var(--fg);
}

/* shared recipe for dark floating overlays. two tints:
   .float-panel — near-black, heavy blur (filter panel, suggest dropdowns)
   .float-menu  — lighter, small context menus (link menu, footer add menu) */
.float-panel, .float-menu {
  border-radius: 8px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.7);
}
.float-panel {
  background: rgba(13, 13, 13, 0.95);
  -webkit-backdrop-filter: blur(48px); backdrop-filter: blur(48px);
}
.float-menu {
  background: rgba(26, 26, 26, 0.95);
  -webkit-backdrop-filter: blur(25px); backdrop-filter: blur(25px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
}

/* ---- top bar ---------------------------------------------------------- */
/* not sticky: the bar scrolls away with the page */
#bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: var(--pad) var(--pad) 4px;
  background: #000;
}
#logo { height: 39px; flex: 0 0 auto; display: flex; align-items: center; opacity: 0.85; transition: opacity 0.2s var(--ease); }
#logo:hover { opacity: 1; }
#logo svg, #logo #logo-custom { height: 39px; width: auto; display: block; }
body.authed #logo { cursor: pointer; }

/* search lives centered in the bar, between logo and the filter button */
#searchwrap {
  flex: 1;
  display: flex; justify-content: center; align-items: baseline; gap: 8px;
  min-width: 0;
}
#search-label { color: var(--dim); display: none; } /* "Search" prefix */
#searchwrap.searching #search-label { display: inline; }
#search {
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 0;
  outline: none;
  width: auto;
}
#search::placeholder { color: var(--dim); }

/* actions pinned to the far right of the bar */
#actions { flex: 0 0 auto; display: flex; gap: 16px; align-items: center; }

/* nav pill: Info + Filter/Work in a dark rounded container (Figma 623:846) */
#navpill {
  display: flex; align-items: center; justify-content: flex-end;
  height: 38px; padding: 2px;
  border-radius: 8px;
  background: rgba(41, 41, 41, 0.8);
  -webkit-backdrop-filter: blur(25px); backdrop-filter: blur(25px);
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.7);
}
#navpill button {
  position: relative; z-index: 1; /* above the magnetic pill background */
  height: 100%; padding: 0 14px;
  border-radius: 6px;
  color: #b5b5b5; cursor: pointer;
  transition: color 0.2s var(--ease);
}
#navpill button:hover { color: var(--fg); }
#navpill button.active { color: var(--fg); }
/* "magnetic pill": one dark background that rests on the active button and
   snaps quickly to whichever button is hovered (JS moves it) */
#navpill-bg {
  position: absolute; top: 2px; bottom: 2px; left: 0; width: 0;
  border-radius: 6px; background: #0b0b0b;
  opacity: 0; pointer-events: none;
  transition: transform 0.15s var(--ease), width 0.15s var(--ease), opacity 0.15s var(--ease);
}

/* filter + view options: an overlay anchored to the bar's bottom edge.
   position:absolute (inside the relatively-positioned #bar) so it floats over
   the grid instead of pushing it down. Collapsed by default; expands on .open
   by animating the height 0 -> content height (easeOutExpo, 0.2s). */
#filter-panel {
  position: absolute;
  top: calc(100% + 4px); right: var(--pad); left: auto; width: auto; /* hugs content, under the pill */
  z-index: 9; /* under the bar (10), over the grid */
  overflow: hidden;
  height: 0; /* collapsed by default; JS animates the height (easeOutExpo, 0.2s) */
  transition: height 0.2s var(--ease);
  /* panel look comes from .float-panel */
}
/* the actual layout + padding — clipped by #filter-panel when collapsed */
#filter-row {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 24px; padding: 18px;
}

/* the three sections sit in a right-aligned row on desktop, 24px apart */
#filter-sections { display: flex; align-items: flex-start; gap: 24px; }
#filter-projects, #filter-tags { min-width: 150px; }

/* each section: a left-aligned vertical list, label on top */
.fsec { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.fsec .chip, .fsec button { white-space: nowrap; }
.fsec-label { color: var(--dim); }   /* "view options" — non-interactive */
.fsec-sep { color: var(--dim); }     /* "-" divider between grid + layout opts */

/* mobile-only search inside the filter panel (hidden on desktop) */
#search-m {
  display: none;
  width: 100%;
  background: transparent; border: none; outline: none;
  color: var(--fg); padding: 0 0 24px;
  border-bottom: 0.5px solid var(--label);
}
#search-m::placeholder { color: var(--dim); }

/* column-count buttons: desktop shows 5/4/3, mobile shows 2/1
   (needs #cols prefix to beat the specificity of "#cols button") */
#cols .mobcol { display: none; }

/* grid + layout options stack vertically within the view-options section */
#cols, #modes { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.chip.active, #cols button.active, #modes button.active { color: var(--fg); }

button { background: transparent; border: none; }

#status { color: var(--dim); text-align: right; }

/* ---- grid ------------------------------------------------------------- */
#grid { padding: var(--pad); }

/* masonry: JS distributes the cells row-major (left to right) into equal-width
   flex columns (.mcol), so the reading order goes across, not down. */
#grid[data-mode="masonry"] { display: flex; align-items: flex-start; gap: var(--gap); }
#grid[data-mode="masonry"] .mcol {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; gap: var(--rowgap);
}

/* top aligned: row by row, items align to top (gaps appear) */
#grid[data-mode="grid"] { display: grid; column-gap: var(--gap); row-gap: var(--rowgap); align-items: start; }
#grid[data-mode="grid"][data-cols="5"] { grid-template-columns: repeat(5, 1fr); }
#grid[data-mode="grid"][data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
#grid[data-mode="grid"][data-cols="3"] { grid-template-columns: repeat(3, 1fr); }
#grid[data-mode="grid"][data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
#grid[data-mode="grid"][data-cols="1"] { grid-template-columns: repeat(1, 1fr); }

.cell {
  break-inside: avoid;
  cursor: pointer;
  display: block;
  position: relative;
  /* the cell's own footprint never changes (siblings must not move on hover) */
}
.cell img,
.cell video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
}
/* hover shifts the image itself up 12px (not a resize) — .media's own box
   never changes size (transforms don't affect layout, so the cell doesn't
   move). the rounded corners live on the media elements themselves (not a
   clipping parent): .media has no overflow:hidden, so the image is free to
   slide past its box's top edge on hover without getting cropped there.
   the caption slides down 12px at the same time, keeping their distance. */
.cell .media { position: relative; }
.cell .media > * { transition: transform 0.2s var(--ease); }
.cell:hover .media > *,
#grid.searching .cell .media > * { transform: translateY(-12px); }

/* shared 16:9 framing for embedded videos so they sit flush with other items;
   posters are cropped (cover) to hide any letterbox baked into the thumbnail */
.cell .media.yt, .cell .media.vimeo { aspect-ratio: 16 / 9; }
.cell .media.yt img, .cell .media.vimeo img { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }

/* YouTube: static poster + a small, minimal play button */
.cell .media.yt .play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  transition: transform 0.2s var(--ease);
  width: 0; height: 0;
  border-style: solid; border-width: 6px 0 6px 11px;
  border-color: transparent transparent transparent rgba(255, 255, 255, 0.92);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}
/* keep the play icon centered on the (now shifted-up) poster on hover */
.cell:hover .media.yt .play,
#grid.searching .cell .media.yt .play { transform: translate(-50%, calc(-50% - 12px)); }

/* Vimeo: the background-mode player overlays the poster, fully chrome-free.
   the iframe wrapper clips itself to a rounded rect (its own overflow:hidden,
   not the shared .media box, so the poster above still slides unclipped) */
.cell .media.vimeo .vimeo-frame {
  position: absolute; inset: 0; opacity: 0;
  border-radius: 2px; overflow: hidden;
  transition: opacity 0.3s var(--ease), transform 0.2s var(--ease);
  pointer-events: none; /* clicks fall through to the cell (open detail) */
}
.cell .media.vimeo.vimeo-playing .vimeo-frame { opacity: 1; }
.cell .media.vimeo .vimeo-frame iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%; display: block; border: 0;
}
/* project name below the tile: fixed at its resting spot (12px into the strip
   the lifted image reveals) and only faded in — no motion of its own */
.cell .cap {
  position: absolute;
  bottom: 0; left: 0;
  height: 24px;
  display: flex; align-items: flex-end;
  color: var(--dim); /* same grey as the detail view values */
  white-space: nowrap;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
  z-index: 2;
}
.cell:hover .cap,
#grid.searching .cell .cap { opacity: 1; }

/* hidden-piece marker: bottom-right corner, opposite the project caption.
   only present for logged-in users (hidden items aren't sent otherwise).
   sits still like the caption, only its opacity animates. */
.cell .hid {
  position: absolute; bottom: 4px; right: 0;
  display: flex; color: var(--dim);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}
.cell:hover .hid { opacity: 1; }

/* drop indicator: a fine white vertical line shown between cells while reordering */
.cell.drop-before::before,
.cell.drop-after::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 0.5px;
  background: var(--fg); z-index: 5; pointer-events: none;
}
.cell.drop-before::before { left: calc(var(--gap) / -2); }
.cell.drop-after::after { right: calc(var(--gap) / -2); }

/* ---- detail / edit view ---------------------------------------------- */
#detail {
  position: fixed; inset: 0; z-index: 50;
  background: #000;
}
#detail .stage {
  position: absolute;
  top: var(--pad); left: 0; right: 0;
  bottom: 64px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 var(--pad);
}
#detail .stage img, #detail .stage video {
  max-width: 80vw; max-height: 90%; display: block;
  border-radius: 2px; /* same rounding as the grid tiles */
}
/* YouTube / embedded player: 16:9, capped to the stage; sits above the nav
   zones so its own controls stay clickable (use ← → keys to navigate) */
#detail .stage .plyr-host .plyr { border-radius: 2px; overflow: hidden; }
#detail .stage .plyr-host {
  width: min(80vw, calc((100vh - 160px) * 16 / 9));
  max-height: 90%;
  z-index: 52;
  /* white accent (progress bar, hover fill). because the hover fill is white,
     the icon must flip to black on hover so it stays visible (white-on-white). */
  --plyr-color-main: #fff;
  --plyr-video-control-color: #fff;
  --plyr-video-control-color-hover: #000;
}
/* big center play button: dark arrow on the white circle (was white-on-white) */
#detail .plyr__control--overlaid { color: #000; background: #fff; }
#detail .plyr__control--overlaid:hover { color: #000; background: #fff; }

#detail .nav { position: fixed; top: 56px; bottom: 64px; width: 30vw; z-index: 51; }
#detail .nav.prev { left: 0; cursor: w-resize; }
#detail .nav.next { right: 0; cursor: e-resize; }
/* while hovering the video's control strip, let clicks through to the player
   instead of the prev/next nav zones that overlap the video's lower corners */
#detail.controls-active .nav { pointer-events: none; }

#detail-close {
  position: fixed; top: var(--pad); right: var(--pad); z-index: 53;
}

/* edit panel: single horizontal row along the bottom */
.panel {
  position: fixed; left: var(--pad); right: var(--pad); bottom: var(--pad); z-index: 52;
  display: flex; gap: 40px; align-items: baseline;
}
.field { display: flex; gap: 12px; align-items: baseline; }
.field.tags { flex: 1; min-width: 0; }
.field .key { color: var(--label); flex: 0 0 auto; }

.combo { position: relative; }
.panel input {
  background: transparent; border: none; outline: none;
  color: var(--dim); padding: 0; line-height: 1.4; width: 120px;
  transition: color 0.2s var(--ease);
}
.panel input:hover, .panel input:focus { color: var(--fg); }
#f-tag { width: 80px; }
.panel input::placeholder { color: var(--label); }

/* optional external project link: visitor sees a dim -> white clickable link */
#f-url-link { text-decoration: none; }
/* visitors have no public/delete actions, so drop that trailing pair and pin
   the project link to the right edge — flush with the Close button above it */
body:not(.authed) .panel-actions { display: none; }
body:not(.authed) #url-field { margin-left: auto; }

.tags-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
#tag-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { white-space: nowrap; }

/* public + delete sit together as a tight pair at the end of the row */
.panel-actions { flex: 0 0 auto; display: flex; gap: 14px; align-items: baseline; }
#f-delete { flex: 0 0 auto; }

/* suggestion dropdowns — .float-panel look, opening upward above the bar */
.suggest {
  position: absolute; left: 0; bottom: 100%; margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px;
  max-height: 220px; overflow-y: auto; min-width: 120px; z-index: 60;
}
.suggest div { white-space: nowrap; }
.suggest div.active { color: var(--fg); }

/* ---- login / setup / reset overlay ------------------------------------ */
#auth {
  position: fixed; inset: 0; z-index: 80;
  background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 32px; padding: var(--pad);
}
#auth-form { display: flex; flex-direction: column; align-items: center; gap: 14px; }
/* the only visible field is the word "Passwort"; no box, dim -> white */
.auth-field {
  background: transparent; border: none; outline: none;
  color: var(--dim); text-align: center; width: 240px; padding: 0;
  transition: color 0.2s var(--ease);
}
.auth-field::placeholder { color: var(--dim); }
.auth-field:hover, .auth-field:focus { color: var(--fg); }
#auth-msg { color: var(--dim); min-height: 1.4em; text-align: center; }
#auth-code { display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: 360px; }
.auth-note { color: var(--dim); text-align: center; }
#auth-code-value { color: var(--fg); letter-spacing: 3px; font-size: 14px; }
/* secondary actions: stacked, pinned to the bottom of the viewport (less important) */
#auth-links {
  position: absolute; left: 0; right: 0; bottom: var(--pad);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}

/* without a session the portfolio is view-only: the panel still shows the
   project + tags, but every editing affordance is hidden / inert */
body:not(.authed) #f-delete,
body:not(.authed) #f-public,
body:not(.authed) .field.tags .combo { display: none; }
body:not(.authed) .panel input { pointer-events: none; }
/* nothing to add a tag with → drop the empty trailing gap before the (hidden) input */
body:not(.authed) .tags-edit { gap: 6px; }
/* logout lives in the filter panel, only when logged in */
body:not(.authed) #btn-logout { display: none; }

/* ---- misc ------------------------------------------------------------- */
.hidden { display: none !important; }

/* force info button visible when authed */
body.authed #btn-info { display: inline-block !important; }

#drop-hint {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.8); color: var(--fg);
  pointer-events: none;
}
body.dragging #drop-hint { display: flex; }

/* branding upload menu — same centered, zero-box style as the auth overlay */
#branding {
  position: fixed; inset: 0; z-index: 85;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; background: #000; padding: var(--pad);
}
#brand-msg { color: var(--dim); min-height: 1.4em; text-align: center; }
#brand-close { margin-top: 12px; }

/* busy overlay: covers everything (incl. detail view) while compressing/uploading */
#busy {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: #000; color: var(--fg); text-align: center; padding: var(--pad);
}
#busy-text { font-size: 14px; }

/* ---- info / about page (/info) + footer pages (/slug) ------------------- */
/* rendered in normal flow below the bar (grid hidden meanwhile), so the header
   nav + shared footer stay in place. footer pages reuse this exact layout,
   only without the client logos. */
#info, #page { padding: 0 var(--pad) var(--pad); flex: 1 0 auto; }
#info .info-inner, #page .info-inner {
  display: flex; flex-direction: column; align-items: stretch; gap: 124px;
}
/* the copy fills the first screen (bar bottom -> viewport bottom) and bottom-aligns
   its text, so it always sits at the bottom of the viewport; padding-top keeps a
   minimum 300px gap from the nav when the text is tall. clients follow below. */
#info .info-copy, #page .info-copy {
  max-width: 732px;
  min-height: calc(100vh - var(--bar-h) - var(--pad));
  min-height: calc(100dvh - var(--bar-h) - var(--pad));
  padding-top: 300px;
  display: flex; flex-direction: column; justify-content: flex-end;
  gap: 24px; align-items: flex-start;
}
#info .info-text, #page .info-text {
  color: var(--dim);
  font-size: 24px; line-height: 1.3;
  width: 100%;
}
/* footer page title: editable input (owner) / heading (visitor), sits above
   the body in the same bottom-aligned stack */
.page-title, .page-title-ro {
  font-size: 24px; line-height: 1.3; color: var(--fg);
  width: 100%; font-family: inherit; font-weight: inherit;
}
#page-title { background: transparent; border: none; outline: none; padding: 0; }
#page-title::placeholder { color: var(--label); }
#page-title-ro:empty { display: none; }
body.authed #page-title-ro { display: none; }
#page-text { outline: none; cursor: text; min-height: 1.3em; white-space: pre-wrap; }
#page-text:empty::before { content: attr(data-placeholder); color: var(--label); }
#page .info-text a { color: #b5b5b5; text-decoration: none; transition: color 0.2s var(--ease); }
#page .info-text a:hover { color: var(--fg); }
/* links read as a slightly dimmer white, brightening to full white on hover */
#info .info-text a { color: #b5b5b5; text-decoration: none; transition: color 0.2s var(--ease); }
#info .info-text a:hover { color: var(--fg); text-decoration: none; }
/* the editable copy behaves like the rendered one */
#info-text { outline: none; cursor: text; min-height: 1.3em; white-space: pre-wrap; }
#info-text:empty::before { content: attr(data-placeholder); color: var(--label); }

/* ---- legal entry editor + meta editor (fixed overlays) ----------------- */
#legal-edit, #meta-edit {
  position: fixed; inset: 0; z-index: 70;
  background: #000; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 64px var(--pad);
}
#legal-edit .info-inner, #meta-edit .meta-inner {
  max-width: 720px; margin: 0 auto;
}
.info-inner, #meta-edit .meta-inner {
  display: flex; flex-direction: column; align-items: stretch; gap: 28px;
}
#legal-edit-close, #meta-edit-close {
  position: fixed; top: var(--pad); right: var(--pad); z-index: 71;
}

/* meta / SEO editor: title + description share the row-input look; the OG
   image row shows a preview with upload / remove actions */
#meta-edit .info-field { align-items: flex-start; }
#meta-title, #meta-desc {
  background: transparent; border: none; outline: none; padding: 0; flex: 1;
  color: var(--dim); font-family: inherit; line-height: 1.4;
  transition: color 0.2s var(--ease); resize: vertical;
}
#meta-title:hover, #meta-title:focus, #meta-desc:hover, #meta-desc:focus { color: var(--fg); }
#meta-title::placeholder, #meta-desc::placeholder { color: var(--label); }
.meta-og { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
#meta-og-preview { max-width: 320px; max-height: 180px; width: auto; height: auto; border-radius: 2px; display: block; }
#meta-msg { color: var(--dim); }

/* field rows mirror the detail panel: a faint key + the value column */
.info-field { display: flex; gap: 20px; align-items: baseline; }
.info-field > .key { color: var(--label); flex: 0 0 96px; }
.info-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }

/* free text — rendered (visitor) or editable (authed) */
.info-text { color: var(--fg); white-space: pre-wrap; width: 100%; }
.info-text a { color: var(--fg); text-decoration: underline; }

.row-x { color: var(--label); cursor: pointer; flex: 0 0 auto; transition: color 0.2s var(--ease); }
.row-x:hover { color: var(--fg); }

/* single inputs in the legal editor share the row-input look */
#le-title, #le-url {
  background: transparent; border: none; outline: none; padding: 0; flex: 1;
  color: var(--dim); font-family: inherit; line-height: 1.4;
  transition: color 0.2s var(--ease);
}
#le-title:hover, #le-title:focus, #le-url:hover, #le-url:focus { color: var(--fg); }
#le-title::placeholder, #le-url::placeholder { color: var(--label); }

/* show only the fields relevant to the entry type (page / link / text) */
#legal-edit:not(.is-page) .le-page { display: none; }
#legal-edit:not(.is-link) .le-link { display: none; }

/* contentEditable page body */
.le-body {
  min-height: 6em; outline: none; cursor: text;
  border-bottom: 0.5px solid var(--label); padding-bottom: 10px;
}
.le-body:empty::before { content: attr(data-placeholder); color: var(--label); }

/* ---- floating link menu (select text -> add a link, Figma-style) ------- */
#linkmenu {
  position: fixed; z-index: 95;
  display: flex; align-items: center; gap: 4px;
  padding: 4px;
  /* menu look comes from .float-menu */
}
#linkmenu button {
  padding: 4px 12px; border-radius: 6px;
  color: #b5b5b5; cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
#linkmenu button:hover { color: var(--fg); background: #0b0b0b; }
#linkmenu input {
  background: transparent; border: none; outline: none;
  color: var(--fg); width: 200px; padding: 4px 8px;
}
#linkmenu input::placeholder { color: var(--dim); }

.info-clients { display: flex; flex-direction: column; gap: 24px; align-items: flex-start; }

/* client logos: a grid of dark tiles, logo centered (Figma 605:20) */
#info-logos {
  display: grid; gap: var(--gap); width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.logo-thumb {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 200px;
  background: #101010;
  border-radius: 2px;
}
.logo-thumb img { max-height: 44px; max-width: 100px; width: auto; height: auto; display: block; }
.logo-thumb .row-x {
  position: absolute; top: 10px; right: 14px;
  opacity: 0; transition: opacity 0.2s var(--ease);
}
.logo-thumb:hover .row-x { opacity: 1; }

/* explicit save: an outlined word so it reads as an action, not a label */
.info-actions { display: flex; gap: 20px; align-items: baseline; }
.save-btn {
  color: var(--fg); cursor: pointer; border: 0.5px solid var(--dim);
  padding: 4px 14px; transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.save-btn:hover { border-color: var(--fg); }
.save-btn:disabled { color: var(--label); border-color: var(--label); cursor: default; }
#info-msg, #le-msg { color: var(--dim); }

/* legal footer at the end of the grid (sticks to the viewport bottom via the
   body flex column when the grid is short) */
#legal-footer {
  display: flex; flex-wrap: wrap; gap: 24px;
  padding: calc(var(--rowgap)) var(--pad) var(--pad);
  margin-top: auto;
}
/* plain text entries (e.g. copyright) — not interactive for visitors */
#legal-footer .foot-text { color: var(--dim); cursor: default; }
#legal-footer .foot-add { color: var(--label); }
#legal-footer .foot-add:hover { color: var(--fg); }
#legal-footer:empty { display: none; }

/* the three add options hide behind a context menu opened from "Add Footer Item" */
#foot-add-menu {
  position: fixed; z-index: 95;
  display: flex; flex-direction: column;
  padding: 4px;
  /* menu look comes from .float-menu */
}
#foot-add-menu button {
  padding: 4px 12px; border-radius: 6px; text-align: left;
  color: #b5b5b5; cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
#foot-add-menu button:hover { color: var(--fg); background: #0b0b0b; }

/* info page / footer pages replace the grid while open — the legal footer
   stays, shared with the homepage, and sits right after the page content */
#info, #page { display: none; }
body.show-info #info { display: block; }
body.show-page #page { display: block; }
body.show-info #grid, body.show-page #grid { display: none; }

/* edit affordances hidden for visitors */
body:not(.authed) .authed-only { display: none !important; }
/* owner edits in place: hide the read-only copies, show the editable ones */
body.authed #info-text-ro, body.authed #page-text-ro { display: none; }

::selection { background: #fff; color: #000; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ---- mobile ----------------------------------------------------------- */
@media (max-width: 640px) {
  :root { --pad: 14px; --gap: 14px; --rowgap: 24px; --bar-h: 52px; }

  #logo, #logo svg { height: 24px; }
  #bar { gap: 12px; }

  /* filter button stays pinned to the right (no flex spacer when bar search is hidden) */
  #actions { margin-left: auto; }

  /* search moves into the filter panel on mobile (full-width, underlined) */
  #searchwrap { display: none; }
  #search-m { display: block; }

  /* narrow panel; sections stack vertically instead of sitting side by side,
     search above them. grows for long project/tag names, capped at the viewport */
  #filter-panel { min-width: 205px; max-width: calc(100vw - 2 * var(--pad)); }
  #filter-row { gap: 24px; padding: 18px; }
  #filter-sections { flex-direction: column; gap: 24px; width: 100%; }

  /* mobile column options: only 2 / 1 (2 is default) */
  #cols .deskcol { display: none; }
  #cols .mobcol { display: flex; }

  /* items capped at 80% of the (visible) viewport height */
  .cell .media { max-height: 80vh; max-height: 80dvh; overflow: hidden; }

  /* info page + footer pages: slightly smaller copy, tighter spacing */
  #info .info-inner, #page .info-inner { gap: 64px; }
  #info .info-text, #page .info-text { font-size: 20px; }
  .page-title, .page-title-ro { font-size: 20px; }
  /* the desktop 300px minimum gap below the nav eats half a phone screen */
  #info .info-copy, #page .info-copy { padding-top: 120px; }
  #info-logos { grid-template-columns: repeat(2, 1fr); }
  .logo-thumb { height: 120px; }

  /* detail view becomes a vertical scroll: media + fields, delete below the fold */
  #detail { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #detail .nav { display: none; } /* swipe to navigate instead */
  #detail .stage {
    position: static; bottom: auto;
    min-height: calc(100vh - 38px);
    min-height: calc(100dvh - 38px);
    padding: 52px var(--pad) 0;
  }
  #detail .stage img, #detail .stage video { max-width: 100%; max-height: 80vh; max-height: 80dvh; }

  /* grid: project (left) + tags (right) on row 1, the optional external link
     on its own full-width row, public + delete on a last row below the fold */
  .panel {
    position: static; left: auto; right: auto; bottom: auto;
    display: grid; grid-template-columns: auto minmax(0, 1fr);
    column-gap: 16px; row-gap: 28px; align-items: baseline;
    padding: 8px var(--pad) 0;
  }
  .panel > .field:first-child { grid-column: 1; }          /* project: left */
  .field.tags { grid-column: 2; min-width: 0; justify-content: flex-end; } /* tags: right */
  #url-field { grid-column: 1 / -1; }                      /* link: own row */
  body:not(.authed) #url-field { margin-left: 0; }         /* grid places it; no flex push needed */
  .field { gap: 8px; }
  /* tags on a single right-aligned line; overflow fades out on the left when too many */
  .tags-edit {
    flex-wrap: nowrap; min-width: 0; overflow: hidden; justify-content: flex-end;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px);
    mask-image: linear-gradient(to right, transparent 0, #000 28px);
  }
  #tag-chips { flex-wrap: nowrap; }
  .field.tags .combo { display: none; } /* hide the add-field on mobile for a clean truncated row */
  /* public + delete on their own line below the fold (revealed on scroll), right-aligned */
  .panel-actions { grid-column: 1 / -1; justify-self: end; margin-bottom: var(--pad); }

  /* tapping the tags expands them: hide project, show every tag (wrapping) */
  .panel.tags-expanded > .field:first-child { display: none; }
  .panel.tags-expanded .field.tags { grid-column: 1 / -1; justify-content: flex-start; }
  .panel.tags-expanded .tags-edit {
    flex-wrap: wrap; overflow: visible; justify-content: flex-start;
    -webkit-mask-image: none; mask-image: none;
  }
  .panel.tags-expanded #tag-chips { flex-wrap: wrap; }
}
